• SpringCloud-zuul


    服务名称:
    microservice-zuul-gateway-9527
    <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">
        <modelVersion>4.0.0</modelVersion>
    
        <parent>
            <groupId>com.atguigu.springcloud</groupId>
            <artifactId>microservicecloud</artifactId>
            <version>0.0.1-SNAPSHOT</version>
        </parent>
    
        <artifactId>microservice-zuul-gateway-9527</artifactId>
    
        <dependencies>
            <!-- zuul路由网关 -->
            <dependency>
                <groupId>org.springframework.cloud</groupId>
                <artifactId>spring-cloud-starter-zuul</artifactId>
            </dependency>
            <dependency>
                <groupId>org.springframework.cloud</groupId>
                <artifactId>spring-cloud-starter-eureka</artifactId>
            </dependency>
            <!-- actuator监控 -->
            <dependency>
                <groupId>org.springframework.boot</groupId>
                <artifactId>spring-boot-starter-actuator</artifactId>
            </dependency>
            <!-- hystrix容错 -->
            <dependency>
                <groupId>org.springframework.cloud</groupId>
                <artifactId>spring-cloud-starter-hystrix</artifactId>
            </dependency>
            <dependency>
                <groupId>org.springframework.cloud</groupId>
                <artifactId>spring-cloud-starter-config</artifactId>
            </dependency>
            <!-- 日常标配 -->
            <dependency>
                <groupId>com.atguigu.springcloud</groupId>
                <artifactId>microservicecloud-api</artifactId>
                <version>${project.version}</version>
            </dependency>
            <dependency>
                <groupId>org.springframework.boot</groupId>
                <artifactId>spring-boot-starter-jetty</artifactId>
            </dependency>
            <dependency>
                <groupId>org.springframework.boot</groupId>
                <artifactId>spring-boot-starter-web</artifactId>
            </dependency>
            <dependency>
                <groupId>org.springframework.boot</groupId>
                <artifactId>spring-boot-starter-test</artifactId>
            </dependency>
            <!-- 热部署插件 -->
            <dependency>
                <groupId>org.springframework</groupId>
                <artifactId>springloaded</artifactId>
            </dependency>
            <dependency>
                <groupId>org.springframework.boot</groupId>
                <artifactId>spring-boot-devtools</artifactId>
            </dependency>
        </dependencies>
    
    </project>

    yml配置文件:

    server: 
      port: 9527
     
    spring: 
      application:
        name: microservice-zuul-gateway
     
    eureka: 
      client: 
        service-url: 
          defaultZone: http://eureka7001.com:7001/eureka,http://eureka7002.com:7002/eureka,http://eureka7003.com:7003/eureka  
      instance:
        instance-id: gateway-9527.com
        prefer-ip-address: true 
     
     
    zuul: 
      #ignored-services: microservicecloud-dept
      prefix: /atguigu
      ignored-services: "*"
      routes: 
        mydept.serviceId: microservicecloud-dept
        mydept.path: /mydept/**
     
    info:
      app.name: atguigu-microcloud
      company.name: www.atguigu.com
      build.artifactId: $project.artifactId$
      build.version: $project.version$

    主启动类:

    package com.atguigu.springcloud;
    
    import org.springframework.boot.SpringApplication;
    import org.springframework.boot.autoconfigure.SpringBootApplication;
    import org.springframework.cloud.netflix.zuul.EnableZuulProxy;
    
    @SpringBootApplication
    @EnableZuulProxy
    public class Zuul_9527_StartSpringCloudApp
    {
        public static void main(String[] args)
        {
            SpringApplication.run(Zuul_9527_StartSpringCloudApp.class, args);
        }
    }

     

     

    想要不显示微服务地址:

    调整YML;

      结果:

     

    将原访问服务名称的方式忽略:

    方法:修改YML文件

     增加前缀:同样修改YML文件

  • 相关阅读:
    监听用户的访问的链接
    软件开发的流程
    PHP性能优化四(业务逻辑中使用场景)
    php性能优化三(PHP语言本身)
    php性能优化二(PHP配置php.ini)
    poj 1676
    计蒜客 蒜头君下棋
    计蒜客 划分整数
    计蒜客 蒜头君的数轴
    计蒜客 藏宝图
  • 原文地址:https://www.cnblogs.com/zqLoveSym/p/10846292.html
Copyright © 2020-2023  润新知