Question

I have exactly the same issue like that one: Terminating mvn spring-boot:run doesn't stop tomcat

The answer there says that it only happens on Windows but it's not actually true. I'm running spring boot on OSX with Intellij and when I stop the spring boot application the embedded tomcat is still running. The is the simple sample app from spring boot tutorial. Any solutions?

Was it helpful?

Solution 3

I have met the same issue and as result I had to review all solutions on this page and related one. No one is good for me. That is why I have made small research and it is appeared that problems with captured TCP port happen just because neither Gradle nor mvn knows nothing about child manipulation with TCP port.

So instead of killing process just use command:

$ gradlew –stop 

(I hope the same exists for mvn)

This command gracefully closes daemons started by Gradle and frees captured by Tomcat ports.

OTHER TIPS

i have exactly the same issue within intellij on MAC (spring boot 1.1.6.RELEASE).

i worked around it by using spring boot actuator which offers a rest endpoint (Post) to shutdown the app:

localhost:port/shutdown

this can be called by commandline: e.g. curl -X POST localhost:port/shutdown

to enable spring boot actuator add the following compile dep:

org.springframework.boot:spring-boot-starter-actuator

i created a gradle task bootStop which does run this cmd for me. you could do the same in maven or you can just call it from cmd line (also trough the intellij terminal)

Especially if you want to use debugging, you should wrap the curl cmd given above in a gradle/maven task.

See working example (gradle) here

Here is a maven example for spring boot actuator to configure HTTP endpoint to shutdown a spring boot web app:

1.Maven Pom.xml:

<dependency>
    <groupId>org.springframework.boot</groupId>
    <artifactId>spring-boot-starter-actuator</artifactId>
</dependency>

2.application.properties:

#No auth  protected 
endpoints.shutdown.sensitive=false

#Enable shutdown endpoint
endpoints.shutdown.enabled=true

All endpoints are listed here:

3.Send a post method to shutdown the app:

curl -X POST localhost:port/shutdown

Following the previous answer, this property is deprecated now, so replace it with:

management.endpoint.shutdown.enabled=true

A simpler solution is to create a "Spring Boot" configuration and use that to start your app instead of the "Gradle" configuration. The "Spring Boot" configuration does not experience this issue.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top