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

华为开发者空间,是为全球开发者打造的专属开发空间,汇聚了华为优质开发资源及工具,致力于让每一位开发者拥有一台云主机,基于华为根生态开发、创新。

更多推荐