您的位置:首页 > 运维架构

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方法...

}
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签:  java properties