LoginSignup
4
1

More than 5 years have passed since last update.

intellijでSpring Bootプロジェクトを作成、起動してもすぐに終了する

Last updated at Posted at 2018-03-13

IntteliJでSpring Bootを始めようと思って、
プロジェクトを作成、実行した時につまづいたときのことです。

症状

IntelliJでSpring Inirializerを使ってプロジェクトを作ってmainからRun Applicationを実行したところ、すぐにアプリケーションが終了してしまいました。

2018-03-13 20:45:42.270  INFO 7595 --- [      Thread-12] o.s.j.e.a.AnnotationMBeanExporter        : Unregistering JMX-exposed beans on shutdown

Process finished with exit code 0

eclipseからの実行ではうまくいくし、gradleからの実行もうまくいく。。。
なぜかIntelliJからのRun Applicationからは起動しない。。。

解決方法

build.gradleのdependenciesにあるspring-boot-starter-tomcatの依存構成をprovidedRuntimeからcompileにすれば起動しました。

build.gradle
dependencies {
    compile('org.springframework.boot:spring-boot-starter-web')
    // providedRuntime('org.springframework.boot:spring-boot-starter-tomcat')
    compile('org.springframework.boot:spring-boot-starter-tomcat')
    testCompile('org.springframework.boot:spring-boot-starter-test')
}

感想

同じようなことでハマった人がいるんですね。
Spring Boot app shuts down automatically

ただ、実際の運用を考えるとspring-boot-starter-tomcatの依存構成は変更しないほうがよさそうですね。
IntelliJからgradleでbootRunを実行して開発を進めます。
デバッグもできるし。

4
1
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
4
1