项目环境:

druid: 1.1.21 
sharding-jdbc:4.1.0

一般是不会报错的,之所以出现这样的原因是依赖出现了冲突,导致找不到 xxMapper.xml 文件。出现报错时引入的依赖为:

<dependency>
    <groupId>com.alibaba</groupId>
    <artifactId>druid-spring-boot-starter</artifactId>
    <version>1.1.21</version>
</dependency>

<dependency>
    <groupId>org.apache.shardingsphere</groupId>
    <artifactId>sharding-jdbc-spring-boot-starter</artifactId>
    <version>4.1.0</version>
</dependency>

druid-spring-boot-startersharding-jdbc-spring-boot-starter 会产生冲突,如果想要用 sharding-jdbc-spring-boot-starter 的话,这里的 druid 就不能使用 starter 版本的,必须使用完整版本的,修改后如下:

<dependency>
    <groupId>com.alibaba</groupId>
    <artifactId>druid</artifactId>
    <version>1.1.21</version>
</dependency>

<dependency>
    <groupId>org.apache.shardingsphere</groupId>
    <artifactId>sharding-jdbc-spring-boot-starter</artifactId>
    <version>4.1.0</version>
</dependency>

这样就可以正常的运行项目了。

个人博客:Roc’s Blog

Logo

魔乐社区(Modelers.cn) 是一个中立、公益的人工智能社区,提供人工智能工具、模型、数据的托管、展示与应用协同服务,为人工智能开发及爱好者搭建开放的学习交流平台。社区通过理事会方式运作,由全产业链共同建设、共同运营、共同享有,推动国产AI生态繁荣发展。

更多推荐