②. EurekaServer集群坏境构建步骤
- ①. 参考cloud-eureka-server7001
cloud-eureka-server7002
- ②. 改pom
<dependencies> <dependency> <groupId>com.atguigu.springcloud</groupId> <artifactId>cloud-api-commons</artifactId> <version>${project.version}</version> </dependency> <!--eureka-server--> <dependency> <groupId>org.springframework.cloud</groupId> <artifactId>spring-cloud-starter-netflix-eureka-server</artifactId> </dependency> <!--自定义api通用包--> <!--<dependency> <groupId>org.xzq.springcloud</groupId> <artifactId>cloud-api-commons</artifactId> <version>${project.version}</version> </dependency>--> <!--boot web acctuator--> <dependency> <groupId>org.springframework.boot</groupId> <artifactId>spring-boot</artifactId> </dependency> <dependency> <groupId>org.springframework.boot</groupId> <artifactId>spring-boot-starter-web</artifactId> </dependency> <dependency> <groupId>org.springframework.boot</groupId> <artifactId>spring-boot-starter-actuator</artifactId> </dependency> <dependency> <groupId>org.springframework.boot</groupId> <artifactId>spring-boot-devtools</artifactId> <scope>runtime</scope> <optional>true</optional> </dependency> </dependencies>
③. 修改映射配置
④. 写YML
server: port: 7002 eureka: instance: #hostname: eureka #eureka服务端实例名称 单机版 hostname: eureka7002.com #eureka服务端实例名称 client: #表示不向注册中心注册自己 register-with-eureka: false #false表示自己就是注册中心,我的职责就是维护服务实例,并不区检索服务 fetch-registry: false service-url: #设置与Eureka server交互的地址查询服务和注册服务都需要依赖这个地址 #defaultZone: http://${eureka.instance.hostname}:${server.port}/eureka/ #单机版 defaultZone: http://eureka7001:7001/eureka/
⑤. 主启动
@SpringBootApplication @EnableEurekaServer public class EurekaMain7002 { public static void main(String[] args) { SpringApplication.run(EurekaMain7002.class,args); } }
⑥. 结果是: