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

How do I do this with string in Java?
Eclipse compile error with generics, but ok with maven/javac
Java Socket closing OutputStream
About the Java interface Cloneable
java.lang.ExceptionInInitializerError in MultiDex Android application
Getting file size from S3 bucket
Recursive function with already predefined prototype
How to convert expression “<<=1” in Java to Python [closed]
I cant do this Heapsort animation
Change the selected state of a JToggleButton (e.g. JCheckBox) without triggering its item listeners [duplicate]
Need String variable from class to equal the variable in another class, also ArrayList data to equal ArrayList data on another class
HttpResponse with special characters
How to test if a value is already in my HashMap while reading a file
Referencing Graphics objects
Easy way to serialize/deserialize public enums?
DataNucleus + JPA [ComposedIdKey]

Categories

HOME
ibm-bluemix
ionic-framework
bluetooth
clips
testng
proxy
magnific-popup
mediawiki
mockito
kde
tinymce
smarty
elm
indesign
add
primary-key
fancybox-3
user-input
export-to-csv
qt-creator
windows-azure-storage
openrefine
autoconf
jasonette
cloudhub
css-animations
microsoft-r
crosstab
webkitspeechrecognition
skia
bluestacks
react-chartjs
oracle-fusion-middleware
create-table
winrt-xaml-toolkit
pim
hexo
main
withings
occlusion
starteam
code-search-engine
android-fingerprint-api
graphenedb
awt
grid.mvc
http-live-streaming
nxlog
isbn
keydown
midl
mime
sencha-touch-2.3
segment
apple-news
auto-update
outlook-2013
hibernate-tools
filepicker
jlink
sage-one
diagnostics
pg-dump
typed-lambda-calculus
minimization
jquery-filter
passport-google-oauth
grails-tomcat-plugin
slicknav
bonobo
phishing
trash
multiple-regression
angstrom-linux
lua-5.1
design-by-contract
srand
icu4j
feedback
computer-algebra-systems
varargs
sailfish-os
vstest.console.exe
dundas
system.reflection
tablelayout
fluentautomation
jquery-layout
htmlcleaner
comexception
picturefill
ms-project-server-2010
dexterity
dataservice
easy-install
dataadapter
eventual-consistency
yui-compressor
sabredav
lcs
robotics-studio
specification-pattern
mt
cisco-jtapi
cascalog
enter
code-cleanup
xmemcached
rfc1123
oncheckedchanged
locate
coda-slider
gin
preference
bespin
user-friendly
sector
dbisam





Mobile Apps Dev
Database Users
javascript
java
csharp
php
android
MS Developer
developer works
python
ios
c
html
jquery
RDBMS discuss
Cloud Virtualization
Database Dev&Adm