• Spring基础(8) : properties配置文件


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

      

  • 相关阅读:
    f5版本升级
    f5申请并激活License
    f5时间设置
    f5 SNMP配置
    f5 Syslog管理
    f5单台安装配置
    f5负载均衡算法
    f5 Seldom used
    f5售后查询
    f5基本介绍
  • 原文地址:https://www.cnblogs.com/lh218/p/6551260.html
Copyright © 2020-2023  润新知