【问题标题】:How to remove .jar file from a war that is overlaid by maven dependency如何从被 maven 依赖项覆盖的战争中删除 .jar 文件
【发布时间】:2012-06-17 15:43:29
【问题描述】:

我有一个 maven3 webapp (war) 项目,它有 2 个依赖项。一个是 jar (ehcache),另一个是战争依赖项(我无法控制的第 3 方库)。

第 3 方战争依赖项依赖于更早版本的 ehcache,这与我需要使用的更高版本发生冲突。

以下步骤在我的应用打包期间发生。

  1. 我的 ehcache jar 被复制到 /WEB-INF/lib/
  2. 包含 ehcache 的 .war 依赖项已构建并覆盖在我的目标之上
  3. 最终的 .war 文件是从目标创建的

无论我做什么,战争总是包括早期版本的ehcache。我什至尝试编写一个我通过 maven-antrun-plugin 执行的 ant 脚本,该脚本从目标目录中删除 .jar 文件。但是,这总是在覆盖 .war 依赖项之前完成。

有谁知道我可以如何排除/删除早期版本的 ehcache?

【问题讨论】:

  • 你对战争有依赖?你有一个多模块构建吗?

标签: maven war ehcache dependency-management


【解决方案1】:

您可能需要按文件名从覆盖中排除 ehcache jar。如果你还没有为你的依赖战争声明一个明确的覆盖,你也必须在战争插件配置中这样做:

<build>
  <plugins>
    <plugin>
      <groupId>org.apache.maven.plugins</groupId>
      <artifactId>maven-war-plugin</artifactId>
      <version>2.2</version>
      <configuration>
        <overlays>
          <overlay>
            <groupId>your.thirdparty.war.groupId</groupId>
            <artifactId>your.thirdparty.war.artifactId</artifactId>
            <excludes>
              <exclude>WEB-INF/lib/ehcache*.jar</exclude>
            </excludes>
          </overlay>
        </overlays>
      </configuration>
    </plugin>
  </plugins>
</build>

【讨论】:

  • 谢谢,这正是我所需要的。
【解决方案2】:
猜你喜欢
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2015-03-07
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
相关资源
最近更新 更多