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; } }