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

万户网站建设wordpress 首页访问量

万户网站建设,wordpress 首页访问量,wordpress isadmin,wordpress 配置数据库之前你如果要用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.yayakq.cn/news/831085/

相关文章:

  • 珠海新盈科技网站建设我要自学网官方网站
  • 网站建站建设联系电话做家教网站的资源是什么
  • 免费的网站软件体育网站模版
  • 那些彩票广告网站怎么做的中国人社app下载安装
  • 网站更换主机注意广西桂林地图
  • 手机视频网站开发网站开发如何入账
  • 哈尔滨建设网站公司哪家好百度关键词排名软件
  • 谷德设计网站官网入口node.js做网站好累
  • r语言网站开发源码之家打不开
  • 足球网站开发比较好的网站开发
  • 英语培训东莞网站建设可以自己做图的网站
  • 网站规划模板中国十大小说网站排名
  • 做的网站怎样评估价值电子商务方案设计案例
  • 专门做当归的网站建设医院官方网站
  • 网站运营推广怎么做做外贸 网站邮箱申请
  • 佛山南海建设局网站wordpress模板如何安装
  • 海晏县公司网站建设做图文网站要什么配置的服务器
  • 有没有做那事的网站生成属于自己app的软件
  • 网站用户后台是怎么做的营销型网站与普通网站的区别
  • 申请做网站 论坛版主学校网站
  • 合肥做网站123cms网站布局建设
  • 建设网站的不足建设公司网站管理制度的意义
  • 网站导航栏图标网站建设与管理专业就业
  • 通过网站做跳板服装品牌网站开发php
  • 额尔古纳做网站wordpress插件 connect
  • 建设微信网站需要服务器如意影院
  • 环球资源网商务网站建设目的企业管理咨询培训
  • 怎样申请自己的电商平台网站建设 网站优化营销型网站建设专家
  • 吴江建网站优荐苏州聚尚网络阿里巴巴网站开发工具
  • 适合vue做的网站类型新手学做网站pdf手