【问题标题】:Spring application stuck in startSpring应用程序卡在启动中
【发布时间】:2021-04-24 04:20:07
【问题描述】:

我导出和导入一个spring项目后遇到问题,现在启动需要70多秒。陷入触发 Spring Data 存储库的延迟初始化...

这是控制台的日志:

  .   ____          _            __ _ _
 /\\ / ___'_ __ _ _(_)_ __  __ _ \ \ \ \
( ( )\___ | '_ | '_| | '_ \/ _` | \ \ \ \
 \\/  ___)| |_)| | | | | || (_| |  ) ) ) )
  '  |____| .__|_| |_|_| |_\__, | / / / /
 =========|_|==============|___/=/_/_/_/
 :: Spring Boot ::        (v2.3.4.RELEASE)

2021-01-19 21:00:48.994  INFO 15368 --- [  restartedMain] com.practica.PracticaFinalApplication    : Starting PracticaFinalApplication on DESKTOP-BG6SBT4 with PID 15368 (D:\workspace-spring-tool-suite-4-4.8.0.RELEASE\PRACTICA_FINAL\target\classes started by dani_ in D:\workspace-spring-tool-suite-4-4.8.0.RELEASE\PRACTICA_FINAL)
2021-01-19 21:00:48.998  INFO 15368 --- [  restartedMain] com.practica.PracticaFinalApplication    : No active profile set, falling back to default profiles: default
2021-01-19 21:00:49.051  INFO 15368 --- [  restartedMain] o.s.b.devtools.restart.ChangeableUrls    : The Class-Path manifest attribute in C:\Users\dani_\.m2\repository\com\oracle\database\jdbc\ojdbc8\19.3.0.0\ojdbc8-19.3.0.0.jar referenced one or more files that do not exist: file:/C:/Users/dani_/.m2/repository/com/oracle/database/jdbc/ojdbc8/19.3.0.0/oraclepki.jar
2021-01-19 21:00:49.051  INFO 15368 --- [  restartedMain] o.s.b.devtools.restart.ChangeableUrls    : The Class-Path manifest attribute in C:\Users\dani_\.m2\repository\com\oracle\database\security\oraclepki\19.3.0.0\oraclepki-19.3.0.0.jar referenced one or more files that do not exist: file:/C:/Users/dani_/.m2/repository/com/oracle/database/security/oraclepki/19.3.0.0/osdt_core.jar,file:/C:/Users/dani_/.m2/repository/com/oracle/database/security/oraclepki/19.3.0.0/osdt_cert.jar,file:/C:/Users/dani_/.m2/repository/com/oracle/database/security/oraclepki/oracle.osdt/osdt_core.jar,file:/C:/Users/dani_/.m2/repository/com/oracle/database/security/oraclepki/oracle.osdt/osdt_cert.jar
2021-01-19 21:00:49.052  INFO 15368 --- [  restartedMain] .e.DevToolsPropertyDefaultsPostProcessor : Devtools property defaults active! Set 'spring.devtools.add-properties' to 'false' to disable
2021-01-19 21:00:49.052  INFO 15368 --- [  restartedMain] .e.DevToolsPropertyDefaultsPostProcessor : For additional web related logging consider setting the 'logging.level.web' property to 'DEBUG'
2021-01-19 21:00:49.767  INFO 15368 --- [  restartedMain] .s.d.r.c.RepositoryConfigurationDelegate : Bootstrapping Spring Data JPA repositories in DEFERRED mode.
2021-01-19 21:00:49.848  INFO 15368 --- [  restartedMain] .s.d.r.c.RepositoryConfigurationDelegate : Finished Spring Data repository scanning in 75ms. Found 6 JPA repository interfaces.
2021-01-19 21:00:50.143  INFO 15368 --- [  restartedMain] trationDelegate$BeanPostProcessorChecker : Bean 'org.springframework.ws.config.annotation.DelegatingWsConfiguration' of type [org.springframework.ws.config.annotation.DelegatingWsConfiguration$$EnhancerBySpringCGLIB$$5974c00c] is not eligible for getting processed by all BeanPostProcessors (for example: not eligible for auto-proxying)
2021-01-19 21:00:50.203  INFO 15368 --- [  restartedMain] .w.s.a.s.AnnotationActionEndpointMapping : Supporting [WS-Addressing August 2004, WS-Addressing 1.0]
2021-01-19 21:00:50.575  INFO 15368 --- [  restartedMain] o.s.b.w.embedded.tomcat.TomcatWebServer  : Tomcat initialized with port(s): 8085 (http)
2021-01-19 21:00:50.586  INFO 15368 --- [  restartedMain] o.apache.catalina.core.StandardService   : Starting service [Tomcat]
2021-01-19 21:00:50.587  INFO 15368 --- [  restartedMain] org.apache.catalina.core.StandardEngine  : Starting Servlet engine: [Apache Tomcat/9.0.38]
2021-01-19 21:00:50.709  INFO 15368 --- [  restartedMain] o.a.c.c.C.[Tomcat].[localhost].[/]       : Initializing Spring embedded WebApplicationContext
2021-01-19 21:00:50.710  INFO 15368 --- [  restartedMain] w.s.c.ServletWebServerApplicationContext : Root WebApplicationContext: initialization completed in 1658 ms
2021-01-19 21:00:50.967  INFO 15368 --- [  restartedMain] o.s.s.concurrent.ThreadPoolTaskExecutor  : Initializing ExecutorService 'applicationTaskExecutor'
2021-01-19 21:00:51.007  INFO 15368 --- [         task-1] o.hibernate.jpa.internal.util.LogHelper  : HHH000204: Processing PersistenceUnitInfo [name: default]
2021-01-19 21:00:51.055  INFO 15368 --- [         task-1] org.hibernate.Version                    : HHH000412: Hibernate ORM core version 5.4.21.Final
2021-01-19 21:00:51.101  WARN 15368 --- [  restartedMain] 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
2021-01-19 21:00:51.160  INFO 15368 --- [         task-1] o.hibernate.annotations.common.Version   : HCANN000001: Hibernate Commons Annotations {5.1.0.Final}
2021-01-19 21:00:51.267  INFO 15368 --- [         task-1] com.zaxxer.hikari.HikariDataSource       : HikariPool-1 - Starting...
2021-01-19 21:00:51.313  INFO 15368 --- [  restartedMain] o.s.s.web.DefaultSecurityFilterChain     : Creating filter chain: any request, [org.springframework.security.web.context.request.async.WebAsyncManagerIntegrationFilter@5548d944, org.springframework.security.web.context.SecurityContextPersistenceFilter@52db2e9a, org.springframework.security.web.header.HeaderWriterFilter@2682a673, org.springframework.security.web.csrf.CsrfFilter@384244c7, org.springframework.security.web.authentication.logout.LogoutFilter@60a9bf00, org.springframework.security.web.authentication.UsernamePasswordAuthenticationFilter@14f3c976, org.springframework.security.web.savedrequest.RequestCacheAwareFilter@14a70864, org.springframework.security.web.servletapi.SecurityContextHolderAwareRequestFilter@9aabdd5, org.springframework.security.web.authentication.AnonymousAuthenticationFilter@61618c62, org.springframework.security.web.session.SessionManagementFilter@1e6efa12, org.springframework.security.web.access.ExceptionTranslationFilter@72c01891, org.springframework.security.web.access.intercept.FilterSecurityInterceptor@43f59fcf]
2021-01-19 21:00:51.534  INFO 15368 --- [         task-1] com.zaxxer.hikari.HikariDataSource       : HikariPool-1 - Start completed.
2021-01-19 21:00:51.551  INFO 15368 --- [         task-1] org.hibernate.dialect.Dialect            : HHH000400: Using dialect: org.hibernate.dialect.Oracle12cDialect
2021-01-19 21:00:51.756  INFO 15368 --- [  restartedMain] o.s.b.d.a.OptionalLiveReloadServer       : LiveReload server is running on port 35729
2021-01-19 21:00:51.825  INFO 15368 --- [  restartedMain] o.s.b.w.embedded.tomcat.TomcatWebServer  : Tomcat started on port(s): 8085 (http) with context path ''
2021-01-19 21:00:51.828  INFO 15368 --- [  restartedMain] DeferredRepositoryInitializationListener : Triggering deferred initialization of Spring Data repositories…
2021-01-19 21:02:03.729  WARN 15368 --- [         task-1] o.h.b.i.InFlightMetadataCollectorImpl    : HHH000069: Duplicate generator name sequence
2021-01-19 21:02:03.741  WARN 15368 --- [         task-1] o.h.b.i.InFlightMetadataCollectorImpl    : HHH000069: Duplicate generator name sequence
2021-01-19 21:02:03.744  WARN 15368 --- [         task-1] o.h.b.i.InFlightMetadataCollectorImpl    : HHH000069: Duplicate generator name sequence
2021-01-19 21:02:04.203  INFO 15368 --- [         task-1] o.h.e.t.j.p.i.JtaPlatformInitiator       : HHH000490: Using JtaPlatform implementation: [org.hibernate.engine.transaction.jta.platform.internal.NoJtaPlatform]
2021-01-19 21:02:04.211  INFO 15368 --- [         task-1] j.LocalContainerEntityManagerFactoryBean : Initialized JPA EntityManagerFactory for persistence unit 'default'
2021-01-19 21:02:04.639  INFO 15368 --- [  restartedMain] DeferredRepositoryInitializationListener : Spring Data repositories initialized!
2021-01-19 21:02:04.647  INFO 15368 --- [  restartedMain] com.practica.PracticaFinalApplication    : Started PracticaFinalApplication in 76.038 seconds (JVM running for 77.006)

这是 pom.xml

4.0.0 org.springframework.boot spring-boot-starter-parent 2.3.4.发布 实用主义 PRACTICA_FINAL 0.0.1-快照 战争 PRACTICA_FINAL 实战

<properties>
    <java.version>1.8</java.version>
</properties>

<dependencies>
    <dependency>
        <groupId>org.springframework.boot</groupId>
        <artifactId>spring-boot-starter-data-jpa</artifactId>
    </dependency>
    <dependency>
        <groupId>org.springframework.boot</groupId>
        <artifactId>spring-boot-starter-thymeleaf</artifactId>
    </dependency>
    <dependency>
        <groupId>org.springframework.boot</groupId>
        <artifactId>spring-boot-starter-web</artifactId>
    </dependency>
    <dependency>
        <groupId>org.springframework.boot</groupId>
        <artifactId>spring-boot-starter-web-services</artifactId>
    </dependency>

    <dependency>
        <groupId>org.springframework.boot</groupId>
        <artifactId>spring-boot-devtools</artifactId>
        <scope>runtime</scope>
        <optional>true</optional>
    </dependency>
    <dependency>
        <groupId>com.oracle.database.jdbc</groupId>
        <artifactId>ojdbc8</artifactId>
        <scope>runtime</scope>
    </dependency>
    <dependency>
        <groupId>org.springframework.boot</groupId>
        <artifactId>spring-boot-starter-tomcat</artifactId>
        <scope>provided</scope>
    </dependency>
    <dependency>
        <groupId>org.springframework.boot</groupId>
        <artifactId>spring-boot-starter-test</artifactId>
        <scope>test</scope>
    </dependency>
    <dependency>
        <groupId>com.github.librepdf</groupId>
        <artifactId>openpdf</artifactId>
        <version>1.3.24</version>
    </dependency>
    <dependency>
        <groupId>org.springframework.boot</groupId>
        <artifactId>spring-boot-starter-security</artifactId>
    </dependency>
    <dependency>
        <groupId>org.thymeleaf.extras</groupId>
        <artifactId>thymeleaf-extras-springsecurity5</artifactId>
    </dependency>
</dependencies>

<build>
    <plugins>
        <plugin>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-maven-plugin</artifactId>
        </plugin>
    </plugins>
</build>

【问题讨论】:

  • 你能用最少的代码复制这个并在这里分享这个代码吗?
  • 您的数据库连接一切正常吗?您的数据库是否在同一主机中?
  • @Armin 是的,数据库在同一台主机上并且工作正常,因为当应用程序启动时一切正常
  • @dan1st 最少的代码是什么意思?
  • 我认为 pom.xml 不足以重现它。你能尝试用最少的代码来创建一个示例项目来重现这个问题吗?详情请见this

标签: java spring oracle hibernate jpa


【解决方案1】:

如果它适用于某人,我找到了解决方案。我只需在属性文件中添加这两行,然后从 70 秒开始到 4 秒开始

spring.jpa.properties.hibernate.temp.use_jdbc_metadata_defaults=false
spring.jpa.properties.hibernate.dialect =org.hibernate.dialect.Oracle12cDialect

【讨论】:

    猜你喜欢
    • 2018-12-16
    • 2017-09-23
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2015-02-15
    • 1970-01-01
    • 2021-11-25
    • 2016-09-10
    相关资源
    最近更新 更多