package controllerexception;
import org.springframework.web.bind.annotation.ControllerAdvice;
import org.springframework.web.bind.annotation.ExceptionHandler;
@ControllerAdvice
public class ControllerException {
@ExceptionHandler(value = Exception.class)
public void exception(Exception e){
e.printStackTrace();
}
}
package controllerexception;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
@RestController
@RequestMapping(“/test”)
public class ControllerTest {
@RequestMapping("/value")
public void test(){
throw new NullPointerException();
}
}