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

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

GitHub 加速计划 / sp / spring-boot
73.97 K
40.4 K
下载
spring-projects/spring-boot: 是一个用于简化Spring应用开发的框架。适合用于需要快速开发企业级Java应用的项目。特点是可以提供自动配置、独立运行和内置的Tomcat服务器,简化Spring应用的构建和部署。
最近提交(Master分支:2 个月前 )
fdf24c6c Closes gh-42976 12 天前
3c42ba8c * pr/42974: Fix copyright year of updated file Polish Closes gh-42974 12 天前
Logo

旨在为数千万中国开发者提供一个无缝且高效的云端环境,以支持学习、使用和贡献开源项目。

更多推荐