This is a code example that executes some processing when the application is started in the Spring Boot application.
package mypackage;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.context.ConfigurableApplicationContext;
@SpringBootApplication
public class MyApplication {
	private static Logger log = LoggerFactory.getLogger(MyApplication.class);
	
	public static void main(String[] args) {
		ConfigurableApplicationContext ctx = SpringApplication.run(MyApplication.class, args);
		MyApplication app = ctx.getBean(MyApplication.class);
		app.execStartup(args);
	}
		
	public void execStartup(String[] args) {
// Write the process you want to execute when the application starts here } }
Recommended Posts