如何使用另一个项目来扩展/定制WAR [英] How to extend/customize a WAR with another project

查看:182
本文介绍了如何使用另一个项目来扩展/定制WAR的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我们的项目有以下情况:

We have the following scenario with our project:


  • 打包成
    战争文件的核心网络应用程序核心项目)。

  • 需要定制或扩展每个客户的核心应用
    (称为客户项目)。这主要包括
    新的bean定义(我们使用
    Spring),即。将
    替换为
    的客户特定实现的核心代码中的
    实现。

  • 我们要独立开发核心和客户项目

  • 当客户项目开发时,我们需要能够使用Core项目作为依赖关系在Eclipse(在Tomcat中)运行/调试它。

  • 当客户项目为构建起来的战争文件包括核心和客户项目。所以这个.war是应用程序的客户特定版本

  • A core web application packaged as a war file (call it Core project).
  • The need to "customize" or "extend" the core app per customer (call it Customer project). This mostly includes new bean definitions (we're using Spring), ie. replacing service implementations in the core.war with customer-specific implementations.
  • We want to develop the Core and Customer projects independently
  • When the Customer project is developed, we need to be able to run/debug it in Eclipse (on Tomcat) with the Core project as a dependency
  • When the Customer project is built, the resulting war file "includes" the core and customer projects. So this .war is the customer-specific version of the application

我正在寻找有关最佳方法的建议在工具和项目配置方面。

I'm looking for suggestions as to the best way to do this in terms of tooling and project configuration.

我们正在使用Ant,但是希望避免被埋在更多的蚂蚁中。有没有人用Maven做过这个?

We're using Ant currently, but would like to avoid getting buried in more ant. Has anyone done this with Maven?

我看过很多关于如何构建一个依赖于java应用程序的Web应用程序的帖子,但是在Web应用程序中没有取决于另一个网络应用程序。

I've seen a lot of posts on how to build a web application that depends on a java application, but nothing on a web application depending on another web app.

谢谢!

推荐答案

有一种本地的WTP方式来做到这一点。它主要使用链接的文件夹和一些小的.settings / org.eclipse.wst.common.component文件。您可以在 http://www.informit .com / articles / article.aspx?p = 759232& seqNum = 3 章节称为将Web模块划分为多个项目。这个问题是链接的文件夹必须相对于某些路径变量。否则链接的文件夹定义(可以在项目根目录中的.project文件中找到)将包含工作站专用路径。路径变量实际上应该是工作空间根。这个解决方案非常适用于WTP,部署和其他一切工作,应该是这样的。

In Eclipse there is a "native" WTP way to do this. It mainly using linked folders and a little hack in .settings/org.eclipse.wst.common.component file. You can read the article about it at http://www.informit.com/articles/article.aspx?p=759232&seqNum=3 the chapter called "Dividing a Web Module into Multiple Projects". The problem with this is that the linked folder must be relative to some path variable can be defined in Window/Preferences/General/Workspace/Linked Resources tab. Otherwise the linked folder definition (can be found in .project file in project root) will contain workstation specific path. The path variable practicly should be the workspace root. This solution works great with WTP, deploy and everything else works like it should.

第二个解决方案是使用蚂蚁。算了吧。你会深感遗憾的。

The second solution is to use ant for it. Forget it. You will deeply regret it.

第三个解决方案是使用maven。如果你不做一些技巧,你可以忘记WTP发布的舒适度。像其他人一样使用战争叠加。确保安装m2eclipse,m2eclipse附件。最近有一个扩展插件可以帮助你。请参阅此博客。我没有尝试,但看起来不错。无论如何,Maven与链接的文件夹无关,所以我认为即使是第一个解决方案,这个maven覆盖可以在必要时一起生活。

The third solution is to use maven for it. You can forget the comfort of WTP publishing if you dont do some tricks. Use war overlays like others suggested. Be sure to install both m2eclipse, m2eclipse extras. There is an extension plugin released recently, that can help you. Described at this blog. I did not try it, but looks ok. Anyway Maven have nothing to do with linked folders, so I think even the first solution and this maven overlay can live together if necessary.

对于无头版本,您可以使用<第一个解决方案的一个href =http://code.google.com/p/headlesseclipse/ =nofollow> HeadlessEclipse 。现在已经死了(我),但仍然工作:)。如果您使用maven覆盖+ eclipse的东西,无头版的构建由maven覆盖。

As for headless builds you can use HeadlessEclipse for the first solution. It is dead (by me) now, but still works :). If you use the maven overlay + eclipse stuff, headless builds are covered by maven.

这篇关于如何使用另一个项目来扩展/定制WAR的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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