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 Boot 核心配置与注解02——配置文件属性值的注入
- spring对抽象类中属性的自动注入
- 对于Spring对websocket的属性注入失败问题,困扰我一天,最后终于解决了
- static静态变量使用@Value注入方式
- Spring Boot系列四 Spring @Value 属性注入使用总结一
- Spring Boot使用@Value注解注入Map、List注入失败踩坑
- Spring Boot系列五 Spring @Value 属性注入使用总结二
- Spring的@Value注入map&List, properties、yml格式配置文件的多种实现方式
- Spring @Value@Configuration注入map、List、Bean,注入失败看这篇就够了
- 在Spring-Boot中使用@Value注解注入集合类