如何将Spring Boot中的Jetty与Camel Jetty组件一起使用? [英] How to use Jetty from Spring Boot with Camel Jetty Component?
问题描述
我有一个使用骆驼码头组件作为网关的Camel Endpoints路由的Spring Boot应用程序.
I have a Spring Boot application with Camel Endpoints routes using camel jetty component as a gateway.
@Component
public class StartEcommerce extends RouteBuilder {
@Override
public void configure() throws Exception {
restConfiguration()
.host("localhost")
.port(8085);
rest("/rest/v1")
.post("/order")
.to("direct:ecommerceRestRoute")
.post("/cancelEnrollment")
.to("direct:cancelEnrollmentRestRoute");
// other routes ...
}
}
如果我将码头组件放在端口8085中执行,一切都将正常工作.
Everything works fine if I put the jetty component to execute in port 8085.
但是,我想使用已经在端口8081中运行的Spring Boot码头,因为我希望能够从执行器访问运行状况检查端点,并能够像这样调用我的其余端点:
However, I would like to use Spring Boot's jetty that is already running in port 8081, because I want to have access to healthcheck endpoints from actuator and be able to call my rest endpoints like this:
localhost:8081/health
localhost:8081/rest/v1/order
localhost:8081/rest/v1/cancelEnrollment
试图关注此讨论
在Spring Boot中将现有的HTTP服务器用作骆驼端点
但是我得到了下面的错误,因为我有两个在同一端口上运行的码头
but I got the error below, because I have two Jettys running on the same port
***************************
APPLICATION FAILED TO START
***************************
Description:
Embedded servlet container failed to start. Port 8081 was already in use.
Action:
Identify and stop the process that's listening on port 8081 or configure this application to listen on another port.
我在使用Spring Boot 1.4.2.RELEASE的camel-jetty 2.18.0.
I'm using camel-jetty 2.18.0 an Spring Boot 1.4.2.RELEASE.
任何建议如何实现?
推荐答案
我找到了解决方案,在build.gradle中设置了不正确的依赖项.
I found the solution, I have a incorrect dependency set in my build.gradle.
compile('org.apache.camel:camel-jetty:2.18.0')
此外,我还从路由中删除了其余配置:
Besides I remove the rest configuration from my route:
restConfiguration()
.host("localhost")
.port(8081);
并遵循克劳斯·易卜生的这个例子
And follow this example from Claus Ibsen
这篇关于如何将Spring Boot中的Jetty与Camel Jetty组件一起使用?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!