1. 概述
Soul 是基于 WebFlux 实现的响应式的 API 网关,具有异步、高性能、跨语言等特点。
猫大人说:我希望能够有一样东西像灵魂一样,保护您的微服务。在参考了 Kong、Spring Cloud Gateway 等优秀的网关后,站在巨人的肩膀上,Soul 由此诞生!
2. 搭建网关环境(github 一键三连 star,watch,fork)
https://github.com/dromara/soul
Fork分支到本地,设置upstream
-
从soul的repo上fork一个分支到您自己的repo来开始工作,并设置upstream为soul的repo。
git remote add upstream https://github.com/dromara/soul.git
创建分支
-
切换到fork的master分支,拉取最新代码,创建本次的分支。
git checkout master git pull upstream master git checkout -b soul-read
编译代码:
mvn clean package install -Dmaven.test.skip=true -Dmaven.javadoc.skip=true -Drat.skip=true -Dcheckstyle.skip=true
启动soul-admin(SoulAdminBootstrap)
1、错误记录:
org.springframework.context.ApplicationContextException: Unable to start web server; nested exception is org.springframework.boot.web.server.WebServerException: Unable to start embedded Tomcat
原因:没有改数据库账号密码:
2、启动完成后,我们可以通过日志看到 Soul Admin 启动在 9095 端口。
2021-01-14 23:11:44.644 INFO 1920 --- [ main] o.s.b.w.embedded.tomcat.TomcatWebServer : Tomcat started on port(s): 9095 (http) with context path ''
2021-01-14 23:11:44.654 INFO 1920 --- [ main] o.dromara.soul.admin.SoulAdminBootstrap : Started SoulAdminBootstrap in 16.306 seconds (JVM running for 21.845)
3、可以看到数据库已经建好了。
4、使用浏览器,访问 http://127.0.0.1:9095/ 地址,进入登录页(admin/123456), 输入账号密码,进入首页 访问:http://localhost:9095
启动 Soul Bootstrap 网关服务 (SoulBootstrapApplication)
1、启动 Soul Bootstrap 网关服务成功后可以看到控制台打印:
2021-01-14 23:22:05.113 INFO 13744 --- [ main] o.s.b.web.embedded.netty.NettyWebServer : Netty started on port(s): 9195
2021-01-14 23:22:05.118 INFO 13744 --- [ main] o.d.s.b.SoulBootstrapApplication : Started SoulBootstrapApplication in 11.573 seconds (JVM running for 16.882)
2、同时,我们在 Soul Admin 的日志输出如下日志,说明 Soul Bootstrap 成功连接上。
3、网关服务,负责启动网关,并转发请求到后端服务。如访问http://127.0.0.1:9195/dubbo/findById?id=9,可以通过网关访问:http://127.0.0.1:9105/findById?id=9
总结
1、为了培养良好的学习习惯,深入学习开源技术底层源码,同时促进整理记录学习知识,分享和表达技术的能力。Soul是一个开始,也是一个flag。
希望这次不要:靡不有初鲜克有终。