阳光沙滩-课程笔记 阳光沙滩-课程笔记
首页 (opens new window)
VIP (opens new window)
  • 课程笔记

    • 《Android项目喜马拉雅FM》
    • 《Android项目领券联盟》
    • 《AndroidStudio技巧》
    • 《Android自定义控件》
    • 《Android开发基础》
    • 《Android约束布局》
    • 《AOSP安卓开源项目》
    • 《RecyclerView》
  • 《领券联盟Nuxt.js》
  • 《博客系统后台管理系统vue.js》
  • 《博客系统门户Nuxt.js》
  • 《博客系统前后端分离后台》
  • 《博客系统部署》
  • 《摸鱼君后台》
  • 《OTA升级管理系统》
  • 阳光沙滩API (opens new window)
  • 领券联盟API (opens new window)
  • 博客系统API (opens new window)
首页 (opens new window)
VIP (opens new window)
  • 课程笔记

    • 《Android项目喜马拉雅FM》
    • 《Android项目领券联盟》
    • 《AndroidStudio技巧》
    • 《Android自定义控件》
    • 《Android开发基础》
    • 《Android约束布局》
    • 《AOSP安卓开源项目》
    • 《RecyclerView》
  • 《领券联盟Nuxt.js》
  • 《博客系统后台管理系统vue.js》
  • 《博客系统门户Nuxt.js》
  • 《博客系统前后端分离后台》
  • 《博客系统部署》
  • 《摸鱼君后台》
  • 《OTA升级管理系统》
  • 阳光沙滩API (opens new window)
  • 领券联盟API (opens new window)
  • 博客系统API (opens new window)
  • 单体应用博客系统

  • 博客系统部署

  • 摸鱼君微服务项目实战

    • 摸鱼君介绍
    • 数据库创建&表字段设计
    • Mybatis-plus
    • 项目创建
    • 编写u-center模块功能
    • 管理中心项目准备
    • 编写mo-yu-jun模块功能
    • 微服务结构
    • 服务注册中心
    • 网关
      • API文档
    • OTA升级管理系统

    • 后台
    • 摸鱼君微服务项目实战
    TrillGates
    2022-03-28
    目录

    网关

    # 网关

    添加依赖

    <dependency>
        <groupId>org.springframework.cloud</groupId>
        <artifactId>spring-cloud-starter-gateway</artifactId>
    </dependency>
    
    1
    2
    3
    4

    配置:

    server:
      port: 40000
    spring:
      application:
        name: my-gateway
      cloud:
        gateway:
          discovery:
            locator:
              lowerCaseServiceId: true
          routes:
            - id: Ucenter
              uri: lb://u-center
              predicates:
                - Path=/uc/**
              filters:
                - StripPrefix=1
            - id: Device
              uri: lb://mo-yu-jun
              predicates:
                - Path=/my/**
              filters:
                - StripPrefix=1
        nacos:
          discovery:
            server-addr: 192.168.220.128:8848
    
    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    13
    14
    15
    16
    17
    18
    19
    20
    21
    22
    23
    24
    25
    26

    允许跨域的配置

    @Configuration
    public class CorsConfig {
        @Bean
        public CorsWebFilter corsFilter() {
            CorsConfiguration config = new CorsConfiguration();
            config.setAllowCredentials(Boolean.TRUE);
            config.addAllowedMethod("*");
            config.addAllowedOrigin("*");
            config.addAllowedHeader("*");
            config.setMaxAge(3600L);
            UrlBasedCorsConfigurationSource source = new UrlBasedCorsConfigurationSource(new PathPatternParser());
            source.registerCorsConfiguration("/**", config);
            return new CorsWebFilter(source);
        }
    }
    
    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    13
    14
    15
    编辑 (opens new window)
    服务注册中心
    API文档

    ← 服务注册中心 API文档→

    Theme by Vdoing | Copyright © 2022-2022 sunofbeach.net
    • 跟随系统
    • 浅色模式
    • 深色模式
    • 阅读模式