Spring Boot 2.0.0.RELEASE环境下无法启动简单Spring Boot Admin Server
解决Spring Boot 2.0.0.RELEASE下Spring Boot Admin Server无法运行的问题
我之前也踩过这个坑,你当前的pom配置里只引入了基础的web starter,但缺少Spring Boot Admin Server的核心依赖,这就是服务启动不了的关键原因。咱们来一步步调整配置:
1. 补充Spring Boot Admin Server依赖
更新你的pom.xml,添加spring-boot-admin-starter-server依赖,注意要选择和Spring Boot 2.0.x兼容的版本(这里用2.0.6,和2.0.0.RELEASE匹配度很好):
<parent> <groupId>org.springframework.boot</groupId> <artifactId>spring-boot-starter-parent</artifactId> <version>2.0.0.RELEASE</version> <relativePath /> <!-- lookup parent from repository --> </parent> <dependencies> <dependency> <groupId>org.springframework.boot</groupId> <artifactId>spring-boot-starter-web</artifactId> </dependency> <!-- 添加Spring Boot Admin Server核心依赖 --> <dependency> <groupId>de.codecentric</groupId> <artifactId>spring-boot-admin-starter-server</artifactId> <version>2.0.6</version> </dependency> </dependencies>
2. 给启动类添加Admin Server注解
你的启动类必须加上@EnableAdminServer注解,才能让Spring Boot识别这是一个Admin Server服务:
import org.springframework.boot.SpringApplication; import org.springframework.boot.autoconfigure.SpringBootApplication; import de.codecentric.boot.admin.server.config.EnableAdminServer; @SpringBootApplication @EnableAdminServer // 必须添加这个注解 public class AdminServerApplication { public static void main(String[] args) { SpringApplication.run(AdminServerApplication.class, args); } }
3. 版本兼容性提醒
一定要注意版本匹配:Spring Boot 2.0.x系列只能搭配Spring Boot Admin 2.0.x版本,如果误用了2.1及以上版本,会出现依赖冲突、启动失败的情况。
完成以上配置后,重新启动服务,访问http://localhost:8080就能看到Spring Boot Admin的控制台界面了。
内容的提问来源于stack exchange,提问作者Jagat
相关产品推荐
相关产品推荐

