mybatis入门常见错误

来源:互联网 发布:apache.exe 编辑:程序博客网 时间:2024/06/05 07:59

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要一致;


0 0
原创粉丝点击