出现
Error creating bean with name 'userController' defined in file [E:\IntelliJ\workspaces\web_workspaces\best_springboot_mybatis\target\classes\com\test\springbm\controller\UserController.class]: Unsatisfied dependency expressed through constructor parameter 0; nested exception is org.springframework.beans.factory.UnsatisfiedDependencyException: Error creating bean with name 'userService' defined in file [E:\IntelliJ\workspaces\web_workspaces\best_springboot_mybatis\target\classes\com\test\springbm\service\UserService.class]: Unsatisfied dependency expressed through constructor parameter 0; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'userMapper' defined in file [E:\IntelliJ\workspaces\web_workspaces\best_springboot_mybatis\target\classes\com\test\springbm\mapper\UserMapper.class]: Cannot resolve reference to bean 'sessionFactory' while setting bean property 'sqlSessionFactory'; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'sessionFactory' defined in class path resource [com/test/springbm/config/impl/DruidConfig.class]: Bean instantiation via factory method failed; nested exception is org.springframework.beans.BeanInstantiationException: Failed to instantiate [org.apache.ibatis.session.SqlSessionFactory]: Factory method 'sqlSessionFactory' threw exception; nested exception is org.springframework.core.NestedIOException: Failed to parse mapping resource: 'file [E:\IntelliJ\workspaces\web_workspaces\best_springboot_mybatis\target\classes\mapper\UserMapper.xml]'; nested exception is org.apache.ibatis.builder.BuilderException: Error parsing Mapper XML. The XML location is 'file [E:\IntelliJ\workspaces\web_workspaces\best_springboot_mybatis\target\classes\mapper\UserMapper.xml]'. Cause: java.lang.IllegalArgumentException: XML fragments parsed from previous mappers already contains value for com.test.springbm.mapper.UserMapper.Base_Column_List
错误
说明你的*Mapper.xml里面有个同名对象
如我这个错误就是有个同名的Base_Column_List
<sql id="Base_Column_List">
id, `name`, `password`
</sql>
<sql id="Base_Column_List">
id, `name`, `password`
</sql>
这种的在用Mybatis Generator自动生成代码的时候,如果生成俩次就很容易生成重复代码
需要去掉id同名的对象
本文详细解析了在使用MyBatis框架时遇到的重复Mapper ID错误,特别是Base_Column_List ID冲突的问题,提供了检查和修复代码的具体步骤,帮助开发者避免在自动生成代码过程中出现的重复定义错误。
3371

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



