Spring Boot properties usage in Apache Camel route(Apache Camel 路由中的 Spring Boot 属性使用)
问题描述
这可以在 Apache Camel 路由中使用 Spring Boot 属性吗?@Value 工作正常,但这是否可以直接放置在表达式的占位符中.
Is this possible to use Spring Boot properties in Apache Camel route? @Value is working fine but is this possible to directly place in place holders of expressions.
更新:我知道 PropertiesComponent,但除了 Applicaiton.yml 之外,这将是我不喜欢的另一种配置.
Update: I know PropertiesComponent but which will be one more configuration apart from Applicaiton.yml that I don't like to have.
application.yml
sftp:
host: 10.10.128.128
user: ftpuser1
password: ftpuser1password
path: /tmp/inputfile/test1
Spring Boot Apache Camel 路线:
@Value("${sftp.user}")
private String sftpUser;
@Value("${sftp.host}")
private String sftpHost;
@Value("${sftp.password}")
private String sftpPassword;
@Value("${sftp.path}")
private String sftpInPath;
from("sftp://"+sftpUser+"@"+sftpHost+sftpInPath+"?delete=true&password="+sftpPassword)
//this is working
from("sftp://${sftp.user}@${sftp.host}${sftp.path}?password=${sftp.password}")
// is this possible something like this?
推荐答案
您可以像这样注入完整链接,而不是将所有属性注入到单独的字段中:
Instead of injecting all you properties to separate fields you can inject your full link like that:
@Value("#{'sftp://'+'${sftp.user}'+'@'+'${sftp.host}'+'${sftp.path}'+'?delete=true&password='+'${sftp.password}'}")
private String fullLink;
然后,您可以在 from
方法中使用它.
Then, you can use it in from
method.
这篇关于Apache Camel 路由中的 Spring Boot 属性使用的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持编程学习网!
本文标题为:Apache Camel 路由中的 Spring Boot 属性使用


基础教程推荐
- 降序排序:Java Map 2022-01-01
- Java:带有char数组的println给出乱码 2022-01-01
- 减少 JVM 暂停时间 >1 秒使用 UseConcMarkSweepGC 2022-01-01
- Java Keytool 导入证书后出错,"keytool error: java.io.FileNotFoundException &拒绝访问" 2022-01-01
- 设置 bean 时出现 Nullpointerexception 2022-01-01
- 在 Libgdx 中处理屏幕的正确方法 2022-01-01
- 如何使用 Java 创建 X509 证书? 2022-01-01
- “未找到匹配项"使用 matcher 的 group 方法时 2022-01-01
- 无法使用修饰符“public final"访问 java.util.Ha 2022-01-01
- FirebaseListAdapter 不推送聊天应用程序的单个项目 - Firebase-Ui 3.1 2022-01-01