配置文件加載的方式

@Component
public class RobotUtils {

    private static String active;

    @Value("${spring.profiles.active}")
    public void setActive(String active){
        RobotUtils.active = active;
    }
}
@Data
@ConfigurationProperties(prefix = "wechat")
@Component
public class WeChatConfig {

    private String tokenUrl;

    private String sendUrl;

    private String grantType;
}
    import org.springframework.core.env.Environment;


    @Resource
    private Environment environment;

    environment.getProperty(key);
    @Value("${wechat.url.token}")
    private String token;

 

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章