搭建单例Eureka Server服务注册中心
服务信息
服务注册中心:cloud-eureka-server (8761)服务提供者:service-resume (8080)服务消费者:server-autodeliver (8090)
搭建步骤
- cloud-parent父工程引入Spring Cloud依赖
```xml
org.springframework.cloud spring-cloud-dependencies Greenwich.RELEASE pom import
2. **cloud-eureka-server子工程**- pom文件引入相关依赖```xml<dependencies><!--Eureka server依赖--><dependency><groupId>org.springframework.cloud</groupId><artifactId>spring-cloud-starter-netflix-eurekaserver</artifactId></dependency></dependencies>
application.yml配置文件
#Eureka server服务端⼝server:port: 8761spring:application:name: cloud-eureka-server # 应⽤名称,会在Eureka中作为服务的id标识(serviceId)eureka:instance:hostname: localhostclient:service-url: # 客户端与EurekaServer交互的地址,如果是集群,也需要写其它Server的地址defaultZone: http://${eureka.instance.hostname}:${server.port}/eureka/register-with-eureka: false # ⾃⼰就是服务不需要注册⾃⼰fetch-registry: false #⾃⼰就是服务不需要从Eureka Server获取服务信息,默认为true,置为false
启动类声明项目为Eureka Server
@SpringBootApplication@EnableEurekaServer // 声明本项⽬是⼀个Eureka服务public class LagouCloudEurekaServerApplication {public static void main(String[] args) {SpringApplication.run(LagouCloudEurekaServerApplication.class,args);}}
执行启动类,访问 http://localhost:8761, 进入Eureka注册中心后台,EurekaServer发布成功

