<context:property-placeholder location="p.properties"/>

    <bean >
         <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"/>

  

相关文章:

  • 2021-07-28
  • 2021-07-14
  • 2022-12-23
  • 2021-10-08
  • 2022-12-23
  • 2021-07-07
  • 2022-12-23
猜你喜欢
  • 2022-12-23
  • 2022-02-25
  • 2021-12-15
  • 2022-12-23
  • 2021-06-21
  • 2021-10-22
  • 2021-12-05
相关资源
相似解决方案