在pom中找不到Maven Shade插件

问题描述

我试图将 maven-shade-plugin 添加到我的pom中,但是每次我将其配置与其他插件一起放入pluginManagement时,在重新加载pom后在我的插件中找到。
pluginManagement之后也添加了不带配置的插件之后,它可以工作,但出现另一个错误。现在找不到外部插件!

这是我的POM的小片段:

<build>
    <pluginManagement>
        <plugins>

            <!-- other plugins -->

            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-shade-plugin</artifactId>
                <version>3.2.4</version>
                <executions>
                    <execution>
                        <id>first_build</id>
                        <phase>package</phase>
                        <goals>
                            <goal>shade</goal>
                        </goals>
                        <configuration>
                            <transformers>
                                <transformer
                                        implementation="org.apache.maven.plugins.shade.resource.ManifestResourceTransformer">
                                    <Main-Class>classpath.to.class</Main-Class>
                                </transformer>
                            </transformers>
                            <finalName>NameOfCreatedJAR</finalName>
                        </configuration>
                    </execution>
                    <execution>
                        <id>second_build</id>
                        <phase>package</phase>
                        <goals>
                            <goal>shade</goal>
                        </goals>
                        <configuration>
                            <transformers>
                                <transformer
                                        implementation="org.apache.maven.plugins.shade.resource.ManifestResourceTransformer">
                                    <Main-Class>classpath.to.class</Main-Class>
                                </transformer>
                            </transformers>
                            <finalName>NameOfCreatedJAR</finalName>
                        </configuration>
                    </execution>
                </executions>
            </plugin>
        </plugins>
    </pluginManagement>

    <plugins>
        <plugin>
            <groupId>org.apache.maven.plugins</groupId>
            <!-- artifactId can't be found -->
            <artifactId>maven-shade-plugin</artifactId>
        </plugin>
    </plugins>
</build>

如果有人能告诉我我做错了,我将不胜感激!
提前致谢:)

解决方法

我来自中国,我的英语很差...... 我遇到了同样的问题,但现在我已经解决了。我将分享我的解决方案。 问题是maven在我们的repository里找不到插件,所以我们可以在我们的repository中找到这个插件(你可以在你的native repository中搜索插件,找到找不到的版本),然后找到并选择一个现有的要使用的插件。如果不能解决问题可以删除插件重新加载。

相关问答

错误1:Request method ‘DELETE‘ not supported 错误还原:...
错误1:启动docker镜像时报错:Error response from daemon:...
错误1:private field ‘xxx‘ is never assigned 按Alt...
报错如下,通过源不能下载,最后警告pip需升级版本 Requirem...