pretty-service-registry、pretty-service-registry-replicas 分别配置端口 10000、10001
application.yml
spring:
application:
name: pretty-service-registry
server:
#服务启动端口
port: 10000
eureka:
client:
registerWithEureka: false
fetchRegistry: false
serviceUrl:
#副本
defaultZone: http://localhost:10001/eureka/
spring:
application:
name: pretty-service-registry-replicas
server:
#服务启动端口
port: 10001
eureka:
client:
registerWithEureka: false
fetchRegistry: false
serviceUrl:
#副本
defaultZone: http://localhost:10000/eureka/
启动类添加@EnableEurekaServer,启用后可以在eureka提供的页面中查看服务注册状态
package com.pretty.service.registry;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.cloud.netflix.eureka.server.EnableEurekaServer;
@EnableEurekaServer
@SpringBootApplication
public class PrettyServiceRegistryApplication {
public static void main(String[] args) {
SpringApplication.run(PrettyServiceRegistryApplication.class, args);
}
}