当前位置: 首页 > 工具软件 > of-admin > 使用案例 >

spring-boot-admin-starter-client与spring-boot版本不匹配的坑

邹星火
2023-12-01

在项目添加了spring-boot-admin-starter-client包后,打包成功,运行时bug.

 

***************************
 APPLICATION FAILED TO START
 ***************************
 
 Description:
 
 An attempt was made to call the method org.springframework.boot.web.client.RestTemplateBuilder.setConnectTimeout(Ljava/time/Duration;)Lorg/springframework/boot/web/client/RestTemplateBuilder; but it does not exist. Its class, org.springframework.boot.web.client.RestTemplateBuilder, is available from the following locations:
 
     jar:file:/home/cs-1.1.1.jar!/BOOT-INF/lib/spring-boot-2.2.1.RELEASE.jar!/org/springframework/boot/web/client/RestTemplateBuilder.class
 
 It was loaded from the following location:
 
     jar:file:/home/cs-1.1.1.jar!/BOOT-INF/lib/spring-boot-2.2.1.RELEASE.jar!/
 
 
 Action:
 
 Correct the classpath of your application so that it contains a single, compatible version of org.springframework.boot.web.client.RestTemplateBuilder

 

 

重点在最后,compatible version of org.springframework.boot.web.client.RestTemplateBuilder,不同的包中包括了不同的RestTemplateBuilder.

查询结果,发现

<dependency>
    <groupId>de.codecentric</groupId>
    <artifactId>spring-boot-admin-starter-client</artifactId>
</dependency>

<parent>
   <groupId>org.springframework.boot</groupId>
   <artifactId>spring-boot-starter-parent</artifactId>
   <relativePath/>
</parent>

版本不同造成,添加相同版本。运行成功。

 类似资料: