Parameter 0 of method sqlSessionTemplate in org.mybatis.spring.boot.autoconfigure.MybatisAutoConfiguration required a single bean, but 2 were found:

Consider marking one of the beans as @Primary, updating the consumer to acce

这个原因是在springboot配置多数据源的时候,可能在某个datasource1中配置了@Primary(主要注解),此时在你的datasource2中也去配置了这个注解,name这个问题就会产生

或者是当你在某个DBconfig中在配置注解@ConfigurationProperties(“mysql.datasource.db1”)在这个注解之前去配置了@Component这个组件注解,同样也会引起报错

==============================================
报错信息
Parameter 0 of method sqlSessionTemplate in org.mybatis.spring.boot.autoconfigure.MybatisAutoConfiguration required a single bean, but 2 were found:
Consider marking one of the beans as @Primary, updating the consumer to acce……

Logo

华为开发者空间,是为全球开发者打造的专属开发空间,汇聚了华为优质开发资源及工具,致力于让每一位开发者拥有一台云主机,基于华为根生态开发、创新。

更多推荐