• springcloud系列11 整合微服务网关zuul


    这个模块是一个独立的模块所以需要建立一个模块,

    首先引入:

    依赖pom.xml

    <?xml version="1.0" encoding="UTF-8"?>
    <project xmlns="http://maven.apache.org/POM/4.0.0"
             xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
             xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
        <parent>
            <artifactId>springcloud-parent</artifactId>
            <groupId>com.cxy</groupId>
            <version>0.0.1-SNAPSHOT</version>
        </parent>
        <modelVersion>4.0.0</modelVersion>
    
        <artifactId>springcloud-zuul</artifactId>
        <dependencies>
            <dependency>
                <groupId>org.springframework.cloud</groupId>
                <artifactId>spring-cloud-starter-netflix-eureka-client</artifactId>
            </dependency>
            <dependency>
                <groupId>org.springframework.cloud</groupId>
                <artifactId>spring-cloud-starter-netflix-zuul</artifactId>
            </dependency>
        </dependencies>
    
    </project>

    编写启动类:

    package com.cxy;
    
    import org.springframework.boot.SpringApplication;
    import org.springframework.boot.autoconfigure.SpringBootApplication;
    import org.springframework.cloud.netflix.zuul.EnableZuulProxy;
    
    /***
     * @ClassName: ZuulApplication
     * @Description:
     * @Auther: cxy
     * @Date: 2019/1/29:12:48
     * @version : V1.0
     */
    @SpringBootApplication
    @EnableZuulProxy
    public class ZuulApplication {
        public static void main(String[] args) {
            SpringApplication.run(ZuulApplication.class,args);
        }
    }

    编写yml文件:

    server:
      port: 8083
    spring:
      application:
        name: cxy-zuul-service
    eureka:
      client:
        service-url:
          defaultZone: http://admin:admin@127.0.0.1:8761/eureka/
      instance:
        prefer-ip-address: true
    zuul:
      routes:
        spring-person: #服务工程名字
          path: /person/** #配置url请求规则
          serviceId: cxy-person-service #服务名称
        spring-user:
          path: /user/**
          erviceId: cxy-user-service

    注意事项:

    二:

     访问体验:

  • 相关阅读:
    进行C# 编写发送邮箱,报错Error: need EHLO and AUTH first !
    vue使jsZip和FileSaver.js打包下载
    基于js或vue项目实现一次批量文件下载功能
    模块
    now 与 down 中的 ow 发音是否一样?
    __time64_t 解决了 2038 年问题,可是没解决 1969年问题
    MagickSetOption(mw, "jpeg:extent", "...kb"); 这个函数有时结果出乎意料
    解决Idea启动Spring Boot很慢的问题
    CAP原理和BASE思想和ACID模型
    java并发编程之Condition
  • 原文地址:https://www.cnblogs.com/xiufengchen/p/10333572.html
Copyright © 2020-2023  润新知