BeanNotOfRequiredTypeException:Bean named 'xxx' must be of type [xxxxx]...

版权声明:本文为原创文章,版权属文章作者所有,欢迎转载,请在文章底部注明原文链接,谢谢!邮箱:[email protected] https://blog.csdn.net/disalong/article/details/71124740

Caused by: org.springframework.beans.factory.BeanNotOfRequiredTypeException: Bean named 'userWriteService' must be of type [com.tingbo.baseUserWS.interf.UserWriteInterface],but was actually of type[org.apache.cxf.jaxws.spring.EndpointDefinitionParser$SpringEndpointImpl]

是因为在cxf的配置文件中注册了sessionWriteService

    <jaxws:endpoint id="sessionWriteService"

       implementor="com.tingbo.baseSessionWS.write.service.SessionWriteService"

       address="/SessionWriteService">

       <!-- <jaxws:inInterceptors>标签中添加多个<ref>标签可以形成拦截器栈 -->

       <jaxws:inInterceptors>

           <ref bean="simpleLoggingInInterceptor" />

           <ref bean="soapInInterceptor" />

       </jaxws:inInterceptors>

       <jaxws:outInterceptors>

           <ref bean="simpleLoggingOutInterceptor" />

           <ref bean="soapOutInterceptor" />

       </jaxws:outInterceptors>

    </jaxws:endpoint>

而你在定义这个类的时候又注册一次:

@Service("UserWriteService")

@WebService(endpointInterface = "com.tingbo.baseUserWS.interf.UserWriteInterface", targetNamespace = "http://baseUserWS.tingbo.com", portName = "UserWriteInterfacePort", serviceName = "UserWriteServiceService")

@BindingType(value = javax.xml.ws.soap.SOAPBinding.SOAP12HTTP_BINDING)

publicclass UserWriteService extends UtilFather implementsUserWriteInterface {

那么当你注入的时候就会报错:

   @Resource

    private UserWriteService userWriteService;

解决办法是将cxf配置文件中的id换一个名字。

猜你喜欢

转载自blog.csdn.net/disalong/article/details/71124740