首页 > 解决方案 > 如何在 Eclipse 上检查另一个正在运行的项目?

问题描述

我正在使用 eclipse IDE 运行我的 spring boot 项目(后端部分),它使用 localhost 上的端口 8080。当我尝试运行我的程序时,它会关闭程序,说端口 8080 已在使用中。没有任何其他应用程序正在使用端口 8080,也没有其他控制台窗口,因此我无法关闭当前正在运行的使用端口 8080 的应用程序。PFB 来自控制台窗口的日志:

:: Spring Boot ::        (v2.3.3.RELEASE)

2020-09-24 19:31:44.942  INFO 4092 --- [           main] c.library_management.lms.LmsApplication  : Starting LmsApplication on DESKTOP-GM2UUP2 with PID 4092 (D:\eclipse-workspace\lms\target\classes started by Electrical Engineer in D:\eclipse-workspace\lms)
2020-09-24 19:31:44.948  INFO 4092 --- [           main] c.library_management.lms.LmsApplication  : No active profile set, falling back to default profiles: default
2020-09-24 19:31:50.633  INFO 4092 --- [           main] .s.d.r.c.RepositoryConfigurationDelegate : Bootstrapping Spring Data JPA repositories in DEFERRED mode.
2020-09-24 19:31:51.947  INFO 4092 --- [           main] .s.d.r.c.RepositoryConfigurationDelegate : Finished Spring Data repository scanning in 1092ms. Found 3 JPA repository interfaces.
2020-09-24 19:31:59.953  INFO 4092 --- [           main] o.s.b.w.embedded.tomcat.TomcatWebServer  : Tomcat initialized with port(s): 8080 (http)
2020-09-24 19:32:00.358  INFO 4092 --- [           main] o.apache.catalina.core.StandardService   : Starting service [Tomcat]
2020-09-24 19:32:00.360  INFO 4092 --- [           main] org.apache.catalina.core.StandardEngine  : Starting Servlet engine: [Apache Tomcat/9.0.37]
2020-09-24 19:32:01.666  INFO 4092 --- [           main] o.a.c.c.C.[Tomcat].[localhost].[/]       : Initializing Spring embedded WebApplicationContext
2020-09-24 19:32:01.667  INFO 4092 --- [           main] w.s.c.ServletWebServerApplicationContext : Root WebApplicationContext: initialization completed in 16526 ms
2020-09-24 19:32:05.077  INFO 4092 --- [           main] o.s.s.concurrent.ThreadPoolTaskExecutor  : Initializing ExecutorService 'applicationTaskExecutor'
2020-09-24 19:32:06.080  INFO 4092 --- [         task-1] o.hibernate.jpa.internal.util.LogHelper  : HHH000204: Processing PersistenceUnitInfo [name: default]
2020-09-24 19:32:06.793  WARN 4092 --- [           main] JpaBaseConfiguration$JpaWebConfiguration : spring.jpa.open-in-view is enabled by default. Therefore, database queries may be performed during view rendering. Explicitly configure spring.jpa.open-in-view to disable this warning
2020-09-24 19:32:08.214  INFO 4092 --- [         task-1] org.hibernate.Version                    : HHH000412: Hibernate ORM core version 5.4.20.Final
2020-09-24 19:32:16.114  INFO 4092 --- [         task-1] o.hibernate.annotations.common.Version   : HCANN000001: Hibernate Commons Annotations {5.1.0.Final}
2020-09-24 19:32:16.817  INFO 4092 --- [           main] o.s.s.web.DefaultSecurityFilterChain     : Creating filter chain: any request, [org.springframework.security.web.context.request.async.WebAsyncManagerIntegrationFilter@5477a1ca, org.springframework.security.web.context.SecurityContextPersistenceFilter@6794ac0b, org.springframework.security.web.header.HeaderWriterFilter@77d680e6, org.springframework.security.web.authentication.logout.LogoutFilter@33a3c44a, org.springframework.security.web.authentication.www.BasicAuthenticationFilter@222afc67, org.springframework.security.web.savedrequest.RequestCacheAwareFilter@5cb5bb88, org.springframework.security.web.servletapi.SecurityContextHolderAwareRequestFilter@3a01773b, org.springframework.security.web.authentication.AnonymousAuthenticationFilter@3ae9d1e2, org.springframework.security.web.session.SessionManagementFilter@5c1f6d57, org.springframework.security.web.access.ExceptionTranslationFilter@6014a9ba, org.springframework.security.web.access.intercept.FilterSecurityInterceptor@65f2f9b0]
2020-09-24 19:32:21.739  INFO 4092 --- [         task-1] com.zaxxer.hikari.HikariDataSource       : HikariPool-1 - Starting...
2020-09-24 19:32:26.793  WARN 4092 --- [           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 8080 is already in use
2020-09-24 19:32:26.862  INFO 4092 --- [           main] j.LocalContainerEntityManagerFactoryBean : Closing JPA EntityManagerFactory for persistence unit 'default'
2020-09-24 19:32:31.239  INFO 4092 --- [         task-1] com.zaxxer.hikari.HikariDataSource       : HikariPool-1 - Start completed.
2020-09-24 19:32:31.877  INFO 4092 --- [         task-1] org.hibernate.dialect.Dialect            : HHH000400: Using dialect: org.hibernate.dialect.MySQL5InnoDBDialect
2020-09-24 19:32:41.109  INFO 4092 --- [         task-1] o.h.e.t.j.p.i.JtaPlatformInitiator       : HHH000490: Using JtaPlatform implementation: [org.hibernate.engine.transaction.jta.platform.internal.NoJtaPlatform]
2020-09-24 19:32:41.172  INFO 4092 --- [         task-1] j.LocalContainerEntityManagerFactoryBean : Initialized JPA EntityManagerFactory for persistence unit 'default'
Exception in thread "task-2" 2020-09-24 19:32:41.202  INFO 4092 --- [           main] o.s.s.concurrent.ThreadPoolTaskExecutor  : Shutting down ExecutorService 'applicationTaskExecutor'
2020-09-24 19:32:41.204  INFO 4092 --- [           main] com.zaxxer.hikari.HikariDataSource       : HikariPool-1 - Shutdown initiated...
java.lang.IllegalStateException: EntityManagerFactory is closed
    at org.hibernate.internal.SessionFactoryImpl.validateNotClosed(SessionFactoryImpl.java:509)
    at org.hibernate.internal.SessionFactoryImpl.getProperties(SessionFactoryImpl.java:503)
    at org.springframework.boot.autoconfigure.orm.jpa.DataSourceInitializedPublisher.findDataSource(DataSourceInitializedPublisher.java:105)
    at org.springframework.boot.autoconfigure.orm.jpa.DataSourceInitializedPublisher.publishEventIfRequired(DataSourceInitializedPublisher.java:97)
    at org.springframework.boot.autoconfigure.orm.jpa.DataSourceInitializedPublisher.access$100(DataSourceInitializedPublisher.java:50)
    at org.springframework.boot.autoconfigure.orm.jpa.DataSourceInitializedPublisher$DataSourceSchemaCreatedPublisher.lambda$postProcessEntityManagerFactory$0(DataSourceInitializedPublisher.java:200)
    at java.util.concurrent.ThreadPoolExecutor.runWorker(Unknown Source)
    at java.util.concurrent.ThreadPoolExecutor$Worker.run(Unknown Source)
    at java.lang.Thread.run(Unknown Source)
2020-09-24 19:32:41.413  INFO 4092 --- [           main] com.zaxxer.hikari.HikariDataSource       : HikariPool-1 - Shutdown completed.
2020-09-24 19:32:41.418  INFO 4092 --- [           main] o.apache.catalina.core.StandardService   : Stopping service [Tomcat]
2020-09-24 19:32:41.629  INFO 4092 --- [           main] ConditionEvaluationReportLoggingListener : 

Error starting ApplicationContext. To display the conditions report re-run your application with 'debug' enabled.
2020-09-24 19:32:41.652 ERROR 4092 --- [           main] o.s.b.d.LoggingFailureAnalysisReporter   : 

***************************
APPLICATION FAILED TO START
***************************

Description:

Web server failed to start. Port 8080 was already in use.

Action:

Identify and stop the process that's listening on port 8080 or configure this application to listen on another port.

标签: javaspringeclipsespring-bootspring-mvc

解决方案


这可能是因为您可能先运行该项目(因此它占用了端口),现在您尝试再次运行它而不关闭最后一个。使用此选项


推荐阅读