不同的WAR文件,共享资源 [英] different WAR files, shared resources

查看:141
本文介绍了不同的WAR文件,共享资源的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

假设你有几个应用程序共享相同的代码和大多数其他资源,但有一些不同的外观和感觉,一些标签变化等(认为品牌)。如果每个Web应用程序都要进入自己的WAR文件,那么您在哪里放置共享资源?



我已经使用类路径来共享类和属性文件。但是javascript和css文件呢?是最好的方式来创建和部署一个额外的WAR文件,将服务这些共享文件到任何其他应用程序需要他们?



我还想到一个构建脚本,做一些魔术和共同的来源提出了(略)不同的WAR,但是我不喜欢它,因为当您需要构建/测试/运行单个应用程序时,它会使不必要的东西复杂化。



任何其他提示和技巧将不胜感激。

解决方案

我看过的策略用于此类产品类似于配置正在使用WAR 覆盖使用 maven 进行构建。您定义一个常见的WAR,其中包含常见的内容,并将其与包含特定内容的其他WAR重叠,以为每个应用程序生成不同的WAR。如果在不同的机器上部署WAR变体,这种方法可能是最有用的。但是我不知道我是否可以推荐这个。



如果您实际覆盖资料,请记住指定重叠式配置,否则重写顺序不是确定性的。甚至可以通过maven-war-plugin升级来改变。 (我们这样做)。


Suppose you have several applications which share the same code and most of the other resources, but have a somewhat different look and feel, some labels change, etc. (think branding). If each web app is to go in its own WAR file, where do you put the shared resources?

I already use the classpath to share classes and property files. But what about javascript and css files? Is the best way to create and deploy one extra WAR file that will serve these shared files to whatever other application requires them?

I also thought of a build script that does some magic and from a common source spews out the (slightly) different WARs, but I don't like it because it just complicates stuff unnecessarily when you need to build/test/run a single application.

Any other tips and tricks would be appreciated.

解决方案

A strategy that I have seen used for such product-line like configurations is using WAR overlays when building with maven. You define a common WAR that contains the common stuff and overlay it with those other WARs that contain the specific stuff to generate different WARs for every application. This method is probably most useful if you deploy the WAR-variants on different machines. But I'm not sure whether I can actually recommend this.

Remember to specify the overlays configuration if you actually override stuff, since otherwise the overriding order is not deterministic. It might even change with a maven-war-plugin upgrade. (It did in our case.)

这篇关于不同的WAR文件,共享资源的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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