My servlet.xml file holds all my spring configuration related information like datasource bean etc.
<bean id="..." class="...">
</bean>
Now my application has other settings that I need to save in a configuration file, is it possible to create my own settings in here or is there a better way?
I want something that loads up once and is very fast to reference in my project.
I need this to store some file paths, and other database settings for things like mongodb etc.
You can use
.propertiesfile:If the file contents are:
You can reference them in Spring XML like this:
Reference: 4.8.2.1 Example: the
PropertyPlaceholderConfigurer.You can also inject these properties into your own classes:
Of course you can also use setter-injection like in the example with
DriverManagerDataSourceif you prefer XML.Also have a look at: Spring 3.1 M1: Unified Property Management.