Spring IoC:找不到依赖项

问题描述

这是我的代码

@Bean("incidencies")
public Jaxb2Marshaller incidenciesMarshaller() {
    Jaxb2Marshaller marshaller = new Jaxb2Marshaller();
    marshaller.setcontextpath("cat.gencat.catsalut.hes.visor.api.common.domain.incidencies");
    return marshaller;
}

@Bean
public IncidenciesWebServiceGatewaySupport incidenciesClientConnector(
    @Qualifier("incidencies") Jaxb2Marshaller marshaller,...

我收到此错误消息:

***************************
APPLICATION Failed TO START
***************************

Description:

Parameter 0 of method incidenciesClientConnector in cat.gencat.catsalut.hes.visor.api.common.configuration.VisorApiConfiguration required a bean of type 'org.springframework.oxm.jaxb.Jaxb2Marshaller' that Could not be found.

我不太明白出了什么问题。

有什么想法吗?

解决方法

您只需要一个带有 QualifierBean

@Bean()
@Qualifier("incidencies") 
public Jaxb2Marshaller incidenciesMarshaller() {
    ...
}