Created
August 28, 2017 01:26
-
-
Save kazz12211/2b9717a56f1a28623af30f8592727dc9 to your computer and use it in GitHub Desktop.
Spring Bootでアプリケーション起動時に何らかの処理を実行するコード例
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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) { | |
// ここにアプリケーション起動時に実行したい処理を書く | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment