spring-projects / spring-data-examples

Spring Data Example Projects
Apache License 2.0
5.17k stars 3.39k forks source link

The examples dont provide application.property settings needed for connecting to multiple databases using JPA #639

Closed dbnex14 closed 2 years ago

dbnex14 commented 2 years ago

I see no information about setting properties such as url, username, password, hibernate dialect. Is it missing?

schauder commented 2 years ago

With multiple data sources you can't simply rely on Spring Boot to pick up your configuration from the application.properties instead you'll have to do that on your own.

In the examples this setup is done in CustomerConfig and OrderConfig This is also described in the readme of the example.

Of course ,you can store information that you want to be easily changed in the application.properties and then inject it in your configuration class, but that is just one of many ways you can handle it and not special for Spring Data. Therefore that isn't included in the example. See for example https://stackoverflow.com/questions/317687/how-can-i-inject-a-property-value-into-a-spring-bean-which-was-configured-using for more ideas.