6.7. 为 Camel Spring Boot 自动配置配置 Camel 属性
Spring Boot auto-configuration 连接到 Spring Boot 外部配置,如属性占位符、操作系统环境变量或带有 Camel 属性支持的系统属性。
流程
在
application.properties
文件中定义属性:route.from = jms:invoices
或者将 Camel 正确设置为系统属性,例如:
java -Droute.to=jms:processed.invoices -jar mySpringApp.jar
使用配置的属性作为 Camel 路由中的占位符,如下所示:
@Component public class MyRouter extends RouteBuilder { @Override public void configure() throws Exception { from("{{route.from}}").to("{{route.to}}"); } }