从 Spring 升级到 Spring 引导中断了 JAX-WS 客户端配置
Upgrade from Spring to Spring Boot broke JAX-WS client configuration
我正在做一个项目,我们目前正在从 Spring 升级到 Spring Boot。我们有一个在控制器中自动装配的 JAX-WS 客户端 bean,但现在它说找不到该类型的 bean。您可以在下面看到代码片段,如果某些命名 link 被破坏,我不得不编辑信息,非常抱歉。
我们在 xml 中有一个 JAX-WS 客户端配置,描述为:
<jaxws:client id="applyClient"
serviceClass="JaxClass"
address="jaxAddress" >
<jaxws:outInterceptors>
<bean class="org.apache.cxf.ws.security.wss4j.WSS4JOutInterceptor">
<constructor-arg>
<map>
<entry key="action" value="Signature Timestamp"/>
<entry key="signatureKeyIdentifier" value="DirectReference"/>
<entry key="passwordType" value="PasswordText" />
<entry key="signaturePropFile" value="signature.properties"/>
<entry key="user" value="userVal" />
<entry key="passwordCallbackRef">
<ref bean="passwordCallback"/>
</entry>
</map>
</constructor-arg>
</bean>
${openComment} <bean class="org.apache.cxf.interceptor.LoggingOutInterceptor" /> ${closeComment}
</jaxws:outInterceptors>
<jaxws:inInterceptors>
${openComment}<bean class="org.apache.cxf.interceptor.LoggingInInterceptor" /> ${closeComment}
</jaxws:inInterceptors>
</jaxws:client>
这项服务class是这样的:
@WebService(targetNamespace = "Folder", name = "TestName")
@XmlSeeAlso({Folder.ObjectFactory.class, otherFolder.ObjectFactory.class})
public interface JaxClass {
@WebResult(...)
@RequestWrapper(...)
@WebMethod
@ResponseWrapper(...)
public java.lang.String updateGBFoaInformation(
@WebParam(...)
Folder.FoaInformation foaInformation
) throws ExchangeRequestValidationException, ExchangeInternalErrorException;
@WebResult(...)
@RequestWrapper(...)
@WebMethod
@ResponseWrapper(...)
public method2 setGBUserSession(
@WebParam(...)
Folder.GBUserSessionRequest gbUserSessionRequest
) throws ExchangeRequestValidationException,
ExchangeInternalErrorException;
}
然后在控制器 class 中,我们将其自动装配为:
@RestController
public class TestController{
@Autowired
JaxClass applyClient;
...
在我们开始升级之前,此设置一直有效。现在我们得到错误:
***************************
APPLICATION FAILED TO START
***************************
Description:
Field applyClient in TestController required a bean of type 'JaxClass' that could not be found.
Action:
Consider defining a bean of type 'JaxClass' in your configuration.
只是有点困惑,因为我在过去一周左右的时间里一直在努力解决这个问题。感谢任何帮助或建议。
请确保在 SpringBoot 应用程序上使用 @ComponentScan 注释扫描 JaxClass 的包 class。
@ComponentScan("com.xxx.yyy")
找到了问题,虽然技术上 xml 文件在类路径中,是文件夹位置,应用程序不知道包含它,所以添加了一个 @ImportResource 注释,它解决了我的问题。
我正在做一个项目,我们目前正在从 Spring 升级到 Spring Boot。我们有一个在控制器中自动装配的 JAX-WS 客户端 bean,但现在它说找不到该类型的 bean。您可以在下面看到代码片段,如果某些命名 link 被破坏,我不得不编辑信息,非常抱歉。
我们在 xml 中有一个 JAX-WS 客户端配置,描述为:
<jaxws:client id="applyClient"
serviceClass="JaxClass"
address="jaxAddress" >
<jaxws:outInterceptors>
<bean class="org.apache.cxf.ws.security.wss4j.WSS4JOutInterceptor">
<constructor-arg>
<map>
<entry key="action" value="Signature Timestamp"/>
<entry key="signatureKeyIdentifier" value="DirectReference"/>
<entry key="passwordType" value="PasswordText" />
<entry key="signaturePropFile" value="signature.properties"/>
<entry key="user" value="userVal" />
<entry key="passwordCallbackRef">
<ref bean="passwordCallback"/>
</entry>
</map>
</constructor-arg>
</bean>
${openComment} <bean class="org.apache.cxf.interceptor.LoggingOutInterceptor" /> ${closeComment}
</jaxws:outInterceptors>
<jaxws:inInterceptors>
${openComment}<bean class="org.apache.cxf.interceptor.LoggingInInterceptor" /> ${closeComment}
</jaxws:inInterceptors>
</jaxws:client>
这项服务class是这样的:
@WebService(targetNamespace = "Folder", name = "TestName")
@XmlSeeAlso({Folder.ObjectFactory.class, otherFolder.ObjectFactory.class})
public interface JaxClass {
@WebResult(...)
@RequestWrapper(...)
@WebMethod
@ResponseWrapper(...)
public java.lang.String updateGBFoaInformation(
@WebParam(...)
Folder.FoaInformation foaInformation
) throws ExchangeRequestValidationException, ExchangeInternalErrorException;
@WebResult(...)
@RequestWrapper(...)
@WebMethod
@ResponseWrapper(...)
public method2 setGBUserSession(
@WebParam(...)
Folder.GBUserSessionRequest gbUserSessionRequest
) throws ExchangeRequestValidationException,
ExchangeInternalErrorException;
}
然后在控制器 class 中,我们将其自动装配为:
@RestController
public class TestController{
@Autowired
JaxClass applyClient;
...
在我们开始升级之前,此设置一直有效。现在我们得到错误:
***************************
APPLICATION FAILED TO START
***************************
Description:
Field applyClient in TestController required a bean of type 'JaxClass' that could not be found.
Action:
Consider defining a bean of type 'JaxClass' in your configuration.
只是有点困惑,因为我在过去一周左右的时间里一直在努力解决这个问题。感谢任何帮助或建议。
请确保在 SpringBoot 应用程序上使用 @ComponentScan 注释扫描 JaxClass 的包 class。
@ComponentScan("com.xxx.yyy")
找到了问题,虽然技术上 xml 文件在类路径中,是文件夹位置,应用程序不知道包含它,所以添加了一个 @ImportResource 注释,它解决了我的问题。