GithubHelp home page GithubHelp logo

wxc-learn / mcloud Goto Github PK

View Code? Open in Web Editor NEW

This project forked from heyuxian/mcloud

0.0 0.0 0.0 1.11 MB

基于Spring Cloud,实现微服务中常用的基础模块,包括 OAuth2 认证服务,统一注册中心,系统监控中心, 统一配置中心,API网关以及熔断器

License: Apache License 2.0

Java 99.15% HTML 0.85%

mcloud's Introduction

MCloud - 微服务基础设施

Build Status Coverage Status License

项目简介

MCloud 基于Spring Cloud进行开发,提供了项目中常用的基础设施:

  • mcloud-registry 服务注册与发现中心。
  • keycloak 用户认证和管理
  • mcloud-apigw 基于Spring cloud zuul 实现的api网关 。
  • mcloud-config 统一配置中心。
  • mcloud-logs 基于logstash Kibana 以及 ElasticSearch 实现的日志服务。
  • mcloud-demo Demo Project
  • mcloud-console 基于 ant-design-pro 搭建的系统控制台

其他模块:

Dependencies

  • Spring Boot 2.0.0.RELEASE
  • Spring Cloud Finchley.M7
  • Gradle 4.6
  • ......

系统结构图

1

环境依赖

  • JDK 1.8 以上
  • IDE 请安装对应IDE的lombok插件
  • 数据库 Mysql 5.5 及以上

Quick Start

修改 hosts

127.0.0.1	mcloud-registry.example.com
127.0.0.1	mcloud-demo.example.com
127.0.0.1	mcloud-config.example.com
127.0.0.1	mcloud-apigw.example.com

安装 keycloak

下载 keycloak 并解压到本地文件夹,在 keycloak bin 目录下运行以下命令启动 keycloak:

Windows

standalone.bat -Djboss.http.port=8443

Linux/MacOs

./standalone.sh -Djboss.http.port=8443

启动后登陆到 keycloak 并导入 data 目录下的 mcloud-realm.jsonmcloud-users-0.json,默认用户为:

  • 管理员:mcloud-admin/123456
  • 普通用户:mcloud-user/123456

克隆项目到本地

git clone https://github.com/heyuxian/mcloud.git

构建并运行

Windows

cd mcloud
#执行构建
gradlew.bat build
# 分别在三个不同的终端运行以下命令
gradlew.bat bootRun -b ./mcloud-registry/mcloud-registry.gradle
gradlew.bat bootRun -b ./mcloud-apigw/mcloud-apigw.gradle
gradlew.bat bootRun -b ./mcloud-demo/mcloud-demo.gradle

Linux/MacOs

cd mcloud
#执行构建
./gradlew build
# 分别在三个不同的终端运行以下命令
./gradlew bootRun -b ./mcloud-registry/mcloud-registry.gradle
./gradlew bootRun -b ./mcloud-apigw/mcloud-apigw.gradle
./gradlew bootRun -b ./mcloud-demo/mcloud-demo.gradle

各个服务运行之后,首先通过 api gateway 进行登陆:

curl --request POST \
  --url http://mcloud-apigw.example.com/auth/login \
  --header 'cache-control: no-cache' \
  --header 'content-type: application/json' \
  --data '{"username": "mcloud-user","password": "123456"}'

如果一切正常,将获取 AccessToken:

  % Total    % Received % Xferd  Average Speed   Time    Time     Time  Current
                                 Dload  Upload   Total   Spent    Left  Speed
100  1500    0  1452  100    48  11616    384 --:--:-- --:--:-- --:--:-- 11616{"access_token":"${access_token}","expires_in":36000,"refresh_expires_in":1800,"token_type":"bearer","id_token":null,"not-before-policy":0,"session_state":"8c808f01-86fd-45fd-bb69-d3edf7218be8"}

此时,使用上面获取的 AccessToken ,即可访问受保护的 api :http://mcloud-apigw.example.com/demo/info

curl --request GET \
  --url http://mcloud-apigw.example.com/demo/info \
  --header 'authorization: Bearer ${access_token}' \
  --header 'cache-control: no-cache' \
  --header 'content-type: application/json' \
  --data '{\n	"grant_type":"password"\n}'

API 也可通过 Swagger 进行调用,地址为: http://mcloud-apigw.example.com/swagger-ui.html

image

最后,还可以直接通过 mcloud-console 项目进入系统。运行并登陆 mcloud-console 后,将看到以下的画面:

image

image

image

问题及建议

若是对于本项目有任何问题或建议,请提 Issue

mcloud's People

Contributors

heyuxian avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.