问题描述
@PostConstruct在servlet中执行时,在构造方法后,init方法前执行,那么在工具类中呢?
今天偶尔看到了springboot将常量注入静态工具类的代码,发现使用了PostConstruct注解,没搞懂在这个类的执行顺序
问题出现的环境背景及自己尝试过哪些方法
@Value("${constant.path}")
private String path;
private static String staticPath;
@PostConstruct
public void getPath() {
staticPath = this.path;
}
一样的,只要这个类纳入spring bean管理,那么都是在构造方法后。