0

以下 URL 用于在 Spring Boot 2.5 中返回 200

http://localhost:8080//执行器/健康

升级到 2.6 后它不再工作并返回 404 Not Found

我发现了这个错误,因为项目的一些集成测试失败了(请求返回 404)。然后我注意到了双斜线,删除它后,问题就解决了。

我只是想了解哪个功能导致了这种新行为?

我多次阅读 2.6发行说明,但没有任何反应。

4

3 回答 3

0

问题是路径匹配策略已经改变。执行器路径模式不能被覆盖

spring.mvc.pathmatch.matching-strategy=ant-path-matcher

解决方案是手动修复包含双斜杠的 URL。

于 2022-02-01T15:30:14.493 回答
0

这可能是原因:PathPattern Based Path Matching Strategy for Spring MVC

将请求路径与注册的 Spring MVC 处理程序映射匹配的默认策略已从 AntPathMatcher 更改为 PathPatternParser。

使固定:

spring.mvc.pathmatch.matching-strategy=ant-path-matcher
于 2022-01-13T02:45:00.947 回答
0
  1. 你能用单斜杠访问执行器端点吗?像 http://localhost:8080/actuator/health

  2. 如果是,那么您是否为您的应用程序配置了弹簧安全性?有一个配置,您可以定义您的应用程序允许在 url 中使用连续斜杠的位置。

    @Bean
    HttpFirewall httpFirewall() {
        StrictHttpFirewall firewall = new StrictHttpFirewall();
        firewall.setAllowUrlEncodedDoubleSlash(true);
        return firewall;
    }
    
于 2022-01-06T13:45:59.120 回答