如何让 Maven 将战争常见的所有罐子放在同一个 EAR 到 EAR 根目录中? [英] How to make maven place all jars common to wars inside the same EAR to EAR root?

查看:10
本文介绍了如何让 Maven 将战争常见的所有罐子放在同一个 EAR 到 EAR 根目录中?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我们有无数次战争的解决方案.战争在它们都使用hibernate和spring的意义上是相似的.这意味着我们在每场战争中都有许多相同的罐子.这已经成为一个问题,因为耳朵的大小开始变得不成比例.

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.

我想使用 Maven 来计算依赖关系,并将多个战争共有的所有 jar 放到 EAR 的根目录中.

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

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

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?

推荐答案

新建一个名为 commons-jars 的工件并将其打包为 pom.jar它应该取决于您使用的所有常见 jar - Spring、Hibernate、Log4j 等.

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.

然后,在您的每次战争中将其添加为具有已提供"范围的依赖项(并且不要忘记将类型设置为 pom).您将能够在您的类路径中看到它,但它们不会被打包到战争中.这样,您还可以将特定于战争的依赖项打包到其中,解决方案来自 瘦身战不提供.

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