spring 配置Value常量(不支持到static上)
Posted 穆晟铭
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了spring 配置Value常量(不支持到static上)相关的知识,希望对你有一定的参考价值。
spring 配置Value常量(不支持到static上)
看代码吧,语言表达有问题。
package com.variflight.xzair.rest.constant; import org.springframework.beans.factory.InitializingBean; import org.springframework.beans.factory.annotation.Value; import org.springframework.stereotype.Component; @Component public class FocFlightConstant implements InitializingBean { /**地址**/ @Value("${foc.flight.url}") public String focFlightUrl; /**FOC: username**/ @Value("${foc.flight.username}") public String focFlightUsername; @Value("${foc.flight.password}") public String focFlightPassowrd; /**varflight-flight: username**/ /**appid**/ @Value("${foc.variflight.appid}") public String variflightAppid; /**security**/ @Value("${foc.variflight.security}") public String variflightSecurity; /**航班动态**/ @Value("${foc.variflight.flight.url}") public String variflightFlightUrl; /**机舱图**/ @Value("${foc.variflight.play.url}") public String varflightPlayUrl; public static String FOC_FLIGHT_URL; public static String FOC_FLIGHT_USERNAME; public static String FOC_FLIGHT_PASSWD; public static String VARIFLIGHT_FLIGHT_APPID; public static String VARIFLIGHT_FLIGHT_SECURITY; public static String VARIFLIGHT_FLIGHT_URL; public static String VARIFLIGHT_PLAY_URL; @Override public void afterPropertiesSet() throws Exception { FOC_FLIGHT_URL = focFlightUrl; FOC_FLIGHT_USERNAME = focFlightUsername; FOC_FLIGHT_PASSWD = focFlightPassowrd; VARIFLIGHT_FLIGHT_APPID = variflightAppid; VARIFLIGHT_FLIGHT_SECURITY = variflightSecurity; VARIFLIGHT_FLIGHT_URL = variflightFlightUrl; VARIFLIGHT_PLAY_URL = varflightPlayUrl; } }
以上是关于spring 配置Value常量(不支持到static上)的主要内容,如果未能解决你的问题,请参考以下文章