ConversionService配置错误

时间:2018-03-28 09:49:59

标签: spring-boot

我在spring boot中使用转换服务。 这是我的配置类

@Configuration
public class ConversionServiceConfig {
  @SuppressWarnings("rawtypes")
  @Autowired
  private Set<Converter> converters;

@Autowired
private ConversionService conversionService;

@PostConstruct
void initConverters() {
    ConverterRegistry registry = (ConverterRegistry) conversionService;
    converters.stream().forEach(converter -> {
        registry.addConverter(converter);
    });
}

}

在服务类

@Autowired
private ConversionService conversionService;

我收到以下错误:

No qualifying bean of type 'org.springframework.core.convert.ConversionService' available: expected single matching bean but found 2: mvcConversionService,defaultConversionService

0 个答案:

没有答案