https://github.com/deepraining/spring-cloud-starter
用于快速创建 Spring Cloud 微服务应用的模板脚手架,使用 Gradle 构建项目
https://github.com/deepraining/spring-cloud-starter
feign gateway gradle microservice nacos spring spring-boot spring-cloud starter
Last synced: 3 months ago
JSON representation
用于快速创建 Spring Cloud 微服务应用的模板脚手架,使用 Gradle 构建项目
- Host: GitHub
- URL: https://github.com/deepraining/spring-cloud-starter
- Owner: deepraining
- License: mit
- Created: 2022-09-15T10:24:38.000Z (over 2 years ago)
- Default Branch: master
- Last Pushed: 2022-09-16T03:24:12.000Z (over 2 years ago)
- Last Synced: 2025-01-15T14:35:56.580Z (4 months ago)
- Topics: feign, gateway, gradle, microservice, nacos, spring, spring-boot, spring-cloud, starter
- Language: Java
- Homepage:
- Size: 76.2 KB
- Stars: 0
- Watchers: 2
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- Changelog: CHANGELOG.md
- License: LICENSE
Awesome Lists containing this project
README
# spring-cloud-starter
用于快速创建 [Spring Cloud](https://spring.io/projects/spring-cloud) 微服务应用的模板脚手架,使用 [Gradle](https://gradle.org/) 构建项目。
## 特性
- 使用 [spring-cloud-gateway](https://github.com/spring-cloud/spring-cloud-gateway) 处理网关路由
- 使用 [Alibaba Nacos](https://nacos.io/) 注册与发现微服务
- 使用 [spring-cloud-openfeign](https://github.com/spring-cloud/spring-cloud-openfeign) 优雅操作 `rpc` 调用
- 使用 [Alibaba Sentinel](https://github.com/alibaba/Sentinel) 做高可用流控防护组件
- 使用 [Twitter Zipkin](https://github.com/openzipkin/zipkin) 做请求链路的跟踪数据## 子项目
- `pro-base`: 基础代码
- `pro-gateway`: 网关项目
- `pro-user-api`: `user` 项目对外开放接口
- `pro-user-cloud`: `user` 项目主体代码
- `pro-article-api`: `article` 项目对外开放接口
- `pro-article-cloud`: `article` 项目主体代码## 创建项目
克隆代码,然后根据需要调整项目与代码
```
git clone https://github.com/deepraining/spring-cloud-starter.git yourProName --depth=1cd yourProName
```去掉原有的 Git 信息,并重新初始化
```
rm -rf .gitgit init
```## 运行项目
请先确保已有 Nacos 服务与 Zipkin 服务。
先运行 `pro-user-cloud` 项目
```
./gradlew pro-user-cloud:run
```再运行 `pro-article-cloud` 项目
```
./gradlew pro-article-cloud:run
```最后运行 `pro-gateway` 项目
```
./gradlew pro-gateway:run
```访问 `http://localhost:9100/`,并在 Console 中执行
```
// 访问user项目接口
fetch('/user/articleList').then(res=>res.json()).then(console.log)// 访问article项目接口
fetch('/article/articleList').then(res=>res.json()).then(console.log)
```## 注意
- 使用 Nacos 时,服务器与客户端版本需匹配,本项目所需的服务器版本是 `v1.1.4`,参考 [Spring Cloud Alibaba Version 版本说明](https://github.com/alibaba/spring-cloud-alibaba/wiki/%E7%89%88%E6%9C%AC%E8%AF%B4%E6%98%8E)
- 部署时,需要调整 `application*.yml` 配置中的相关服务地址
- 本项目只示例了两个模块 `user, article`,实际使用时,可以自行添加多个模块