您好,登錄后才能下訂單哦!
這篇文章給大家介紹如何解決框架集成Mybatis Plus中未找到綁定語句的問題,內容非常詳細,感興趣的小伙伴們可以參考借鑒,希望對大家能有所幫助。
1.引入jar包,我就是沒引入mybatis-plus-extension jar包報 invalid bound statement (not found)錯誤,具體的可以查看官方文檔http://doc.ruoyi.vip/ruoyi/document/cjjc.html#%E9%9B%86%E6%88%90mybatis-plus%E5%AE%9E%E7%8E%B0mybatis%E5%A2%9E%E5%BC%BA
<!-- mybatis-plus --><dependency> <groupId>com.baomidou</groupId> <artifactId>mybatis-plus-boot-starter</artifactId> <version>3.4.2</version></dependency><dependency> <groupId>com.baomidou</groupId> <artifactId>mybatis-plus-extension</artifactId> <version>3.4.2</version></dependency><dependency> <groupId>com.baomidou</groupId> <artifactId>mybatis-plus-core</artifactId> <version>3.4.2</version></dependency><dependency> <groupId>com.baomidou</groupId> <artifactId>mybatis-plus</artifactId> <version>3.4.2</version></dependency>
2.需要替換原來的MybatisConfig
package com.ruoyi.framework.config;import com.baomidou.mybatisplus.annotation.DbType;import com.baomidou.mybatisplus.extension.plugins.MybatisPlusInterceptor;import com.baomidou.mybatisplus.extension.plugins.inner.BlockAttackInnerInterceptor;import com.baomidou.mybatisplus.extension.plugins.inner.OptimisticLockerInnerInterceptor;import com.baomidou.mybatisplus.extension.plugins.inner.PaginationInnerInterceptor;import org.mybatis.spring.annotation.MapperScan;import org.springframework.context.annotation.Bean;import org.springframework.context.annotation.Configuration;import org.springframework.transaction.annotation.EnableTransactionManagement;/** * Mybatis Plus 配置 * * @author ruoyi */@EnableTransactionManagement(proxyTargetClass = true)@Configuration@MapperScan({"com.ruoyi.project.**.mapper","com.ruoyi.business.**.mapper"})public class MybatisPlusConfig {@Bean public MybatisPlusInterceptor mybatisPlusInterceptor() { MybatisPlusInterceptor interceptor = new MybatisPlusInterceptor();// 分頁插件 interceptor.addInnerInterceptor(paginationInnerInterceptor());// 樂觀鎖插件 interceptor.addInnerInterceptor(optimisticLockerInnerInterceptor());// 阻斷插件 interceptor.addInnerInterceptor(blockAttackInnerInterceptor());return interceptor; }/** * 分頁插件,自動識別數據庫類型 https://baomidou.com/guide/interceptor-pagination.html */ public PaginationInnerInterceptor paginationInnerInterceptor() { PaginationInnerInterceptor paginationInnerInterceptor = new PaginationInnerInterceptor();// 設置數據庫類型為mysql paginationInnerInterceptor.setDbType(DbType.MYSQL);// 設置最大單頁限制數量,默認 500 條,-1 不受限制 paginationInnerInterceptor.setMaxLimit(-1L);return paginationInnerInterceptor; }/** * 樂觀鎖插件 https://baomidou.com/guide/interceptor-optimistic-locker.html */ public OptimisticLockerInnerInterceptor optimisticLockerInnerInterceptor() {return new OptimisticLockerInnerInterceptor(); }/** * 如果是對全表的刪除或更新操作,就會終止該操作 https://baomidou.com/guide/interceptor-block-attack.html */ public BlockAttackInnerInterceptor blockAttackInnerInterceptor() {return new BlockAttackInnerInterceptor(); } }
關于如何解決框架集成Mybatis Plus中未找到綁定語句的問題就分享到這里了,希望以上內容可以對大家有一定的幫助,可以學到更多知識。如果覺得文章不錯,可以把它分享出去讓更多的人看到。
免責聲明:本站發布的內容(圖片、視頻和文字)以原創、轉載和分享為主,文章觀點不代表本網站立場,如果涉及侵權請聯系站長郵箱:is@yisu.com進行舉報,并提供相關證據,一經查實,將立刻刪除涉嫌侵權內容。