Building two different versions a given war with maven profiles and filtering from eclipse(使用 Maven 配置文件构建两个不同的版本并从 Eclipse 中过滤)
问题描述
我正在尝试使用 maven 配置文件 和 过滤 来生成给定 Web 存档的 两个不同版本(war):
I am trying to use maven profiles and filtering in order to produce two different versions of a given web archive (war):
- 第一个 本地部署到我在 localhost 上的本地机器
- 第二个用于远程部署到 cloudfoundry
- A first one for local deployment to my local machine on localhost
- A second one for remote deployment to cloudfoundry
根据应用是部署到我的本地计算机还是部署到 cloudfoundry,有许多属性会有所不同.
There are a number of properties that differ according to whether the app is deployed to my local machine or to cloudfoundry.
当然,困难在于我正在尝试从 STS/Eclipse 完成所有这些操作,并从 Eclipse 部署到我的本地 tomcat 和 cloudfoundry...
Of course the difficult bit is that I am trying to do all this from STS/Eclipse and deploy from Eclipse to my local tomcat and to cloudfoundry...
谁能提供建议、提示或建议?
Can anyone please provide advice, tips or suggestions?
推荐答案
如果您使用 Spring 版本控制 3.1+,则 spring bean 配置 xml 中
的profile"属性将是最佳选择.看看这里的文档:http://docs.cloudfoundry.com/frameworks/java/spring/spring.html#using-spring-profiles-to-conditionalize-cloud-foundry-configuration
If you are using Spring versioning 3.1+ the "profile" attribute for <beans>
in the spring bean configuration xml would be the best choice. Take a look at the doc here: http://docs.cloudfoundry.com/frameworks/java/spring/spring.html#using-spring-profiles-to-conditionalize-cloud-foundry-configuration
基本上您需要指定至少 2 个元素.一种用于本地属性 (profile="default"
),另一种用于部署到 CF 时的属性.后者应该定义为<beans profile="cloud">
.在本地运行时,云"中的属性将被忽略,默认"中的属性将生效.推送到 CF 时,CF 会检测名为cloud"的配置文件,更好的是注入 CF 自己提供的服务的相应数据源连接信息.您也可以在该文档中找到详细的 CF 指定属性.
Basically you need to specify at least 2 elements. One for your local properties (profile="default"
) and one for the properties when deployed to CF. The latter one should be defined as <beans profile="cloud">
. When running locally the properties within "cloud" would be ignored and properties in "default" will take effect. When pushed to CF, CF will detect the profile named "cloud" and, which is better, inject corresponding datasource connection info of the services provisioned by CF itself. You can find the detailed CF-specified properties in that doc as well.
有关配置文件属性的更多信息,请参阅此处的文档:http://blog.springsource.com/2011/02/11/spring-framework-3-1-m1-released/
For more information about the profile attribute, see the doc here: http://blog.springsource.com/2011/02/11/spring-framework-3-1-m1-released/
这篇关于使用 Maven 配置文件构建两个不同的版本并从 Eclipse 中过滤的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持编程学习网!
本文标题为:使用 Maven 配置文件构建两个不同的版本并从 Ec


- 转换 ldap 日期 2022-01-01
- 未找到/usr/local/lib 中的库 2022-01-01
- 获取数字的最后一位 2022-01-01
- 如何使 JFrame 背景和 JPanel 透明且仅显示图像 2022-01-01
- Eclipse 的最佳 XML 编辑器 2022-01-01
- 如何指定 CORS 的响应标头? 2022-01-01
- GC_FOR_ALLOC 是否更“严重"?在调查内存使用情况时? 2022-01-01
- java.lang.IllegalStateException:Bean 名称“类别"的 BindingResult 和普通目标对象都不能用作请求属性 2022-01-01
- 在 Java 中,如何将 String 转换为 char 或将 char 转换 2022-01-01
- 将 Java Swing 桌面应用程序国际化的最佳实践是什么? 2022-01-01