当前位置: 首页 > news >正文

给别人做ppt的网站网站到首页排名

给别人做ppt的网站,网站到首页排名,网站备份流程,网龙网络公司简介之前你如果要用spring cloud gateway ,就必须是webflux 的,也就是必须是异步响应式编程。不能和spring mvc 一起使用。现在spring cloud 新出了一个可以不用webflux的gateway。 具体使用mvc的gateway步骤如下 普通的Eureka Client的项目 如果你只是想测…

之前你如果要用spring cloud gateway ,就必须是webflux 的,也就是必须是异步响应式编程。不能和spring mvc 一起使用。现在spring cloud 新出了一个可以不用webflux的gateway。

具体使用mvc的gateway步骤如下

普通的Eureka Client的项目

如果你只是想测试一下gateway mvc,可以建一个普通的spring boot项目,然后写一个/test rest api就可以了。

application.yml

spring:application:name: eureka-clientcloud:compatibility-verifier:enabled: false
eureka:client:service-url:defaultZone: http://localhost:8761/eureka/instance:hostname: localhost
server:servlet:context-path: /eureka-clientport: 8080

TestController.java

@RestController
public class TestController {@RequestMapping(value = "/test", method = RequestMethod.GET)public String test() {return "test";}
}

EurekaClientApplication.java

@SpringBootApplication
@EnableDiscoveryClient
public class EurekaClientApplication {public static void main(String[] args) {SpringApplication.run(EurekaClientApplication.class, args);}
}

访问http://localhost:8080/eureka-client/test

Gateway MVC 的项目

在pom.xml加spring-cloud-starter-gateway-mvc 

    <parent><groupId>org.springframework.boot</groupId><artifactId>spring-boot-starter-parent</artifactId><version>3.2.4</version><relativePath/> <!-- lookup parent from repository --></parent><properties><java.version>17</java.version><spring-cloud.version>2023.0.0</spring-cloud.version></properties><dependencies><dependency><groupId>org.springframework.cloud</groupId><artifactId>spring-cloud-starter-gateway-mvc</artifactId></dependency></dependencies><dependencyManagement><dependencies><dependency><groupId>org.springframework.cloud</groupId><artifactId>spring-cloud-dependencies</artifactId><version>${spring-cloud.version}</version><type>pom</type><scope>import</scope></dependency></dependencies></dependencyManagement>

application.yml

spring:application:name: gateway-mvc
server:port: 8088

RouteConfiguration.java

package com.example.gateway;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.web.servlet.function.RouterFunction;
import org.springframework.web.servlet.function.ServerResponse;import static org.springframework.cloud.gateway.server.mvc.handler.GatewayRouterFunctions.route;
import static org.springframework.cloud.gateway.server.mvc.handler.HandlerFunctions.http;@Configuration
public class RouteConfiguration {@Beanpublic RouterFunction<ServerResponse> getRoute() {return route("simple_route").GET("/eureka-client/**", http("http://localhost:8080")).build();}
}

或者用配置文件的方式.application.yml

spring:cloud:gateway:mvc:routes:- id: simple_routeuri: http://localhost:8080predicates:- Path=/eureka-client/**

GatewayApplication.java

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

访问http://localhost:8080/eureka-client/test

如果你不想hardcode 你的hostname和端口,也可以用Eureka 的方式来获取hostname和端口号

    @Beanpublic RouterFunction<ServerResponse> gatewayRouterFunctionsAddReqHeader() {return route("api_route").GET("/eureka-client/**", http()).filter(lb("EUREKA-CLIENT")).build();}

Spring Cloud Gateway Server MVC :: Spring Cloud Gateway

http://www.mnyf.cn/news/52661.html

相关文章:

  • 上海红酒网站建设seo建站公司
  • 包包网站建设策划书百度快照怎么用
  • 自适应网站什么做微信软文范例100字
  • 网站建设aichengkejiseo在线优化技术
  • 网站建设分工表百度关键词搜索推广
  • 网站打不开 域名做解析宁波seo基础入门
  • 建立个网站湖南长沙seo
  • 泰州网站建设方案开发泽成杭州seo网站推广排名
  • 从事网站建设的职业chrome谷歌浏览器官方下载
  • 网站前台设计教程南宁seo排名外包
  • 做网站 需求百度统计流量研究院
  • 上海市网站seo公司合肥seo网络营销推广
  • 丰台路网站建设高端网站建设深圳
  • 网站排名不可有利就前百度云手机登录入口
  • 外贸b2c网站如何做推广怎样在百度上推广
  • 免费做橙光封面的网站百度自然排名优化
  • 云速建站与传统网站的区别淘宝流量助手平台
  • jsp做网站遇到的问题百度网页游戏排行榜
  • 齐齐哈尔做网站独立网站和平台网站
  • 网站开发推进计划表谷歌浏览器下载安装(手机安卓版)
  • 买了空间和域名 怎么做网站中央人民政府
  • 济南网站建设行知科技旺道seo推广系统怎么收费
  • 营销网站建站开发8大营销工具指的是哪些
  • 用ai怎么做网站网站怎么优化搜索
  • 做网站找模板去哪好十大搜索引擎排名
  • 优化师的工作内容绍兴seo优化
  • 开发网站需要什么技术2022seo网站推广排名
  • 下模板做网站企业培训内容有哪些
  • 高密做网站的公司网络营销出来可以干什么工作
  • 做se要明白网站广东免费网络推广软件