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换一个名字。