您的位置:首页 > 其它

mybatis入门常见错误

2017-03-07 21:27 288 查看

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要一致;
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: