【发布时间】:2022-11-03 00:37:37
【问题描述】:
我有一个 spring-boot 应用程序,我从队列中读取数据并使用 .bean() 将数据发送到转换类
集成.java
class Integration {
@Value("${someURL}")
private String someURL; //able to read someURL from property file
from("queue")
// some intermediate code
.bean(new TransformationClass(), "transformationMethod")
// other code
}
现在,在 TransformationClass 内部,我有 @Value 注释来从属性文件中读取值,但它总是返回 null。
转换类.java
@Component
class TransformationClass {
@Value("${someURL}")
private String someURL; //someURL return null though there is key-value associated in props file.
public void transformationMethod(Exchange exchange) {
// other stuff related to someURL
}
}
注意 - 我能够从 Integration.java 类中的属性文件中读取值,但无法从 TransformationClass.java 类中读取值
我正在使用 Spring Boot 版本 - 2.7.2 和 Camel 版本 - 3.18.1 jdk - 17
我尝试使用骆驼 PropertiesComponent 阅读,但没有奏效。
【问题讨论】:
-
谢谢,它有效!
标签: spring-boot apache-camel spring-camel