Spring Boot 请求分派的缓存未命中

rvpgvaaj  于 2024-01-06  发布在  Spring
关注(0)|答案(2)|浏览(229)

我目前使用的是Sping Boot updated version 3.2.0,并实现了SecurityFilterChain,运行应用程序后,我得到了以下消息:

  1. 2023-12-11T12:08:04.541+06:00 WARN 28000 --- [nio-8080-exec-1] o.s.w.s.h.HandlerMappingIntrospector : Cache miss for REQUEST dispatch to '/' (previous null). Performing CorsConfiguration lookup. This is logged once only at WARN level, and every time at TRACE.
  2. 2023-12-11T12:08:04.550+06:00 WARN 28000 --- [nio-8080-exec-1] o.s.w.s.h.HandlerMappingIntrospector : Cache miss for REQUEST dispatch to '/' (previous null). Performing MatchableHandlerMapping lookup. This is logged once only at WARN level, and every time at TRACE.

字符串
SecurityFilterChain的Code

  1. @Bean
  2. public SecurityFilterChain securityFilterChain(HttpSecurity http) throws Exception {
  3. http
  4. .authorizeHttpRequests((requests) -> requests
  5. .requestMatchers("/", "/Signup", "/css/**", "/js/**").permitAll()
  6. .anyRequest().authenticated()
  7. )
  8. .formLogin((form) -> form
  9. .loginPage("/Login")
  10. .permitAll()
  11. )
  12. .logout((logout) -> logout.permitAll())
  13. .formLogin((form) -> form.defaultSuccessUrl("/home", true));
  14. return http.build();
  15. }


任何想法为什么我得到这个消息.当我点击localhost:8080自动转到登录页面其罚款,但不会去注册页面,当我点击注册按钮,它只是重定向到登录页面.你能提供详细的工作过程,并解决这个问题.
I followed the official documentation to implement SecurityFilterChain
先谢谢你了。

lymnna71

lymnna711#

我只是在升级项目的Sping Boot 版本时遇到了这个问题。
这是一个带有Sping Boot 3.2.0的current issue。它应该用这个ticket修复。
在此期间,我们可以将日志记录级别更改为error:

  1. logging.level.org.springframework.web.servlet.handler.HandlerMappingIntrospector=ERROR

字符串

wmtdaxz3

wmtdaxz32#

在Sping Boot 版本3.2.0中,我看到在Sping Boot 应用程序中配置Security(主要与CORS相关)可能会导致多次调用(大约8到9次)HandlerMappingIntrospector 类的 getResultFor(HttpServletRequest请求) 方法。导致请求分派缓存未命中问题并影响性能,如此链接所示。
考虑将Sping Boot 版本升级到3.2.1以解决此问题。
升级之后,我观察到Spring不再调用上面提到的方法(基于我的测试,尽管我不能在高级别上确认)。

相关问题