使用Kotlin的Spring Boot 2.0.0.M2应用程序的UnsatisfiedDependencyException
我试图用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: {}
以下异常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: {}
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: {}
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微服务应用程序。
让我知道是否有任何其他代码片段,我需要提供我的问题是有道理的。