Spring Boot Remove Whitelabel Error Page -
i'm trying remove white label error page, i've done created controller mapping "/error",
@restcontroller public class indexcontroller { @requestmapping(value = "/error") public string error() { return "error handling"; } }
but i"m getting error.
exception in thread "awt-eventqueue-0" org.springframework.beans.factory.beancreationexception: error creating bean name 'requestmappinghandlermapping' defined in class path resource [org/springframework/web/servlet/config/annotation/delegatingwebmvcconfiguration.class]: invocation of init method failed; nested exception java.lang.illegalstateexception: ambiguous mapping found. cannot map 'basicerrorcontroller' bean method public org.springframework.http.responseentity<java.util.map<java.lang.string, java.lang.object>> org.springframework.boot.autoconfigure.web.basicerrorcontroller.error(javax.servlet.http.httpservletr equest) {[/error],methods=[],params=[],headers=[],consumes=[],produces=[],custom=[]}: there 'indexcontroller' bean method
don't know whether i'm doing wrong. please advice.
edit:
already added error.whitelabel.enabled=false
application.properties file, still getting same error
you need change code following:
@restcontroller public class indexcontroller implements errorcontroller{ private static final string path = "/error"; @requestmapping(value = path) public string error() { return "error handling"; } @override public string geterrorpath() { return path; } }
your code did not work, because spring boot automatically registers basicerrorcontroller
spring bean when have not specified implementation of errorcontroller
.
to see fact navigate errormvcautoconfiguration.basicerrorcontroller
here.
Comments
Post a Comment