【问题标题】:How to exclude a package from a jar (with maven)如何从 jar 中排除包(使用 maven)
【发布时间】:2016-02-16 20:44:15
【问题描述】:

我想从我的项目中排除 geronimo-javamail_1.4_spec jar,我正在使用 maven 构建项目,我看到了 this 文章,我将 exclusion 部分添加到了我的 pom.xml 但不知何故在我构建了我的项目我在我的 war 文件的 WEB-INF\lib 中看到了 geronimo-javamail_1.4_spec-1.7.1.jar

请告诉我如何从我的 .war 中排除这个 jar。

【问题讨论】:

  • 如果它被声明为直接依赖,那么你应该使用<scope>provided</scope>。如果没有 - 那么你应该尝试mvn dependency:tree,并找到所有添加它的地方。
  • 我用mvn dependency:tree找到了这些地方,我现在该怎么办?
  • @Shahe "我现在该怎么办?"好像是the post you've cited。 “因此,您的解决方案是明确添加核心 jar 并排除您的依赖项。”到你所有的依赖

标签: java maven jar build geronimo


【解决方案1】:
<dependency>
    <groupId>org.apache.geronimo.specs</groupId>
    <artifactId>geronimo-javamail_1.4_spec</artifactId>
    <version>1.4</version>
     <scope>provided</scope>
</dependency>


This way the maven will add them to the compilation classpath, but will not package them

【讨论】:

  • &lt;scope&gt;provided&lt;/scope&gt; 为我完成了这项工作。谢谢
猜你喜欢
  • 2012-04-02
  • 2016-05-16
  • 1970-01-01
  • 1970-01-01
  • 2014-11-22
  • 2011-01-27
  • 2015-02-19
  • 2017-07-11
  • 2016-01-02
相关资源
最近更新 更多