ITeye博客

Spring 加载配置文件

augustcoco · 2015-06-03 16:59 · web · Spring · Java · 编程语言 · Markdown


 <bean id="propertyConfigurer"       class="org.springframework.beans.factory.config.PropertyPlaceholderConfigurer">
        <property name="location">
            <value>classpath:com/starxing/test/database.properties</value>
        </property>
       <!-- 使用locations属性定义多个配置文件
       <property name="locations">
            <list>
                <value>classpath:config/mail.properties</value>
                <value>classpath:config/database.properties</value>
            </list>
      </property>
     -->
</bean>

示例:



    <bean id="dataSource"
            class="org.springframework.jdbc.datasource.DriverManagerDataSource">
            <property name="url">
                <value>${database.url}</value>
            </property>
            <property name="driverClassName">
                <value>${database.driver}</value>
            </property>
            <property name="username">
                <value>${database.user}</value>
            </property>
            <property name="password">
                <value>${database.password}</value>
            </property>
    </bean>


评论(0)

暂无评论。

评论功能维护中,当前仅展示历史评论。