码迷,mamicode.com
首页 > 其他好文 > 详细

@Value() 使用方法

时间:2017-04-01 15:02:36      阅读:342      评论:0      收藏:0      [点我收藏+]

标签:erro   ror   class   nbsp   ati   error   logs   code   pac   

使用@Value():

1、该注解所在的类,必须要被扫描到:

  <context:component-scan base-package="com.laiw"/>

备注:

  1、在静态类,该注解无效

  2、无效,使用properties进行取值:

  

public static final String GLOBAL_CONFIG_PATH = "file:" + System.getProperty("integral.config.path");


public static String getProperties(String key) {
        try {
            Properties p = PropertiesLoader.loadProperties(GLOBAL_CONFIG_PATH + "/integral.properties");
            return p.getProperty(key);
        } catch (IOException e) {
            logger.error("错误", e, e.getMessage());
        }
        return "";
    }


public static final String HR_VERSION = PropertiesLoader.getProperties("HRVersion");

    public static final String BR_MERCHANT_CODE = PropertiesLoader.getProperties("bankMerchantCode");

 

@Value() 使用方法

标签:erro   ror   class   nbsp   ati   error   logs   code   pac   

原文地址:http://www.cnblogs.com/zilanghuo/p/6655937.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!