我收到一个错误,我无法弄清楚它与 Spring WebserviceTemplate 有什么关系。
这是类定义:(有趣的部分是如果我删除 @Service 注释,它工作正常。)
@Service
public class PTSWebServicesClientStubImpl implements PTSWebServicesStub
{
@Autowired
@Qualifier("PTS")
private WebServiceTemplate ptsWebServiceTemplate;
.....//
}
这是xml配置:
<bean id="ptsWebServiceTemplate" class="org.springframework.ws.client.core.WebServiceTemplate">
<qualifier value="PTS" />
<constructor-arg ref="messageFactory" />
<property name="marshaller" ref="ptsJaxbMarshaller" />
<property name="unmarshaller" ref="ptsJaxbMarshaller" />
<property name="interceptors">
<list>
<ref bean="loggingInterceptor" />
</list>
</property>
</bean>
当我尝试部署它或从 Junit 测试中调用它时,我收到以下错误:
Caused by: org.springframework.beans.factory.NoSuchBeanDefinitionException: No matching bean of type [org.springframework.ws.client.core.WebServiceTemplate] found for dependency: expected at least 1 bean which qualifies as autowire candidate for this dependency. Dependency annotations: {@org.springframework.beans.factory.annotation.Autowired(required=true), @org.springframework.beans.factory.annotation.Qualifier(value=PTS)}
at org.springframework.beans.factory.support.DefaultListableBeanFactory.raiseNoSuchBeanDefinitionException(DefaultListableBeanFactory.java:920)
at org.springframework.beans.factory.support.DefaultListableBeanFactory.doResolveDependency(DefaultListableBeanFactory.java:789)
at org.springframework.beans.factory.support.DefaultListableBeanFactory.resolveDependency(DefaultListableBeanFactory.java:703)
at org.springframework.beans.factory.annotation.AutowiredAnnotationBeanPostProcessor$AutowiredFieldElement.inject(AutowiredAnnotationBeanPostProcessor.java:474)
... 100 more