我是骆驼新手。我正在 spring-boot 中做一个项目,使用camel作为路由。我注意到,当我去 SwaggerUi 查看 Post 调用的正确功能时,路由的 contextPath 不起作用:
public void configure() {
restConfiguration().component("servlet").contextPath("service/");
rest("/ocs")
.post("/homologation")
.id(camelRoutesIdConfig.getHomologationRequestRouteId())
.consumes("application/json")
.produces("application/json")
.param()
.name("IntegrationRequestDto")
.type(RestParamType.body)
.required(true)
.description("attivazione nuovo contratto sul portale")
.endParam()
.to("direct:homologation")
}
如果在 application.yml 中我像这样指定 contextPath ,则不会出现此问题:
camel:
rest:
component: servlet
binding-mode: json
enable-cors: true
data-format-property:
prettyPrint: false
component:
servlet:
mapping:
context-path: /service/*
当我在一种情况下拨打 Post 电话时,它可以工作,而在路线中的 ContextPath 情况下,它无法识别该命令并给出
{
"timestamp": "2020-11-22T17:44:26.701+0000",
"status": 404,
"error": "Not Found",
"message": "Not Found",
"path": "/service/ocs/homologation"
}
为什么会出现这个问题呢?为什么我还被迫在 application.yml 中指定,而不是在路由中仅使用一次?感谢大家提供可能的答案