概述
常见排除依赖自身依赖的jar,实现jar一致性的方式如下
<dependency>
<groupId>ru.yandex.qatools.ashot</groupId>
<artifactId>ashot</artifactId>
<version>1.5.2</version>
<exclusions>
<exclusion>
<groupId>org.seleniumhq.selenium</groupId>
<artifactId>selenium-remote-driver</artifactId>
</exclusion>
</exclusions>
</dependency>
排除指定类使用maven-shade-plugin 这个插件,如下排除elastic-job下的几个类,这种方式可以更好的保持依赖包升级的兼容性。
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-shade-plugin</artifactId>
<version>2.3</version>
<executions>
<execution>
<phase>package</phase>
<goals>
<goal>shade</goal>
</goals>
<configuration>
<filters>
<filter>
<artifact>com.dangdang:elastic-job-lite-core</artifact>
<!-- <includes> -->
<!-- <include>junit/framework/**</include> -->
<!-- <include>org/junit/**</include> -->
<!-- </includes> -->
<excludes>
<exclude>com/dangdang/ddframe/job/lite/api/JobScheduler</exclude>
<exclude>com/dangdang/ddframe/job/lite/internal/schedule/SchedulerFacade</exclude>
<exclude>com/dangdang/ddframe/job/lite/config/LiteJobConfiguration</exclude>
<exclude>com/dangdang/ddframe/job/lite/internal/config/LiteJobConfigurationGsonFactory</exclude>
<!-- <exclude>org/junit/runners/**</exclude> -->
</excludes>
</filter>
<filter>
<artifact>com.dangdang:elastic-job-lite-lifecycle</artifact>
<!-- <includes> -->
<!-- <include>junit/framework/**</include> -->
<!-- <include>org/junit/**</include> -->
<!-- </includes> -->
<excludes>
<exclude>com/dangdang/ddframe/job/lite/lifecycle/domain/JobSettings</exclude>
<exclude>com/dangdang/ddframe/job/lite/lifecycle/internal/settings/JobSettingsAPIImpl</exclude>
<!-- <exclude>org/junit/runners/**</exclude> -->
</excludes>
</filter>
<!-- <filter> -->
<!-- <artifact>*:*</artifact> -->
<!-- <excludes> -->
<!-- <exclude>META-INF/*.SF</exclude> -->
<!-- <exclude>META-INF/*.DSA</exclude> -->
<!-- <exclude>META-INF/*.RSA</exclude> -->
<!-- </excludes> -->
<!-- </filter> -->
</filters>
</configuration>
</execution>
</executions>
</plugin>
最后
以上就是昏睡白开水为你收集整理的maven dependency 排除依赖jar或者指定类的全部内容,希望文章能够帮你解决maven dependency 排除依赖jar或者指定类所遇到的程序开发问题。
如果觉得靠谱客网站的内容还不错,欢迎将靠谱客网站推荐给程序员好友。
本图文内容来源于网友提供,作为学习参考使用,或来自网络收集整理,版权属于原作者所有。
发表评论 取消回复