5.3. Camel Spring Boot 应用程序的结构
Camel Spring Boot 应用程序的目录结构如下:
├── LICENSE.md
├── pom.xml
├── README.md
├── configuration
│ └── settings.xml
└── src
├── main
│ ├── fabric8
│ │ └── deployment.yml
│ ├── java
│ │ └── org
│ │ └── example
│ │ └── fis
│ │ ├── Application.java
│ │ └── MyTransformer.java
│ └── resources
│ ├── application.properties
│ ├── logback.xml
│ └── spring
│ └── camel-context.xml
└── test
└── java
└── org
└── example
└── fis以下文件对于开发应用程序非常重要:
- pom.xml
-
包括其他依赖项。与 Spring Boot 兼容的 Camel 组件在入门版本中可用,如
camel-jdbc-starter或camel-infinispan-starter。启动者包含在pom.xml中后,它们会自动配置并在引导时使用 Camel 内容注册。用户可以使用application.properties文件配置组件的属性。 - application.properties
允许您对配置进行外部化,并在不同的环境中使用相同的应用程序代码。详情请参阅 外部化配置
例如,在这个 Camel 应用程序中,您可以配置某些属性,如应用程序名称或 IP 地址等。
application.properties
#spring.main.sources=org.example.fos logging.config=classpath:logback.xml # the options from org.apache.camel.spring.boot.CamelConfigurationProperties can be configured here camel.springboot.name=MyCamel # lets listen on all ports to ensure we can be invoked from the pod IP server.address=0.0.0.0 management.address=0.0.0.0 # lets use a different management port in case you need to listen to HTTP requests on 8080 management.port=8081 # disable all management endpoints except health endpoints.enabled = false endpoints.health.enabled = true
- Application.java
它是运行应用程序的重要文件。作为用户,您将在此处导入
camel-context.xml文件,以使用 Spring DSL 配置路由。Application.java 文件指定@SpringBootApplication注释,它等同于@Configuration、@EnableAutoConfiguration和@ComponentScan。Application.java
@SpringBootApplication // load regular Blueprint file from the classpath that contains the Camel XML DSL @ImportResource({"classpath:blueprint/camel-context.xml"})它必须具有运行 Spring Boot 应用程序的主要方法。
Application.java
public class Application { /** * A main method to start this application. */ public static void main(String[] args) { SpringApplication.run(Application.class, args); } }- camel-context.xml
src/main/resources/spring/camel-context.xml是开发应用程序的重要文件,因为它包含 Camel 路由。注意您可以在开发 第一个 Spring Boot 应用程序中找到有关开发 Spring-Boot 应用程序的更多信息
- src/main/fabric8/deployment.yml
提供与 fabric8-maven-plugin 生成的默认 OpenShift 配置文件合并的额外配置。
注意此文件不是 Spring Boot 应用程序的一部分,但它用于限制 CPU 和内存用量等资源。