我是靠谱客的博主 昏睡白开水,这篇文章主要介绍maven dependency 排除依赖jar或者指定类,现在分享给大家,希望可以做个参考。

常见排除依赖自身依赖的jar,实现jar一致性的方式如下

复制代码
1
2
3
4
5
6
7
8
9
10
11
12
<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下的几个类,这种方式可以更好的保持依赖包升级的兼容性。

复制代码
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
<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内容请搜索靠谱客的其他文章。

本图文内容来源于网友提供,作为学习参考使用,或来自网络收集整理,版权属于原作者所有。
点赞(71)

评论列表共有 0 条评论

立即
投稿
返回
顶部