Loading properties files in the spring configuration
The issue:
Our webapp is using a spring and hibernate backend, and both spring configuration and Java classes need to access database connection properties.
Currently there is an application.properties file and a spring applicationContext.xml, both which contain the same information for the database connection. Ideally, there should be only one configuration file to define the properties, which is used by both spring and Java.
Spring has the ability to load properties files as part of the application configuration, for use internally. The properties can be referenced within spring configuration files using ant-style placeholders, e.g.
${app.var}. To solve our issue though we'll also need to provide a populated bean that can be used by our production classes. Here's the properties file (
application.properties):