使用@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");

 

相关文章:

  • 2022-12-23
  • 2022-12-23
  • 2021-04-07
  • 2021-11-07
  • 2022-12-23
  • 2021-07-18
猜你喜欢
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2021-04-27
  • 2022-12-23
相关资源
相似解决方案