Pergunta

I am using IntelliJ 13.1 on Linux and try to build a basic REST application following the example http://spring.io/guides/gs/spring-boot/

When I execute the target bootRun from within IntelliJ the intergrated tomcat server is started and everything works fine.

10:09:35: Executing external task 'bootRun'...
:compileJava UP-TO-DATE
:processResources UP-TO-DATE
:classes UP-TO-DATE
:findMainClass
:bootRun

But stopping the execution does not affect the gradle task:

10:11:40: External task execution finished 'bootRun'.

I still can access the tomcat instance on the configured port. Only closing IntelliJ will destroy the process.

I searched on this topic but could not find any reasonable answers. I wonder if it is a

  • gradle problem (using gradle wrapper version 1.11)
  • Linux problem (Ubuntu 12.04)
  • IntelliJ problem (IDEA 13.1.2)
  • Spring Boot problem (tried different versions from 1.0.0.RELEASE to 1.1.0.M2)
Foi útil?

Solução

I am pretty sure it's an IntelliJ issue because:

When you run the bootRun from IntelliJ's Gradle integration and then press stop, the application continues to run as you mentioned.

However, if you use the command line and run gradle bootRun and then use Cntrl+C, the application stops just fine.

Note that my setup is Windows 7, IntelliJ 13.1.3, Gradle 1.12 and Spring Boot 1.1.0.M2.

If your need to is to be able to easily debug your application, all you need to do is run the Java (or Groovy) Class that has the main method, since that it is the easiest way to run Spring Boot applications! Kudos to Spring Boot for that!!!

Of course you can continue to use Gradle for tasks like running all the tests or creating the packaged application.

Outras dicas

I know this answer was already answered, but as this is first topic when searching in Google, I thought in sharing an alternative I went with and didn't find in other topics I read.

My main problem with this terminate was that always I changed something in my classes, I needed to restart the server, and it would fail so I needed to stop/start the server sometimes.

To avoid this, I use spring-boot-devtools. Basically:

Applications that use spring-boot-devtools will automatically restart whenever files on the classpath change.

The only catch is that on Intellij it only makes the project if click Build > Make Project, so either set it to build automatically or remember to click on make.

To use, simply add the dependency to your build.gradle / pom.xml: compile('org.springframework.boot:spring-boot-devtools')

I found this to be really useful in development.

I am using IntelliJ in Mac, running Spring boot application was giving the same issue. Whenever I run the app in Terminal and use CTRL + Z, the terminal will strop running the app. But when I run the app again in the same terminal, will give error saying the port 8080 was in use. I just tried the option to close the Terminal session ( right click -> select -> Close Session). This will close the terminal, and when I clicked the terminal option again and ran the app, it ran smoothly.

Licenciado em: CC-BY-SA com atribuição
Não afiliado a StackOverflow
scroll top