http.exceptionHandler() 在 spring 6.2 中已弃用并删除

Obi*_*Obi 3 https spring-boot

我正在尝试在 Spring 6.1.2 中设置 HttpSecurity 并且需要向其中添加 jwtEntrypoint 但我发现

protected void configure(HttpSecurity http) throws Exception {
    http.cors().and().csrf().disable();
    http.exceptionHandling().authenticationEntryPoint(jwtAuthenticationEntryPoint);has been removed
Run Code Online (Sandbox Code Playgroud)

我尝试了 http.exceptionHandling().authenticationEntryPoint(jwtAuthenticationEntryPoint); 正如一些答案中所见,但它仍然不起作用

Obi*_*Obi 5

我找到了解决方案。显然 spring 已经在 spring 6.1 中删除了 http.exceptionHandling() 所以为了解决我所做的问题

  http.exceptionHandling((exception)-> exception.authenticationEntryPoint(jwtAuthenticationEntryPoint).accessDeniedPage("/error/accedd-denied"));
Run Code Online (Sandbox Code Playgroud)