Apache的骆驼+春季(战争)+ Tomcat的+ REST [英] Apache Camel + Spring (war) + Tomcat + REST
问题描述
我想develp使用Apache骆驼休息服务。我的项目是部署Tomcat上Spring MVC的战争。
I am trying to develp a rest service using apache camel. My project is a spring mvc war deployed on tomcat.
我不想使用Apache CXF(CXF的servlet)。
I dont want to use 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的。
web.xml has dispatcherservlet, contextloaderlistener.
分配器 - servlet.xml中有MVC:注解drivem,语境:组件扫描,
dispatcher-servlet.xml has mvc:annotation-drivem, context:component-scan,
<camelContext id="server" trace="true" xmlns="http://camel.apache.org/schema/spring">
<contextScan />
</camelContext>
的pom.xml有骆驼核心,骆驼CXF,骆驼流,CXF-RT-运输-HTTP-码头,CXF-RS-前端-JAXRS,骆驼弹簧,弹簧webmvc,弹簧网,春天-context。
pom.xml has camel-core, camel-cxf, camel-stream, cxf-rt-transports-http-jetty, cxf-rs-frontend-jaxrs, camel-spring, spring-webmvc, spring-web, spring-context.
在Tomcat的运行8080,似乎也不例外,当服务器出现。但是,我想打的网址(的http://本地主机:1234 /样品
),似乎没有任何要发生的事情。
Tomcat runs on 8080, there seems to be no exception when server comes up. But, I tried hitting the url (http://localhost:1234/sample
), nothing seems to be happening.
我在想什么?我最终将这个扩大到其余的春天DSL或REST到Java DSL与认证,过滤器和拦截器。
What am i missing? I would eventually extend this to REST to Spring DSL or REST to Java DSL with authentication, filters and interceptors.
我也试过CXF:rsServer,并提到在路由器类。
I also tried cxf:rsServer and referred that in router class.
此外,在未来,如果我不得不使用https而不是http?不然怎么办我有没有网址硬codeD?
Also, in the future if i have to use https instead of http? or how do i have the url not hard-coded?
推荐答案
这可能为时已晚,但消耗的HTTP请求,可以使用Apache的骆驼的Servlet组件
It may be too late, but to consume HTTP requests, one may use Apache Camel Servlet component
http://camel.apache.org/servlet.html
这篇关于Apache的骆驼+春季(战争)+ Tomcat的+ REST的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!