pom依赖
<dependency>
<groupId>org.springframework.cloud</groupId>
<artifactId>spring-cloud-starter-netflix-eureka-server</artifactId>
</dependency>
application.yml
server:
port: 8761
eureka:
instance:
hostname: localhost
prefer-ip-address: true
client:
register-with-eureka: false
fetch-registry: false
service-url:
defaultZone: http://localhost:8761/eureka/
logging:
config: classpath:logback.xml
启动配置
@EnableEurekaServer
@SpringBootApplication
public class BackendEurekaServerApplication {
public static void main(String[] args) {
SpringApplication.run(BackendEurekaServerApplication.class, args);
}
}
启动效果,访问localhost:8761
client 配置
server:
port: 8201
eureka:
client:
service-url:
defaultZone: http://localhost:8761/eureka/
spring:
application:
name: hello-service
启动入口注解
@EnableDiscoveryClient
Eureka 和 zookeeper 对比:
Eureka 注册慢:
Eureka自我保护: