{channel.title!channel.name} - 楚淮公司周东林

mybatis-generator逆向工程生成mapper.xml内容重复

mybatis-generator逆向工程生成mapper.xml内容重复导致下面的报错。重复的主要原因是执行时候 -overwrite 加了这个参数。


报错信息

2018-11-30 16:38:19,543 [RMI TCP Connection(5)-127.0.0.1] ERROR [org.springframework.web.context.ContextLoader] - Context initialization failed
org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'sqlSessionFactory' defined in class path resource [config/mybatis-config.xml]: Invocation of init method failed; nested exception is org.springframework.core.NestedIOException: Failed to parse mapping resource: 'file [D:\apache-tomcat-7.0.70\webapps\WEB-INF\classes\com\jschrj\admin\mapping\SysJsMapper.xml]'; nested exception is java.lang.RuntimeException: Error parsing Mapper XML. Cause: java.lang.IllegalArgumentException: Result Maps collection already contains value for com.jschrj.admin.dao.SysJsMapper.BaseResultMap
 at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.initializeBean(AbstractAutowireCapableBeanFactory.java:1553)
 at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:539)
 at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:475)

如果加 -overwrite 这个参数,之前如果生成过需要把原来生成的文件删除,不然会生成重复内容, ID 重复导致报错。


浏览.发表于:2018-11-30 16:49:33