构建SpringCloudGateway|学习笔记

简介: 快速学习构建 SpringCloudGateway

开发者学堂课程【精通 Spring Cloud Alibaba构建 SpringCloudGateway】学习笔记,与课程紧密联系,让用户快速学习知识

课程地址:https://developer.aliyun.com/learning/course/634/detail/10114


构建 SpringCloudGateway


内容介绍:

一、 创建项目并引入 jar 包

二、 写入 application 配置

三、 创建 AppGateWay.java

 

一、 创建项目并引入 jar 包

1. 引入依赖 jar 包

<parent>

<gcoupId>ong.springframework.boot</gcoupId>

<antifactId>spring-boot-starter-parent</antifactId>

<version>2.0.0.RELEASE</version>

</parent>

<dependencies>

<dependency>

<groupId>ocg.spningfcamework..sloud</gcoupId>

<antifactId>spring-cloud-starter-gateway</antifactId>

<version>2.0.0.RELEASE</version>

</dependency>

</dependencies>


二、 写入 application 配置

server :

port: 80

####服务网关名称

spring:

application:

name: mayikt-gateway

cloud:

gateway:

###路由策略

routes:

###路由id

id: mayikt

####转发hhttp://ww.mayikt.com/

uri: http://www.mayikt.com/

###匹配规则

predicates:

- Path=/mayikt/**

### 127.0.0.1/mayikt 转到 http://www.mayikt.com/


三、 创建 AppGateWay.java

import org.springframework.boot.SpringApplication;

import org.springframework.boot.autoconfigure.SpringBootApplication;

@SpringBootApplication

public class AppGateway {

public static void main(String[] args) {

SpringApplication.run(AppGateway.class);

}

}

相关文章
|
算法 Java 索引
Byte Hex CRC计算笔记
Byte Hex CRC计算笔记
245 0
|
存储 关系型数据库 MySQL
MySQL 数据库详解与实践指南
本文全面解析MySQL数据库核心概念、存储引擎、数据类型及高级特性,涵盖索引优化、查询性能提升、安全配置、备份恢复与主从复制等实战技巧,助你掌握MySQL高效应用与运维最佳实践。
196 1
|
数据库
达梦数据库最大连接数处理
达梦数据库最大连接数处理
495 0
|
机器学习/深度学习 人工智能 自然语言处理
360Zhinao2-7B:360推出自研360智脑大模型的升级版
360Zhinao2-7B是360自研的AI大模型360智脑7B参数升级版,涵盖基础模型及多种上下文长度的聊天模型。该模型在语言理解与生成、聊天能力、数学逻辑推理等方面表现出色,支持多语言和多上下文长度,适用于多种商业应用场景。
469 23
360Zhinao2-7B:360推出自研360智脑大模型的升级版
|
JavaScript
Vue项目启动报错处理
Vue项目启动报错处理
481 1
|
Java Maven 微服务
使用Spring Cloud Gateway构建微服务网关
以上简要示例介绍了使用Spring Cloud Gateway构建微服务网关的基本步骤,包括添加依赖、配置路由、编写过滤器等。通过配置和自定义过滤器,可以实现请求转发、过滤、鉴权等功能。
378 5
|
Java Spring
【已解决】Failed to start bean ‘documentationPluginsBootstrapper‘; nested exception .lang.NullPointerEx
【已解决】Failed to start bean ‘documentationPluginsBootstrapper‘; nested exception .lang.NullPointerEx
422 0
|
Python
gyp ERR! stack Error: Can‘t find Python executable “python“, you can set the PYTHON env variable.
gyp ERR! stack Error: Can‘t find Python executable “python“, you can set the PYTHON env variable.
483 1
|
安全 网络协议 Linux
如何在IDEA中使用固定公网地址SSH远程连接服务器开发环境(一)
该文介绍了如何通过IDEA设置远程连接Linux服务器的步骤,使用Cpolar内网穿透工具实现在没有公网IP的情况下进行远程开发。主要内容包括检查Linux SSH服务、本地连接测试、在Linux上安装Cpolar、创建远程连接的公网地址、公网远程连接测试以及固定连接公网地址。文章还提供了相关截图辅助说明,适用于IDEA2023.2.5版本。
|
前端开发 JavaScript 程序员
一文搞懂:关于Defferred对象知识详解
一文搞懂:关于Defferred对象知识详解
276 0