读书人

加载项目中的properties资料.小述

发布时间: 2012-11-23 22:54:33 作者: rapoo

加载项目中的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}" />

?像这样配置就行了。

?

读书人网 >软件架构设计

热点推荐