创建简单的Spring boot 项目,并且将该项目加入到注册中心。
创建一个名为System的maven项目。
在pom.xml 中导入eureka-client 包。
<dependencies>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-web</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.cloud</groupId>
<artifactId>spring-cloud-starter-netflix-eureka-client</artifactId>
</dependency>
</dependencies>
将application 中注册 Eureka
@SpringBootApplication
@EnableEurekaClient
public class SystemApplication {
}
在application.yaml中设置端口以及名称 ,及默认注册中心地址
spring:
application:
name: System
server:
port: 9001
eureka:
client:
service-url:
defaultZone: http://localhost:8761/eureka/