Coder Social home page Coder Social logo

spring-cloud's Introduction

简介

此项目是用于搭建Spring Cloud项目,版本为Finchley,包含 网关注册中心服务消费服务链路追踪 流量控制,以及三个微服务

springcloud初体验.png

项目模块介绍

注册中心

registration-center模块为注册中心,使用的 eureka,可以稍作修改切换为 consul或者是 Nacos

网关

gateway-center模块为网关,使用的 gateway,Spring Cloud F版本已经不支持使用 Zuul作为网关,

使用 gateway作为网关时,因为对性能要求比较高,所以web框架使用的使Web Flux

服务链路追踪

链路追踪使用的使 Zipkinsleuth,在三个微服务中都有使用,Zipkin的新版本已经不需要手动搭建Zipkin Server了,直接下载jar包运行即可,默认的端口为9411

Zipkin Server的镜像下载地址:下载

流量控制

流量控制使用阿里的 sentinel,在三个微服务中添加如下依赖

        <dependency>
            <groupId>org.springframework.cloud</groupId>
            <artifactId>spring-cloud-alibaba-sentinel</artifactId>
            <version>0.2.1.RELEASE</version>
        </dependency>

然后还需要下载 Sentinel Dashboard,下载地址:下载。下载后运行jar包,默认端口为8080,建议使用 --server.port=xxx参数修改运行端口

微服务

portal-service

门户服务,可以看成对外提供的各种API

auth-service

认证服务,用于登录以及校验token

resource-service

资源服务,只有一个接口,用于获取指定路径下的文件/文件夹名称

启动流程

  1. 启动注册中心
    • 可以 java -jar registration-center-1.0-SNAPSHOT.jar启动,即使用单个eureka注册中心
    • 也可以使用 java -jar registration-center-1.0-SNAPSHOT.jar -Dspring.profiles.active=server1java -jar registration-center-1.0-SNAPSHOT.jar -Dspring.profiles.active=server2启动两个注册中心,形成一个小集群
  2. 启动网关
    • java -jar gateway-center-1.0-SNAPSHOT.jar
  3. 启动Zipkin Server
    1. 首先下载jar包
    2. 运行 java -jar zipkin-server-2.21.5-exec.jar
  4. 启动Sentinel Dashboard
    1. 首先下载jar包
    2. 运行并且指定端口为8000,java -jar sentinel-dashboard-1.7.2.jar --server.port=8000
  5. 启动微服务
    1. 启动portal-service,java -jar portal-service-1.0-SNAPSHOT.jar
    2. 启动auth-service,java -jar auth-service-1.0-SNAPSHOT.jar
    3. 启动resource-service,java -jar resource-service-1.0-SNAPSHOT.jar -Dspring.profiles.active=service1java -jar resource-service-1.0-SNAPSHOT.jar -Dspring.profiles.active=service2

spring-cloud's People

Contributors

614756773 avatar hybridhotpot avatar

Watchers

 avatar  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.