Apache Camel路由中的Spring Boot属性用法 [英] Spring Boot properties usage in Apache Camel route

查看:116
本文介绍了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属性用法的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆