zoukankan      html  css  js  c++  java
  • Spring MVC 中使用properties文件

    首先要搭建Spring mvc的环境,然后开始properties文件里的配置:

    第一步:在springcontext中注入properties,具体路径自己调整

    <bean id="config" class="org.springframework.beans.factory.config.PropertiesFactoryBean">
         <property name="locations">
             <list>
                   <value>classpath:config.properties</value>
             </list>
         </property>
         <property name="fileEncoding" value="utf-8" />
    </bean>


    第二步:在使用的地方加上Value 注解

    @Value("#{config['email.hostName']}")
    private String hostName;
    
    @Value("#{config['email.address']}")
    private String address;

    第三步:使用属性

    System.out.println(hostName);
    System.out.println(address);

    附 config.properties:

    ##配置
    email.hostName=smtp.aliyun.com
    email.address=lixingwu@aliyun.com
  • 相关阅读:
    grid layout
    flex box布局
    box-shadow
    text-shadow
    border-radius
    manjaro conky配置
    博客园样式设置
    python排序参数key以及lambda函数
    python-批量解压zip、rar文件
    Python
  • 原文地址:https://www.cnblogs.com/lixingwu/p/9249104.html
Copyright © 2011-2022 走看看