1 <jdbc.host.global>127.0.0.1</jdbc.host.global> 2 <jdbc.databasename.global>test</jdbc.databasename.global> 3 <jdbc.username.global>root</jdbc.username.global> 4 <jdbc.password.global>123</jdbc.password.global>
1 jdbc.driver=com.MysqL.jdbc.Driver 2 jdbc.url=jdbc:MysqL://${jdbc.host.global}:3306/${jdbc.databasename.global}?characterEncoding=utf-8 3 jdbc.username=${jdbc.username.global} 4 jdbc.password=${jdbc.password.global}
只需要在applicationContext.xml文件中添加下面这一行即可:
1 <context:property-placeholder location="classpath:db.properties"/>
1 <resources> 2 <resource> 3 <directory>src/main/resources</directory> 4 <filtering>true</filtering> 5 </resource> 6 </resources>