Spring Cloud 服务接入到 Apache ShenYu 网关完整案例
Spring Cloud快速开始本文档演示如何将Spring Cloud服务接入到Apache ShenYu网关。您可以直接在工程下找到本文档的示例代码 。环境准备请参考运维部署的内容选择一种方式启动shenyu-admin。比如通过 本地部署 启动Apache ShenYu后台管理系统。启动网关如果是通过源码的方式直接运行shenyu-bootstrap中的ShenyuBootstrapApplication。启动顺序启动shenyu-admin启动shenyu-bootstrap启动注册中心例如shenyu-examples下的eureka项目配置shenyu-examples-springcloud注册发现shenyu:discovery:enable:truetype:eurekaserverList:${eureka.client.serviceUrl.defaultZone}registerPath:${spring.application.name}props:nacosNameSpace:ShenyuRegisterCenter运行shenyu-examples-springcloud示例项目中我们使用eureka作为Spring Cloud的注册中心。你可以使用本地的eureka也可以使用示例中提供的应用。下载 shenyu-examples-eureka 、shenyu-examples-springcloud .启动eureka服务运行org.apache.shenyu.examples.eureka.EurekaServerApplicationmain方法启动项目。启动spring cloud服务运行org.apache.shenyu.examples.springcloud.ShenyuTestSpringCloudApplicationmain方法启动项目。成功启动会有如下日志2021-02-1014:03:51.301 INFO2860---[main]o.s.s.concurrent.ThreadPoolTaskExecutor:Initializing ExecutorServiceapplicationTaskExecutor2021-02-1014:03:51.669 INFO2860---[pool-1-thread-1]o.d.s.client.common.utils.RegisterUtils:springCloud client register success:{appName:springCloud-test,context:/springcloud,path:/springcloud/order/save,pathDesc:,rpcType:springCloud,ruleName:/springcloud/order/save,enabled:true}2021-02-1014:03:51.676 INFO2860---[pool-1-thread-1]o.d.s.client.common.utils.RegisterUtils:springCloud client register success:{appName:springCloud-test,context:/springcloud,path:/springcloud/order/path/**,pathDesc:,rpcType:springCloud,ruleName:/springcloud/order/path/**,enabled:true}2021-02-1014:03:51.682 INFO2860---[pool-1-thread-1]o.d.s.client.common.utils.RegisterUtils:springCloud client register success:{appName:springCloud-test,context:/springcloud,path:/springcloud/order/findById,pathDesc:,rpcType:springCloud,ruleName:/springcloud/order/findById,enabled:true}2021-02-1014:03:51.688 INFO2860---[pool-1-thread-1]o.d.s.client.common.utils.RegisterUtils:springCloud client register success:{appName:springCloud-test,context:/springcloud,path:/springcloud/order/path/**/name,pathDesc:,rpcType:springCloud,ruleName:/springcloud/order/path/**/name,enabled:true}2021-02-1014:03:51.692 INFO2860---[pool-1-thread-1]o.d.s.client.common.utils.RegisterUtils:springCloud client register success:{appName:springCloud-test,context:/springcloud,path:/springcloud/test/**,pathDesc:,rpcType:springCloud,ruleName:/springcloud/test/**,enabled:true}2021-02-1014:03:52.806 WARN2860---[main]ockingLoadBalancerClientRibbonWarnLogger:You already have RibbonLoadBalancerClient on your classpath. It will be used by default. As Spring Cloud Ribbon isinmaintenance mode. We recommend switching to BlockingLoadBalancerClient instead. In order to use it,setthe value ofspring.cloud.loadbalancer.ribbon.enabledtofalseor remove spring-cloud-starter-netflix-ribbon from your project.2021-02-1014:03:52.848 WARN2860---[main]iguration$LoadBalancerCaffeineWarnLogger:Spring Cloud LoadBalancer is currently working with default default cache. You can switch to using Caffeine cache, by adding it to the classpath.2021-02-1014:03:52.921 INFO2860---[main]o.s.c.n.eureka.InstanceInfoFactory:Setting initial instance status as: STARTING2021-02-1014:03:52.949 INFO2860---[main]com.netflix.discovery.DiscoveryClient:Initializing Eurekainregion us-east-12021-02-1014:03:53.006 INFO2860---[main]c.n.d.provider.DiscoveryJerseyProvider:Using JSON encoding codec LegacyJacksonJson2021-02-1014:03:53.006 INFO2860---[main]c.n.d.provider.DiscoveryJerseyProvider:Using JSON decoding codec LegacyJacksonJson2021-02-1014:03:53.110 INFO2860---[main]c.n.d.provider.DiscoveryJerseyProvider:Using XML encoding codec XStreamXml2021-02-1014:03:53.110 INFO2860---[main]c.n.d.provider.DiscoveryJerseyProvider:Using XML decoding codec XStreamXml2021-02-1014:03:53.263 INFO2860---[main]c.n.d.s.r.aws.ConfigClusterResolver:Resolving eureka endpoints via configuration2021-02-1014:03:53.546 INFO2860---[main]com.netflix.discovery.DiscoveryClient:Disable delta property:false2021-02-1014:03:53.546 INFO2860---[main]com.netflix.discovery.DiscoveryClient:Single vip registry refresh property:null2021-02-1014:03:53.547 INFO2860---[main]com.netflix.discovery.DiscoveryClient:Force full registry fetch:false2021-02-1014:03:53.547 INFO2860---[main]com.netflix.discovery.DiscoveryClient:Application is null:false2021-02-1014:03:53.547 INFO2860---[main]com.netflix.discovery.DiscoveryClient:Registered Applications size is zero:true2021-02-1014:03:53.547 INFO2860---[main]com.netflix.discovery.DiscoveryClient:Application version is -1:true2021-02-1014:03:53.547 INFO2860---[main]com.netflix.discovery.DiscoveryClient:Getting all instance registry info from the eureka server2021-02-1014:03:53.754 INFO2860---[main]com.netflix.discovery.DiscoveryClient:The response status is2002021-02-1014:03:53.756 INFO2860---[main]com.netflix.discovery.DiscoveryClient:Starting heartbeat executor: renew interval is:302021-02-1014:03:53.758 INFO2860---[main]c.n.discovery.InstanceInfoReplicator:InstanceInfoReplicator onDemand update allowed rate per min is42021-02-1014:03:53.761 INFO2860---[main]com.netflix.discovery.DiscoveryClient:Discovery Client initialized at timestamp1612937033760with initial instances count:02021-02-1014:03:53.762 INFO2860---[main]o.s.c.n.e.s.EurekaServiceRegistry:Registering application SPRINGCLOUD-TEST with eureka with status UP2021-02-1014:03:53.763 INFO2860---[main]com.netflix.discovery.DiscoveryClient:Sawlocalstatus change event StatusChangeEvent[timestamp1612937033763,currentUP,previousSTARTING]2021-02-1014:03:53.765 INFO2860---[nfoReplicator-0]com.netflix.discovery.DiscoveryClient:DiscoveryClient_SPRINGCLOUD-TEST/host.docker.internal:springCloud-test:8884: registering service...2021-02-1014:03:53.805 INFO2860---[main]o.s.b.w.embedded.tomcat.TomcatWebServer:Tomcat started on port(s):8884(http)with context path2021-02-1014:03:53.807 INFO2860---[main].s.c.n.e.s.EurekaAutoServiceRegistration:Updating port to88842021-02-1014:03:53.837 INFO2860---[nfoReplicator-0]com.netflix.discovery.DiscoveryClient:DiscoveryClient_SPRINGCLOUD-TEST/host.docker.internal:springCloud-test:8884 - registration status:2042021-02-1014:03:54.231 INFO2860---[main]o.d.s.e.s.ShenyuTestSpringCloudApplication:Started ShenyuTestSpringCloudApplicationin6.338seconds(JVM runningfor7.361)启动shenyu-examples-springcloud之后在admin的系统的divide插件上即可看到刚注册上来的数据测试Http请求shenyu-examples-springcloud项目成功启动之后会自动把加ShenyuSpringMvcClient注解的接口方法注册到网关。下面使用postman模拟http的方式来请求你的SpringCloud服务使用IDEA HTTP Client插件模拟http的方式来请求你的SpringCloud服务[本地访问不使用shenyu代理]:使用IDEA HTTP Client插件模拟http的方式来请求你的SpringCloud服务[使用shenyu代理]:Spring Cloud快速开始 | Apache ShenYu

相关新闻

selenium 自动化测试工具实战项目(窗口切换)

selenium 自动化测试工具实战项目(窗口切换)

介绍 测试的系统:白月黑羽网站的测试系统(白月SMS系统) 测试内容:点击【学习教程】链接跳转到白月黑羽网站,获取此网站上的标题,然后回到原来的系统。 所涉及的知识点:frame切换/窗口切换 这个iframe元素非常的特殊&…

2026/7/4 20:02:24 阅读更多 →
学霸同款 9个AI论文写作软件测评:本科生毕业论文+开题报告高效工具推荐

学霸同款 9个AI论文写作软件测评:本科生毕业论文+开题报告高效工具推荐

在当前学术研究日益精细化、AI技术快速发展的背景下,本科生在撰写毕业论文和开题报告时,常常面临内容组织混乱、文献资料查找困难、格式规范不熟悉等多重挑战。为帮助学生更高效地完成学术写作任务,笔者基于2026年的实测数据与用户反馈&#…

2026/6/24 20:11:46 阅读更多 →
源荷不确定性 考虑源荷随机特征的热电联供微网优化matlab 王锐的《含可再生能源的热电联供型...

源荷不确定性 考虑源荷随机特征的热电联供微网优化matlab 王锐的《含可再生能源的热电联供型...

源荷不确定性 考虑源荷随机特征的热电联供微网优化matlab 王锐的《含可再生能源的热电联供型微网经济运行优化》 由风电机组、光伏电池、燃料电池、余热锅炉、燃气锅炉、蓄电池以及热电负荷构成的热电联供型微网系统,考虑风电、光伏功率以及热电负荷的随机性&#x…

2026/7/3 2:33:21 阅读更多 →

最新新闻

Excel ROUND函数底层原理与财务工程级避坑指南

Excel ROUND函数底层原理与财务工程级避坑指南

1. 项目概述:为什么一个“四舍五入”函数值得写上万字?Excel里敲下ROUND(A1,2),结果立刻出来——看起来简单得不能再简单。但如果你在财务报表里用它算过增值税、在工程预算中处理过材料损耗率、在科研数据里校验过有效数字,你大概…

2026/7/6 10:46:37 阅读更多 →
Plone电商基建加固:GetPaid Recipe Release 1.4.1深度解析

Plone电商基建加固:GetPaid Recipe Release 1.4.1深度解析

1. 项目概述:一个被低估的 Plone 电商基建工具包更新 Plone 是个老派但极其扎实的内容管理系统,尤其在政府、教育、科研类机构里扎根很深。它不像 WordPress 那样靠主题和插件堆出花哨界面,而是靠严格的权限模型、内容生命周期管理和可审计性…

2026/7/6 10:46:37 阅读更多 →
ZODB对象数据库原理与Zope内容管理实战

ZODB对象数据库原理与Zope内容管理实战

1. 项目概述:当应用服务器与数据库在对象层面“无缝焊接”我第一次接触 Zope 是在 1998 年,那会儿连“Web 应用框架”这个词都还没被广泛使用。打开文档,第一反应不是兴奋,而是皱眉——“这玩意儿默认不让我连 MySQL?”…

2026/7/6 10:46:37 阅读更多 →
Linux防火墙端口管理:firewalld、iptables、ufw 3种方案深度对比与选择指南

Linux防火墙端口管理:firewalld、iptables、ufw 3种方案深度对比与选择指南

Linux防火墙端口管理:firewalld、iptables、ufw 3种方案深度对比与选择指南在Linux服务器管理中,防火墙配置是确保系统安全的关键环节。面对不同的发行版和业务需求,系统管理员常常需要在firewalld、iptables和ufw这三种主流防火墙工具之间做…

2026/7/6 10:44:32 阅读更多 →
可视化指挥闭环:城市安防视频孪生时空感知技术详解

可视化指挥闭环:城市安防视频孪生时空感知技术详解

可视化指挥闭环:城市安防视频孪生时空感知技术详解摘要传统城市安防指挥体系存在视频孤岛、时空基准割裂、预警处置脱节、调度无空间量化支撑、事后复盘证据碎片化五大核心痛点,指挥链路停留在“看画面、接警情、人工派单”的线性被动模式,无…

2026/7/6 10:44:32 阅读更多 →
如何快速上手eulerfs-test:从配置到执行的完整教程

如何快速上手eulerfs-test:从配置到执行的完整教程

如何快速上手eulerfs-test:从配置到执行的完整教程 【免费下载链接】eulerfs-test test scripts for eulerfs 项目地址: https://gitcode.com/openeuler/eulerfs-test 前往项目官网免费下载:https://ar.openeuler.org/ar/ eulerfs-test是openEul…

2026/7/6 10:42:30 阅读更多 →

日新闻

H2 与 MySQL 单元测试兼容性:5 个关键 SQL 语句差异与规避方案

H2 与 MySQL 单元测试兼容性:5 个关键 SQL 语句差异与规避方案

H2与MySQL单元测试兼容性:5个关键SQL语句差异与规避方案1. 单元测试中的数据库兼容性挑战在Java开发领域,单元测试是保证代码质量的重要环节。当应用涉及数据库操作时,测试环境的搭建往往成为开发者的痛点。H2数据库因其轻量级、内存模式和快…

2026/7/6 0:01:17 阅读更多 →
Windows任务栏终极清理指南:用RBTray一键隐藏窗口到系统托盘

Windows任务栏终极清理指南:用RBTray一键隐藏窗口到系统托盘

Windows任务栏终极清理指南:用RBTray一键隐藏窗口到系统托盘 【免费下载链接】rbtray A fork of RBTray from http://sourceforge.net/p/rbtray/code/. 项目地址: https://gitcode.com/gh_mirrors/rb/rbtray 你是否厌倦了Windows任务栏上密密麻麻的图标&…

2026/7/6 0:01:17 阅读更多 →
Visual C++ 运行时库一键安装终极指南:告别DLL缺失烦恼

Visual C++ 运行时库一键安装终极指南:告别DLL缺失烦恼

Visual C 运行时库一键安装终极指南:告别DLL缺失烦恼 【免费下载链接】vcredist AIO Repack for latest Microsoft Visual C Redistributable Runtimes 项目地址: https://gitcode.com/gh_mirrors/vc/vcredist 你是否曾经遇到过这样的情况:下载了…

2026/7/6 0:05:19 阅读更多 →

周新闻

B站视频下载神器BiliTools:5分钟学会轻松保存任何B站内容

B站视频下载神器BiliTools:5分钟学会轻松保存任何B站内容

B站视频下载神器BiliTools:5分钟学会轻松保存任何B站内容 【免费下载链接】BiliTools A cross-platform bilibili toolbox. 跨平台哔哩哔哩工具箱,支持下载视频、番剧等等各类资源 项目地址: https://gitcode.com/GitHub_Trending/bilit/BiliTools …

2026/7/6 8:11:50 阅读更多 →
威胁模型全解析:从新手入门到实战应用,助你构建安全产品!

威胁模型全解析:从新手入门到实战应用,助你构建安全产品!

威胁模型的陌生现状在忙碌疲惫的一天里,参与了关于混合后量子密码学的讨论,应付端点攻击找茬的人,还参与留言板讨论后,发现“威胁模型”对多数人仍是陌生概念,且多被当作时髦用语。有趣的相关画作有一幅由 Embyr 创作的…

2026/7/6 8:11:52 阅读更多 →
渗透测试入门指南:从零基础到实战环境搭建

渗透测试入门指南:从零基础到实战环境搭建

1. 从“看热闹”到“入门”:我理解的渗透测试到底是什么?每次看到新闻里说某个大公司的数据被“黑”了,或者某个网站被攻击导致服务瘫痪,你是不是和我一样,心里会冒出两个念头:一是“这黑客真厉害”&#x…

2026/7/6 6:52:56 阅读更多 →

月新闻