Maven-Maven排除依赖和可选依赖

推荐先阅读Maven

可选依赖指对外隐藏当前所依赖的资源–不透明

<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<version>4.12</version>
<optional>true</optional>
</dependency>

排除依赖指主动断开依赖的资源,被排除的资源无需指定版本一一不需要

<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<version>4.12</version>
<exclusions>
<exclusion>
<groupId>org.hancrest</groupId>
<artifactId>hamcrest-core</artifactId>
</exclusion>
</exclusions>
</dependency>

Maven排除依赖和可选依赖