spring boot exception handling
package com.tutorialspoint.demo.exception;
import org.springframework.web.bind.annotation.ControllerAdvice;
@ControllerAdvice
public class ProductExceptionController {
}
spring boot exception handling
package com.tutorialspoint.demo.exception;
import org.springframework.web.bind.annotation.ControllerAdvice;
@ControllerAdvice
public class ProductExceptionController {
}
spring security controlleradvice
@Component("restAuthenticationEntryPoint")
public class RestAuthenticationEntryPoint implements AuthenticationEntryPoint{
public void commence(HttpServletRequest request, HttpServletResponse response, AuthenticationException authenticationException) throws IOException, ServletException {
response.setContentType("application/json");
response.setStatus(HttpServletResponse.SC_UNAUTHORIZED);
response.getOutputStream().println("{ \"error\": \"" + authenticationException.getMessage() + "\" }");
}
}
Copyright © 2021 Codeinu
Forgot your account's password or having trouble logging into your Account? Don't worry, we'll help you to get back your account. Enter your email address and we'll send you a recovery link to reset your password. If you are experiencing problems resetting your password contact us