I can successfully start spring-boot with mvn spring-boot
, the documentation mentions to gracefully exit the application hit ctrl-c
.
For Powershell, put the following code in a file ending with '.ps1'
$processes = (get-NetTCPConnection| ? {$_.LocalPort -eq "8080"}).OwningProcess
foreach ($process in $processes) {Get-Process -PID $process | Stop-Process -Force}
Yes this is correct that when you do a maven install with spring-boot-run and after the application is stopped, tomcat port still listens.
I am attaching a screenshot for those who faced this problem port/address already in use. What you have to do is before running the spring boot application again,just go to your windows Task manager and end the Process named "Java(TM) Platform SE binary" and run your boot application your port would be free of the process and you wont get the issue again.(You don't have to do this after you run your application for the first time ) It worked miracle for me. Hope it helps Good day
I know i am too late to answer but may be some one get help with this. STS users can use the Relaunch
button rather than Run
to ensure that any existing instance is closed.
For Reference :
https://docs.spring.io/spring-boot/docs/current/reference/html/using-boot-running-your-application.html
That only happens in Windows. https://github.com/spring-projects/spring-boot/issues/773
Update: should be fixed now.
I fall in the same issue, but there is a much better and simple way to run your Spring boot app that does not have this problem.
Run As -> Java Application
Update: Furthermore, if you use Spring STS (available for VS Code, IntelliJ, Eclipse...) you have the chance to manage your application from the Boot Dashboard. It's really useful.
We can kill that tomcat instance right from the eclipse console
view, by hitting the stop (Red square icon) button and Red button beside the run icon, run the spring boot application again.