码迷,mamicode.com
首页 > 编程语言 > 详细

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

时间:2018-12-14 12:54:33      阅读:317      评论:0      收藏:0      [点我收藏+]

标签:表达   ppi   动态   pack   username   package   pac   err   ant   

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

标签:表达   ppi   动态   pack   username   package   pac   err   ant   

原文地址:https://www.cnblogs.com/achengmu/p/10118251.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!