Springboot 2.3.x application stuck on startup

Viewed 2505

I have a standard spring boot application with the following spring auto configuration

    implementation 'org.springframework.boot:spring-boot-starter-actuator'
    implementation 'org.springframework.boot:spring-boot-starter-data-jpa'
    implementation 'org.springframework.boot:spring-boot-starter-web'
    implementation 'org.springframework.boot:spring-boot-starter-validation'

The app runs fine until I create my first entity and repository and service referencing them:

@Entity
@Table(name = "xxx")
public class XXX extends AuditingEntity{


@Repository
public interface XXXRepository extends CrudRepository<XXX, Integer> {

}

@Service
public class XXXService {

    @Resource
    XXXRepository xxxRepository;
    ...

The application just failed to start and stuck on the following and never preceding

2020-06-15 15:48:23.826  INFO [xxx,,,] 2882 --- [           main] o.f.c.internal.license.VersionPrinter    : Flyway Community Edition 6.4.4 by Redgate
2020-06-15 15:48:23.911  INFO [xxx,,,] 2882 --- [           main] com.zaxxer.hikari.HikariDataSource       : HikariPool-1 - Starting...
2020-06-15 15:48:24.161  INFO [xxx,,,] 2882 --- [           main] com.zaxxer.hikari.HikariDataSource       : HikariPool-1 - Start completed.
2020-06-15 15:48:24.222  INFO [xxx,,,] 2882 --- [           main] o.f.c.internal.database.DatabaseFactory  : Database: jdbc:mysql://localhost/xxx (MySQL 5.7)
2020-06-15 15:48:24.387  INFO [xxx,,,] 2882 --- [           main] o.f.core.internal.command.DbValidate     : Successfully validated 2 migrations (execution time 00:00.062s)
2020-06-15 15:48:24.434  INFO [xxx,,,] 2882 --- [           main] o.f.core.internal.command.DbMigrate      : Current version of schema `xxx`: 0.0.1
2020-06-15 15:48:24.437  INFO [xxx,,,] 2882 --- [           main] o.f.core.internal.command.DbMigrate      : Schema `xxx` is up to date. No migration necessary.
2020-06-15 15:48:24.621  INFO [xxx,,,] 2882 --- [           main] o.s.s.concurrent.ThreadPoolTaskExecutor  : Initializing ExecutorService 'applicationTaskExecutor'
2020-06-15 15:48:24.812  WARN [xxx,,,] 2882 --- [           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


I have been using earlier version of spring boot for a long time, anyone know how to fix it?

1 Answers

This is likely to caused by this bug: https://github.com/spring-projects/spring-framework/issues/25111

The problem is caused by Spring Boot 2.3 moving to bootstrapping Hibernate asynchronously by default. [...] Bootstrapping results in a call back into the bean factory via SpringBeanContainer and a deadlock occurs. [...] In the meantime, you can avoid the problem by disabling deferred bootstrapping:

spring:
  data:
    jpa:
      repositories:
        bootstrap_mode: default
Related