問題描述@PostConstruct在servlet中執(zhí)行時(shí),在構(gòu)造方法后,init方法前執(zhí)行,那么在工具類中呢?今天偶爾看到了springboot將常量注入靜態(tài)工具類的代碼,發(fā)現(xiàn)使用了PostConstruct注解,沒搞懂在這個(gè)類的執(zhí)行順序問題出現(xiàn)的環(huán)境背景及自己嘗試過哪些方法@Value("${constant.path}")private String path;private static String staticPath;@PostConstructpublic void getPath() {
staticPath = this.path;
}
- 2 回答
- 0 關(guān)注
- 3724 瀏覽
添加回答
舉報(bào)
0/150
提交
取消