6.2. Camel Spring Boot アプリケーションの構造
Camel Spring Boot アプリケーションのディレクトリー構造は以下のようになります。
このうち、アプリケーションの開発に重要なファイルは次のとおりです。
- pom.xml
-
追加の依存関係が含まれます。Spring Boot と互換性のある Camel コンポーネントは、
camel-jdbc-starter
やcamel-infinispan-starter
などのスターターバージョンを利用できます。pom.xml
にスターターが含まれると、スターターは自動的に設定され、起動時に Camel コンテンツと登録されます。application.properties
ファイルを使用すると、コンポーネントのプロパティーを設定できます。 - application.properties
設定の外部化を可能にし、異なる環境で同じアプリケーションコードを使用して作業できるようになります。詳細は Externalized Configuration を参照してください。
たとえば、この Camel アプリケーションでアプリケーションの名前や IP アドレスなどの特定のプロパティーを設定できます。
application.properties
Copy to Clipboard Copied! Toggle word wrap Toggle overflow - Application.java
これはアプリケーションを実行するために重要なファイルです。ユーザーとして
camel-context.xml
ファイルをインポートし、Spring DSL を使用してルートを設定します。Application.java file
は@SpringBootApplication
アノテーションを指定します。このアノテーションは、デフォルトの属性を持つ@Configuration
、@EnableAutoConfiguration
、および@ComponentScan
と同等です。Application.java
@SpringBootApplication // load regular Spring XML file from the classpath that contains the Camel XML DSL @ImportResource({"classpath:spring/camel-context.xml"})
@SpringBootApplication // load regular Spring XML file from the classpath that contains the Camel XML DSL @ImportResource({"classpath:spring/camel-context.xml"})
Copy to Clipboard Copied! Toggle word wrap Toggle overflow Spring Boot アプリケーションを実行するには
main
メソッドが必要です。Application.java
Copy to Clipboard Copied! Toggle word wrap Toggle overflow - camel-context.xml
src/main/resources/spring/camel-context.xml
は、Camel ルートが含まれる、アプリケーションの開発に重要なファイルです。注記Spring Boot アプリケーションの開発に関する詳細は、Developing your first Spring Boot Application を参照してください。
- src/main/jkube/deployment.yml
openshift-maven-plugin によって生成されるデフォルトの OpenShift 設定ファイルにマージされる追加設定を提供します。
注記このファイルは Spring Boot アプリケーションの一部として使用されませんが、CPU やメモリー使用量などのリソースを制限するためにすべてのクイックスタートで使用されます。