Skip to content

Error when trying to bootstrap Hibernate asynchronously and using @EnableScheduling #15038

@michal-lyson

Description

@michal-lyson

After upgrading application to Spring 2.1.0 I tried to use Hibernate asynchronously bootstrap, but when I'm adding a flag spring.data.jpa.repositories.bootstrap-mode=deferred to configuration then application throws error during startup:

Parameter 0 of method entityManagerFactory in org.springframework.boot.autoconfigure.orm.jpa.JpaBaseConfiguration required a single bean, but 2 were found: - [ ] - applicationTaskExecutor: defined by method 'applicationTaskExecutor' in class path resource [org/springframework/boot/autoconfigure/task/TaskExecutionAutoConfiguration.class] - taskScheduler: defined by method 'taskScheduler' in class path resource [org/springframework/boot/autoconfigure/task/TaskSchedulingAutoConfiguration.class]

Looks like Spring have trouble with finding unique AsyncTaskExecutor bean and both beans are coming from auto configuration. To make it work I excluded TaskExecutionAutoConfiguration:

@SpringBootApplication(exclude = {TaskExecutionAutoConfiguration.class})
@EnableScheduling
class MyApp {}

Metadata

Metadata

Assignees

Labels

Type

No type

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions