Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

Solutions to the problems encountered in springboot Integrated mybatis-plus

2025-03-10 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >

Share

Shulou(Shulou.com)06/03 Report--

This article mainly introduces "the solution to the problem encountered by springboot integration mybatis-plus". In the daily operation, I believe that many people have doubts about the solution to the problem encountered by springboot integration mybatis-plus. The editor consulted all kinds of materials and sorted out simple and easy-to-use operation methods. I hope it will be helpful for you to answer the doubt of "solution to the problem encountered by springboot integration mybatis-plus". Next, please follow the editor to study!

First of all, I put the xml package is no problem, but the introduction of the rack package and configuration problems, the problem configuration is as follows

Solution: please change mybatis-plus to mybatis,mybatis,mybtis. Say the important thing three times. The necessary packages are as follows.

Org.mybatis.spring.boot mybatis-spring-boot- starter com.baomidou mybatis-plus 2.1.9 org.mybatis.spring.boot mybatis-spring-boot-autoconfigure 1.3.2

Note that the first one is mybatis-spring-boot-start, not mybatisplus-spring-boot-start, and declare MybatisSqlSessionFactoryBean in the mybatis configuration file, so the problem is solved.

@ Configurationpublic class MybatisPlusConfig {@ Autowired private DataSource dataSource; @ Autowired private MybatisProperties properties; @ Autowired private ResourceLoader resourceLoader = new DefaultResourceLoader (); @ Autowired (required = false) private Interceptor [] interceptors; @ Autowired (required = false) private DatabaseIdProvider databaseIdProvider; / * mybatis-plus paging plug-in * / @ Bean public PaginationInterceptor paginationInterceptor () {PaginationInterceptor page = new PaginationInterceptor (); page.setDialectType ("mysql"); return page } / * all resources that have been loaded automatically by mybatis-autoconfigure are used here. Do not manually specify * configuration file and mybatis-boot profile synchronization * @ return * / @ Bean public MybatisSqlSessionFactoryBean mybatisSqlSessionFactoryBean () {MybatisSqlSessionFactoryBean mybatisPlus = new MybatisSqlSessionFactoryBean (); mybatisPlus.setDataSource (dataSource); mybatisPlus.setVfs (SpringBootVFS.class); if (StringUtils.hasText (this.properties.getConfigLocation () {mybatisPlus.setConfigLocation (this.resourceLoader.getResource (this.properties.getConfigLocation ();} mybatisPlus.setConfiguration (properties.getConfiguration ()) If (! ObjectUtils.isEmpty (this.interceptors)) {mybatisPlus.setPlugins (this.interceptors);} MybatisConfiguration mc = new MybatisConfiguration (); mc.setDefaultScriptingLanguage (MybatisXMLLanguageDriver.class); mybatisPlus.setConfiguration (mc); if (this.databaseIdProvider! = null) {mybatisPlus.setDatabaseIdProvider (this.databaseIdProvider);} if (StringUtils.hasLength (this.properties.getTypeAliasesPackage () {mybatisPlus.setTypeAliasesPackage (this.properties.getTypeAliasesPackage ()) } if (StringUtils.hasLength (this.properties.getTypeHandlersPackage () {mybatisPlus.setTypeHandlersPackage (this.properties.getTypeHandlersPackage ());} if (! ObjectUtils.isEmpty (this.properties.resolveMapperLocations () {mybatisPlus.setMapperLocations (this.properties.resolveMapperLocations ());} return mybatisPlus;}} at this point, the study on "the solution to the problem encountered by springboot integrated mybatis-plus" is over, hoping to solve everyone's doubts. The collocation of theory and practice can better help you learn, go and try it! If you want to continue to learn more related knowledge, please continue to follow the website, the editor will continue to work hard to bring you more practical articles!

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Development

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report