rest - Apache Camel + Spring( war )+ Tomcat + REST

标签 rest tomcat spring-mvc apache-camel cxfrs

我正在尝试使用 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 组件

http://camel.apache.org/servlet.html

关于rest - Apache Camel + Spring( war )+ Tomcat + REST,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/22188478/

相关文章:

java - 处理 Rest API 的大响应

java - 如何将 Json String 映射到 POJO?

tomcat - 我构建我的 servlet 了吗?

eclipse - http 404错误报告tomcat eclipse

tomcat - tomcat 7 管理器的用户/密码

javascript - 有没有办法使用浏览器从要求授权 header 的 RESTful Web 服务下载文件

java - 无法使用 spring-boot-devtools 运行 2 个 Web 服务器

java - 在 Spring 环境中泄漏 Tomcat JDBC MySQL 驱动程序

java - hibernate 中的 com.mysql.jdbc.exceptions.jdbc4.MySQLSyntaxErrorException

java - Hibernate 不会完全刷新实体子项