[JAVA] Processing at application startup with Spring Boot

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

Processing at application startup with Spring Boot
Inquiry application creation with Spring Boot
Start web application development with Spring Boot
Launch Nginx + Spring Boot application with docker-compose
Asynchronous processing with Spring Boot using @Async
Run WEB application with Spring Boot + Thymeleaf
Spring Boot 2.3 Application Availability
Download with Spring Boot
Configure Spring Boot application with maven multi module
Asynchronous processing with regular execution in Spring Boot
Execute arbitrary processing after Basic authentication with Spring boot.
Generate barcode with Spring Boot
Hello World with Spring Boot
Implement GraphQL with Spring Boot
Try using OpenID Connect with Keycloak (Spring Boot application)
Get started with Spring boot
Hello World with Spring Boot!
Spring with Kotorin --6 Asynchronous processing
[Spring Boot] Web application creation
Run LIFF with Spring Boot
SNS login with Spring Boot
File upload with Spring Boot
Spring Boot starting with copy
CICS-Run Java application-(4) Spring Boot application
Spring Boot starting with Docker
Hello World with Spring Boot
Set cookies with Spring Boot
Use Spring JDBC with Spring Boot
Add module with Spring Boot
Getting Started with Spring Boot
Create microservices with Spring Boot
Send email with spring boot
Implement REST API with Spring Boot and JPA (Application Layer)
Spring Boot application that specifies DB connection settings with parameters
Use Basic Authentication with Spring Boot
Spring Boot application development in Eclipse
Spring Boot application code review points
gRPC on Spring Boot with grpc-spring-boot-starter
Create an app with Spring Boot 2
Hot deploy with Spring Boot development
Database linkage with doma2 (Spring boot)
Spring Boot programming with VS Code
Until "Hello World" with Spring Boot
Get validation results with Spring Boot
(Intellij) Hello World with Spring Boot
Create an app with Spring Boot
Google Cloud Platform with Spring Boot 2.0.0
Check date correlation with Spring Boot
Implement Spring Boot application in Gradle
I tried GraphQL with Spring Boot
[Java] LINE integration with Spring Boot
Beginning with Spring Boot 0. Use Spring CLI
I tried Flyway with Spring Boot
Message cooperation started with Spring Boot
Spring Boot gradle build with Docker
Let's make a book management web application with Spring Boot part1
Let's make a book management web application with Spring Boot part3
Let's make a book management web application with Spring Boot part2
[Beginner] Let's write REST API of Todo application with Spring Boot
Hello World with Eclipse + Spring Boot + Maven
Send regular notifications with LineNotify + Spring Boot