提供服务端

在provider的8001端口下使用

需要添加一个Eureka的依赖

1
2
3
4
5
6
<!-- https://mvnrepository.com/artifact/org.springframework.cloud/spring-cloud-starter-eureka -->
<dependency>
<groupId>org.springframework.cloud</groupId>
<artifactId>spring-cloud-starter-eureka</artifactId>
<version>1.4.7.RELEASE</version>
</dependency>

在添加一个基本的配置注解就可以使用了

1
@EnableEurekaClient

运行的时候注册中心就会出现一个服务

image-20201023205554597

右边的配置文件可以通过改变application.yaml里面的instance instance-id来实现

左边的属性;

1
2
3
spring:
application:
name: saxon

右边的属性:

1
2
3
4
5
6
eureka:
client:
service-url:
defaultZone: http://localhost:7001/eureka
instance:
instance-id: saxonmo
1
2
3
4
eureka:
client:
service-url:
defaultZone: http://localhost:7001/eureka

要把服务注册到的地方

Eureka的自我保护机制

Eureka自我保护机制

image-20201023211021943