1、在篇一基础上。
1、在parent下创建工程eureka-clinet工程
主要依赖
<dependencies>
<dependency>
<groupId>org.springframework.cloud</groupId>
<artifactId>spring-cloud-starter</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.cloud</groupId>
<artifactId>spring-cloud-starter-netflix-eureka-client</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-test</artifactId>
<scope>test</scope>
</dependency>
</dependencies>
2、配置yml文件
server:
port: 8861
spring:
application:
name: eureka-client
eureka:
client:
service-url:
defaultZone: http://peer1:8761/eureka/ 这里填写 篇一的地址
3、在启动类添加提供者注解
@SpringBootApplication
@EnableEurekaClient
public class EurekaClientApplication {
public static void main(String[] args) {
SpringApplication.run(EurekaClientApplication.class, args);
}
}
4、先启动注册中心,在启动提供者。访问peer1:8761即可看到
下一篇写分布式搭建注册中心。 不懂随时可以联系我