我想調用兩個SOAP Web服務並在我的spring REST項目中獲取數據。org.springframework.beans.factory.BeanCreationException的錯誤
我有兩個不同的兩個(SOAP)Web服務的WSDL(VoucherService.wsdl和CGWebService.wsdl)文件。
首先,我使用「gradle wsdl2java」命令添加一個WSDL(VoucherService.wsdl)來投影並生成類。
然後用下面的Beans更新ModuleConfig類。
@Bean
public Jaxb2Marshaller getVoucherServiceMarshaller() {
Jaxb2Marshaller marshaller = new Jaxb2Marshaller();
marshaller.setContextPath(environment.getProperty("voucher.service.marshaller.contextPath"));
rpr return marshaller; }
@Bean
public WebServiceTemplate getVoucherServiceTemplate() {
WebServiceTemplate template = new WebServiceTemplate(getVoucherServiceMarshaller());
template.setDefaultUri(environment.getProperty("voucher.service.defaultUri"));
return template;
}
@Bean
public VoucherServiceProxy getVoucherServiceProxy() {
VoucherServiceProxy voucherServiceProxy = new VoucherServiceProxy();
return voucherServiceProxy;
}
然後創建VoucherServiceProxy類並添加這些自動裝配。
@Autowired
private WebServiceTemplate voucherServiceTemplate;
@Autowired
private Jaxb2Marshaller marshaller;
然後創建VoucherServiceProxy類中所需的方法和部署,它工作正常。
之後,我使用 「的gradle WSDL2Java的」 命令
然後創建以下的ModuleConfig類的內部豆生成第二WSDL(CGWebService.wsdl)類。
@Bean
public ChargingGatewayServiceProxy getChargingGatewayServiceProxy() {
ChargingGatewayServiceProxy chargingGatewayServiceProxy = new ChargingGatewayServiceProxy();
return chargingGatewayServiceProxy;
}
@Bean
public Jaxb2Marshaller getChargingGatewayServiceMarshaller() {
Jaxb2Marshaller marshaller = new Jaxb2Marshaller();
marshaller.setContextPath(environment.getProperty("cg.service.marshaller.contextPath1"));
return marshaller;
}
@Bean
public WebServiceTemplate getChargingGatewayServiceTemplate() {
WebServiceTemplate template = new WebServiceTemplate(getChargingGatewayServiceMarshaller());
template.setDefaultUri(environment.getProperty("cg.service.url"));
return template;
}
然後創建ChargingGatewayServiceProxy並添加這些自動裝配。
@Autowired
private WebServiceTemplate cgServiceTemplate;
@Autowired
private Jaxb2Marshaller marshaller;
裏面VoucherServiceProxy類我創建必要的方法。
然後我嘗試部署它,但是得到了這個錯誤。
注入自動裝配依賴項失敗;嵌套異常是org.springframework.beans.factory.BeanCreationException:無法自動裝載字段:private org.springframework.ws.client.core.WebServiceTemplate lk.ideahub.symphony.product.dapp.common.VoucherServiceProxy.voucherServiceTemplate;嵌套異常是org.springframework.beans.factory.NoUniqueBeanDefinitionException:無類型的排位豆[org.springframework.ws.client.core.WebServiceTemplate]被定義:預期單一匹配豆但發現2:getVoucherServiceTemplate,getChargingGatewayServiceTempla TE
上下文初始化失敗 org.springframework.beans.factory.BeanCreationException:創建名爲'DAppSyncServiceImpl'的bean時出錯:注入自動裝配的依賴項失敗;嵌套異常是org.springframework.beans.factory.BeanCreationException:無法自動裝入字段:private lk.ideahub.symphony.product.dapp.common.VoucherServiceProxy lk.ideahub.symphony.product.dapp.sync.service.DAppSyncServiceImpl.voucherServiceProxy;嵌套異常是org.springframework.beans.factory.BeanCreationException:創建名爲'voucherServiceProxy'的bean時出錯:注入自動裝配依賴失敗;嵌套異常是org.springframework.beans.factory.BeanCreationException:無法自動裝載字段:private org.springframework.ws.client.core.WebServiceTemplate lk.ideahub.symphony.product.dapp.common.VoucherServiceProxy.voucherServiceTemplate;嵌套異常是org.springframework.beans.factory.NoUniqueBeanDefinitionException:沒有合格的bean類型[org.springframework.ws.client.core。WebServiceTemplate]定義:預期單個匹配的bean,但發現2:getVoucherServiceTemplate,getChargingGatewayServiceTemplate
當我評論有關在類的ModuleConfig其他服務代理一個服務代理是沒有錯誤的工作bean的方法。但不能同時部署。
有人可以幫我找到一種方法來創建這兩個服務代理類在同一個項目中沒有任何豆工廠的錯誤。
感謝。這個對我有用。有用的答案。 –