2017-08-29 47 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 - 我沒有得到這個錯誤