自己启动Eureka server时,如果发现依赖正确引入了,但是@EnableEurekaServer注解不可用,那可能是SpringCloud版本不对,可尝试修改下版本即可:
<dependency>
<groupId>org.springframework.cloud</groupId>
<artifactId>spring-cloud-starter-eureka-server</artifactId>
</dependency>
<dependencyManagement>
<dependencies>
<dependency>
<groupId>org.springframework.cloud</groupId>
<artifactId>spring-cloud-dependencies</artifactId>
<!--<version>Finchley.RC1</version>-->
<version>Edgware.SR4</version>
<type>pom</type>
<scope>import</scope>
</dependency>
</dependencies>
</dependencyManagement>
Edgware版本基于SpringBoot 1.5x构建,不兼容SpringBoot 2.0x;
Finchley版本基于SpringBoot 2.0x构建,不兼容SpringBoot 1.5x;