关于错误Cause: org.apache.ibatis.builder.BuilderException: Mapper’s namespace cannot be empty的解决方案
错误原因:
是Mapper.xml中的namespace没有命名,所以报错。
<?xml version="1.0" encoding="UTF-8" ?>
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
"http://mybatis.org/dtd/mybatis-3-mapper.dtd">
<mapper>
<select id="selectAll" resultType="Goods">
select * from book;
</select>
</mapper>
<!--其余代码略……-->
解决方案:
添加上namespace即可
<?xml version="1.0" encoding="UTF-8" ?>
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
"http://mybatis.org/dtd/mybatis-3-mapper.dtd">
<!--添加上namespace即可-->
<mapper namespace="com.ssm.mapper.BookInfoMapper">
<select id="selectAll" resultType="Goods">
select * from book;
</select>
</mapper>
本文介绍了一个常见的MyBatis使用错误——Mapper.xml文件中namespace为空导致的异常,并给出了具体的修正方法。
2万+

被折叠的 条评论
为什么被折叠?



