自从我更新到Maven3之后,我在每次构建时都会收到以下警告消息:
我怎样才能摆脱这些警告?
[INFO] Scanning for projects...
[WARNING]
[WARNING] Some problems were encountered while building the effective model for proj:id:jar:3.1
[WARNING] 'build.plugins.plugin.version' for org.apache.maven.plugins:maven-javadoc-plugin is missing. @ line 195, column 15
[WARNING] 'build.plugins.plugin.version' for org.apache.maven.plugins:maven-compiler-plugin is missing. @ line 204, column 15
[WARNING] 'build.plugins.plugin.version' for org.apache.maven.plugins:maven-surefire-plugin is missing. @ line 227, column 15
[WARNING] 'build.plugins.plugin.version' for org.apache.maven.plugins:maven-jar-plugin is missing. @ line 215, column 15
[WARNING] 'reporting.plugins.plugin.version' for org.codehaus.mojo:jdepend-maven-plugin is missing. @ line 271, column 15
[WARNING]
[WARNING] It is highly recommended to fix these problems because they threaten the stability of your build.
[WARNING]
[WARNING] For this reason, future Maven versions might no longer support building such malformed projects.发布于 2011-07-24 08:50:45
在pom.xml文件中的<plugin> <artifactId>后面添加一个<version>元素。查找以下文本:
<plugin>
<artifactId>maven-compiler-plugin</artifactId>将版本标签添加到其中:
<plugin>
<artifactId>maven-compiler-plugin</artifactId>
<version>2.3.2</version>应解决该警告。
关于这一点:
缺少org.apache.maven.plugins:maven-compiler-plugin的
'build.plugins.plugin.version‘
许多人提到了为什么会发生这个问题,但没有提出解决方法。我所需要做的就是进入项目的POM文件,并添加如上所示的<version>标记。
要发现版本号,一种方法是在Maven完成运行后查看它的输出。如果缺少版本号,Maven将显示其默认版本:
[INFO] --- maven-compiler-plugin:2.3.2:compile (default-compile) @ entities ---获取该版本号(与上面的2.3.2相同),并将其添加到您的POM中,如下所示。
发布于 2010-11-08 18:55:32
Maven 3对POM结构有更多的限制。例如,您必须设置插件的版本。
在maven 3.1中,这些警告可能会破坏您的构建。maven2和maven3之间有更多的变化:https://cwiki.apache.org/confluence/display/MAVEN/Maven+3.x+Compatibility+Notes
发布于 2017-04-06 18:28:57
从以下网址获取最新版本信息:
https://mvnrepository.com/artifact/org.apache.maven.plugins/maven-compiler-plugin
点击最新版本(或你想要使用的版本),你会看到依赖信息(截至2019-05是3.8.1):
<!-- https://mvnrepository.com/artifact/org.apache.maven.plugins/maven-compiler-plugin -->
<dependency>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<version>3.8.1</version>
</dependency>您可能希望使用版本标签和注释作为您的插件标签。
<!-- https://mvnrepository.com/artifact/org.apache.maven.plugins/maven-compiler-plugin -->
<plugin>
<artifactId>maven-compiler-plugin</artifactId>
<version>3.8.1</version>
<configuration>
<source />
<target />
</configuration>
</plugin>如果您愿意,您可以修改您的pom,使其在属性标签中包含版本信息,如另一个答案中所述。
https://stackoverflow.com/questions/4123044
复制相似问题