在启动eureka,config,gateway,业务应用的时候,突然之间遇到一个很懵逼的问题。
通过网关访问业务应用居然报404错误,分析原因。
1:地址错误
检查地址:排除
2:端口错误:
检查端口:排除
3:检查gateway的路由规则和业务应用:
检查:排除。
后来去查看gateway的启动类
@EnableZuulServer
@EnableEurekaClient
@SpringBootApplication
public class GatewayApplication {
public static void main(String[] args) throws Exception {
SpringApplication.run(GatewayApplication.class, args);
}
}
一眼看过去发现真没什么错误,但是仔细查看才发现Zuul的响应的注解是有问题的,正确的配置如下:
@EnableZuulProxy
@EnableEurekaClient
@SpringBootApplication
public class GatewayApplication {
public static void main(String[] args) throws Exception {
SpringApplication.run(GatewayApplication.class, args);
}
}
应该使用注解:@EnableZuulProxy 而非 @EnableZuulServer