目录
七、启动shenyu-examples中的shenyu-examples-http
一、背景
最近参加了一个直播"Apache DolphinScheduler& Apache ShenYu(Incubating) 联合 Meetup",听各大佬还有初入开源社区的小白分享经验,收益匪浅,先玩玩apache-shenyu,本文主要是实战,理论知识请移官网:https://shenyu.apache.org/
二、Apache-shenyu是什么?
Apache ShenYu是使用Java reactor编程方式开发的,具有异步,高性能,跨语言等特性的 API 网关。
在流量控制方面,有精美的Admin控制台,能够精准,动态控制流量,满足复杂的业务场景。
在功能方面,它使用插件化的设计思想,支持许多常见的协议:如 http/https, Dubbo、 Spring Cloud、 GRPC、 Motan、 Sofa、 Tars等。
废话不多说,其他见官网:https://shenyu.apache.org/zh/docs/index
三、下载代码
1、先登陆git网站,进入https://github.com/apache/incubator-shenyu.git
2、点击fork,将代码fork到自己的仓库
3、git clone https://github.com/xxxxx/incubator-shenyu.git
4、不出意外,会报错;
...
WebSocketClientConfiguration.java: Filename too long
解决方案:
git config --global core.longpaths true
5、删除文件夹,重新下载
四、加载工程
这个就不截图了,使用IDEA打开incubator-shenyu文件夹
这里有一个坑需要注意下:主pom
文件记得在modules
把examples/test加进去,否则不加载无法启动。
<module>shenyu-examples</module>
<module>shenyu-integrated-test</module>
注意:这个下载依赖包需要一个过程,耐心等待………
五、启动shenyu-admin
1、初始化脚本,路径:
src/main/resources/sql-script/mysql/schema.sql
2、修改application.yml配置文件
spring:
profiles:
active: mysql
3、修改application-mysql.yml数据库连接
spring:
datasource:
url: jdbc:mysql://localhost:3306/shenyu?useUnicode=true&characterEncoding=utf-8&useSSL=false
username: root
password: 123456
driver-class-name: com.mysql.jdbc.Driver
4、运行启动类 ShenyuAdminBootstrap
http://localhost:9095/#/user/login
用户名/密码:admin/123456
六、启动shenyu-bootstrap
这里有个坑:
Error running ShenyuBootstrapApplication. Command line is too long.
修改下idea配置文件即可。
修改shorten command line
为JAR manifest
。
七、启动shenyu-examples中的shenyu-examples-http
注意:
端口号不要冲突
验证:
图一为直接访问,图二为通过gateway访问
至此,apache-shenyu基本demo就跑起来了。