首页 > 编程语言 > 详细

Spring @Value注入static属性

时间:2019-08-20 22:31:30      阅读:100      评论:0      收藏:0      [点我收藏+]
import org.springframework.beans.factory.annotation.Value;
import org.springframework.stereotype.Component;

import javax.annotation.PostConstruct;

@Component
public class Constants {

    @Value("${com.password}")
    private String password;

    public static String PASSWORD;

    @PostConstruct
    public void init() {
        PASSWORD = password;
    }

}

 

Spring @Value注入static属性

原文:https://www.cnblogs.com/shix0909/p/11385505.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!