Spring @Value注入static属性

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

}

 

posted @ 2019-08-20 20:42  sixinshuier  阅读(240)  评论(0)    收藏  举报