1. 程式人生 > >spring 配置Value常量(不支持到static上)

spring 配置Value常量(不支持到static上)

err exce sse org 地址 ack security ans factory

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上)