Grails supports the notion of property placeholder configuration through an extended version of Spring's
PropertyPlaceholderConfigurer, which is typically useful when used in combination with
externalized configuration.
Settings defined in either
ConfigSlurper scripts of Java properties files can be used as placeholder values for Spring configuration in
grails-app/conf/spring/resources.xml
. For example given the following entries in
grails-app/conf/Config.groovy
(or an externalized config):
database.driver="com.mysql.jdbc.Driver"
database.dbname="mysql:mydb"
You can then specify placeholders in
resources.xml
as follows using the familiar ${..} syntax:
<bean id="dataSource" class="org.springframework.jdbc.datasource.DriverManagerDataSource">
<property name="driverClassName"><value>${database.driver}</value></property>
<property name="url"><value>jdbc:${database.dbname}</value></property>
</bean>