首页 > 解决方案 > 带有数据 jpa 的 Spring Boot 在启动时出错

问题描述

启动我的 Spring Boot 应用程序时出错。这是一个堆栈跟踪,但我无法找到根本原因。我正在使用带有 spring data jpa 的 spring boot 2.3.4。任何帮助表示赞赏。

{"timestamp": "12/21/2020 18:52:02:0871", "class": "org.hibernate.engine.transaction.jta.platform.internal.JtaPlatformInitiator", "file": "JtaPlatformInitiator.java", "level" : " INFO", "line_number" : "52", "url": "", "ip_address": "", "server_trace_id":"", "message": HHH000490: Using JtaPlatform implementation: [org.hibernate.engine.transaction.jta.platform.internal.NoJtaPlatform], "method": "initiateService", "thread_name": "task-1"},
{"timestamp": "12/21/2020 18:52:02:0872", "class": "org.hibernate.query.spi.NamedQueryRepository", "file": "NamedQueryRepository.java", "level" : "DEBUG", "line_number" : "151", "url": "", "ip_address": "", "server_trace_id":"", "message": Checking 0 named HQL queries, "method": "checkNamedQueries", "thread_name": "task-1"},
{"timestamp": "12/21/2020 18:52:02:0872", "class": "org.hibernate.query.spi.NamedQueryRepository", "file": "NamedQueryRepository.java", "level" : "DEBUG", "line_number" : "167", "url": "", "ip_address": "", "server_trace_id":"", "message": Checking 0 named SQL queries, "method": "checkNamedQueries", "thread_name": "task-1"},
{"timestamp": "12/21/2020 18:52:02:0891", "class": "org.hibernate.internal.SessionFactoryRegistry", "file": "SessionFactoryRegistry.java", "level" : "DEBUG", "line_number" : "52", "url": "", "ip_address": "", "server_trace_id":"", "message": Initializing SessionFactoryRegistry : org.hibernate.internal.SessionFactoryRegistry@263b5690, "method": "<init>", "thread_name": "task-1"},
{"timestamp": "12/21/2020 18:52:02:0891", "class": "org.hibernate.internal.SessionFactoryRegistry", "file": "SessionFactoryRegistry.java", "level" : "DEBUG", "line_number" : "74", "url": "", "ip_address": "", "server_trace_id":"", "message": Registering SessionFactory: 64cd8993-8947-4c28-8a99-8717be785280 (<unnamed>), "method": "addSessionFactory", "thread_name": "task-1"},
{"timestamp": "12/21/2020 18:52:02:0891", "class": "org.hibernate.internal.SessionFactoryRegistry", "file": "SessionFactoryRegistry.java", "level" : "DEBUG", "line_number" : "81", "url": "", "ip_address": "", "server_trace_id":"", "message": Not binding SessionFactory to JNDI, no JNDI name configured, "method": "addSessionFactory", "thread_name": "task-1"},
{"timestamp": "12/21/2020 18:52:02:0896", "class": "org.hibernate.internal.SessionFactoryImpl", "file": "SessionFactoryImpl.java", "level" : "DEBUG", "line_number" : "771", "url": "", "ip_address": "", "server_trace_id":"", "message": HHH000031: Closing, "method": "close", "thread_name": "restartedMain"},
{"timestamp": "12/21/2020 18:52:02:0897", "class": "org.hibernate.type.spi.TypeConfiguration$Scope", "file": "TypeConfiguration.java", "level" : "DEBUG", "line_number" : "350", "url": "", "ip_address": "", "server_trace_id":"", "message": Un-scoping TypeConfiguration [org.hibernate.type.spi.TypeConfiguration$Scope@3fbaa2e9] from SessionFactory [org.hibernate.internal.SessionFactoryImpl@1741883a], "method": "unsetSessionFactory", "thread_name": "restartedMain"},
{"timestamp": "12/21/2020 18:52:02:0902", "class": "org.hibernate.service.internal.AbstractServiceRegistryImpl", "file": "AbstractServiceRegistryImpl.java", "level" : "DEBUG", "line_number" : "419", "url": "", "ip_address": "", "server_trace_id":"", "message": Implicitly destroying ServiceRegistry on de-registration of all child ServiceRegistries, "method": "deRegisterChild", "thread_name": "restartedMain"},
{"timestamp": "12/21/2020 18:52:02:0902", "class": "org.hibernate.boot.registry.internal.BootstrapServiceRegistryImpl", "file": "BootstrapServiceRegistryImpl.java", "level" : "DEBUG", "line_number" : "295", "url": "", "ip_address": "", "server_trace_id":"", "message": Implicitly destroying Boot-strap registry on de-registration of all child ServiceRegistries, "method": "deRegisterChild", "thread_name": "restartedMain"},
Exception in thread "task-2" org.springframework.beans.factory.BeanCreationNotAllowedException: Error creating bean with name 'delegatingApplicationListener': Singleton bean creation not allowed while singletons of this factory are in destruction (Do not request a bean from a BeanFactory in a destroy method implementation!)
    at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:220)
DefaultSingletonBeanRegistry.java:220
    at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:322)
AbstractBeanFactory.java:322
    at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:207)
AbstractBeanFactory.java:207
    at org.springframework.context.event.AbstractApplicationEventMulticaster.retrieveApplicationListeners(AbstractApplicationEventMulticaster.java:245)
AbstractApplicationEventMulticaster.java:245
    at org.springframework.context.event.AbstractApplicationEventMulticaster.getApplicationListeners(AbstractApplicationEventMulticaster.java:197)
AbstractApplicationEventMulticaster.java:197
    at org.springframework.context.event.SimpleApplicationEventMulticaster.multicastEvent(SimpleApplicationEventMulticaster.java:134)
SimpleApplicationEventMulticaster.java:134
    at org.springframework.context.support.AbstractApplicationContext.publishEvent(AbstractApplicationContext.java:404)
AbstractApplicationContext.java:404
    at org.springframework.context.support.AbstractApplicationContext.publishEvent(AbstractApplicationContext.java:361)
AbstractApplicationContext.java:361
    at org.springframework.boot.autoconfigure.orm.jpa.DataSourceInitializedPublisher.publishEventIfRequired(DataSourceInitializedPublisher.java:99)
DataSourceInitializedPublisher.java:99
    at org.springframework.boot.autoconfigure.orm.jpa.DataSourceInitializedPublisher.access$100(DataSourceInitializedPublisher.java:50)
DataSourceInitializedPublisher.java:50
    at org.springframework.boot.autoconfigure.orm.jpa.DataSourceInitializedPublisher$DataSourceSchemaCreatedPublisher.lambda$postProcessEntityManagerFactory$0(DataSourceInitializedPublisher.java:200)
DataSourceInitializedPublisher.java:200
{"timestamp": "12/21/2020 18:52:02:0905", "class": "com.zaxxer.hikari.HikariDataSource", "file": "HikariDataSource.java", "level" : " INFO", "line_number" : "350", "url": "", "ip_address": "", "server_trace_id":"", "message": HikariPool-1 - Shutdown initiated..., "method": "close", "thread_name": "restartedMain"},
{"timestamp": "12/21/2020 18:52:02:0906", "class": "com.zaxxer.hikari.pool.HikariPool", "file": "HikariPool.java", "level" : "DEBUG", "line_number" : "421", "url": "", "ip_address": "", "server_trace_id":"", "message": HikariPool-1 - Before shutdown stats (total=1, active=0, idle=1, waiting=0), "method": "logPoolState", "thread_name": "restartedMain"},
    at java.base/java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1130)
    at java.base/java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:630)
    at java.base/java.lang.Thread.run(Thread.java:832)

标签: springspring-bootspring-data-jpa

解决方案


设置 JAVA_HOME 路径并更新 JDK 版本。之后重新启动您的服务器,它应该可以正常工作!如果这不起作用,请检查您有多少个 tomcat 实例。如果您有多个,请将它们关闭。如果您使用错误,@Transactional 注释也可能存在问题,您可以在此处查看更多详细信息->http://www.javablog.fr/spring-transaction-visibility-proxy-propagation-required-and -requires_new.html


推荐阅读