2017-08-29 81 views
3

我试图升级JHipster项目,但是我发现了以下问题:春天发现2名候选人,但只有一个

Description: 
Parameter 0 of constructor in com.cervaki.config.AsyncConfiguration required a single bean, but 2 were found: 
- jhipster-io.github.jhipster.config.JHipsterProperties: defined in null 
- io.github.jhipster.config.JHipsterProperties: defined in null 
Action: 
Consider marking one of the beans as @Primary, updating the consumer to accept multiple beans, or using @Qualifier to identify the bean that should be consumed 

我明白了什么是春天不能注入正确的,因为豆有两个候选人,但我只有io.github.jhipster.config.JHipsterProperties实现:

package com.cervaki.config; 

import io.github.jhipster.async.ExceptionHandlingAsyncTaskExecutor; 
import io.github.jhipster.config.JHipsterProperties; 

import org.slf4j.Logger; 
import org.slf4j.LoggerFactory; 
import org.springframework.aop.interceptor.AsyncUncaughtExceptionHandler; 
import org.springframework.aop.interceptor.SimpleAsyncUncaughtExceptionHandler; 
import org.springframework.context.annotation.Bean; 
import org.springframework.context.annotation.Configuration; 
import org.springframework.scheduling.annotation.*; 
import org.springframework.scheduling.concurrent.ThreadPoolTaskExecutor; 

import java.util.concurrent.Executor; 

@Configuration 
@EnableAsync 
@EnableScheduling 
public class AsyncConfiguration implements AsyncConfigurer { 

    private final Logger log = LoggerFactory.getLogger(AsyncConfiguration.class); 

    private final JHipsterProperties jHipsterProperties; 

    public AsyncConfiguration(JHipsterProperties jHipsterProperties) { 
     this.jHipsterProperties = jHipsterProperties; 
    } 

    @Override 
    @Bean(name = "taskExecutor") 
    public Executor getAsyncExecutor() { 
     log.debug("Creating Async Task Executor"); 
     ThreadPoolTaskExecutor executor = new ThreadPoolTaskExecutor(); 
     executor.setCorePoolSize(jHipsterProperties.getAsync().getCorePoolSize()); 
     executor.setMaxPoolSize(jHipsterProperties.getAsync().getMaxPoolSize()); 
     executor.setQueueCapacity(jHipsterProperties.getAsync().getQueueCapacity()); 
     executor.setThreadNamePrefix("cervaki-Executor-"); 
     return new ExceptionHandlingAsyncTaskExecutor(executor); 
    } 

    @Override 
    public AsyncUncaughtExceptionHandler getAsyncUncaughtExceptionHandler() { 
     return new SimpleAsyncUncaughtExceptionHandler(); 
    } 
} 

您也可以下载的pom.xml here

我在整个代码和库中搜索,找到jhipster-io.github.jhipster.config.JHipsterProperties文件,但是我没有找到任何东西。 我能做些什么来解决这个问题?

+0

你能分享你POM /的gradle构建和进口? – juanlumn

+0

@juanlumn我分享了pom.xml并添加了导入,如你所请求 – brevleq

+0

从哪个版本升级到哪个版本?你运行mvnw干净吗? –

回答

0

我也产生新的JhipsterApp后面对这个问题,
正如你 - 我不觉得在项目
的“jhipster-io的”依赖我如何解决这个问题:

  1. src/main/java/your/package/config创建一个 “AppConfiguration.java”
  2. 与内容:

    import io.github.jhipster.config.JHipsterProperties; 
    import org.springframework.context.annotation.Bean; 
    import org.springframework.context.annotation.Configuration; 
    import org.springframework.context.annotation.Primary; 
    
    @Configuration 
    public class AppConfiguration { 
    
        @Bean 
        @Primary 
        public JHipsterProperties jHipsterProperties() { 
         return new JHipsterProperties(); 
        } 
    } 
    

即使没有 @Primary - 我没有得到这个错误