18SpringCloud - 服务网关 zuul项目示例

    xiaoxiao2022-07-02  120

    新建项目spring-cloud-zuul-service

    添加依赖

    <dependency> <groupId>org.springframework.cloud</groupId> <artifactId>spring-cloud-starter-zuul</artifactId> </dependency>

    开启服务注册

    在程序的启动类 ZuulApplication通过 @EnableZuulProxy 开启 Zuul 服务网关

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

    添加配置

    配置文件 application.yml

    spring: application: name: zuul-service server: port: 9000 zuul: routes: blog: path: /ymq/** url: http://www.xxx.io/about
    最新回复(0)