【发布时间】:2018-09-17 16:57:29
【问题描述】:
我有一个非常简单的 Zuul 应用程序,我正在尝试运行它,只是为了让事情脱离实际,没有过滤器或类似的东西。我只是想为我想要测试的服务运行一个简单的传递。然而,Zuul 映射或路由似乎并未被创建,而且我的所有请求都得到了 404。
对于我的 zuul 边缘服务器,这是我的设置:
pom.xml:
<?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">
<modelVersion>4.0.0</modelVersion>
<groupId>com.example</groupId>
<artifactId>gzuul</artifactId>
<version>0.0.1-SNAPSHOT</version>
<packaging>jar</packaging>
<name>gzuul</name>
<description>Demo project for Spring Boot</description>
<parent>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-parent</artifactId>
<version>2.0.5.RELEASE</version>
<relativePath/> <!-- lookup parent from repository -->
</parent>
<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding>
<java.version>1.8</java.version>
<spring-cloud.version>Finchley.SR1</spring-cloud.version>
</properties>
<dependencies>
<dependency>
<groupId>org.springframework.cloud</groupId>
<artifactId>spring-cloud-starter-netflix-zuul</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-test</artifactId>
<scope>test</scope>
</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>
<build>
<plugins>
<plugin>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-maven-plugin</artifactId>
</plugin>
</plugins>
</build>
</project>
application.yml:
server:
port: 8084
management:
endpoints:
web:
exposure:
include: "*"
endpoint:
mappings:
enabled: true
routes:
enabled: true
zuul:
routes:
invoicing:
path: /invoicing/**
url: [url that I know works]/invoicing
还有我的“主”课:
package com.example.gzuul;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.cloud.netflix.zuul.EnableZuulProxy;
@EnableZuulProxy
@SpringBootApplication
public class GzuulApplication {
public static void main(String[] args) {
SpringApplication.run(GzuulApplication.class, args);
}
}
所以,是的,整体设置非常简单。
但是,每当我尝试访问像 localhost:8084/invoicing/[some stuff to pass through] 这样的 url 时,我都会收到以下错误:
2018-09-17 11:55:19.625 DEBUG 34902 --- [nio-8084-exec-1] s.b.a.e.w.s.WebMvcEndpointHandlerMapping : Looking up handler method for path /invoicing/v1/invoice/7900007809
2018-09-17 11:55:19.629 DEBUG 34902 --- [nio-8084-exec-1] s.b.a.e.w.s.WebMvcEndpointHandlerMapping : Did not find handler method for [/invoicing/v1/invoice/7900007809]
2018-09-17 11:55:19.629 DEBUG 34902 --- [nio-8084-exec-1] a.e.w.s.ControllerEndpointHandlerMapping : Looking up handler method for path /invoicing/v1/invoice/7900007809
2018-09-17 11:55:19.629 DEBUG 34902 --- [nio-8084-exec-1] a.e.w.s.ControllerEndpointHandlerMapping : Did not find handler method for [/invoicing/v1/invoice/7900007809]
此外,尝试访问 /actuator/routes 也会返回 404。
任何帮助将不胜感激,如果以上内容还不够,可以提供更多信息。
【问题讨论】:
-
当我没有
@EnableZuulProxy时,我得到了那个确切的错误。否则,一个相同的应用程序对我来说很好。你能分享一个可下载的样本吗?执行器不会工作,因为它不是依赖项。
标签: spring-boot spring-cloud netflix-zuul