java - 是否有必要在 pom 中指定 maven 插件的版本?

标签 java maven netbeans

我正在使用 NetBeans 进行开发,它具有内置菜单功能,允许我们添加 maven-checkstyle-plugin在 pom 中进行代码格式化。但是,当您单击该菜单时,它会自动在 pom 中添加以下代码,但没有 <version>信息。现在我的 IDE 一直在提示,在页边空白处有一条小提示消息说“版本”标签丢失了。我的问题是: 是否所有添加的插件都必须有 <version> pom 中的标签?

pom.xml

 <reporting>
        <plugins>
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-checkstyle-plugin</artifactId>
                <configuration>
                    <configLocation>config/sun_checks.xml</configLocation>
                </configuration>
            </plugin>
        </plugins>
    </reporting>

最佳答案

这不是必须的,但强烈建议使用版本标签。

When a plugin was invoked without an explicit version given in the POM or on the command line, Maven 2.x used to pick the latest version available where the latest version could either be a release or a snapshot. For the sake of stability, Maven 3.x prefers the latest release version over the latest snapshot version.

Given the threat of non-reproducible builds imposed by automatic plugin version resolution, this feature is scheduled for removal as far as plugin declarations in the POM are concerned. Users of Maven 3.x will find it output a warning when missing plugin versions are detected to encourage the addition of plugin versions to the POM or one of its parent POMs. The Enforcer rule requirePluginVersions can be used additionally check for missing plugin versions in the POM.

https://cwiki.apache.org/confluence/display/MAVEN/Maven+3.x+Compatibility+Notes

关于java - 是否有必要在 pom 中指定 maven 插件的版本?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/22621252/

相关文章:

java - 托管 Web 服务(Netbeans)

java - 使用字符串生成器时出现错误 "String index out of range: 0"

java - 如何识别字符串是否包含无法使用 utf8-mb4 字符集存储的特殊字符

java - Maven 在构建 jar 时损坏 src/main/resources 中的二进制文件

maven - 如何将 JSR-269 处理器的依赖项传递给 maven-compiler-plugin

java - Netbeans 8.0.2安装 native 库错误

netbeans - 如何设置对包含多个 jar 文件的文件夹的引用?

java - 在应用程序服务器的生产中使用 Google Guice 的正确阶段是什么?

java - LibGDX BitmapFont 不会停止摇晃

java - Maven 依赖解析(冲突)