Is it possible to create a data source by reading the values from an external file which is not bundled with WAR in spring application.
Asked
Active
Viewed 606 times
2 Answers
1
You can use the @PropertySource
annotation to load your db properties and you can load the properties from file location like below:-
@PropertySource("file:${app.home}/db.properties")
reference link here:-
https://www.mkyong.com/spring/spring-propertysources-example/
For XML based configuration sample code could be like below:-
<bean class="org.springframework.beans.factory.config.PropertyPlaceholderConfigurer">
<property name="locations">
<list>
<value>${app.home}/db.properties</value>
</list>
</property>
</bean>

kakabali
- 3,824
- 2
- 29
- 58
-1
you can setup your datasource in any properties file, and then you have to provide the classpath for that file in your catalina.sh where you are running your war. don't forget to load that property file in in your application.

Ravat Tailor
- 1,193
- 3
- 20
- 44