Camel REST(restlet)URL - 与路径参数

时间:2018-03-20 00:04:07

标签: apache-camel

我使用Camel Rest(带有restlet组件),我有以下API:

rest("/order")
    .get("/{orderId}").produces("application/json")
        .param().dataType("int").type(RestParamType.path).name("orderId").endParam()
    .route()
    .bean(OrderService.class, "findOrderById")
    .endRest()


    .get("/customer").produces("application/json").route()
    .bean(OrderService.class, "findOrderByCustomerId")
    .endRest()

问题是/ order / customer不起作用(参见下面的例外)。 / customer的参数来自JWT ...

  

java.lang.String到所需类型:java.lang.Long with value   客户到期非法字符:客户

我认为骆驼会将... / {orderId}参数与... / customer混淆。 如果我为/ customer / orders更改/ customer,它就会起作用。

Spring Boot中的相同想法可以用:

@RequestMapping("/order/{orderId}")
public Order getOrder(@PathVariable Long orderId) {
    return orderRepo.findOne(orderId);
}

@RequestMapping("/order/customer")
public List<Order> getOrder() {
    return orderRepo.listOrderByCustomer(1l);
}

关于发生了什么事的想法?

1 个答案:

答案 0 :(得分:1)

尝试更改Camel Rest DSL中GET操作的顺序。 restlet组件在匹配最佳方法时有一些问题

有几张与此相关的JIRA门票:

相关问题