Reputation: 166
I have a spring web application which has several modules. Each module has its own spring context file. When i assemble the application these context files are built into jar files. Sometimes i need to change some configuration details in these files, for example data source database url. I don't like when all configurations happen at compile time and require rebuilding. Is there a common way of configuring application at deploy time?
Thank you.
Upvotes: 2
Views: 219
Reputation: 4666
Depending of the application server you use, but a common way to configure database url is to use a property file on the server. The file is loaded when the server starts.
You can load this file using Spring with a PropertyPlaceholderConfigurer. Then it's possible to reference a property by its key.
<bean id="dataSource" class="org.springframework.jdbc.datasource.DriverManagerDataSource">
<property name="driverClassName"><value>${driver}</value></property>
<property name="url"><value>jdbc:${dbname}</value></property>
</bean>
What application server do you use?
Upvotes: 2