创建cloud-consumer-order80模块
pom文件添加依赖
<dependencies>
<!-- 引入Eureka client依赖 -->
<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-web</artifactId>
</dependency>
<dependency>
<groupId>org.projectlombok</groupId>
<artifactId>lombok</artifactId>
<version>1.18.22</version>
</dependency>
</dependencies>
写yml文件
eureka:
client:
# Eureka Server地址
service-url:
defaultZone: http://localhost:7001/eureka
spring:
application:
# 设置应用名字
name: cloud-order-consumer
server:
port: 80
编写主启动类
/**
* 主启动类
*/
@SpringBootApplication
@EnableEurekaClient
@Slf4j
public class OrderMain80 {
public static void main(String[] args) {
SpringApplication.run(OrderMain80.class,args);
log.info("*************** 订单服务消费者启动成功 ***********");
}
}
测试
先启动EurekaServer服务,访问http://locahost:7001