简体   繁体   English

在另一个属性文件中包含属性

[英]include properties in another properties file

First of all, I apologize for my approximative english ;) 首先,我对我的近似英语表示歉意;)

I load two properties file in xml like this 我像这样在xml中加载两个属性文件

<propertyPlaceholder id="properties" 
                     location="path/to/my/properties/folder/file2.properties,
                               path/to/my/properties/folder/file1.properties"/>

my properties files look like this : 我的属性文件如下所示:
file1.properties file1.properties

endpoint-from=rest:post:useraccounts:
endpoint-to=http4://${host}:${port}/endpoint

file2.properties (mocked variable for the example) file2.properties(示例的模拟变量)

host=0.0.0.0
host=9999

Yes we talk about camel routing (v2.17) 是的,我们谈论骆驼路由(v2.17)
when I launch my app, il seems that the variables host and port are not populated. 当我启动应用程序时,il似乎没有填充变量host和port。 Is it possible to do this this way, use variables from another properties file inside an specific properties file ? 是否可以通过这种方式使用特定属性文件中另一个属性文件中的变量?

Why I would like to do this ? 为什么我要这样做? I have multiple configuration file which called the two or three external services and if my host changes (migration, different environment), it is easier to change only the host variable in file2 instead of changing all host in all others files (I have more than 60 endpoints declared. 我有多个配置文件,这些文件称为两个或三个外部服务,如果我的主机发生更改(迁移,不同的环境),则仅更改file2中的主机变量而不是更改所有其他文件中的所有主机会比较容易(我拥有更多已声明60个端点。

I hope i am clear enough to make myself understand and I hope you can and will help me 我希望我足够清楚以使自己了解我,希望您能够并且会帮助我

In your routes, you can use the following syntax: 在您的路线中,可以使用以下语法:

${properties:bar.end?locations=com/mycompany/bar.properties}

In your actual property files, I'm not sure if is possible. 在您的实际属性文件中,我不确定是否可能。

R. R.

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM