maven与同一个jar的两个版本发生战争

bas*_*sin 5 maven-2 war

Maven将axis-1.3.jar和axis-1.4.jar放到我战争的WEB-INF/lib中.有人可以解释如何告诉它只使用axis-1.4.jar吗?

<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
    <parent>
        <groupId>dummy</groupId>
        <artifactId>test-war</artifactId>
        <version>0.1</version>
    </parent>

  <modelVersion>4.0.0</modelVersion>
  <groupId>dummy</groupId>
  <artifactId>war-part2</artifactId>
  <name>war-part1</name>
  <version>0.1</version>
  <packaging>war</packaging>

  <dependencies>
    <dependency>
        <groupId>org.apache.axis</groupId>
        <artifactId>axis</artifactId>
        <version>1.4</version>
    </dependency>
    <dependency>
      <groupId>com.jaspersoft.jasperserver</groupId>
      <artifactId>jasperserver-ireport-plugin</artifactId>
      <version>2.0.1</version>
    </dependency>
  </dependencies>
</project>
Run Code Online (Sandbox Code Playgroud)

[dependency:tree {execution:default-cli}]

+- org.apache.axis:axis:jar:1.4:compile
\- com.jaspersoft.jasperserver:jasperserver-ireport-plugin:jar:2.0.1:compile
   +- javax.activation:activation:jar:1.1:compile
   +- javax.mail:mail:jar:1.4:compile
   +- log4j:log4j:jar:1.2.12:compile
   \- com.jaspersoft.jasperserver:jasperserver-common-ws:jar:2.0.1:compile
      +- xerces:xercesImpl:jar:2.8.1:compile
      |  \- xml-apis:xml-apis:jar:1.3.03:compile
      \- axis:axis:jar:1.3:compile
         +- axis:axis-jaxrpc:jar:1.3:compile
         +- axis:axis-saaj:jar:1.3:compile
         +- wsdl4j:wsdl4j:jar:1.5.1:compile
         +- commons-logging:commons-logging:jar:1.0.4:compile
         \- commons-discovery:commons-discovery:jar:0.2:compile
Run Code Online (Sandbox Code Playgroud)

Maven是2.2.1

Pas*_*ent 8

从理论上讲,Maven应该处理依赖关系或传递依赖关系中存在的工件版本的收敛.这里的问题是,axis-1.4.jar并且axis-1.3.jar 不具有相同的groupId(org.apache.axisvs axis),因此Maven将它们视为不同的工件并将它们包括在内.

如果您不想axis-1.3.jar只获取axis-1.4.jar,则必须jasperserver-ireport-plugin使用以下方法明确地从依赖项中排除不需要的内容exclusion:

<dependency>
  <groupId>com.jaspersoft.jasperserver</groupId>
  <artifactId>jasperserver-ireport-plugin</artifactId>
  <version>2.0.1</version>
  <exclusions>
    <exclusion>
      <groupId>axis</groupId>
      <artifactId>axis</artifactId>
    </exclusion>
  </exclusions>
</dependency>
Run Code Online (Sandbox Code Playgroud)

不能说是否jasperserver-ireport-plugin会合作axis-1.4.jar.


Pet*_*ans 6

您可以在依赖项中排除某些依赖库:

<dependency>
  <groupId>com.jaspersoft.jasperserver</groupId>
  <artifactId>jasperserver-ireport-plugin</artifactId>
  <version>2.0.1</version>
  <exclusions>
    <exclusion>
      <groupId>axis</groupId>
      <artifactId>axis</artifactId>
    </exclusion>
  </exclusions>
</dependency>
Run Code Online (Sandbox Code Playgroud)

然后maven会跳过这种依赖.

您必须确定Jasper可以在您提供的库中找到所需的类.