java
Is it possible to disable Spring Boot's autoexception handling from application.properties
Is it possible to disable Spring Boot's autoexception handling from application.properties? I am trying to disable Spring Boots general exception handling without renaming error.html while coding and turn it on at production from application.properties. I've found the following from Spring documentation: At start-up, Spring Boot tries to find a mapping for /error. By convention, a URL ending in /error maps to a logical view of the same name: error. In the demo application this view maps in turn to the error.html Thymeleaf template. (If using JSP, it would map to error.jsp according to the setup of your InternalResourceViewResolver). If no mapping from /error to a View can be found, Spring Boot defines its own fall-back error page - the so-called “Whitelabel Error Page” (a minimal page with just the HTTP status information and any error details, such as the message from an uncaught exception). If you rename the error.html template to, say, error2.html then restart, you will see it being used. And also I tried the following properties which didn't work: server.error.path=/somewrongurl server.error.whitelabel.enabled=false
Add following lines into your application.properties file spring.mvc.throw-exception-if-no-handler-found=true spring.resources.add-mappings=false And define your own Exception Controller to catch all related exceptions like #ControllerAdvice public class ExceptionController { #ExceptionHandler(value = Exception.class) public ResponseEntity<?> handleException(Exception e) { //handle your exception } }
Related Links
Eclipse running old programs, no main method
Data is not ordered correctly with pagination: Sql server and Hibernate 3.6.10
I want another class like main activity to receive data from bluetooth, am unable to switch to another activity
How to make a Repeating Alarm for API 23 , 19 And less
Calling a method in the while loop condition
Sikuli Jar is throwing error in remote machine while using ssh /Jenkins Asked
Compare String to a Regex
Java: remove a range of indices from a list
How to write XML code for width and heigh in Java
Java: properly closing sockets for multi threaded servers
JAX-RS (RestEasy) middleware: brokering client request
Adding Jsoup Jar to MapReduce
LibGDX: Drawing 50x50 tiles is very slow
Broadcast receiver register in on create of class extend from application
Selenium WebDriver tests sometimes doesn't find elements
builder pattern json deserialize