Several ways to execute methods before the springboot project starts

The following is in the order of execution:

1. Self-construction method

2,

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

3. Implement the InitializingBean interface to override the afterPropertiesSet method

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

Guess you like

Origin blog.csdn.net/xc_nostalgia/article/details/108662021
Recommended