zoukankan      html  css  js  c++  java
  • spring cloud: zuul: 微网关-简单使用与路由配置

    spring cloud: 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>
    

      

    入口文件加入@EnableZuulProxy注解

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

      

    application.properties

    server.port = 8040
    #spring
    spring.application.name=spring-boot-zuul
    #localhost
    #user.userServicePath=http://localhost:7900/simple/
    #eureka
    eureka.client.healthcheck.enable=true
    eureka.client.serviceurl.defaultzone=http://localhost:8761/eureka
    eureka.instance.preferIpAddress=true #ip
    

      

    启动zuul服务,eureka服务,user服务

    访问:

    http://192.168.1.4:8040/spring-boot-movie-ribbon/movie/1

    http://192.168.1.4:8040/spring-boot-user/simple/3

    二。配置zuul路由

    application.properties

    zuul.routes.spring-boot-user=/user/**
    

      

    启动,访问

  • 相关阅读:
    Javascript
    Linux折腾
    arch linux 教程
    fedora 安装 网易云音乐
    angularJS
    vim以超级用户权限保存文件
    Laravel 安装
    nginx
    xargs 简单功能
    yum 安装 php5.6 和 mysql5.6
  • 原文地址:https://www.cnblogs.com/achengmu/p/9932444.html
Copyright © 2011-2022 走看看