SPRING CLOUD ZUUL 替换成 GATEWAY

application.properties

spring.cloud.gateway.routes[0].id=spring-cloud-server-xxx

spring.cloud.gateway.routes[0].uri=lb://spring-cloud-server-xxx

spring.cloud.gateway.routes[0].predicates[0]=Path=/xxx/**
#1 不包含xxx
spring.cloud.gateway.routes[0].filters[0]=StripPrefix=1

使用 gateway 排除 spring-boot-starter-web 的包

<exclusions>
    <exclusion>
        <dependency>
           <groupId>org.springframework.boot</groupId>
           <artifactId>spring-boot-starter-web</artifactId>
        </dependency>
    </exclusion>
</exclusions>

使用 gateway eureka 还要排除tomcat容器 因为gateway用的是netty框架 好像和tomcat冲突了,为什么不知道还没有细细研究,可能是 gateway自带了用netty开发的服务器吧

<!--使用 gateway  还要排除netflix-eureka中的tomcat容器 因为gateway用的是netty框架 ,好像和tomcat冲突了为什么不知道,还没有时间细细研究, 可能是 gateway自带了用netty开发的服务器吧 -->
<dependency>
    <groupId>org.springframework.cloud</groupId>
    <artifactId>spring-cloud-starter-gateway</artifactId>
</dependency>

<dependency>
    <groupId>org.springframework.cloud</groupId>
    <artifactId>spring-cloud-starter-netflix-eureka-server</artifactId>
    <exclusions>
        <exclusion>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-starter-tomcat</artifactId>
        </exclusion>
    </exclusions>
</dependency>
最后编辑于
©著作权归作者所有,转载或内容合作请联系作者
【社区内容提示】社区部分内容疑似由AI辅助生成,浏览时请结合常识与多方信息审慎甄别。
平台声明:文章内容(如有图片或视频亦包括在内)由作者上传并发布,文章内容仅代表作者本人观点,简书系信息发布平台,仅提供信息存储服务。

友情链接更多精彩内容