我试图用apache骆驼develp休息服务。我的项目是一个部署在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。
调度-servlet.xml中具有MVC:注解drivem,上下文:组分扫描,
<camelContext id="server" trace="true" xmlns="http://camel.apache.org/schema/spring">
<contextScan />
</camelContext>
的pom.xml具有骆驼核,骆驼CXF,骆驼流,CXF-RT-运输-http-jetty,cxf-rs-frontend-jaxrs,camel-spring,spring-webmvc,spring-web,spring-context。
Tomcat在8080上运行,服务器启动时似乎没有异常。但是,我试图击中url(http://localhost:1234/sample
),似乎没有任何事情发生。
我在想什么?我最终将这个延伸到REST,以使用认证,过滤器和拦截器将DSL或REST迁移到Java DSL。
我也试过cxf:rsServer,并在路由器类中提到过。
此外,在未来,如果我必须使用https而不是http?或者我如何使url不被硬编码?
正如我所说的,我没有使用CXF Servlet或Camel Servlet。另外,我正在部署Tomcat。我在cxf:rsServer xml config中配置的端口为123,而tomcat在8080上运行。 我只想确认是否可以在不使用servlet的情况下在tomcat上进行部署。另外,我不确定为什么我需要为服务配置不同的端口,而不是服务器以及它如何工作。另外为什么我需要包含cxf-jetty jar,尽管我使用的是tomcat。 –
我可以得到一些帮助吗? –
可以在不使用servlet传输的情况下发布webserivce。在这种情况下,您只需确保cxf-rt-http-jetty jar在您的类路径中。 –