你必须会的微服务之Gateway网关

网关GateWay的使用详解、路由、过滤器、跨域配置 gateway网关基础概念,以及最常用的功能在SpringBoot、SpringCloud微服务项目中如何使用 阅读详情

微服务已经成当前各大大厂追求的主流技术架构,学习微服务前景非常可观,而SpringCloud已成为主流微服务技术栈。本系列文章将以SpringCloud技术栈进行精讲,全方位剖析讲解SpringCloud技术栈在微服务场景下的实战应用

Spring Cloud Gateway

知识索引

  • Gateway简介
  • 入门案例
  • 路由前缀
  • 过滤器

 

1 Gateway简介

Spring Cloud Gateway 是Spring Cloud团队的一个全新项目,基于Spring 5.0、SpringBoot2.0、Project Reactor 等技术开发的网关。旨在为微服务架构提供一种简单有效统一的REST请求路由管理方式。

Spring Cloud Gateway 作为SpringCloud生态系统中的网关,目标是替代Netflix Zuul。Gateway不仅提供统一路由方式,并且基于Filter链的方式提供网关的基本功能。例如:安全,监控/指标,和限流。

 

2 入门案例

在spring_cloud_demos项目中创建gateway_demo子模块

 

2.1 引入依赖

<dependencies>
    <dependency>
        <groupId>org.springframework.cloud</groupId>
        <artifactId>spring-cloud-starter-gateway</artifactId>
    </dependency>
    <dependency>
        <groupId>org.springframework.cloud</groupId>
        <artifactId>spring-cloud-starter-consul-discovery</artifactId>
    </dependency>
</dependencies>

<dependencyManagement>
    <dependencies>
        <dependency>
            <groupId>org.springframework.cloud</groupId>
            <artifactId>spring-cloud-dependencies</artifactId>
            <version>Hoxton.SR12</version>
            <type>pom</type>
            <scope>import</scope>
        </dependency>
    </dependencies>
</dependencyManagement>

 

2.2 启动类

/**
 * Copyright (c) 2022 itmentu.com, All rights reserved.
 *
 * @Author: yang
 */
@SpringBootApplication
public class GateWayDemoApplication {
    public static void main(String[] args) {
        SpringApplication.run(GateWayDemoApplication.class, args);
    }
}

 

2.3 配置

server:
  port: 8502
spring:
  application:
    name: gateway
  cloud:
    consul:
      host: 192.168.184.128
      port: 8500
      discovery:
        service-name: ${spring.application.name}
        register: false

 

2.4 路由配置

gateway:
  # 路由si(集合)
  routes:
    # id唯一标识
    - id: consumer-service-route
      # 路由服务地址 
      uri: lb://service-consumer
      # 断言
      predicates:
        - Path=/**

代码说明:

1:routes:id表示路由标识,唯一即可,当前案例中表示消费者服务对应的路由
2:uri: lb://service-consumer表示uri使用负载均衡模式,lb表示loadbalance,”lb:“后跟注册中心对应的服务名

 

2.5 改造原本的service-consumer服务

新增@EnableDiscoveryClient注解注册开启注册中心

/**
 * Copyright (c) 2022 itmentu.com, All rights reserved.
 *
 * @Author: yang
 */
@SpringBootApplication
@EnableFeignClients
@EnableCircuitBreaker
@EnableHystrixDashboard
@EnableDiscoveryClient
public class ServiceConsumerApplication {

    public static void main(String[] args) {
        SpringApplication.run(ServiceConsumerApplication.class, args);
    }

    @Bean
    @LoadBalanced//开启负载均衡
    public RestTemplate restTemplate(){
        return new RestTemplate();
    }
}

修改配置为注册到注册中心

spring:
  cloud:
    consul:
      discovery:
        register: true

 

2.6 测试

通过http://localhost:8502/consumer/hello-feign地址访问消费者服务接口

image-20220320180509185

 

3 路由前缀

3.1 添加前缀

在gateway中可以通过配置路由的过滤器PrefixPath 实现映射路径中的前缀添加。可以起到隐藏接口地址的作用,避免接口地址暴露。

配置请求地址添加路径前缀过滤器

spring:
    gateway:
      routes:
          filters:
            - PrefixPath=/consumer

 

测试

重启路由服务访问

http://localhost:8502/hello-feign

结果如下,说明路由到了

http://localhost:8002/consumer/hello-feign

image-20220320181817680

 

3.2 去除前缀

在gateway中通过配置路由过滤器StripPrefix,实现映射路径中地址的去除。通过StripPrefix=1来指定路由要去掉的前缀个数。如:路径/api/consumer/hello-feign将会被路由到/consumer/hello-feign

 

配置去除路径前缀过滤器

spring:
    gateway:
      routes:
          filters:
            - StripPrefix=1

 

测试

重启路由服务访问

http://localhost:8502/api/consumer/hello-feign

结果如下,说明被路由到了

/consumer/hello-feign

image-20220320182253539

 

4 过滤器

过滤器作为网关的其中一个重要功能,就是实现请求的鉴权。前面的路由前缀章节中的功能也是使用过滤器实现的。

 

4.1 常见过滤器

Gateway自带过滤器有几十个,常见自带过滤器有:

过滤器名称说明
StripPrefix对匹配上的请求路径去除前缀
PrefixPath对匹配上的请求路径添加前缀
AddRequestHeader对匹配上的请求加上Header
AddRequestParameter对匹配上的请求添加参数
AddResponseHeader对从网关返回的响应添加Header

 

4.2 常见场景

  • 请求鉴权:如果没有访问权限,直接进行拦截
  • 异常处理:记录异常日志
  • 服务调用时长统计

 

4.3 过滤器配置说明

Gateway有两种过滤器

局部过滤器:只作用在当前配置的路由上,上面我们配置的路由前缀过滤器就是局部过滤器
全局过滤器:作用在所有路由上。

 

4.4 全局过滤器配置演示

全局配置过滤器AddResponseHeader

spring:
  cloud:
    gateway:
     # 配置全局默认过滤器
      default-filters:
      # 往响应过滤器中加入信息
        - AddResponseHeader=key1,value1

测试

在浏览器中可以看到响应头

image-20220320183325636

Spring Cloud微服务笔记七(Gateway网关) 概述 在Spring Cloud微服务中有一个很重要的组件就是网关,在开始的1.x版本中都是采用的Zuul网关,但在2.x版本中,由于Zuul的跳票,Spring Cloud自己研发了Zuul的替代版,也就是Gateway。 Gateway是在Spring 生态系统之上构建的API网关,旨在提供一种简单而有效的方式来对API进行路由,目标是提供统一的路由方式,且基于Filter链的方式提供了网关的基本功能,例如:安全、监控/指标和限流。 官网地址:传送门 **作用:**反向代理、权健、流量控制、熔断、日志监 阅读详情

相关推荐

微服务网关 Spring Cloud Gateway

API网关方式的核心要点是,所有的客户端和消费端都通过统一的网关接入微服务,在网关层处理所有的非业务功能。现在Spring Cloud中引用的还是Zuul 1.x版本,而这个版本是基于过滤器的,是阻塞IO,不支持长连接。执行所有的“pre”过滤逻辑,然后发出代理请求,最后执行“post”过滤逻辑。像Nginx这类网关,性能肯定是没得说,它适合做那种门户网关,是作为整个全局的网关,是对外的,处于最外层的;优先级最高的过滤器将会是“pre”阶段中的第一个过滤器,同时它也将是“post”阶段中的最后一个过滤器。

2401_86940371的博客 1180

Gateway路由的配置方式

路由是网关配置的基本组成模块,和Zuul的路由配置模块类似。一个Route模块由一个ID,一个目标URI,一组断言和一组过滤器定义。如果断言为真,则路由匹配,目标URI会被访问。

fwdwqdwq的博客 4752

微服务架构 --- Gateway网关的项目实战教学

数据在网络间传输,从一个网络传输到另一网络时就需要经过网关来做数据的路由和转发以及数据安全的校验。

记得开心一点嘛的博客 1922

Gateway网关动态路由配置(YAML格式 + JSON格式)

在我们开发微服务系统时,Gateway是必不可少的一个组件,我们可以通过Gateway来转发用户进行的请求,这样就可以隐藏具体系统的信息。YAMLroutes其中第二种和第三种都可以结合Nacos实现动态路由,主要看开发者怎么选择。第二种就是结合Nacos的配置中心,将routes参数下的数据放入到nacos中,我这里使用第三种进行展示,用JSON的格式配置路由信息。

qq_45515182的博客 6011

微服务网关Gateway和搭建

微服务网关Gateway 1.微服务网关概述 不同的微服务一般会有不同的网络地址,而外部客户端可能需要调用多个服务的接口才能完成一个业务需求,如果让客户端直接与各个微服务通信,会有以下的问题: 客户端会多次请求不同的微服务,增加了客户端的复杂性 存在跨域请求,在一定场景下处理相对复杂 认证复杂,每个服务都需要独立认证 难以重构,随着项目的迭代,可能需要重新划分微服务。例如,可能将多个服务合并成一个或者将一个服务拆分成多个。如果客户端直接与微服务通信,那么重构将会很难实施 以上这些问题可以借助网关

weixin_60668060的博客 904

Eureka上集成Spring Cloud 微服务网关 gateway

API 网关是一个搭建在客户端和微服务之间的服务,我们可以在 API 网关中处理一些非业务功能的逻辑,例如权限验证、监控、缓存、请求路由等。基于上一章节的内容,已经集成了Spring Cloud Netflix微服务组件。其中服务发现、注册组件:Eureka,服务远程调用、负载均衡组件:OpenFeign。本章节在DNS、Nginx层之后加入网关层,通过Nginx + GateWay 去访问服务。网关层可以做路由、限流、权限验证、请求过滤等操作。

Java 技术专栏,从入门到精通,熟悉企业级开发 3万+

SpringCloud - Spring Cloud 之 Gateway网关,Route路由,Predicate 谓词/断言,Filter 过滤器(十三)

SpringCloud - Spring Cloud 之 Gateway网关(十三)_MinggeQingchun的博客-优快云博客 一、路由配置

MinggeQingchun的博客 9688

微服务网关总结之 —— Gateway

前言 在上一篇我们聊了下zuul作为微服务网关的简单使用,本节继续探讨一下微服务中的另一个网关Gateway 为什么使用Gateway 既然zuul已经提供了很强大而且灵活的网关功能了,为什么还要考虑Gateway呢?这个问题成为很多技术选型者的苦恼,其实这个很好解释,Gateway作为后出来的新一代网关,在功能吸收了zuul的基础上,底层做了更多的优化,并扩展了zuul的功能,最为核心的是,Gateway的底层通信采用了异步非阻塞的netty,相比目前的zuul的1.X版本,这个优势是明显的,可能因为这一

congge 1909

微服务--Gateway网关

Zuul是Spring Cloud早期版本中广泛使用的网关组件,它基于Netflix Zuul构建。Zuul提供了路由、负载均衡、容错、安全性等多种功能,是微服务架构中API网关的常用选择之一。然而,需要注意的是,随着Spring Cloud的发展,Zuul逐渐进入维护模式,Spring Cloud官方推荐使用Spring Cloud Gateway作为替代方案。

weixin_51933701的博客 3395

汽车电子电气架构演进:从分布式ECU到域集中与中央计算

汽车电子电气架构(EEA)是整车电子系统的顶层设计框架,定义了计算、通信、供电等核心要素的组织方式。其演进遵循从分布式到集中式的技术路径,旨在解决传统架构下ECU数量膨胀带来的成本、复杂度和协同难题。通过域控制器(DCU)整合功能域,以及向中央计算+区域控制架构发展,实现了硬件资源池化、软硬件解耦与高速通信。这一变革的核心技术价值在于提升算力利用率、简化线束布局、支持软件定义汽车(SDV)与持续OTA升级。在智能电动汽车时代,新架构为智能座舱、自动驾驶等复杂应用提供了可扩展的平台基础,推动了汽车产业从硬件导

weixin_30326741的博客 387

打造会自主学习的 AI 助手:OpenClaw 记忆系统完全指南

这不是科幻,这是我正在使用的系统。我的 AI 助手「小琳」已经运行了一段时间,积累了大量的知识和经验,而且还在不断学习成长。心跳(Heartbeat)是 OpenClaw 的定时轮询机制,可以让 AI 主动做一些事情。你有没有遇到过这样的困扰:每次和 AI 对话,它都像失忆了一样,之前聊过的内容完全不记得?设置定时任务:每天早上 8 点,查询天气和热点新闻,通过钉钉推送给我。让你的 AI 助手拥有持久记忆,能够自主学习、总结经验、不断成长。这不仅仅是一个「能记住事情的 AI」,而是一个。

Honmaple的博客 1634

微服务网关之Gateway

什么是SpringCloud GatewaySpring官方出品,基于Spring5+Reactor技术开发的网关性能强劲,基于Reactor+WebFlux,功能多样基于springboot2.x,可以直接jar包方式运行。

2302_76363587的博客 1421

全面分析总结解决Could not transfer artifact org.apache.maven.plugins等此类问题的方法

全面分析总结解决Could not transfer artifact org.apache.maven.plugins,Could not transfer artifact xxx from/to xxx等此类问题的方法

ccjjjjdff的博客 1万+

微服务组件详解——gateway网关

微服务组件详解——gateway网关。网关是微服务项目的唯一入口反向代理:直接访问网关,网关来决定访问哪个微服务项目鉴权:访问网关的时候可以加上token,用来鉴权流量控制 :这个后来都用sentenal做熔断日志监控在启动类添加如下代码, KeyResolver 用于计算某一个类型的限流的KEY也就是说,可以通过KeyResolver 来指定限流的Key。//定义一个KeyResolver@Bean@Overridereturn。

qq_62859013的博客 1604

MT5策略如何设置回测结果才能最接近实盘

摘要:在MT5回测中,选择"每笔分笔报价"模式最接近实盘交易,因其使用真实Tick数据模拟价格波动、点差和滑点。关键设置包括:下载高质量历史数据、合理设定点差和滑点、使用正常回测速度。该模式能准确测试挂单、止盈止损等策略,虽然速度较慢但结果最可靠,避免其他模式造成的失真,是评估交易策略表现的最佳选择。(149字)

weixin_38915451的博客 1879

Visual Studio 2022调试Godot 4 C#项目全攻略:从环境配置到断点调试

本文详细介绍了如何配置Visual Studio 2022以高效调试Godot 4 C#项目。从环境搭建、外部编辑器设置到两种核心调试模式(附加到进程与启动配置)的实战指南,帮助开发者构建无缝的工业级工作流,解决编码乱码、断点失效等常见问题,大幅提升开发与问题排查效率。

bush的博客 391

微服务网关Spring Gateway

微服务Spring cloud 的网关gateWay的基本介绍

愿你我都能实现自己的梦想 885

SAP ABAP CDS View 里的日期函数

摘要:本文系统介绍了ABAP CDS日期函数在企业级应用中的关键作用,包括账龄计算、合同续期等业务场景。重点解析了DATS_IS_VALID、DATS_DAYS_BETWEEN等核心函数的语义和使用边界,特别强调on_error四种异常处理策略的选择逻辑。针对系统日期获取,对比了经典CDS的参数注入和View Entity会话变量两种方式。文章还提供了完整可运行的示例代码(包含CDS视图和ABAP程序),帮助开发者快速验证不同版本下的函数行为差异,确保在实际项目中正确应用这些日期处理函数。(149字)

2007 年 ~ 2025 年,深耕 SAP 技术 18 年 380

SpringCloud微服务网关Gateway

网关就是对所有微服务作统一的入口,它封装了应用程序的内部结构,为客户端提供统一服务,一些与业务本身功能无关的公共逻辑可以在这里实现,诸如认证、鉴权、监控、路由转发等等。没有网关时客户端调用微服务的情况如下这样的架构,会存在着诸多的问题:1、客户端多次请求不同的微服务,增加客户端代码或配置编写的复杂性2、认证复杂,每个服务都需要独立认证。3、存在跨域请求,在一定场景下处理相对复杂。

T_Ghost的博客 1303

【图像处理】德里奇( Deriche)边缘检测器

Deriche边缘检测,同canny算法齐名,因此,知道canny原理,也有必要知道德里奇的检测原理。本篇专门针对德里奇算法展开讨论。

gongdiwudu的专栏 8683

飞牛NAS1.1.19更新后SSH连不上?两步快速恢复连接

飞牛NAS1.1.19版本更新后SSH无法连接😟,实则是官方安全策略升级默认关闭了该服务,本文分享两步实操配置恢复SSH连接💻,还同步了官方的设备安全配置建议,帮助用户兼顾使用与设备防护🔒。

XiaoqiangClub的博客 2105

Spring Cloud Gateway——(一)微服务网关搭建以及微服务网关跨域

微服务网关微服务搭建

Zack_tzh的博客 4万+

深度学习工具包 DeepLearningToolbox

深度学习工具包Deprecation notice.-----This toolbox is outdated and no longer maintained.There are much better tools available for deep learning than this toolbox, e.g. [Theano](http://deeplearning.net/software/theano/), [torch](http://torch.ch/) or [tensorflow](http://www.tensorflow.org/)I would suggest you use one of the tools mentioned above rather than use this toolbox.Best, Rasmus.DeepLearnToolbox================A Matlab toolbox for Deep Learning.Deep Learning is a new subfield of machine learning that focuses on learning deep hierarchical models of data.It is inspired by the human brain's apparent deep (layered, hierarchical) architecture.A good overview of the theory of Deep Learning theory is[Learning Deep Architectures for AI](http://www.iro.umontreal.ca/~bengioy/papers/ftml_book.pdf)For a more informal introduction, see the following videos by Geoffrey Hinton and Andrew Ng.* [The Next Generation of Neural Networks](http://www.youtube.com/watch?v=AyzOUbkUf3M) (Hinton, 2007)* [Recent Developments in Deep Learning](http://www.youtube.com/watch?v=VdIURAu1-aU) (Hinton, 2010)* [Unsupervised Feature Learning and Deep Learning](http://www.youtube.com/watch?v=ZmNOAtZIgIk) (Ng, 2011)If you use this toolbox in your research please cite [Prediction as a candidate for learning deep hierarchical models of data](http://www2.imm.dtu.dk/pubdb/views/publication_details.php?id=6284)```@MASTERSTHESIS\{IMM2012-06284, author = "R. B. Palm", title = "Prediction as a candidate for learning deep hierarchical models of data", year = "2012",}```Contact: rasmusbergpalm at gmail dot comDirectories included in the toolbox-----------------------------------`NN/` - A library for Feedforward Backpropagation Neural Networks`CNN/` - A library for Convolutional Neural Networks`DBN/` - A library for Deep Belief Networks`SAE/` - A library for Stacked Auto-Encoders`CAE/` - A library for Convolutional Auto-Encoders`util/` - Utility functions used by the libraries`data/` - Data used by the examples`tests/` - unit tests to verify toolbox is workingFor references on each library check REFS.mdSetup-----1. Download.2. addpath(genpath('DeepLearnToolbox'));Example: Deep Belief Network---------------------```matlabfunction test_example_DBNload mnist_uint8;train_x = double(train_x) / 255;test_x = double(test_x) / 255;train_y = double(train_y);test_y = double(test_y);%% ex1 train a 100 hidden unit RBM and visualize its weightsrand('state',0)dbn.sizes = [100];opts.numepochs = 1;opts.batchsize = 100;opts.momentum = 0;opts.alpha = 1;dbn = dbnsetup(dbn, train_x, opts);dbn = dbntrain(dbn, train_x, opts);figure; visualize(dbn.rbm{1}.W'); % Visualize the RBM weights%% ex2 train a 100-100 hidden unit DBN and use its weights to initialize a NNrand('state',0)%train dbndbn.sizes = [100 100];opts.numepochs = 1;opts.batchsize = 100;opts.momentum = 0;opts.alpha = 1;dbn = dbnsetup(dbn, train_x, opts);dbn = dbntrain(dbn, train_x, opts);%unfold dbn to nnnn = dbnunfoldtonn(dbn, 10);nn.activation_function = 'sigm';%train nnopts.numepochs = 1;opts.batchsize = 100;nn = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.10, 'Too big error');```Example: Stacked Auto-Encoders---------------------```matlabfunction test_example_SAEload mnist_uint8;train_x = double(train_x)/255;test_x = double(test_x)/255;train_y = double(train_y);test_y = double(test_y);%% ex1 train a 100 hidden unit SDAE and use it to initialize a FFNN% Setup and train a stacked denoising autoencoder (SDAE)rand('state',0)sae = saesetup([784 100]);sae.ae{1}.activation_function = 'sigm';sae.ae{1}.learningRate = 1;sae.ae{1}.inputZeroMaskedFraction = 0.5;opts.numepochs = 1;opts.batchsize = 100;sae = saetrain(sae, train_x, opts);visualize(sae.ae{1}.W{1}(:,2:end)')% Use the SDAE to initialize a FFNNnn = nnsetup([784 100 10]);nn.activation_function = 'sigm';nn.learningRate = 1;nn.W{1} = sae.ae{1}.W{1};% Train the FFNNopts.numepochs = 1;opts.batchsize = 100;nn = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.16, 'Too big error');```Example: Convolutional Neural Nets---------------------```matlabfunction test_example_CNNload mnist_uint8;train_x = double(reshape(train_x',28,28,60000))/255;test_x = double(reshape(test_x',28,28,10000))/255;train_y = double(train_y');test_y = double(test_y');%% ex1 Train a 6c-2s-12c-2s Convolutional neural network %will run 1 epoch in about 200 second and get around 11% error. %With 100 epochs you'll get around 1.2% errorrand('state',0)cnn.layers = { struct('type', 'i') %input layer struct('type', 'c', 'outputmaps', 6, 'kernelsize', 5) %convolution layer struct('type', 's', 'scale', 2) %sub sampling layer struct('type', 'c', 'outputmaps', 12, 'kernelsize', 5) %convolution layer struct('type', 's', 'scale', 2) %subsampling layer};cnn = cnnsetup(cnn, train_x, train_y);opts.alpha = 1;opts.batchsize = 50;opts.numepochs = 1;cnn = cnntrain(cnn, train_x, train_y, opts);[er, bad] = cnntest(cnn, test_x, test_y);%plot mean squared errorfigure; plot(cnn.rL);assert(er<0.12, 'Too big error');```Example: Neural Networks---------------------```matlabfunction test_example_NNload mnist_uint8;train_x = double(train_x) / 255;test_x = double(test_x) / 255;train_y = double(train_y);test_y = double(test_y);% normalize[train_x, mu, sigma] = zscore(train_x);test_x = normalize(test_x, mu, sigma);%% ex1 vanilla neural netrand('state',0)nn = nnsetup([784 100 10]);opts.numepochs = 1; % Number of full sweeps through dataopts.batchsize = 100; % Take a mean gradient step over this many samples[nn, L] = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.08, 'Too big error');%% ex2 neural net with L2 weight decayrand('state',0)nn = nnsetup([784 100 10]);nn.weightPenaltyL2 = 1e-4; % L2 weight decayopts.numepochs = 1; % Number of full sweeps through dataopts.batchsize = 100; % Take a mean gradient step over this many samplesnn = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.1, 'Too big error');%% ex3 neural net with dropoutrand('state',0)nn = nnsetup([784 100 10]);nn.dropoutFraction = 0.5; % Dropout fraction opts.numepochs = 1; % Number of full sweeps through dataopts.batchsize = 100; % Take a mean gradient step over this many samplesnn = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.1, 'Too big error');%% ex4 neural net with sigmoid activation functionrand('state',0)nn = nnsetup([784 100 10]);nn.activation_function = 'sigm'; % Sigmoid activation functionnn.learningRate = 1; % Sigm require a lower learning rateopts.numepochs = 1; % Number of full sweeps through dataopts.batchsize = 100; % Take a mean gradient step over this many samplesnn = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.1, 'Too big error');%% ex5 plotting functionalityrand('state',0)nn = nnsetup([784 20 10]);opts.numepochs = 5; % Number of full sweeps through datann.output = 'softmax'; % use softmax outputopts.batchsize = 1000; % Take a mean gradient step over this many samplesopts.plot = 1; % enable plottingnn = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.1, 'Too big error');%% ex6 neural net with sigmoid activation and plotting of validation and training error% split training data into training and validation datavx = train_x(1:10000,:);tx = train_x(10001:end,:);vy = train_y(1:10000,:);ty = train_y(10001:end,:);rand('state',0)nn = nnsetup([784 20 10]); nn.output = 'softmax'; % use softmax outputopts.numepochs = 5; % Number of full sweeps through dataopts.batchsize = 1000; % Take a mean gradient step over this many samplesopts.plot = 1; % enable plottingnn = nntrain(nn, tx, ty, opts, vx, vy); % nntrain takes validation set as last two arguments (optionally)[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.1, 'Too big error');```[![Bitdeli Badge](https://d2weczhvl823v0.cloudfront.net/rasmusbergpalm/deeplearntoolbox/trend.png)](https://bitdeli.com/free "Bitdeli Badge")

微服务架构的Gateway网关设计

视频号2023年度优秀创作者,互联网大厂P8技术专家,Spring Cloud Alibaba微服务架构实战派(上下册)和RocketMQ消息中间件实战派(上下册)的作者,资深架构师,技术负责人,极客时间训练营讲师,四维口袋KVP最具价值技术专家,技术领域专家团成员,2021电子工业出版社年度优秀作者,获得2023电子工业出版技术成长领路人称号。

huxian1234的专栏 1557

假人有限元模型

假人模型,车辆碰撞假人有限元模型,适合做乘员安全的研究者利用

霍尼韦尔SoftMaster使用说明

霍尼韦尔SoftMaster使用说明

SpringCloud 微服务网关Gateway介绍及简单路由配置

概述:什么是微服务网关?为了解决用户客户端在调用微服务系统中的多个消费者工程接口时,需要维护非常多的消费者应用接口地址等信息,以及可能存在不同应用见的调用跨域等问题,微服务网关组件随即出现。网关作为用户客户端和微服务接口之间的一个统一路由及其他功能的组件,方便了用户客户端请求接口时不用去关注不同接口的地址路径等。只需要统一调用网关的服务即可。微服务网关为一个服务器服务,是系统对外的唯一入口。网关可以提供身份验证、监控、负载均衡、缓存、请求分片与管理、等功能。 一、Gateway 简介 微服务网关比较

liuhenghui5201的专栏 1万+

jdk-8u144-linux-x64.tar.gz.

该资源为搭建Linux系统Java环境用,资源的后缀为tar.gz格式的压缩包

Dubbo结合Gateway实现微服务网关

Dubbo结合Gateway实现微服务网关 前言 最近,我发布了Dubbo Demo项目以及Gateway网关的博客,于是奇思妙想到能不能将两者结合起来呢?首先我们可以在Dubbo的官网中看了开发者文档,它推荐使用的网关只有三种Kong、Dubbo Proxy以及Zuul,而GateWay被认为是Zuul的替代品,所以从理论上是完全可行,所以来吧,展示! Nacos安装以及其使用可参考我的博客:Nacos服务治理中心和配置中心 Gateway安装及使用可参考我的博客:微服务网关-Gateway 正文 网关模

蹊源的奇思妙想的博客 2万+

微服务网关实战——Spring Cloud Gateway

导读 作为Netflix Zuul的替代者,Spring Cloud Gateway是一款非常实用的微服务网关,在Spring Cloud微服务架构体系中发挥非常大的作用。本文对Spring Cloud Gateway常见使用场景进行了梳理,希望对微服务开发人员提供一些帮助。 微服务网关SpringCloudGateway 1.概述 Spring cloud gateway是...

BoCloud博云 7万+
上一篇: MySQL性能优化
下一篇: mysql性能调优之查询优化
评论
成就一亿技术人!
拼手气红包6.0元
还能输入1000个字符
 
 条评论被折叠 查看
添加红包

请填写红包祝福语或标题

个

红包个数最小为10个

元

红包金额最低5元

当前余额3.43元 前往充值 >
需支付:10.00元
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付元
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值