Warning: file_get_contents(/data/phpspider/zhask/data//catemap/4/maven/6.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 使用着色jar作为依赖项在原始项目中导致着色_Java_Maven_Maven Shade Plugin - Fatal编程技术网

Java 使用着色jar作为依赖项在原始项目中导致着色

Java 使用着色jar作为依赖项在原始项目中导致着色,java,maven,maven-shade-plugin,Java,Maven,Maven Shade Plugin,我的项目依赖于另一个项目的着色jar。另一个项目是使用shade插件将包a.b.c中的所有类重新定位到工件a版本1到shade.a.b.c 我的项目也使用这个工件,但是版本2。当我构建我的项目时,我看到项目中a.b.c.d的导入语句(我希望它来自artifact a version 2,并且在artifact a version 1中不存在)已更改为着色。a.b.c.d。我没有在我的原始项目中使用着色,但是我看到dependency jar中的着色插件导致了我的原始项目中的着色 这是预期的行为吗

我的项目依赖于另一个项目的着色jar。另一个项目是使用shade插件将包
a.b.c
中的所有类重新定位到
工件a版本1
shade.a.b.c

我的项目也使用这个
工件,但是版本2
。当我构建我的项目时,我看到项目中
a.b.c.d
的导入语句(我希望它来自
artifact a version 2
,并且在
artifact a version 1
中不存在)已更改为
着色。a.b.c.d
。我没有在我的原始项目中使用着色,但是我看到dependency jar中的着色插件导致了我的原始项目中的着色

这是预期的行为吗?有没有办法阻止这种过渡着色

其他项目的阴影插件:

<plugin>
    <groupId>org.apache.maven.plugins</groupId>
    <artifactId>maven-shade-plugin</artifactId>
    <version>2.3</version>
    <executions>
        <execution>
            <phase>package</phase>
            <goals>
                <goal>shade</goal>
            </goals>
        </execution>
    </executions>
    <configuration>
        <shadedArtifactAttached>false</shadedArtifactAttached>
        <outputDirectory>${project.build.directory}</outputDirectory>
        <createDependencyReducedPom>true</createDependencyReducedPom>
        <promoteTransitiveDependencies>true</promoteTransitiveDependencies>
        <shadeSourcesContent>true</shadeSourcesContent>
        <relocations>
            <relocation>
                <pattern>a.b.c</pattern>
                <shadedPattern>shaded.a.b.c</shadedPattern>
            </relocation>
        </relocations>
    </configuration>
</plugin>

org.apache.maven.plugins
maven阴影插件
2.3
包裹
阴凉处
假的
${project.build.directory}
真的
真的
真的
a、 不列颠哥伦比亚省
a.b.c

结果是
工件A
在项目父pom中也被定义为依赖项(而不是依赖项管理)。“其他项目”是由maven首先构建的,它是着色的
工件A
,这个着色的工件(仍然不知道为什么)随后被该项目之后的所有其他子项目使用

将依赖项移动到父项目中的依赖项管理,并在子项目中定义各自的依赖项,修复了此问题