当我第一次在localhost中运行应用程序时,它可以工作。但是我更改代码并重新运行,它显示了这个错误消息。终止所有进程并重新运行时。再次显示下面的消息。
. ____ _ __ _ _
/\ / ___'_ __ _ _(_)_ __ __ _
( ( )___ | '_ | '_| | '_ / _` |
\/ ___)| |_)| | | | | || (_| | ) ) ) )
' |____| .__|_| |_|_| |___, | / / / /
=========|_|==============|___/=/_/_/_/
:: Spring Boot :: (v2.4.1)
2021-01-15 13:25:06.321 INFO 7180 --- [ main] com.example.demo.SocialApiApplication : Starting SocialApiApplication using Java 15.0.1 on DESKTOP-TCH1T7S with PID 7180 (E:springbootSocialAPItargetclasses started by Samanthika in E:springbootSocialAPI)
2021-01-15 13:25:06.325 INFO 7180 --- [ main] com.example.demo.SocialApiApplication : No active profile set, falling back to default profiles: default
2021-01-15 13:25:07.193 INFO 7180 --- [ main] o.s.b.w.embedded.tomcat.TomcatWebServer : Tomcat initialized with port(s): 8006 (http)
2021-01-15 13:25:07.205 INFO 7180 --- [ main] o.apache.catalina.core.StandardService : Starting service [Tomcat]
2021-01-15 13:25:07.205 INFO 7180 --- [ main] org.apache.catalina.core.StandardEngine : Starting Servlet engine: [Apache Tomcat/9.0.41]
2021-01-15 13:25:07.298 INFO 7180 --- [ main] o.a.c.c.C.[Tomcat].[localhost].[/] : Initializing Spring embedded WebApplicationContext
2021-01-15 13:25:07.298 INFO 7180 --- [ main] w.s.c.ServletWebServerApplicationContext : Root WebApplicationContext: initialization completed in 918 ms
2021-01-15 13:25:07.487 INFO 7180 --- [ main] o.s.s.concurrent.ThreadPoolTaskExecutor : Initializing ExecutorService 'applicationTaskExecutor'
2021-01-15 13:25:07.676 WARN 7180 --- [ main] ConfigServletWebServerApplicationContext : Exception encountered during context initialization - cancelling refresh attempt: org.springframework.context.ApplicationContextException: Failed to start bean 'webServerStartStop'; nested exception is org.springframework.boot.web.server.PortInUseException: Port 8006 is already in use
2021-01-15 13:25:07.677 INFO 7180 --- [ main] o.s.s.concurrent.ThreadPoolTaskExecutor : Shutting down ExecutorService 'applicationTaskExecutor'
2021-01-15 13:25:07.683 INFO 7180 --- [ main] o.apache.catalina.core.StandardService : Stopping service [Tomcat]
2021-01-15 13:25:07.700 INFO 7180 --- [ main] ConditionEvaluationReportLoggingListener :
Error starting ApplicationContext. To display the conditions report re-run your application with 'debug' enabled.
2021-01-15 13:25:07.714 ERROR 7180 --- [ main] o.s.b.d.LoggingFailureAnalysisReporter :
***************************
APPLICATION FAILED TO START
***************************
Description:
Web server failed to start. Port 8006 was already in use.
Action:
Identify and stop the process that's listening on port 8006 or configure this application to listen on another port.
但是我换了服务器。应用程序属性中的端口。它的工作原理。但我试着再运行一次,我得到了以上的错误。当我一直运行时,我应该想要更改application.properties中的服务器端口。有解决这个问题的办法吗?
用于tomcat 8006的端口已被使用。您需要终止该进程并重新运行项目
在cmd上使用此命令获取进程的PID号:
netstat -ano | findstr :8006
然后使用以下命令终止该进程:
taskkill /PID <PID> /F