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

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

问题描述

假设您有多个应用程序共享相同的代码和大多数其他资源,但有一些不同的外观和感觉,一些标签更改等(认为品牌)。如果每个网络应用程序都在自己的WAR文件中,你把共享资源放在哪里?

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?

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

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?

我也想到了一个构建脚本,魔法和从一个共同的源发出了(略)不同的WAR,但我不喜欢它,因为它只是复杂化的东西不必要的,当你需要构建/测试/运行一个应用程序。

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.

推荐答案

类似配置使用WAR 覆盖当使用 maven 构建时。你定义一个公共WAR包含常见的东西,并覆盖它与包含特定的东西,为每个应用程序生成不同的WAR的其他WAR。如果在不同的计算机上部署WAR变量,这种方法可能是最有用的。

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.

如果你实际覆盖了东西,请记住指定覆盖层配置,否则覆盖顺序不是确定性的。它甚至可能改变与maven战争插件升级。 (在我们的情况下。)

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天全站免登陆