Skip to content
Advertisement

Spring Boot 2 Multiple Datasource – work only the one with @Primay annotation

I have a problem, I’m trying to use two Oracle databases in spring boot using DataSource, The DataSource wiht the @Primay annotation works fine but the oher one only gives me:

JavaScript

I don’t have idea what I should do now. Any help will be welcomed. Thanks!

application.properties

JavaScript

pom.xml

JavaScript

DatabaseConfiguration.java

JavaScript

Repository from 1st DB

JavaScript

Repository from 2nd DB

JavaScript

Advertisement

Answer

I could resolve the problem with the following changes in my code:

application.properties

I changed the spring.jpa.hibernate.ddl-auto from none to validate and made some other chages

JavaScript

pom.xml

Added a new dependency

JavaScript

Divided the DatabaseConfiguration.java in two separeated files InMpConfig.java and SgcConfig.java

InMpConfig.java

JavaScript

SgcConfig.java

JavaScript

And made some changes to the models, such as add the @Table and @Column annotation

JavaScript

I hope this is helpful for someone else.

User contributions licensed under: CC BY-SA
6 People found this is helpful
Advertisement