7.14. 自動設定の XML ルートのクラスパスへの追加

デフォルトでは、camel ディレクトリーのクラスパスにある Camel XML ルートは Camel Spring Boot コンポーネントによって自動検出され、含まれます。設定オプションを使用すると、ディレクトリー名を設定でき、設定オプションを使用してこの機能を無効化できます。

手順

  • 以下のようにクラスパスの Camel Spring Boot XML ルートを設定します。

    // turn off
    camel.springboot.xmlRoutes = false
    // scan in the com/foo/routes classpath
    camel.springboot.xmlRoutes = classpath:com/foo/routes/*.xml
    注記

    XML ファイルによって Camel XML ルート要素が定義され、CamelContext 要素は定義されないはずです。例を以下に示します。

       <routes xmlns="http://camel.apache.org/schema/spring">
            <route id="test">
                <from uri="timer://trigger"/>
                <transform>
                    <simple>ref:myBean</simple>
                </transform>
                <to uri="log:out"/>
            </route>
        </routes>

Spring XML ファイルの使用

<camelContext> で Spring XML ファイルを使用するには、Spring XML ファイルまたは application.properties ファイルの Camel コンテキストを設定します。Camel コンテキストの名前を設定し、ストリームキャッシングを有効にするには、以下を application.properties ファイルに追加します。

camel.springboot.name = MyCamel
camel.springboot.stream-caching-enabled=true