7.15. 为自动配置添加 XML Rest-DSL 路由

Camel Spring Boot 组件会自动探测并嵌入 camel-rest 目录下的 classpath 中添加的 Camel Rest-DSL XML 路由。您可以使用配置选项配置目录名称或禁用此功能。

流程

  • 在 classpath 中配置 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>