标签:内容 getbean ace app string bean context sys lap
<context:property-placeholder location="p.properties"/> <bean id="p" class="com.Person"> <property name="name" value="${name}"/> </bean>
工程 resource下新建一个 p.properties文件,里面内容为:
name=hahadaxiao
使用:
public static void main(String[] args){ ClassPathXmlApplicationContext context = new ClassPathXmlApplicationContext("a.xml"); Person p = context.getBean("p",Person.class); System.out.println(p.name); }
打印:
hahadaxiao
若有多个properties文件,则用 *号通配符,或者用逗号分隔
<context:property-placeholder location="*.properties"/>
<context:property-placeholder location="p.properties,pbp.properties"/>
标签:内容 getbean ace app string bean context sys lap
原文地址:http://www.cnblogs.com/lh218/p/6551260.html