微信公众号搜"智元新知"关注
微信扫一扫可直接关注哦!

Spring IoC:找不到依赖项

如何解决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() {
    ...
}

版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。