007API Gateway Service Zuul

Source: Internet
Author: User

001. POM Configuration

Increased Eureka Client, Zuul dependency, and spring cloud dependency management compared to the normal spring boot project

<Dependencies>    <Dependency>        <groupId>Org.springframework.cloud</groupId>        <Artifactid>Spring-cloud-starter-eureka</Artifactid>    </Dependency>    <Dependency>        <groupId>Org.springframework.cloud</groupId>        <Artifactid>Spring-cloud-starter-zuul</Artifactid>    </Dependency></Dependencies><dependencymanagement>    <Dependencies>        <Dependency>            <groupId>Org.springframework.cloud</groupId>            <Artifactid>Spring-cloud-dependencies</Artifactid>            <version>${spring-cloud.version}</version>            <type>Pom</type>            <Scope>Import</Scope>        </Dependency>    </Dependencies></dependencymanagement>

002, enable to Zuul Proxy

@SpringBootApplication @enablezuulproxy     // Enable API Gateway  Public class apigatewayzuulapplication {    publicstaticvoid  main (string[] args) {        Springapplication.run (apigatewayzuulapplication. class , args);}    }

003, src/main/resources under the configuration file application.yml

Spring:  application:    name:api-gateway-zuulserver:  Port:5001eureka:  client:    serviceurl :      defaultzone:http://discovery:1000/eureka/

Steps to use:

A) Start the Eureka Server service Eureka-server

b) Start the Hello service Hello-service-provider (can start multiple)

c) Start Api-gateway-zuul Service

d) access to Hello service via Http://localhost:5001/hello-service-provider/hello

004. Custom Service Path

Zuul:  routes:    SayHello:                               # can write casually, on the Zuul above the only can, when the value here = Service-id, Service-id can not write. Path      :/sayhello/**                    # The path you want to map to      Service-id:hello-service-provider    # Eureka in Serviceid

The service of Hello Service can be accessed via Http://localhost:5001/sayhello/hello at this time

005, ignore the specified service does not proxy

Zuul:  Ignored-services:hello-service-provider

The Hello-service-provider service will not be proxied at this time

007API Gateway Service Zuul

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.