Error parsing Mapper XML. Cause: java.lang.NullPointerException
异常org.springframework.beans.factory.BeanCreationException:Errorcreatingbeanwithname's...
异常
org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'sqlSessionFactory' defined in file [D:\soft\apache-tomcat-7.0.57-windows-x64\apache-tomcat-7.0.57\webapps\springmvc6\WEB-INF\classes\spring\applicationContext.xml]: Invocation of init method failed; nested exception is org.springframework.core.NestedIOException: Failed to parse mapping resource: 'file [D:\soft\apache-tomcat-7.0.57-windows-x64\apache-tomcat-7.0.57\webapps\springmvc6\WEB-INF\classes\com\test\dao\IContactsInfoMapper.xml]'; nested exception is java.lang.RuntimeException: Error parsing Mapper XML. Cause: java.lang.NullPointerException
xml
<?xml version="1.0" encoding="UTF-8" ?>
<!DOCTYPE sqlMap
PUBLIC "-//ibatis.apache.org//DTD SQL Map 2.0//EN"
"http://ibatis.apache.org/dtd/sql-map-2.dtd">
<sqlMap>
<typeAlias alias="User" type="ibatis.model.User" />
<select id="selContactsInfo" resultClass="User">
select *
from users
</select>
</sqlMap>
<bean class="org.mybatis.spring.mapper.MapperScannerConfigurer">
<property name="basePackage" value="com.test.dao" />
</bean>
什么问题求解 谢谢! 展开
org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'sqlSessionFactory' defined in file [D:\soft\apache-tomcat-7.0.57-windows-x64\apache-tomcat-7.0.57\webapps\springmvc6\WEB-INF\classes\spring\applicationContext.xml]: Invocation of init method failed; nested exception is org.springframework.core.NestedIOException: Failed to parse mapping resource: 'file [D:\soft\apache-tomcat-7.0.57-windows-x64\apache-tomcat-7.0.57\webapps\springmvc6\WEB-INF\classes\com\test\dao\IContactsInfoMapper.xml]'; nested exception is java.lang.RuntimeException: Error parsing Mapper XML. Cause: java.lang.NullPointerException
xml
<?xml version="1.0" encoding="UTF-8" ?>
<!DOCTYPE sqlMap
PUBLIC "-//ibatis.apache.org//DTD SQL Map 2.0//EN"
"http://ibatis.apache.org/dtd/sql-map-2.dtd">
<sqlMap>
<typeAlias alias="User" type="ibatis.model.User" />
<select id="selContactsInfo" resultClass="User">
select *
from users
</select>
</sqlMap>
<bean class="org.mybatis.spring.mapper.MapperScannerConfigurer">
<property name="basePackage" value="com.test.dao" />
</bean>
什么问题求解 谢谢! 展开
3个回答
展开全部
springmvc与mybatis整合出现的异常:
org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'userHandler': Injection of resource dependencies failed; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'userServiceImp': Injection of resource dependencies failed; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'userMapper' defined in file [G:\tomcat\apache-tomcat-7.0.57\webapps\springmvc_mybatis\WEB-INF\classes\com\tanghaibin\mapper\UserMapper.class]: Invocation of init method failed; nested exception is java.lang.IllegalArgumentException: org.apache.ibatis.builder.BuilderException: Error parsing Mapper XML. Cause: java.lang.NullPointerException
Related cause: org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'userMapper' defined in file [G:\tomcat\apache-tomcat-7.0.57\webapps\springmvc_mybatis\WEB-INF\classes\com\tanghaibin\mapper\UserMapper.class]: Invocation of init method failed; nested exception is java.lang.IllegalArgumentException: org.apache.ibatis.builder.BuilderException: Error parsing Mapper XML. Cause: java.lang.NullPointerException
解决:
mapper配置文件中的namespace没有填;而且namespase的值应该填为:mapper的权限定名;否则还是会抛出异常
org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'userHandler': Injection of resource dependencies failed; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'userServiceImp': Injection of resource dependencies failed; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'userMapper' defined in file [G:\tomcat\apache-tomcat-7.0.57\webapps\springmvc_mybatis\WEB-INF\classes\com\tanghaibin\mapper\UserMapper.class]: Invocation of init method failed; nested exception is java.lang.IllegalArgumentException: org.apache.ibatis.builder.BuilderException: Error parsing Mapper XML. Cause: java.lang.NullPointerException
Related cause: org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'userMapper' defined in file [G:\tomcat\apache-tomcat-7.0.57\webapps\springmvc_mybatis\WEB-INF\classes\com\tanghaibin\mapper\UserMapper.class]: Invocation of init method failed; nested exception is java.lang.IllegalArgumentException: org.apache.ibatis.builder.BuilderException: Error parsing Mapper XML. Cause: java.lang.NullPointerException
解决:
mapper配置文件中的namespace没有填;而且namespase的值应该填为:mapper的权限定名;否则还是会抛出异常
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询