springcloud-alibaba核心组件后端环境搭建

Gitee仓库地址
点我

  • 服务注册与发现: nacos
  • 配置中心: nacos
  • 服务远程调用: openfeign
  • 微服务网关: gateway
  • 服务限流降级熔断等: sentinel

实现的功能demo

  • openfeign服务远程调用
  • sentinel限流测试
  • gateway网关调用2个微服务
  • nacos的服务注册与发现
软件架构(环境)
  • jdk: 1.8
  • maven: 3.5.2
  • nacos: 注册中心-配置中心
  • gateway: 微服务网关
  • openfeign: 服务远程调用
  • sentinel: 熔断,限流,服务保护等

nacos上等相关配置

order服务
  • dataId: cloud-order-dev.yaml
  • Group: DEV_GROUP
server:
  port: 8081
spring:
  application:
    name: cloud-order
  cloud:
    nacos:
      discovery:
        server-addr: localhost:8848
        namespace: 0d497b0f-19fe-47f3-a5d0-6499c698841a
        group: DEV_GROUP
    sentinel:
      transport:
        dashboard: localhost:8089
      eager: true
feign:
  sentinel:
    enabled: true
user服务
  • dataId: cloud-user-dev.yaml
  • Group: DEV_GROUP
server:
  port: 8082
spring:
  application:
    name: cloud-user
  cloud:
    nacos:
      discovery:
        server-addr: localhost:8848
        namespace: 0d497b0f-19fe-47f3-a5d0-6499c698841a
        group: DEV_GROUP
    sentinel:
      transport:
        dashboard: localhost:8089
      eager: true
feign:
  sentinel:
    enabled: true
gateway
  • dataId: cloud-gateway-dev.yaml
  • Group: DEV_GROUP
server:
  port: 8083
spring:
  cloud:
    nacos:
      discovery:
        server-addr: localhost:8848
        namespace: 0d497b0f-19fe-47f3-a5d0-6499c698841a
        group: DEV_GROUP
    gateway:
      globalcors:
          corsConfigurations:
            '[/**]': 
              allowedOrigins: "*" 
              allowedHeaders: "*"
              allowCredentials: true
              allowedMethods:
                - GET
                - POST
                - PUT
                - DELETE
      routes:
        - id: cloud-order
          uri: lb://cloud-order
          predicates:
          - Path=/cloud-order/**
          filters:
          - StripPrefix=1
        - id: cloud-user
          uri: lb://cloud-user
          predicates:
          - Path=/cloud-user/**
          filters:
          - StripPrefix=1
  application:
    name: cloud-gateway
Logo

权威|前沿|技术|干货|国内首个API全生命周期开发者社区

更多推荐