Terminating mvn spring-boot:run doesn't stop tomcat

后端 未结 18 1256
别那么骄傲
别那么骄傲 2020-12-04 07:11

I can successfully start spring-boot with mvn spring-boot, the documentation mentions to gracefully exit the application hit ctrl-c.



        
相关标签:
18条回答
  • 2020-12-04 07:55

    I encountered same problem running SpringBoot application in eclipse on Mac. I manually had to find all the PID's using 8080 and kill them. But, fortunately, I realized that we can kill that tomcat instance right from the eclipse "console" view, by hitting the stop(Red square icon) button and run the spring boot application again.

    0 讨论(0)
  • 2020-12-04 07:57

    This solution worked for me with Spring Boot v1.x und works now, with v2.x:

    hangingJavaProcessToStop=`jps | grep Application | awk '{print $1}'`
    echo "hangingJavaProcessToStop: $hangingJavaProcessToStop"
    kill -9 $hangingJavaProcessToStop
    

    This way you can kill specifically Spring Boot's Application Java process instead of killing all Java processes at once. I assume if your Spring Boot "Application" (main method containing class) is called differently, you must use its name instead of Application.

    I am running the snippet above, on my Windows machine using WSL/Debian. I am not using PowerShell or Windows'command line.

    0 讨论(0)
  • 2020-12-04 08:00

    Here is what I do on Mac:

    kill `lsof -i -n -P | grep TCP | grep 8080 | tr -s " " "\n" | sed -n 2p`
    

    It finds the PID using 8080 and kills it.

    0 讨论(0)
  • 2020-12-04 08:00

    If you are using NetBeans you can stop the server or process by clicking on the cross icon in the bottom right corner where it says Run (Project name).

    0 讨论(0)
  • 2020-12-04 08:01

    For those using Eclipse, this is by far the best answer:

    Open "run configurations", edit the maven launch you defined for your project, and under the "JRE" tab, add -Dfork=false to the VM arguments text area.

    Then when you hit the red stop button, the tomcat server will stop and your ports will be released.

    Answer comes from a post here on Github by jordihs

    0 讨论(0)
  • 2020-12-04 08:03

    I had the same issue in Windows 10, wenn I was running mvn spring-boot:run in a Cygwin Terminal. I wasn't even able to find the Tomcat process in Cygwin using ps -ef; I had to search for the process in PowerShell using netstat -ao.

    Using mvn spring-boot:run in PowerShell is working fine for me.

    0 讨论(0)
提交回复
热议问题