mybatis入门常见错误

举报
tea_year 发表于 2021/12/30 01:07:34 2021/12/30
【摘要】 1.Exception in thread "main" java.io.IOException: Could not find resource config2.xml 需要去Reader reader=Resources.getResourceAsReader("config2.xml");代码处看下,是否和src下面的配置文件名...

1.Exception in thread "main" java.io.IOException: Could not find resource config2.xml

需要去Reader reader=Resources.getResourceAsReader("config2.xml");代码处看下,是否和src下面的配置文件名称一样,如果不一样,泽会报没有发现资源文件的错误;

2.White spaces are required after keyword PUBLIC in DOCTYPE decl,原因是<!DOCTYPE configuration PUBLIC"-//mybatis.org//DTD Config 3.0//EN"
    "http://mybatis.org/dtd/mybatis-3-config.dtd">,public后面应该加空格;

3.Element type "enviroments" must be declared.或Element type "enviroment" must be declared.,Attribute "resourse" must be declared for element type "mapper".等type需要定义的错误,则是标签出问题了,需要检查xml配置文件;

4.The content of element type "transactionManager" must match "(property)*".,错误是<transactionManager type="JDBC"/>,标签用完就结束,不要包含property.

5.Error resolving class. Cause: org.apache.ibatis.type.TypeException: Could not resolve type alias 'Dept'.  Cause: java.lang.ClassNotFoundException: Cannot find class: Dept,,原因是<select id="selectOne" parameterType="int" resultType="Dept">,此处的返回类型出问题了!!!,需要返回bean包下的实体类。

综上所述,针对开始学习配置文件的同学们来说,写的时候,要仔细再仔细!!!注意大小写 空格 单引号 全交 半角等等问题!!!

6.### Error opening session.  Cause: java.lang.NullPointerException
### Cause: java.lang.NullPointerException,原因是配置环境问题

<environments default="development">
            <environment id="developmet">,id和default要一致;

 

文章来源: aaaedu.blog.csdn.net,作者:tea_year,版权归原作者所有,如需转载,请联系作者。

原文链接:aaaedu.blog.csdn.net/article/details/60780001

【版权声明】本文为华为云社区用户转载文章,如果您发现本社区中有涉嫌抄袭的内容,欢迎发送邮件进行举报,并提供相关证据,一经查实,本社区将立刻删除涉嫌侵权内容,举报邮箱: cloudbbs@huaweicloud.com
  • 点赞
  • 收藏
  • 关注作者

评论(0

0/1000
抱歉,系统识别当前为高风险访问,暂不支持该操作

全部回复

上滑加载中

设置昵称

在此一键设置昵称,即可参与社区互动!

*长度不超过10个汉字或20个英文字符,设置后3个月内不可修改。

*长度不超过10个汉字或20个英文字符,设置后3个月内不可修改。