Spring Boot Multiple Databse : No qualifying bean of type EntityManagerFactoryBuilder

@Primary must be used exactly on one bean among the required types.

Extract from @Primary javadoc

Indicates that a bean should be given preference when multiple candidates are qualified to autowire a single-valued dependency. If exactly one 'primary' bean exists among the candidates, it will be the autowired value.


You have an error in your code. You specify

@Primary 

Annotation for both of datasources, therefore Spring claims. So you need to remove this annotation from one of your class and all will be ok.

Also please note that Primary annotation is helpful whenever we’re going to implicitly or explicitly inject the transaction manager without specifying which one by name.