SpringBoot+MyBatis-Plus启动报错MybatisPlusProperties

SpringBoot+MyBatis-Plus启动报错如下

***************************
APPLICATION FAILED TO START
***************************

Description:

Parameter 1 of constructor in com.baomidou.mybatisplus.autoconfigure.IdentifierGeneratorAutoConfiguration$InetUtilsAutoConfig required a bean of type 'com.baomidou.mybatisplus.autoconfigure.MybatisPlusProperties' that could not be found.


Action:

Consider defining a bean of type 'com.baomidou.mybatisplus.autoconfigure.MybatisPlusProperties' in your configuration.

参考资料:透过源码解决SeataAT模式整合Mybatis-Plus失去MP特性的问题

解决办法(网上方法多种,本文提供其中一种解决办法):去掉自己配置的sqlSessionFactory,直接让DataSource bean返回的是一个被代理过的bean,并且加入了@Primary,让MyBatis-Plus优先使用我们配置的数据源。(在自己配置的数据源上加上@Primary即可启动)
在这里插入图片描述


版权声明:本文为u014800975原创文章,遵循CC 4.0 BY-SA版权协议,转载请附上原文出处链接和本声明。