springcloud系列11 整合微服務網關zuul

這個模塊是一個獨立的模塊因此須要創建一個模塊,spring

 

首先引入:apache

依賴pom.xmlapp

<?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>

編寫啓動類:maven

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文件:url

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

注意事項:spa

二:.net

 訪問體驗:code

相關文章
相關標籤/搜索