Result Maps collection already contains value for xxxMapper.BaseResultMap错误解决办法
来源:互联网 发布:如何成为首富 知乎 编辑:程序博客网 时间:2024/06/07 10:52
Result Maps collection already contains value for xxxMapper.BaseResultMap错误解决办法
一、问题描述
今天在做项目时,遇到一个错误:“Result Maps collection already contains value for com.xxx.dao.tb_userMapper.BaseResultMap”
二、原因分析
Mybatis-Generator在生成Mapper.xml文件时,会在原来基础上再生成,导致内容重复。
三、解决办法
(1)改造Mybatis-generator插件
参考mybatis-generator重新生成代码时的SQL映射文件覆盖
(2)将手写xml文件与自动生成xml文件分离
手写文件放在src/main/resources/mybatis目录中
生成文件放在src/main/resources/mybatis-generator目录中,这样便于在生成之前手动删除。
generatorConfig.xml配置:
<?xml version="1.0" encoding="UTF-8" ?>
<!DOCTYPE generatorConfiguration PUBLIC "-//mybatis.org//DTD MyBatis Generator Configuration 1.0//EN" "http://mybatis.org/dtd/mybatis-generator-config_1_0.dtd" >
<generatorConfiguration>
<classPathEntry
location="D:\Java\maven\repository\mysql\mysql-connector-java\5.1.31\mysql-connector-java-5.1.31.jar" />
<context id="aisSnsTables" targetRuntime="MyBatis3">
<plugin type="org.mybatis.generator.plugins.SerializablePlugin" />
<plugin type="org.mybatis.generator.plugins.EqualsHashCodePlugin" />
<plugin type="org.mybatis.generator.plugins.ToStringPlugin" />
<!-- 抑制生成代码的注释 -->
<commentGenerator>
<property name="suppressAllComments" value="true" />
</commentGenerator>
<jdbcConnection driverClass="com.mysql.jdbc.Driver"
connectionURL="jdbc:mysql://localhost:3306/liying" userId="root"
password="root@" />
<javaModelGenerator targetPackage="com.uni2uni.model"
targetProject="src/main/java" />
<sqlMapGenerator targetPackage="/"
targetProject="src/main/resources/mybatis-generator" />
<javaClientGenerator targetPackage="com.uni2uni.dao"
targetProject="src/main/java" type="XMLMAPPER">
<property name="enableSubPackages" value="true" />
</javaClientGenerator>
<table schema="liying" tableName="tb_user" domainObjectName="tb_user" />
<table schema="liying" tableName="tb_admin" domainObjectName="tb_admin" />
<table schema="liying" tableName="tb_role" domainObjectName="tb_role" />
<table schema="liying" tableName="tb_resource" domainObjectName="tb_resource" />
<table schema="liying" tableName="tb_user_role" domainObjectName="tb_user_role" />
<table schema="liying" tableName="tb_role_resource" domainObjectName="tb_role_resource" />
<table schema="liying" tableName="tb_category" domainObjectName="tb_category"/>
<table schema="liying" tableName="tb_shop" domainObjectName="tb_shop"/>
</context>
</generatorConfiguration>
mybatis.xml配置:
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE configuration PUBLIC "-//mybatis.org//DTD Config 3.0//EN" "http://mybatis.org/dtd/mybatis-3-config.dtd">
<configuration>
<typeAliases>
<typeAlias alias="user" type="com.uni2uni.model.tb_user" />
<typeAlias alias="admin" type="com.uni2uni.model.tb_admin" />
<typeAlias alias="role" type="com.uni2uni.model.tb_role" />
<typeAlias alias="resource" type="com.uni2uni.model.tb_resource" />
<typeAlias alias="category" type="com.uni2uni.model.tb_category" />
<typeAlias alias="shop" type="com.uni2uni.model.tb_shop" />
</typeAliases>
<plugins>
<plugin
interceptor="com.github.miemiedev.mybatis.paginator.OffsetLimitInterceptor">
<property name="dialectClass"
value="com.github.miemiedev.mybatis.paginator.dialect.MySQLDialect" />
</plugin>
</plugins>
<mappers>
<mapper resource="mybatis/tb_user.xml" />
<mapper resource="mybatis-generator/tb_userMapper.xml" />
<mapper resource="mybatis/tb_admin.xml" />
<mapper resource="mybatis-generator/tb_adminMapper.xml" />
<mapper resource="mybatis/tb_role.xml" />
<mapper resource="mybatis-generator/tb_roleMapper.xml" />
<mapper resource="mybatis/tb_resource.xml" />
<mapper resource="mybatis-generator/tb_resourceMapper.xml" />
<mapper resource="mybatis/tb_user_role.xml" />
<mapper resource="mybatis-generator/tb_user_roleMapper.xml" />
<mapper resource="mybatis/tb_role_resource.xml" />
<mapper resource="mybatis-generator/tb_role_resourceMapper.xml" />
<mapper resource="mybatis/tb_category.xml" />
<mapper resource="mybatis-generator/tb_categoryMapper.xml" />
<mapper resource="mybatis/tb_shop.xml" />
<mapper resource="mybatis-generator/tb_shopMapper.xml" />
</mappers>
一、问题描述
今天在做项目时,遇到一个错误:“Result Maps collection already contains value for com.xxx.dao.tb_userMapper.BaseResultMap”
二、原因分析
Mybatis-Generator在生成Mapper.xml文件时,会在原来基础上再生成,导致内容重复。
三、解决办法
(1)改造Mybatis-generator插件
参考mybatis-generator重新生成代码时的SQL映射文件覆盖
(2)将手写xml文件与自动生成xml文件分离
手写文件放在src/main/resources/mybatis目录中
生成文件放在src/main/resources/mybatis-generator目录中,这样便于在生成之前手动删除。
generatorConfig.xml配置:
<?xml version="1.0" encoding="UTF-8" ?>
<!DOCTYPE generatorConfiguration PUBLIC "-//mybatis.org//DTD MyBatis Generator Configuration 1.0//EN" "http://mybatis.org/dtd/mybatis-generator-config_1_0.dtd" >
<generatorConfiguration>
<classPathEntry
location="D:\Java\maven\repository\mysql\mysql-connector-java\5.1.31\mysql-connector-java-5.1.31.jar" />
<context id="aisSnsTables" targetRuntime="MyBatis3">
<plugin type="org.mybatis.generator.plugins.SerializablePlugin" />
<plugin type="org.mybatis.generator.plugins.EqualsHashCodePlugin" />
<plugin type="org.mybatis.generator.plugins.ToStringPlugin" />
<!-- 抑制生成代码的注释 -->
<commentGenerator>
<property name="suppressAllComments" value="true" />
</commentGenerator>
<jdbcConnection driverClass="com.mysql.jdbc.Driver"
connectionURL="jdbc:mysql://localhost:3306/liying" userId="root"
password="root@" />
<javaModelGenerator targetPackage="com.uni2uni.model"
targetProject="src/main/java" />
<sqlMapGenerator targetPackage="/"
targetProject="src/main/resources/mybatis-generator" />
<javaClientGenerator targetPackage="com.uni2uni.dao"
targetProject="src/main/java" type="XMLMAPPER">
<property name="enableSubPackages" value="true" />
</javaClientGenerator>
<table schema="liying" tableName="tb_user" domainObjectName="tb_user" />
<table schema="liying" tableName="tb_admin" domainObjectName="tb_admin" />
<table schema="liying" tableName="tb_role" domainObjectName="tb_role" />
<table schema="liying" tableName="tb_resource" domainObjectName="tb_resource" />
<table schema="liying" tableName="tb_user_role" domainObjectName="tb_user_role" />
<table schema="liying" tableName="tb_role_resource" domainObjectName="tb_role_resource" />
<table schema="liying" tableName="tb_category" domainObjectName="tb_category"/>
<table schema="liying" tableName="tb_shop" domainObjectName="tb_shop"/>
</context>
</generatorConfiguration>
mybatis.xml配置:
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE configuration PUBLIC "-//mybatis.org//DTD Config 3.0//EN" "http://mybatis.org/dtd/mybatis-3-config.dtd">
<configuration>
<typeAliases>
<typeAlias alias="user" type="com.uni2uni.model.tb_user" />
<typeAlias alias="admin" type="com.uni2uni.model.tb_admin" />
<typeAlias alias="role" type="com.uni2uni.model.tb_role" />
<typeAlias alias="resource" type="com.uni2uni.model.tb_resource" />
<typeAlias alias="category" type="com.uni2uni.model.tb_category" />
<typeAlias alias="shop" type="com.uni2uni.model.tb_shop" />
</typeAliases>
<plugins>
<plugin
interceptor="com.github.miemiedev.mybatis.paginator.OffsetLimitInterceptor">
<property name="dialectClass"
value="com.github.miemiedev.mybatis.paginator.dialect.MySQLDialect" />
</plugin>
</plugins>
<mappers>
<mapper resource="mybatis/tb_user.xml" />
<mapper resource="mybatis-generator/tb_userMapper.xml" />
<mapper resource="mybatis/tb_admin.xml" />
<mapper resource="mybatis-generator/tb_adminMapper.xml" />
<mapper resource="mybatis/tb_role.xml" />
<mapper resource="mybatis-generator/tb_roleMapper.xml" />
<mapper resource="mybatis/tb_resource.xml" />
<mapper resource="mybatis-generator/tb_resourceMapper.xml" />
<mapper resource="mybatis/tb_user_role.xml" />
<mapper resource="mybatis-generator/tb_user_roleMapper.xml" />
<mapper resource="mybatis/tb_role_resource.xml" />
<mapper resource="mybatis-generator/tb_role_resourceMapper.xml" />
<mapper resource="mybatis/tb_category.xml" />
<mapper resource="mybatis-generator/tb_categoryMapper.xml" />
<mapper resource="mybatis/tb_shop.xml" />
<mapper resource="mybatis-generator/tb_shopMapper.xml" />
</mappers>
</configuration>
阅读全文
0 0
- Result Maps collection already contains value for xxxMapper.BaseResultMap错误解决办法
- Result Maps collection already contains value for xxxMapper.BaseResultMap错误解决办法
- Result Maps collection already contains value for xxxMapper.BaseResultMap
- Result Maps collection already contains value for BaseResultMap
- Result Maps collection already contains value for BaseResultMap
- Result Maps collection already contains value for...BaseResultMap原因及解决办法
- Result Maps collection already contains value for Mapper.BaseResultMap错误原因
- mybatisGenerator 代码自动生成报错 Result Maps collection already contains value for BaseResultMap
- 使用mybatis_generatoer工具后出现Result Maps collection already contains value for BaseResultMap
- 已解决。。。mybatis 代码自动生成报错 Result Maps collection already contains value for BaseResultMap
- Result Maps collection already contains value for ssm.orm.menu.S_MenuMapper.BaseResultMap
- mybatisGenerator 代码自动生成报错 Result Maps collection already contains value for BaseResultMap
- result Maps collection already contains value for io.z77z.dao.SysPermissionInitMapper.BaseResultMap
- Result Maps collection already contains value for com.dm.dao.FigureMapper.BaseResultMap
- mybatisGenerator 代码自动生成报错 Result Maps collection already contains value for BaseResultMap
- 使用SSM搭建项目,启动报:Result Maps collection already contains value for XXXMapper的解决方案
- mybatis 报错 Result Maps collection already contains value for BaseResultMap
- Mybatis错误:Result Maps collection already contains value for ***
- 「游族杯」上海市高校程序设计邀请赛暨华东师范大学第九届 ECNU Coder 程序设计竞赛 A. 足球锦标赛
- 子数组之和
- SQLi-Labs 学习笔记(Less 1-10)
- Makefile语法规则教程
- org.hibernate.LazyInitializationException
- Result Maps collection already contains value for xxxMapper.BaseResultMap错误解决办法
- 廖雪峰的Git教程五
- E
- 面试题8
- 心得小记之一领导想要长期做一件事情一定要将事情公开化
- 【算法】自适应辛普森(Simpson)算法详解
- 原型式继承
- 廖雪峰的Git教程六-撤销修改
- Sky数