Resource Annotation: No qualifying bean of type [javax.sql.DataSource] is defined: expected single matching bean but found 2

后端 未结 3 1980
醉酒成梦
醉酒成梦 2021-02-03 10:30

I am using Spring Java Based configuration for configure multiple database with Spring Data. In the configuration file, i am creating two data source for MySQ

3条回答
  •  既然无缘
    2021-02-03 10:57

    I had the same problem and found this old post that explained it:

    http://xantorohara.blogspot.ch/2013/11/spring-boot-jdbc-with-multiple.html

    It looks like if you need multiple data sources, the Spring Boot magic runs out, and you have to take over the configuration manually.

    In my case, I had to modify the EnableAutoConfiguration to take over the data source and transaction manager configuration myself:

    @EnableAutoConfiguration(exclude = {DataSourceAutoConfiguration.class,DataSourceTransactionManagerAutoConfiguration.class}) 
    

    It looks like the Spring Boot magic ran out at the point I had to use multiple data sources...

提交回复
热议问题