zoukankan      html  css  js  c++  java
  • <Spring Cloud>入门六 Zuul

    1.Zuul

    2.操作

    2.1 pom

    <?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>spring-cloud-learning</artifactId>
            <groupId>org.org.maple</groupId>
            <version>0.0.1-SNAPSHOT</version>
        </parent>
        <modelVersion>4.0.0</modelVersion>
    
        <artifactId>ms-zuul-gateway-9527</artifactId>
    
        <dependencies>
            <dependency>
                <groupId>org.springframework.cloud</groupId>
                <artifactId>spring-cloud-starter-netflix-zuul</artifactId>
            </dependency>
            <dependency>
                <groupId>org.springframework.cloud</groupId>
                <artifactId>spring-cloud-starter-netflix-eureka-client</artifactId>
            </dependency>
            <dependency>
                <groupId>org.springframework.boot</groupId>
                <artifactId>spring-boot-starter-actuator</artifactId>
            </dependency>
            <dependency>
                <groupId>org.springframework.cloud</groupId>
                <artifactId>spring-cloud-starter-netflix-hystrix</artifactId>
            </dependency>
            <dependency>
                <groupId>org.springframework.cloud</groupId>
                <artifactId>spring-cloud-starter-netflix-hystrix-dashboard</artifactId>
            </dependency>
            <dependency>
                <groupId>org.springframework.boot</groupId>
                <artifactId>spring-boot-starter-web</artifactId>
            </dependency>
            <dependency>
                <groupId>org.org.maple</groupId>
                <artifactId>ms-common-api</artifactId>
                <version>0.0.1-SNAPSHOT</version>
            </dependency>
    
        </dependencies>
    
    
    </project>

    2.2  yml

    server:
      port: 9527
    spring:
      application:
        name: ms-zuul-gateway
    
    eureka:
      client:
        service-url:
          defaultZone: http://eureka-server01:8761/eureka/,http://eureka-server02:8762/eureka/
      instance:
        instance-id: gateway-9527
        prefer-ip-address: true
    
    info:
      app.name: spring-cloud-learning
      company.name: mapleins
      build.artifactId: $[project.artifactId]
      build.version: $[project.version]

    2.3 启动类

    package org.mape;
    
    import org.springframework.boot.SpringApplication;
    import org.springframework.boot.autoconfigure.SpringBootApplication;
    import org.springframework.cloud.netflix.zuul.EnableZuulProxy;
    
    /**
     * @author mapleins
     * @Date 2019-01-13 13:26
     * @Desc
     **/
    @SpringBootApplication
    @EnableZuulProxy
    public class App_Zuul_Gateway_9527 {
    
        public static void main(String[] args) {
            SpringApplication.run(App_Zuul_Gateway_9527.class,args);
        }
    }

    2.4 host文件

    2.5 访问

    直接访问

    通过网关访问

    2.6 重新配置

    zuul:
      prefix: /springcloud #添加统一前缀
      ignored-services: ms-provider-dept # 忽略真实地址 忽略所有的真实地址 使用 "*"
      # 相当于把微服务的名字换成了 新的名字
      routes:
        dept: # 随便写,起个名字
          serviceId: ms-provider-dept
          path: /mydept/**

  • 相关阅读:
    pytorch lstm crf 代码理解
    python sys.argv是什么?
    如何用简单易懂的例子解释条件随机场(CRF)模型?它和HMM有什么区别?
    jieba分词工具的使用方法
    手把手教你用Python实现自动特征工程
    命名实体识别视频51cto
    命名实体识别入门教程(必看)
    零基础入门--中文命名实体识别(BiLSTM+CRF模型,含代码)
    自然语言处理深度学习篇-BiLSTM文本挖掘实践 命名实体识别
    导航栏颜色
  • 原文地址:https://www.cnblogs.com/mapleins/p/10262439.html
Copyright © 2011-2022 走看看