要在Maven war项目中打包的不同文件 [英] Different files to be packaged in a Maven war project

查看:195
本文介绍了要在Maven war项目中打包的不同文件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个war包装Maven项目,其中我有一个名为myapp.properties的Java属性文件。在此属性文件中,我存储了一些参数,例如,将由webapp使用的数据库连接参数。

I have a war packaging Maven project, in which I have a Java properties files called myapp.properties. In this properties file, I store some parameters, for example, database connection parameters, which will be used by the webapp.


  1. 无论是在持续集成环境中还是在我的开发环境中,我都想在myapp.properties中设置一些测试参数来连接我的测试例如,数据库。

  2. 同时,我希望在最终的war包中将这些参数留空,以便用户可以在部署到其环境期间自行添加这些值。最终的war包应该是在持续集成环境中生成的构建工件。

本质上,有两个版本的myapp.properties文件我想在不同的情况下使用。我的问题是,Maven解决这个问题的方法是什么?我在开发环境中使用Eclipse + WTP + m2eclipse,我希望该解决方案能够与我的开发工具一起使用。

Essentially, there are two versions of myapp.properties file I want to use in different cases. My question is, what is the Maven way to solve this problem? I use Eclipse + WTP + m2eclipse in my development environment, and I hope the solution can works well together with my development tools.

推荐答案

您可以查看此博客: http://blog.jayway.com/2010/01/21/one-artifact-with-multiple-configurations-in-maven/

他们构建不同的war文件并使用不同的分类器(而不是不同的配置文件)。
我不确定它是否是maven方式,但它适用于我的一些项目。

They build different war-files and use different classifier (instead of different profiles). I am not sure if it is the maven way, but it works for some of my projects.

这篇关于要在Maven war项目中打包的不同文件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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