springboot 项目启动前想要执行方法的几种方式

以下为按照执行的先后顺序:

1,自身构造方法

2,

@PostConstruct// import javax.annotation.PostConstruct;
public void test(){
    System.out.println("PostConstruct-------------test");
}

3,实现InitializingBean接口重写afterPropertiesSet方法

@Override
public void afterPropertiesSet() throws Exception {
    System.out.println("afterPropertiesSet-------------test");
}

猜你喜欢

转载自blog.csdn.net/xc_nostalgia/article/details/108662021
今日推荐