Warning: file_get_contents(/data/phpspider/zhask/data//catemap/6/eclipse/8.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Java Maven:在排除嵌套依赖项时出现问题_Java_Eclipse_Maven_Intellij Idea - Fatal编程技术网

Java Maven:在排除嵌套依赖项时出现问题

Java Maven:在排除嵌套依赖项时出现问题,java,eclipse,maven,intellij-idea,Java,Eclipse,Maven,Intellij Idea,我有一个项目A,它依赖于项目B,它进一步依赖于项目C,它进一步依赖于项目D A->B->C->D 第一个项目B是使用maven shade插件构建的, 所以bjar对C和D都有依赖性 现在,当我在A中包含项目B时,A已经对D有了不同版本的依赖关系。 当我被排除在外的时候 我把D排除在项目B之外,但什么也没发生 在项目A pom.xml中: <dependencies> <dependency> <groupId>sample.Project

我有一个项目A,它依赖于项目B,它进一步依赖于项目C,它进一步依赖于项目D A->B->C->D

第一个项目B是使用maven shade插件构建的, 所以bjar对C和D都有依赖性

现在,当我在A中包含项目B时,A已经对D有了不同版本的依赖关系。 当我被排除在外的时候 我把D排除在项目B之外,但什么也没发生

在项目A pom.xml中:

<dependencies>
    <dependency>
      <groupId>sample.ProjectB</groupId>
      <artifactId>Project-B</artifactId>
      <version>1.0-SNAPSHOT</version>
      <exclusions>
        <exclusion>
          <groupId>sample.ProjectD</groupId> <!-- Exclude Project-D from Project-B -->
          <artifactId>Project-D</artifactId>
        </exclusion>
      </exclusions>
    </dependency>
  </dependencies>



 mvn dependecy:tree doesnt show that it has C in its path or D in its path after exclude. 
    But within scala class, I am able to use classes from package D. 

    When I open the Jar of B, I can see C and D as classPaths in B. Is it anything to do be maven-shade ?

示例项目B
B项目
1.0-快照
示例项目d
项目D
mvn dependecy:树在排除后不显示其路径中有C或路径中有D。
但是在scala类中,我可以使用包D中的类。
当我打开B的Jar时,我可以看到C和D是B中的类路径。使用maven shade做什么?
我的Maven Pom带有构建标记:

<build>
    <finalName>dp-experiment</finalName>
    <plugins>
        <plugin>
            <groupId>org.scala-tools</groupId>
            <artifactId>maven-scala-plugin</artifactId>
            <version>2.15.0</version>
            <executions>
                <execution>
                    <goals>
                        <goal>compile</goal>
                        <goal>testCompile</goal>
                    </goals>
                    <configuration>
                        <args>
                            <arg>-make:transitive</arg>
                            <arg>-dependencyfile</arg>
                            <arg>${project.build.directory}/.scala_dependencies</arg>
                        </args>
                    </configuration>
                </execution>
            </executions>
        </plugin>
        <plugin>
            <groupId>org.apache.maven.plugins</groupId>
            <artifactId>maven-jar-plugin</artifactId>
            <configuration>
                <outputDirectory>${basedir}/target</outputDirectory>
            </configuration>
        </plugin>
        <plugin>
            <groupId>org.apache.maven.plugins</groupId>
            <artifactId>maven-shade-plugin</artifactId>
            <configuration>
                <filters>
                    <filter>
                        <artifact>*:*</artifact>
                        <excludes>
                            <exclude>META-INF/*.SF</exclude>
                            <exclude>META-INF/*.DSA</exclude>
                            <exclude>META-INF/*.RSA</exclude>
                        </excludes>
                    </filter>
                </filters>
                <createDependencyReducedPom>false</createDependencyReducedPom>
                <keepDependenciesWithProvidedScope>true</keepDependenciesWithProvidedScope>
            </configuration>
            <executions>
                <execution>
                    <phase>package</phase>
                    <goals>
                        <goal>shade</goal>
                    </goals>
                </execution>
            </executions>
        </plugin>
        <plugin>
            <groupId>org.apache.maven.plugins</groupId>
            <artifactId>maven-surefire-plugin</artifactId>
            <version>2.7</version>
            <configuration>
                <skipTests>false</skipTests>
            </configuration>
        </plugin>
    </plugins>

</build>

dp试验
org.scala-tools
maven scala插件
2.15.0
编译
测试编译
-make:及物的
-从属文件
${project.build.directory}/.scala\u依赖项
org.apache.maven.plugins
maven jar插件
${basedir}/目标
org.apache.maven.plugins
maven阴影插件
*:*
META-INF/*.SF
META-INF/*.DSA
META-INF/*.RSA
假的
真的
包裹
阴凉处
org.apache.maven.plugins
maven surefire插件
2.7
假的
在pom项目中我能做什么? 从B中排除C的jar

什么是我不能做的?
排除C中任何依赖项的jar或B中依赖项的内部依赖项。

是否所有4个项目都包含此版本?1.0-Snapshot你是说C和D应该是1.0版?不,他们不是。C是1.2版,D是C中的1.0版。B和A在pom.xml中有相同的D版本号?不,我希望A有不同的D版本。这就是为什么我想从B中排除。我希望A有D的1.1快照。我创建了一个新项目来检查问题。在A中有一个依赖项,即B与C和D的两个排除项。然后我创建了一个类,并尝试使用一个D类。我可以使用它。这意味着D不被排除在外。