mybatis使用mapper接口加注释的时候出错
Exceptioninthread"main"java.lang.ExceptionInInitializerErrorCausedby:org.apache.ibati...
Exception in thread "main" java.lang.ExceptionInInitializerError
Caused by: org.apache.ibatis.exceptions.PersistenceException:
### Error building SqlSession.
### The error may exist in SQL Mapper Configuration
### Cause: org.apache.ibatis.builder.BuilderException: Error creating document instance. Cause: org.xml.sax.SAXParseException; lineNumber: 27; columnNumber: 65; 必须为元素类型 "mapper" 声明属性 "class"。
at org.apache.ibatis.exceptions.ExceptionFactory.wrapException(ExceptionFactory.java:8)
at org.apache.ibatis.session.SqlSessionFactoryBuilder.build(SqlSessionFactoryBuilder.java:50)
at org.apache.ibatis.session.SqlSessionFactoryBuilder.build(SqlSessionFactoryBuilder.java:33)
at com.yihaomen.mybatis.test.TestEmp1.<clinit>(TestEmp1.java:26)
Caused by: org.apache.ibatis.builder.BuilderException: Error creating document instance. Cause: org.xml.sax.SAXParseException; lineNumber: 27; columnNumber: 65; 必须为元素类型 "mapper" 声明属性 "class"。 展开
Caused by: org.apache.ibatis.exceptions.PersistenceException:
### Error building SqlSession.
### The error may exist in SQL Mapper Configuration
### Cause: org.apache.ibatis.builder.BuilderException: Error creating document instance. Cause: org.xml.sax.SAXParseException; lineNumber: 27; columnNumber: 65; 必须为元素类型 "mapper" 声明属性 "class"。
at org.apache.ibatis.exceptions.ExceptionFactory.wrapException(ExceptionFactory.java:8)
at org.apache.ibatis.session.SqlSessionFactoryBuilder.build(SqlSessionFactoryBuilder.java:50)
at org.apache.ibatis.session.SqlSessionFactoryBuilder.build(SqlSessionFactoryBuilder.java:33)
at com.yihaomen.mybatis.test.TestEmp1.<clinit>(TestEmp1.java:26)
Caused by: org.apache.ibatis.builder.BuilderException: Error creating document instance. Cause: org.xml.sax.SAXParseException; lineNumber: 27; columnNumber: 65; 必须为元素类型 "mapper" 声明属性 "class"。 展开
展开全部
你是用的spring-mybatis整合还是单独用的,我是用的整合,你看下你那xml里面是不是没有这句话<bean class="org.mybatis.spring.mapper.MapperScannerConfigurer">
追问
我的mybatis是单独用的没有加其他的东西,
<mapper resource="com/yihaomen/mybatis/model/emps.xml"/>
<mapper class="com.yihaomen.mybatis.mapper.EmpMapper1"/>
加了第二句就报错了
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询