【发布时间】:2016-10-10 15:31:07
【问题描述】:
我正在为我想在我的 Spring-boot 应用程序中添加的 Spring-WS 路由而苦苦挣扎。我在启动时不断收到以下异常:
Caused by: java.lang.IllegalArgumentException: No instance of CamelSpringWSEndpointMapping found in Spring ApplicationContext. This bean is required for Spring-WS consumer support (unless the 'spring-ws:beanname:' URI scheme is used)
at org.apache.camel.component.spring.ws.SpringWebserviceComponent.addEndpointMappingToConfiguration(SpringWebserviceComponent.java:142)
at org.apache.camel.component.spring.ws.SpringWebserviceComponent.addConsumerConfiguration(SpringWebserviceComponent.java:83)
at org.apache.camel.component.spring.ws.SpringWebserviceComponent.createEndpoint(SpringWebserviceComponent.java:67)
at org.apache.camel.impl.DefaultComponent.createEndpoint(DefaultComponent.java:114)
at org.apache.camel.impl.DefaultCamelContext.getEndpoint(DefaultCamelContext.java:568)
... 40 common frames omitted
这很奇怪,因为我在我的 Spring 配置中明确添加了 CamelEndpointMapping(从 CamelSpringWSEndpointMapping 扩展而来),如下所示:
@EnableWs
@SpringBootApplication
public class Application
{
public static void main(String[] args)
{
SpringApplication.run(Application.class, args);
}
@Bean
public ServletRegistrationBean messageDispatcherServlet(ApplicationContext applicationContext)
{
MessageDispatcherServlet messageDispatcherServlet = new MessageDispatcherServlet();
messageDispatcherServlet.setApplicationContext(applicationContext);
messageDispatcherServlet.setTransformWsdlLocations(true);
return new ServletRegistrationBean(messageDispatcherServlet, "/soap/*");
}
@Bean
public CamelEndpointMapping endpointMapping()
{
return new CamelEndpointMapping();
}
}
我的路线:
@Component
public class MyRoutes extends RouteBuilder
{
@Override
public void configure() throws Exception
{
from("spring-ws:soapaction:http://example.com/myservice")
.to("log:cameltest?level=DEBUG");
}
}
我在这里做错了什么?你可以在 GitHub 上找到我的示例项目的完整源代码:https://github.com/verhage/cameltest
【问题讨论】:
-
您的 CamelEndpointMapping 类是否扩展了 CamelSpringWSEndpointMapping? ...没关系,是的。刚刚在你的解释中注意到了。在您的 @Configuration 类中,尝试将返回类型设置为 CamelSpringWSEndpointMapping 而不是 CamelEndpointMapping
-
你是如何运行这段代码的?当我下载它并尝试运行它时遇到依赖问题
-
将返回类型显式更改为 CamelSpringWSEndpointMapping 没有帮助。 @davidfrancis,您是否使用 mvn 获取所有依赖项?
-
是的,虽然当然可能出了点问题!你到底是如何运行它的?
-
我使用 IntelliJ,导入 maven 项目并运行 Application#main。也许您的存储库中有一个 settings.xml 指向不包含所有库的存储库?它应该能够从中心解决所有问题。
标签: java soap spring-boot apache-camel spring-ws