Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

http.exceptionHandler() deprecated and removed in spring 6.2

I am trying to set up HttpSecurity in Spring 6.1.2 and I need to add jwtEntrypoint to it but I discovered

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

I tried http.exceptionHandling().authenticationEntryPoint(jwtAuthenticationEntryPoint); as seen in some answers but it still doesnt work

like image 689
Obi Avatar asked Apr 18 '26 15:04

Obi


2 Answers

I found the solution. Apparently spring has removed http.exceptionHandling() in spring 6.1 so to solve the problem I did

  http.exceptionHandling((exception)-> exception.authenticationEntryPoint(jwtAuthenticationEntryPoint).accessDeniedPage("/error/accedd-denied"));
like image 162
Obi Avatar answered Apr 20 '26 17:04

Obi


If in Kotlin

.exceptionHandling {
     it.authenticationEntryPoint(jwtAuthenticationEntryPoint)
}
like image 30
achraf Avatar answered Apr 20 '26 18:04

achraf



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!