1 | initial version |
There are different ways to execute code once Spring Boot has started:
@Component
public class MyCommandLineRunner implements CommandLineRunner {
@Override
public void run(String... args) throws Exception {
// Your code here
}
}
@Component
public class MyApplicationRunner implements ApplicationRunner {
@Override
public void run(ApplicationArguments args) throws Exception {
// Your code here
}
}
@Component
public class MyComponent {
@PostConstruct
public void init() {
// Your code here
}
}