Spring应用程序无法启动,多个ConversionService,webFluxConversionService和intergationConversionService

时间:2019-04-09 11:56:43

标签: spring-boot spring-integration spring-webflux

在Spring Boot 2.0.8.RELEASE应用程序中使用 spring-boot-starter-webflux spring-boot-starter-integration ,两个ConversionService s将被注册,webFluxConversionServiceintegrationConversionService Spring应用程序无法启动,并且需要其中一个bean。

@Component
@RequiredArgsConstructor
public class SomeServiceAdapterImpl {

 @Qualifier("webFluxConversionService")
 private final ConversionService conversionService;

 // SOME METHOD
}


Error messages

APPLICATION FAILED TO START
***************************

Description:

Parameter 1 of constructor in 
de.test.service.SomeServiceAdapterImpl required a single bean,
 but 2 were found:
    - webFluxConversionService: defined by method 'webFluxConversionService' in org.springframework.web.reactive.config.DelegatingWebFluxConfiguration
    - integrationConversionService: 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

2 个答案:

答案 0 :(得分:0)

您需要显示@Bean的{​​{1}}。但是,从本质上讲,如果您需要转换服务,则需要指定哪一项(大概是webflux);只需按照错误消息中的说明进行操作即可。

在bean工厂方法的de.test.service.SomeServiceAdapterImpl参数中添加@Qualifier("webFluxConversionService")

答案 1 :(得分:0)

尝试添加主bean:

IndexError