@EnableEurekaServer 注解无法引入问题
大致有两个原因:
这个注解一般用在注册中心, 只要引入以下依赖即可:
<properties>
<spring-cloud.version>Finchley.RELEASE</spring-cloud.version>
</properties>
<dependencies>
<dependency>
<groupId>org.springframework.cloud</groupId>
<artifactId>spring-cloud-dependencies</artifactId>
<version>${spring-cloud.version}</version>
<type>pom</type>
<scope>import</scope>
</dependency>
<dependency>
<groupId>org.springframework.cloud</groupId>
<artifactId>spring-cloud-starter-netflix-eureka-server</artifactId>
</dependency>
</dependencies>
上一步引入 eureka 启动依赖后, 还有可能会出现代码中 @EnableEurekaServer 注解无法引入的问题, Spring Cloud 版本和 Spring Boot 版本不一致会导致这个问题, 值得注意的是, Spring Cloud 代号的不同后缀也会出现版本不一致. 版本对应关系很重要, 因为版本不对应会出现很多意想不到的问题, 所有要准守这个规则, 不然会走很多弯路. 具体的版本对应可以到这里查: https://spring.io/projects/spring-cloud
Spring Cloud | Boot Boot |
---|---|
Angle版本 | 兼容 Spring Boot 1.2.x |
Brixton 版本 | 兼容 Spring Boot 1.3.x, 也兼容Spring Boot 1.4.x |
Camden 版本 | 兼容 Spring Boot 1.4.x, 也兼容Spring Boot 1.5.x |
Dalston 版本、Edgware 版本 | 兼容 Spring Boot 1.5.x, 不兼容Spring Boot 2.0.x |
Finchley 版本 | 兼容 Spring Boot 2.0.x, 不兼容Spring Boot 1.5.x |
Greenwich 版本 | 兼容 Spring Boot 2.1.x |
Spring Cloud | Boot Boot |
---|---|
Dalston.RC1 | 1.5.2.RELEASE |
Edgware.RELEASE | 1.5.9.RELEASE |
Finchley.BUILD-SNAPSHOT | 2.0.2.RELEASE |
版本后缀 | 说明 | |
---|---|---|
BUILD-XXX | 开发版 | 开发团队内部使用,不是很稳定 |
GA | 稳定版 | 相比于开发版,基本上可以使用了 |
PRE(M1、M2) | 里程碑版 | 主要是修复了一些BUG的版本,一个GA后通常有多个里程碑版 |
RC | 候选发布版 | 该阶段的软件类似于最终版的一个发行观察期,基本只修复比较严重的BUG |
SR | 正式发布版 | 正式发行版本 |
扫码关注腾讯云开发者
领取腾讯云代金券
Copyright © 2013 - 2025 Tencent Cloud. All Rights Reserved. 腾讯云 版权所有
深圳市腾讯计算机系统有限公司 ICP备案/许可证号:粤B2-20090059 深公网安备号 44030502008569
腾讯云计算(北京)有限责任公司 京ICP证150476号 | 京ICP备11018762号 | 京公网安备号11010802020287
Copyright © 2013 - 2025 Tencent Cloud.
All Rights Reserved. 腾讯云 版权所有