Как проверить наличие другого запущенного проекта в Eclipse?

#java #spring #eclipse #spring-boot #spring-mvc

#java #весна #eclipse #spring-boot #spring-mvc

Вопрос:

Я использую eclipse IDE для запуска моего проекта spring boot (серверная часть), который использует порт 8080 на localhost. Когда я пытаюсь запустить свою программу, она завершает работу программы, сообщая, что порт 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-workspacelmstargetclasses started by Electrical Engineer in D:eclipse-workspacelms)
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.

  

Ответ №1:

Это может быть связано с тем, что вы могли бы сначала запустить проект (чтобы он занял порт), и теперь вы пытаетесь запустить его снова, не закрывая последний.Используйте эту опцию

Комментарии:

1. Здесь можно увидеть все запущенные консоли.

Ответ №2:

Сообщение об ошибке не является двусмысленным, и это не то, что будет происходить «ошибочно» (говоря, что что-то использует порт, когда он фактически не используется). Порт не обязательно должен использоваться чем-то, что вы запустили из Eclipse. Нет сомнений в том, что что-то уже прослушивает этот порт. Вам просто нужно выяснить, что это такое. В качестве альтернативы вы можете настроить свое приложение для запуска на другом порту.

Комментарии:

1. Да, когда я проверял, доставлялись те же данные, которые это приложение доставляло при последнем запуске. Итак, я решил, что был достаточно глуп, чтобы закрыть Eclipse IDE перед завершением программы. Мне пришлось перезагрузить компьютер, чтобы он заработал. В любом случае спасибо 🙂