Sprint加载properties文件内容相关配置。
2015-07-30 09:24
253 查看
properties文件路径:config/properties/test.properties
内容:
test.id=123
test.name=测试
XML配置文件:
<?xml version="1.0" encoding="uTF-8"?>
<beans xmlns="http://www.springframework.org/schema/beans"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:p="http://www.springframework.org/schema/p"
xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-3.0.xsd">
<bean id="propertyConfigurer"
class="org.springframework.beans.factory.config.PropertyPlaceholderConfigurer">
<property name="locations">
<list>
<value>config/properties/test.properties</value><!-- 加载队列配置文档 -->
</list>
</property>
</bean>
<bean class="com.test.entity.Test">
<property name="id" >
<value>${test.id}</value>
</property>
<property name="name" >
<value>${test.name}</value>
</property>
</bean>
Test类:
public class Test{
public static String id;
public static String name;
//get set方法...
}
内容:
test.id=123
test.name=测试
XML配置文件:
<?xml version="1.0" encoding="uTF-8"?>
<beans xmlns="http://www.springframework.org/schema/beans"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:p="http://www.springframework.org/schema/p"
xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-3.0.xsd">
<bean id="propertyConfigurer"
class="org.springframework.beans.factory.config.PropertyPlaceholderConfigurer">
<property name="locations">
<list>
<value>config/properties/test.properties</value><!-- 加载队列配置文档 -->
</list>
</property>
</bean>
<bean class="com.test.entity.Test">
<property name="id" >
<value>${test.id}</value>
</property>
<property name="name" >
<value>${test.name}</value>
</property>
</bean>
Test类:
public class Test{
public static String id;
public static String name;
//get set方法...
}
相关文章推荐
- java对世界各个时区(TimeZone)的通用转换处理方法(转载)
- java-注解annotation
- java-模拟tomcat服务器
- java-用HttpURLConnection发送Http请求.
- java-WEB中的监听器Lisener
- Android IPC进程间通讯机制
- Android Native 绘图方法
- Android java 与 javascript互访(相互调用)的方法例子
- 介绍一款信息管理系统的开源框架---jeecg
- 聚类算法之kmeans算法java版本
- java实现 PageRank算法
- PropertyChangeListener简单理解
- 插入排序
- 冒泡排序
- 堆排序
- 快速排序
- 二叉查找树
- [原创]java局域网聊天系统