# Grails 1.1 运行时Spring与Beans DSL - 属性占位符配置

**URL:** <https://www.isharkfly.com/t/grails-1-1-spring-beans-dsl/6823>\
**Category:** 程序语言\
**Created:** [November 11, 2012, 4:49am UTC](https://www.isharkfly.com/t/grails-1-1-spring-beans-dsl/6823 "2012-11-11T04:49:14Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![honeymoose](https://www.isharkfly.com/user_avatar/www.isharkfly.com/honeymoose/32/20796_2.png) [@honeymoose](https://www.isharkfly.com/u/honeymoose)\
**Post date:** [November 11, 2012, 4:49am UTC](https://www.isharkfly.com/t/grails-1-1-spring-beans-dsl/6823/1 "2012-11-11T04:49:14Z")

</div>

通过扩展的Spring的PropertyPlaceholderConfigurer，Grails支持属性占位符配置，这和 外部配置配合使用非常有用。

接着在 resources.xml中用${…}语法定义占位符：`<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>`
