在SpringBoot项目中,希望在遇到异常时(比如404,或者代码中抛出的未知错误),能统一返回规定的格式(例如返回JSON格式的异常报错{"result": false, "message": "NullPonterException ..."}),而不是希望在所有的逻辑处理上加上监测异常。 application.properties下增加如下: server.error.whitelabel.enabled=false spring.mvc.throw-exception-if-no-handler-fou…