且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

如何让 Maven 将战争常见的所有罐子放在同一个 EAR 到 EAR 根目录中?

更新时间:2023-09-29 22:33:16

新建一个名为 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.