【问题标题】:Maven Shade Plugin not found in pom在 pom 中找不到 Maven Shade 插件
【发布时间】:2021-01-28 20:23:51
【问题描述】:

我正在尝试将 ma​​ven-shade-plugin 添加到我的 pom 中,但每次我将其与配置一起放入 pluginManagement 时,其他插件都找不到它重新加载 pom 后我的插件。
在添加了没有外部配置的插件之后,在pluginManagement 之后它可以工作,但我得到另一个错误。现在找不到外部插件!

这是我的 POM 的一个小 sn-p:

<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-shade-plugin 的整个插件部分移到 pluginManagement 之外...

标签: java maven pom.xml


【解决方案1】:

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

【讨论】:

    猜你喜欢
    • 2021-12-13
    • 1970-01-01
    • 2019-02-03
    • 2012-05-15
    • 2018-08-19
    • 1970-01-01
    • 2014-07-23
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多