I have strange thing when I try to modify Spring project inside my Spring Tool Suite. On the first load (deploy) everything is fine, application compiles and runs on localho
Goto Window->Preferences, search for Launching.
Select the "Terminate and Relaunch while launching" option.
Press Apply.
It sometimes happen even when we stop running processes in IDE with help of Red button , we continue to get same error.
It was resolved with following steps,
Check what processes are running at available ports
netstat -ao |find /i "listening"
We get following
TCP 0.0.0.0:7981 machinename:0 LISTENING 2428
TCP 0.0.0.0:7982 machinename:0 LISTENING 2428
TCP 0.0.0.0:8080 machinename:0 LISTENING 12704
TCP 0.0.0.0:8500 machinename:0 LISTENING 2428
i.e. Port Numbers and what Process Id they are listening to
Stop process running at your port number(In this case it is 8080 & Process Id is 12704)
Taskkill /F /IM 12704
(Note: Mention correct Process Id)
For more information follow these links Link1 and Link2.
My Issue was resolved with this, Hope this helps !
No Need to manually start an application every time at time of development to implements changes use 'spring-boot-devtool' maven dependency.
Automatic Restart : To use the module you simply need to add it as a dependency in your Maven POM:
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-devtools</artifactId>
</dependency>
When you have the spring-boot-devtools module included, any classpath file changes will automatically trigger an application restart. We do some tricks to try and keep restarts fast, so for many microservice style applications this technique might be good enough.
If you got any error on your console by saying, “Embedded servlet container failed to start. Port 8080 was already in use.” Then go to application.properties file and add this property “server.port = 8090”.
Actually the default port for spring boot is 8080, if you have something else on that port, the above error will occur. So we are asking spring boot to run on other port by adding “server.port = 8090” in application.properties file.
You can use list open file command and then kill the process like below.
sudo lsof -t -i tcp:8181 | xargs kill -9
or
sudo lsof -i tcp:8181
kill -9 PID
Print the list of running processes and try to find the one that says spring
in it. Once you find the appropriate process ID (PID
), stop the given process.
ps aux | grep spring
kill -9 INSERT_PID_HERE
After that, try and run the application again. If you killed the correct process your port should be freed up and you can start the server again.