如何使maven将所有罐子通向同一EAR内的战争到EAR根? [英] How to make maven place all jars common to wars inside the same EAR to EAR root?

查看:127
本文介绍了如何使maven将所有罐子通向同一EAR内的战争到EAR根?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我们有许多战争的解决方案。在所有使用冬眠和春天这个意义上,战争是相似的。这意味着我们在每次战争中都有相同的罐子。这正在成为一个问题,因为耳朵的大小开始变得不成比例。



我想使用Maven来计算依赖关系并将所有的jar放在一起到多个战争到EAR的根。



我尝试使用j2ee原型(maven-archetype-j2ee-simple)组织我的项目,但是所有的战争仍然包含在WEB-INF / lib中的依赖项。
有没有办法使Maven计算共同的依赖关系并将它们放置到EAR,就像在构建一个战争或一个jar时能够计算所有的过渡依赖项一样?

解决方案

创建一个名为commons-jars的新工件,并将其打包为pom。它应该依赖于你使用的所有常见的jar - Spring,Hibernate,Log4j等。



然后,在你的战争中的每一个添加它作为依赖与范围提供(不要忘了把类型设为pom)。你将能够看到它在你的类路径,但不会被包装在战争。这样,您也可以将包含战争的依赖关系打包到其中,从瘦的战争不提供。


We have a solution with numerous wars. Wars are similar in the sense they all use hibernate and spring. This means that we have a number of same jars inside each war. This is becoming a problem, because the size of the ear is starting to grow out of proportion.

I would like to use Maven to calculate dependencies and to place all jars common to multiple wars to the root of the EAR.

I tried organizing my project using j2ee archetype (maven-archetype-j2ee-simple), but all wars are still packaged with dependencies inside the WEB-INF/lib. Is there a way to make Maven calculate common dependencies and place them to EAR, just as he is able to calculate all transitional dependencies when constructing a war or a jar?

解决方案

Create a new artifact named commons-jars and package it as pom. It should depend on all the common jars you are using - Spring, Hibernate, Log4j, etc.

Then, in each on your wars add it as dependency with scope "provided" (and don't forget to set the type as pom). You will be able to see it in your classpath but they won't be packaged into the war. This way you can also have war specific dependencies packaged into it, which the solution from skinny wars does not provide.

这篇关于如何使maven将所有罐子通向同一EAR内的战争到EAR根?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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