首页 > 其他 > 详细

@Value() 使用方法

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

使用@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() 使用方法

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

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!