spring boot解决类初始化顺序问题
这两天在学习的时候,忽然看到一个解决初始化跟注入类之间前后顺序的方法
@Component public class TestInitClass implements InitializingBean { private Integer order; private TestInitClass(){ System.out.println("初始化:order:"+this.order); } /** * 初始化之后才执行 * @throws Exception */ @Override public void afterPropertiesSet() throws Exception { this.order = 1; System.out.println("afterPropertiesSet order值:"+this.order); } }

浙公网安备 33010602011771号