6.15. 为自动配置添加 XML Rest-DSL 路由
Camel Spring Boot 组件自动探测并嵌入在 camel-rest
目录下的类路径中添加的 Camel Rest-DSL XML 路由。您可以使用配置选项配置目录名称或禁用此功能。
流程
按照如下所示,在类路径中配置 Camel Spring Boot Rest-DSL XML 路由:
// turn off camel.springboot.xmlRests = false // scan in the com/foo/routes classpath camel.springboot.xmlRests = classpath:com/foo/rests/*.xml
注意Rest-DSL XML 文件应当定义 Camel XML REST 元素而不是
CamelContext
元素,例如:<rests xmlns="http://camel.apache.org/schema/spring"> <rest> <post uri="/persons"> <to uri="direct:postPersons"/> </post> <get uri="/persons"> <to uri="direct:getPersons"/> </get> <get uri="/persons/{personId}"> <to uri="direct:getPersionId"/> </get> <put uri="/persons/{personId}"> <to uri="direct:putPersionId"/> </put> <delete uri="/persons/{personId}"> <to uri="direct:deletePersionId"/> </delete> </rest> </rests>