Maven 多配置文件部署在 WEB-INF/classes 中
我需要在我的最后一场战争中包含一些内容:
我在 src/main/resources 中遇到了多个配置文件文件的情况:
configuration.properties (local)
configuration.dev.properties
configuration.production.properties
所以,我希望当执行“-PProduction”时,文件配置.生产.属性是复制到 WEB-INF/classes 目录的 war 中并重命名为“configuration.properties”。我怎样才能得到它?
谢谢
随机化
I need to include some stuff in my final war:
I have a situation with multi profiles files in the src/main/resources:
configuration.properties (local)
configuration.dev.properties
configuration.production.properties
so, I would like that when for example '-Pproduction' is executed the file configuration.production.properties is copied in the war at the dir WEB-INF/classes and renamed as 'configuration.properties'. How can I get that?
Thanks
Randomize
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
我不会这样做。
相反,我将有一个configuration.properties,保存根据配置文件不同的值的占位符:
然后使用资源插件的过滤功能,以便用从配置文件中获取的实际值替换占位符
:你的 pom :
I would not do it like this.
Instead, I would have a single configuration.properties, holding placeholders for the values that differ depending on the profile :
And then use the filtering capabilities of the resources plugin in order to replace the placeholder with actual values fetched from the profile:
And now in your pom :
资源可以包含在每个配置文件的基础上,我认为如果您按环境/配置文件对它们进行分组会更优雅:
我还不知道是否可以包含在每个配置文件的基础上的源(如果可以的话请帮忙 :D)。
Resources can be included on a per-profile basis and I think it would be more elegant if you would group them by environment/profile:
What I don't know yet is if I can include sources on a per profile basis (please help out if you can :D).
你为什么不过滤它们。只有一个具有该名称的文件,您可以执行以下操作:
Why don't you filter them. Only one file with the name and you do: