javascript
Spring Boot + Mybatis——RowBoundsPlugin造成的[Mapped Statements collection already contains value]解决方案
基本概念
RowBoundsPlugin:通過(guò)ResultSet的游標(biāo)實(shí)現(xiàn)的分頁(yè)查詢插件,容易出現(xiàn)性能問(wèn)題
<plugin type="org.mybatis.generator.plugins.RowBoundsPlugin">問(wèn)題描述
Caused by: java.lang.IllegalArgumentException: Mapped Statements collection already contains value for club.zstuca.platform.mapper.UserMapper.selectByExampleWithRowbounds. please check file [E:\Code\Project\JAVA\platform\target\classes\mapper\UserMapper.xml] and file [E:\Code\Project\JAVA\platform\target\classes\mapper\UserMapper.xml]at org.apache.ibatis.session.Configuration$StrictMap.put(Configuration.java:947) ~[mybatis-3.5.3.jar:3.5.3]at org.apache.ibatis.session.Configuration$StrictMap.put(Configuration.java:903) ~[mybatis-3.5.3.jar:3.5.3]at org.apache.ibatis.session.Configuration.addMappedStatement(Configuration.java:702) ~[mybatis-3.5.3.jar:3.5.3]at org.apache.ibatis.builder.MapperBuilderAssistant.addMappedStatement(MapperBuilderAssistant.java:297) ~[mybatis-3.5.3.jar:3.5.3]at org.apache.ibatis.builder.xml.XMLStatementBuilder.parseStatementNode(XMLStatementBuilder.java:113) ~[mybatis-3.5.3.jar:3.5.3]at org.apache.ibatis.builder.xml.XMLMapperBuilder.buildStatementFromContext(XMLMapperBuilder.java:137) ~[mybatis-3.5.3.jar:3.5.3]at org.apache.ibatis.builder.xml.XMLMapperBuilder.buildStatementFromContext(XMLMapperBuilder.java:130) ~[mybatis-3.5.3.jar:3.5.3]at org.apache.ibatis.builder.xml.XMLMapperBuilder.configurationElement(XMLMapperBuilder.java:120) ~[mybatis-3.5.3.jar:3.5.3]... 77 common frames omittedProcess finished with exit code 0問(wèn)題分析
?RowBoundsPlugin生成的代碼存在兩個(gè)id為selectByExampleWithRowbounds的方法導(dǎo)致[Mapped Statements collection already contains value]錯(cuò)誤。
<select id="selectByExampleWithBLOBsWithRowbounds" parameterType="club.zstuca.platform.model.UserExample" resultMap="ResultMapWithBLOBs"><!--WARNING - @mbg.generatedThis element is automatically generated by MyBatis Generator, do not modify.This element was generated on Tue Feb 04 21:47:29 CST 2020.-->select<if test="distinct">distinct</if><include refid="Base_Column_List" />,<include refid="Blob_Column_List" />from user<if test="_parameter != null"><include refid="Example_Where_Clause" /></if><if test="orderByClause != null">order by ${orderByClause}</if></select> <select id="selectByExampleWithRowbounds" parameterType="club.zstuca.platform.model.UserExample" resultMap="BaseResultMap"><!--WARNING - @mbg.generatedThis element is automatically generated by MyBatis Generator, do not modify.This element was generated on Tue Feb 04 21:26:31 CST 2020.-->select<if test="distinct">distinct</if><include refid="Base_Column_List" />from user<if test="_parameter != null"><include refid="Example_Where_Clause" /></if><if test="orderByClause != null">order by ${orderByClause}</if></select><select id="selectByExampleWithRowbounds" parameterType="club.zstuca.platform.model.UserExample" resultMap="BaseResultMap"><!--WARNING - @mbg.generatedThis element is automatically generated by MyBatis Generator, do not modify.This element was generated on Tue Feb 04 21:26:31 CST 2020.-->select<if test="distinct">distinct</if><include refid="Base_Column_List" />from user<if test="_parameter != null"><include refid="Example_Where_Clause" /></if><if test="orderByClause != null">order by ${orderByClause}</if></select>刪除一個(gè)selectByExampleWithRowbounds以后啟動(dòng)?Spring Boot 會(huì)找不到?Blob_Column_List 再刪除?selectByExampleWithBLOBsWithRowbounds 即可。
注:
User表結(jié)構(gòu)如下:
并沒(méi)有默認(rèn)轉(zhuǎn)成BLOB的字段類型。
但是為什么會(huì)這樣,暫時(shí)未知,可能是個(gè)BUG。
解決方案
如問(wèn)題分析。
參考文章
Mybatis Generator 相關(guān):
https://www.cnblogs.com/yejg1212/p/9592369.html
Mapped Statements collection already contains value 相關(guān):
https://www.iteye.com/blog/dugu61888-2202549
http://www.zuidaima.com/blog/4316526703807488.htm
https://www.cnblogs.com/yanan7890/p/9474336.html
https://www.cnblogs.com/scode2/p/8744710.html
Spring Boot配置[mybatis.type-aliases-package]?相關(guān):
https://blog.csdn.net/daijiguo/article/details/82827430
https://www.cnblogs.com/yejg1212/p/9592369.html
Mybatis的generator生成XXXWithBLOBS.java文件 相關(guān):
https://blog.csdn.net/sinat_31350717/article/details/80574105
https://blog.csdn.net/qq_34982426/article/details/83180450
總結(jié)
以上是生活随笔為你收集整理的Spring Boot + Mybatis——RowBoundsPlugin造成的[Mapped Statements collection already contains value]解决方案的全部?jī)?nèi)容,希望文章能夠幫你解決所遇到的問(wèn)題。
- 上一篇: JAVA——Scanner类绑定Syst
- 下一篇: Web Security——英语写作与教