我正在尝试用Kotlin重写JHipster应用程序的DataConfiguration.java
实现。我遇到问题的方法是:
@Bean
public SpringLiquibase liquibase(@Qualifier("taskExecutor") TaskExecutor taskExecutor,
DataSource dataSource, LiquibaseProperties liquibaseProperties) {
// Use liquibase.integration.spring.SpringLiquibase if you don't want Liquibase to start asynchronously
SpringLiquibase liquibase = new AsyncSpringLiquibase(taskExecutor, env);
liquibase.setDataSource(dataSource);
liquibase.setChangeLog("classpath:config/liquibase/master.xml");
liquibase.setContexts(liquibaseProperties.getContexts());
liquibase.setDefaultSchema(liquibaseProperties.getDefaultSchema());
liquibase.setDropFirst(liquibaseProperties.isDropFirst());
if (env.acceptsProfiles(JHipsterConstants.SPRING_PROFILE_NO_LIQUIBASE)) {
liquibase.setShouldRun(false);
} else {
liquibase.setShouldRun(liquibaseProperties.isEnabled());
log.debug("Configuring Liquibase");
}
return liquibase;
}
我改写为:
@Bean
fun liquibase(@Qualifier("taskExecutor") taskExecutor: TaskExecutor,
dataSource: DataSource, liquibaseProperties: LiquibaseProperties): SpringLiquibase {
// Use liquibase.integration.spring.SpringLiquibase if you don't want Liquibase to start asynchronously
val liquibase = AsyncSpringLiquibase(taskExecutor, env)
liquibase.dataSource = dataSource
liquibase.changeLog = "classpath:config/liquibase/master.yml"
liquibase.contexts = liquibaseProperties.contexts
liquibase.defaultSchema = liquibaseProperties.defaultSchema
liquibase.isDropFirst = liquibaseProperties.isDropFirst
if (env.acceptsProfiles(SPRING_PROFILE_NO_LIQUIBASE)) {
liquibase.setShouldRun(false)
} else {
liquibase.setShouldRun(liquibaseProperties.isEnabled)
log.debug("Configuring Liquibase")
}
return liquibase
}
当我运行Spring Boot应用程序时,我得到以下异常Exception encountered during context initialization - cancelling refresh attempt: org.springframework.beans.factory.UnsatisfiedDependencyException: Error creating bean with name 'liquibase' defined in class path resource [com/sample/myapplication/config/DatabaseConfiguration.class]: Unsatisfied dependency expressed through method 'liquibase' parameter 0; nested exception is org.springframework.beans.factory.NoSuchBeanDefinitionException: No qualifying bean of type 'org.springframework.core.task.TaskExecutor' available: expected at least 1 bean which qualifies as autowire candidate. Dependency annotations: {}
。
我可能缺少什么想法?我正在使用Gradle来运行应用程序,而我的配置基于未经修改的JHipster微服务应用程序。
如果有任何其他代码段我需要提供给我的问题才能让我知道。