SpringBoot依赖版本被覆盖

因为开发需求,引入了如下一些包:

1
2
3
4
5
6
7
8
9

<dependencies>
    <dependency>
        <groupId>com.sdstc.starter</groupId>
        <artifactId>elasticjob-spring-boot-starter</artifactId>
        <version>1.0.0</version>
    </dependency>
</dependencies>

结果项目无法正常启动,报如下错误:


***************************
APPLICATION FAILED TO START
***************************
Description:
An attempt was made to call a method that does not exist. The attempt was made from the following location:
com.dangdang.ddframe.job.reg.zookeeper.ZookeeperRegistryCenter.persistEphemeral(ZookeeperRegistryCenter.java:246)
The following method did not exist:
org.apache.curator.framework.api.CreateBuilder.creatingParentsIfNeeded()Lorg/apache/curator/framework/api/ProtectACLCreateModePathAndBytesable;
The method's class, org.apache.curator.framework.api.CreateBuilder, is available from the following locations:
jar:file:/home/usr/updacnce/srm.jar!/BOOT-INF/lib/curator-framework-4.0.1.jar!/org/apache/curator/framework/api/CreateBuilder.class
It was loaded from the following location:
jar:file:/home/usr/updacnce/srm.jar!/BOOT-INF/lib/curator-framework-4.0.1.jar!/
Action:
Correct the classpath of your application so that it contains a single, compatible version of org.apache.curator.framework.api.CreateBuilder

同事提示,项目中存在包冲突,需要加入上下配置。加上配置后,问题确实解决了,但是我认为这不是优雅的解决方案,优雅的方案不是应该升级一下elasticjob-spring-boot-starter么。

 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

<dependencyManagement>
    <dependencies>
        <dependency>
            <groupId>com.dangdang</groupId>
            <artifactId>elastic-job-lite-core</artifactId>
            <version>2.1.5</version>
        </dependency>
        <dependency>
            <groupId>com.dangdang</groupId>
            <artifactId>elastic-job-lite-spring</artifactId>
            <version>2.1.5</version>
        </dependency>
        <dependency>
            <groupId>org.apache.curator</groupId>
            <artifactId>curator-recipes</artifactId>
            <version>2.10.0</version>
        </dependency>
        <dependency>
            <groupId>org.apache.curator</groupId>
            <artifactId>curator-framework</artifactId>
            <version>2.10.0</version>
        </dependency>
        <!-- https://mvnrepository.com/artifact/com.google.guava/guava -->
        <dependency>
            <groupId>com.google.guava</groupId>
            <artifactId>guava</artifactId>
            <version>20.0</version>
        </dependency>
    </dependencies>
</dependencyManagement>