我正在尝试使用 apache camel 开发休息服务。我的项目是部署在tomcat上的spring mvc war。
我不想使用 apache cxf(cxf servlet)。
public class SampleRouter extends RouteBuilder {
@override
public void configure() throws Exception {
from("cxfrs://http://localhost:1234/sample")
.process (new Processor() {
public void process(Exchange exchange) throws Exception {
System.out.println("test");
}
})).setBody(constant("SUCCESS"));
}
}
@Path("/sample")
public class SampleResource {
@GET
public void test() {
}
}
web.xml有dispatcherservlet,contextloaderlistener。
dispatcher-servlet.xml 有 mvc:annotation-drivem, context:component-scan,
<camelContext id="server" trace="true" xmlns="http://camel.apache.org/schema/spring">
<contextScan />
</camelContext>
pom.xml 有 camel-core, camel-cxf, camel-stream, cxf-rt-transports-http-jetty, cxf-rs-frontend-jaxrs, camel-spring, spring-webmvc, spring-web, spring -上下文。
Tomcat运行在8080上,服务器上来好像也没有异常。但是,我尝试点击 url (http://localhost:1234/sample
),似乎没有任何反应。
我错过了什么?我最终会将其扩展到 REST 到 Spring DSL 或 REST 到 Java DSL,并带有身份验证、过滤器和拦截器。
我还尝试了 cxf:rsServer 并在路由器类中引用了它。
此外,将来我是否必须使用 https 而不是 http?或者我如何让 url 不是硬编码的?
最佳答案
可能为时已晚,但要使用 HTTP 请求,可以使用 Apache Camel Servlet 组件
关于rest - Apache Camel + Spring( war )+ Tomcat + REST,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/22188478/