本文介绍了使用 Maven 配置文件构建两个不同的版本并从 Eclipse 中过滤的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试使用 ma​​ven 配置文件过滤 来生成给定 Web 存档的 两个不同版本(war):

I am trying to use maven profiles and filtering in order to produce two different versions of a given web archive (war):

  1. 第一个 本地部署到我在 localhost 上的本地机器
  2. 第二个用于远程部署到 cloudfoundry
  1. A first one for local deployment to my local machine on localhost
  2. 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 中过滤的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

07-24 12:28