英文:
Spring boot cloud gateway - always 404 except one endpoint
问题
以下是您要翻译的内容:
我只想让Spring Boot Cloud Gateway运行起来。
使用以下代码,在/get端点上获得了结果。
其他任何情况都返回404。因此,/test或者我添加的任何其他端点都返回404。
@SpringBootApplication
@RestController
@EnableConfigurationProperties(UriConfiguration.class)
public class ApigatewayApplication {
public static void main(String[] args) {
SpringApplication.run(ApigatewayApplication.class, args);
}
@Bean
public RouteLocator routes(RouteLocatorBuilder builder, UriConfiguration uriConfiguration){
return builder.routes()
.route(p -> p
.path("/get")
.filters(f -> f.addRequestHeader("Hello", "World"))
.uri(uriConfiguration.getTestUrl()))
.route(p -> p
.path("/test")
.filters(f -> f.addRequestHeader("Hello", "World"))
.uri(uriConfiguration.getTestUrl()))
.build();
}
}
我按照教程操作,但不知道为什么一个端点能正常工作,而其他端点却不能。
谢谢
英文:
I just want to get the Spring Boot Cloud Gateway running.
I get a result with the following Code with the /get endpoint.
anything else, returns 404. So /test or any other endpoint i add returns 404.
@SpringBootApplication
@RestController
@EnableConfigurationProperties(UriConfiguration.class)
public class ApigatewayApplication {
public static void main(String[] args) {
SpringApplication.run(ApigatewayApplication.class, args);
}
@Bean
public RouteLocator routes(RouteLocatorBuilder builder, UriConfiguration uriConfiguration){
return builder.routes()
.route(p -> p
.path("/get")
.filters(f -> f.addRequestHeader("Hello", "World"))
.uri(uriConfiguration.getTestUrl()))
.route(p -> p
.path("/test")
.filters(f -> f.addRequestHeader("Hello", "World"))
.uri(uriConfiguration.getTestUrl()))
.build();
}
}
I followed the tutorial but i have no idea why one endpoint is working and the others not
thank you
答案1
得分: 0
好的,看起来如果多个路由具有相同的目标URI,则会出现404错误...
英文:
Ok, it looks like if multiple routes have the same destination URI, you get a 404...
专注分享java语言的经验与见解,让所有开发者获益!
评论