By default, Camel uses the context path /camel/*
.
So, your curl
command should look like this:
curl -X GET http://localhost:8080/camel/api
You can control the context path in the following ways.
With restConfiguration
restConfiguration()//Bind the api servlet to the localhost port 8080
.component("servlet").host("localhost").port(8080)
.contextPath("/test/*")
.bindingMode(RestBindingMode.auto);
With application.properties
camel.component.servlet.mapping.context-path=/test/*
For me, only the latter works.
Something worth mentioning here.
You are using the servlet
component in your rest definition. In this case, Camel ignores the port
configuration and uses the underlying servlet component. As you are using spring-boot, the tomcat port is being used, which by default happens to be 8080.
If for some reason, you change the tomcat port, your rest service port will change.
For example, if you change the server port in the application.properties
.
server.port=8180
Your rest service uses that port, ignoring the definition in the restConfiguration
.
curl -X GET http://localhost:8180/camel/api
Rest DSL docs
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…