加载项目中的properties文件....小述
下面是db.properties内容:
?
db.url = jdbc:mysql://localhost:3306/xxxxxcreateDatabaseIfNotExist=truedb.username = xxxdb.password = xxxdb.driverClassName = com.mysql.jdbc.Driverhibernate.show_sql = truehibernate.dialect = org.hibernate.dialect.MySQLInnoDBDialecthibernate.hbm2ddl.auto = update
?
应用的时候, 在命名空间上配置上spring-context-3.0.xsd ;
?
?
然后在spring的配置(application.xml)文件中, 加入
<context:property-placeholder location="classpath:db.properties"/>
?
就OK啦。
?
用到db.properties里面属性的时候,只要
<property name="username" value="${db.username}" />?像这样配置就行了。
?