I’m currently developing an REST app whith Spring boot. For development, I hardcode my database configuration in application.properties
. However, this app is going to be deployed on different WildFly servers, each of them defining their DB config (user credentials) in standalone.xml
.
As I’m a newbe to Spring/Java, here is my question: How can I use the DB config from standalone for my spring app?
I already did some research. What I got is to define Services with an @PersistenceContext
annotated entity manager. But how can I use it without defining new services, just by using plain JpaRepositories?
Advertisement
Answer
In Wildfly you will have a datasource configured with at JNDI name.
Instead of configuring url, username and password you have to configure this JNDI name:
spring.datasource.jndi-name=java:jboss/datasources/myGreatDS
That’s all.