在项目添加了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>

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

Logo

为开发者提供学习成长、分享交流、生态实践、资源工具等服务,帮助开发者快速成长。

更多推荐