我正在尝试使用 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-context。
Tomcat 运行在 8080 上,服务器启动时似乎也不例外。但是,我尝试点击 url ( http://localhost:1234/sample
),似乎没有发生任何事情。
我错过了什么?我最终会将其扩展到带有身份验证、过滤器和拦截器的 REST 到 Spring DSL 或 REST 到 Java DSL。
我还尝试了 cxf:rsServer 并在路由器类中引用了它。
另外,将来我是否必须使用 https 而不是 http?或者我如何让 url 没有硬编码?