Spring boot @Qualifier doesn't work with datasources

The error is indicating that at some point in the application, a bean is being injected by the type DataSource and not being qualified by name at that point.


It does not matter that you have added @Qualifier in one location. The injection is failing in some other location that has not been qualified. It's not your fault though because that location is in Spring Boot's DataSourceAutoConfiguration which you should be able to see in your stack trace, below the piece that you have posted.


I would recommend excluding DataSourceAutoConfiguration i.e. @SpringBootApplication(exclude = DataSourceAutoConfiguration.class). Otherwise, this configuration is only being applied to the bean you have made @Primary. Unless you know exactly what that is, it is likely to result in subtle and unexpected differences in behaviour between your DataSources.




原文地址


猜你喜欢

转载自blog.csdn.net/K0000000r/article/details/77883033