1. 先启动注册中心:
a. my-eureka工程下的MyRegistrationCenter类,run as --> java application;
b. 运行URL:http://localhost:1111/ 查看是否启动成功;
成功后页面展示如下:

2. 启动服务
a. my-producer工程下的MyProducerStart类,run as --> java application;
b. 运行URL:http://localhost:2226/add?a=10&b=11 查看是否启动成功;

3. 启动含断路器的服务
a. my-consumer工程下的MyConsumerStart类,run as --> java application;
b. 运行URL:http://localhost:3337/add?a=10&b=11 查看是否启动成功;
c. 关闭my-producer工程提供的服务,二次运行URL:http://localhost:3337/add?a=10&b=11 查看是否走进断路器,正常返回-9999;

4. 启动网关
a. my-api-gateway工程下的MyApiGatewayStart类,run as --> java application;
b. 运行URL:http://localhost:5555/api-a/add?a=10&b=11&accessToken=110 查看是否启动成功;

5.代码见附件
本文详细介绍了基于Eureka注册中心的微服务架构搭建步骤,包括启动注册中心、服务提供者和服务消费者,以及如何通过断路器保护服务调用,并最终启动API网关实现统一入口。

被折叠的 条评论
为什么被折叠?



