Maven 架构 jar 灰色毒奶瓶解决之道SSS

由于不同工具不同版本,内部封装的环境不同。在使Maven仓库,引入jar是会出现偏差。但这个问题网上都没有明确答案,我在思索和人讨论之后得出的结论是: scope域的偏差
以此为例:

	<dependency>
	    <groupId>junit</groupId>
	    <artifactId>junit</artifactId>
	    <version>4.12</version>
	    <scope>test</scope>
	</dependency>

在eclipse4.9.exe中 pom.xml引用时会发生灰色毒奶瓶.无法正常使用架包.
需要改变Maven中的scope域,既引用架包引用的使用范围.
(已提供范围) provided 优先选择1
(编译范围) compile 优先选择2
(运行时范围) runtime
(系统范围) system
(测试范围) test
在eclipse4.9.exe 改为:

	<dependency>
	    <groupId>junit</groupId>
	    <artifactId>junit</artifactId>
	    <version>4.12</version>
	    <scope>provided</scope>
	</dependency>

也可以去掉 整个 provided,
再在右键项目–Maven–Update Project–OK
在这里插入图片描述
但eclipse4.6的话就用:

	<dependency>
	    <groupId>junit</groupId>
	    <artifactId>junit</artifactId>
	    <version>4.12</version>
	    <scope>test</scope>
	</dependency>
	以此类推,相信聪明的大家了解之后就能活学活用。

猜你喜欢

转载自blog.csdn.net/qq_41340765/article/details/84562025