spring-integration - Spring Integration 配置文件中的环境特定 url
问题描述
我正在寻找是否可以为不同的环境动态配置 -
- API 密钥
- 网关 URL
<int:chain input-channel="reportInChannel"
output-channel="headerFilterChannel">
<int:header-enricher>
<int:header name="Api-Key" value="B82853E8B"></int:header>
</int:header-enricher>
<int-http:outbound-gateway
url="https://shh.str1.tst.bl/ia-zadmin/rest/sign/v2/{signalId}"
http-method="GET"
header-mapper="headerMapper"
expected-response-type="java.lang.String"
encode-uri="false" request-factory="sslFactory">
<int-http:uri-variable name="signalId" expression="payload" />
</int-http:outbound-gateway>
<int:object-to-string-transformer></int:object-to-string-transformer>
</int:chain>
编辑1:
@SpringBootApplication
@EnableIntegration
@PropertySource("classpath:/application.properties")
@ImportResource({"classpath:/common.xml","classpath:/so-on-config.xml"})
@EnableJms
@EnableSwagger2c
public class SpringIntegrationMQApplication {
private QueueConnectionFactory jmsConFactory;
public static void main(String[] args) {
ConfigurableApplicationContext context = SpringApplication.run(SpringIntegrationMQApplication.class, args);
}
@Bean
public Docket api() {
return new Docket(DocumentationType.SWAGGER_2)
.select()
.apis(RequestHandlerSelectors.any())
.paths(PathSelectors.any())
.build();
}
@Bean
public static PropertySourcesPlaceholderConfigurer placeHolderConfigurer() {
return new PropertySourcesPlaceholderConfigurer();
}
}
我的配置 xml 中的占位符没有被替换。我也希望能够使用配置文件 [application-test.properties] 等。谢谢
解决方案
您可以在属性中使用属性占位符。所以,你B82853E8B
可以用类似的东西代替:
<int:header name="Api-Key" value="${my.api.key}">
url
in<int-http:outbound-gateway
也可以作为对一些外部配置属性的引用:
url="${my.http.url}"
推荐阅读
- html - 更改 Vuetify 禁用复选框的背景颜色
- python - 如何找到函数的 x 对应值?
- julia - 如何修改 Julia 中的上标(牛虻图的标签)?
- reactjs - 如何制作 React 的
在生产中工作? - excel - 如何对同一列中连续突出显示的单元格求和?
- redash - 如何将 Redash 主机服务移至我的 ec2?迁移脚本不起作用
- c++ - 查找给定矩阵转置的程序
- javascript - Javascript:如何将键发送到这个特定的输入元素?
- javascript - 如何使用有效的 https 将域重新映射到另一个域?
- python - Pyspark .collect() 错误 - IndexError:列表索引超出范围