


<?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 https://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>com.cloud.zuul.demo</groupId>
<artifactId>springcloud-zuul-demo</artifactId>
<version>0.0.1-SNAPSHOT</version>
<name>springcloud-zuul-demo</name>
<description>Demo project for Spring Cloud</description>
<properties>
<java.version>1.8</java.version>
</properties>
<dependencies>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-web</artifactId>
<version>2.2.1.RELEASE</version>
</dependency>
<dependency>
<groupId>org.springframework.cloud</groupId>
<artifactId>spring-cloud-starter-netflix-zuul</artifactId>
<version>2.2.1.RELEASE</version>
</dependency>
<!--zuul网关限流保护-->
<dependency>
<groupId>com.marcosbarbero.cloud</groupId>
<artifactId>spring-cloud-zuul-ratelimit</artifactId>
<version>2.2.1.RELEASE</version>
</dependency>
<!---->
<dependency>
<groupId>com.fasterxml.jackson.core</groupId>
<artifactId>jackson-core</artifactId>
<version>2.8.6</version>
</dependency>
<dependency>
<groupId>com.fasterxml.jackson.module</groupId>
<artifactId>jackson-module-jaxb-annotations</artifactId>
<version>2.8.6</version>
</dependency>
<!--健康检查依赖-->
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-actuator</artifactId>
<version>2.2.2.RELEASE</version>
</dependency>
<!--SpringCloud Consul的支持-->
<dependency>
<groupId>org.springframework.cloud</groupId>
<artifactId>spring-cloud-starter-consul-discovery</artifactId>
<version>2.2.1.RELEASE</version>
</dependency>
<!--Consul作为配置中心-->
<dependency>
<groupId>org.springframework.cloud</groupId>
<artifactId>spring-cloud-starter-consul-config</artifactId>
<version>2.2.1.RELEASE</version>
</dependency>
</dependencies>
<build>
<plugins>
<plugin>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-maven-plugin</artifactId>
</plugin>
</plugins>
</build>
</project>
server.port=8093
spring.application.name=feign-zuul
##注册中心访问地址和端口
spring.cloud.consul.host=localhost
spring.cloud.consul.port=8500
#注册到consul的服务名称
spring.cloud.consul.discovery.serviceName=${spring.application.name}
##配置路由映射
zuul.routes.usercenter-provider.path=/user/**
zuul.routes.usercenter-provider.serviceId=user-demo
package com.cloud.demo.zuul;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.cloud.client.discovery.EnableDiscoveryClient;
import org.springframework.cloud.netflix.zuul.EnableZuulProxy;
@SpringBootApplication//
@EnableDiscoveryClient//
@EnableZuulProxy//
public class SpringCloudZuulDomeApplication {
public static void main(String[] args) {
SpringApplication.run(SpringCloudZuulDomeApplication.class, args);
}
}
Whitelabel Error Page
This application has no explicit mapping for /error, so you are seeing this as a fallback.
Wed Aug 03 02:15:54 CST 2022
There was an unexpected error (type=Not Found, status=404).
No message available
问题原因:没有重新启动部署

http://localhost::8093/user/zuul/getHello

本文介绍了如何使用Spring Cloud Zuul构建一个网关应用,包括添加Web服务支持、集成Zuul限流保护和Consul配置管理。通过实例展示了如何配置路由映射、健康检查以及服务注册与发现。

480

被折叠的 条评论
为什么被折叠?



