Maven 3需要知道插件版本

在Maven 2中,如果未为pom.xml中使用的每个插件指定版本,它将自动选择最新的插件版本,这非常方便。 但是,在Maven 3中,如果您未明确指定插件版本,它将提示您警告消息。 阅读此“ Maven 3兼容性 ”以获取详细信息。

例如,在Maven 2中,通常,我们使用“ maven-compiler-plugin ”插件而不指定版本,并且该插件100%有效。

//...pom.xml in Maven 2
	<build>
		<finalName>SpringMVC</finalName>
		<plugins>
			<plugin>
				<artifactId>maven-compiler-plugin</artifactId>
				<configuration>
					<source>1.6</source>
					<target>1.6</target>
				</configuration>
			</plugin>
		</plugins>
	</build>
//...

但是,在Maven 3中,以上声明将提示您以下“ WARNING ”消息:

[INFO] Scanning for projects...
[WARNING] Some problems were encountered while building the effective model 
          for com.mkyong.common:SpringMVC:war:1.0-SNAPSHOT
[WARNING] 'build.plugins.plugin.version' for org.apache.maven.plugins:maven-compiler-plugin 
          is missing. @ line 55, column 12
[WARNING] It is highly recommended to fix these problems because they threaten 
          the stability of your build.
[WARNING] For this reason, future Maven versions might no longer support 
          building such malformed projects.

要修复它,只需指定如下插件版本:

//...pom.xml in Maven 3
	<build>
		<finalName>SpringMVC</finalName>
		<plugins>
			<plugin>
				<artifactId>maven-compiler-plugin</artifactId>
				<version>2.3.2</version>
				<configuration>
					<source>1.6</source>
					<target>1.6</target>
				</configuration>
			</plugin>
		</plugins>
	</build>

如何知道Maven的插件版本是什么?
您可以尝试在http://search.maven.org/上搜索插件,或访问插件网站,例如– Maven编译器插件官方网站

参考文献

  1. Maven 3兼容性
  2. Maven编译器插件

翻译自: https://mkyong.com/maven/maven-3-need-to-know-the-plugin-version/

  • 1
    点赞
  • 2
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值