PropertyPlaceholderConfigurer vs Filters -- Spring Beans
Posted
by John
on Stack Overflow
See other posts from Stack Overflow
or by John
Published on 2010-05-03T11:36:50Z
Indexed on
2010/05/03
11:48 UTC
Read the original article
Hit count: 280
Hi there.
I've got a question regarding the difference between PropertyPlaceholderConfigurer (org.springframework.beans.factory.config.PropertyPlaceholderConfigurer) and normal filters defined in my pom.xml.
I've been looking at examples, and it seems that even though filters are defined and marked to be active by default in the pom.xml they still make use of PropertyPlaceholderConfigurer in Spring's applicationContext.xml.
This means that the pom.xml has a reference to a filter-LOCAL.properties while applicationContext.xml has a reference to application.properties and they both contain the same settings.
Why is that? Is that how it is supposed to be done? I'm able to run the goal mvn jetty:run without the application.properties present, but if I add settings to the application.properties that differ from the filter-LOCAL.properties they don't seem to override.
Here's an example of what I mean:
pom.xml
<profiles> <profile> <id>LOCAL <activation> <activeByDefault>true </activation> <properties> <env>LOCAL </properties> </profile> </profiles>
applicationContext.xml
<bean id="propertyConfigurer" class="org.springframework.beans.factory.config.PropertyPlaceholderConfigurer"> <property name="locations"> <list> <value>classpath:application.properties </list> </property> <property name="ignoreResourceNotFound" value="true"/> </bean> <bean id="dataSource" class="org.apache.commons.dbcp.BasicDataSource" destroy-method="close"> <property name="driverClassName" value="${jdbc.driver}"/> <property name="url" value="${jdbc.url}"/> <property name="username" value="${jdbc.username}"/> <property name="password" value="${jdbc.password}"/> </bean>
an example of the content of application.properties and filters-LOCAL.properties
jdbc.driver=org.postgresql.Driver jdbc.url=jdbc:postgresql://localhost/shoutbox_dev jdbc.username=tester jdbc.password=tester
Can I remove the propertyConfigurer from the applicationContext, create a PROD filter and disregard the application.properties file, or will that give me issues when deploying to the production server?
© Stack Overflow or respective owner