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

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