Closed infoShare closed 9 months ago
Starting with Spring Framework 6.1 (which Boot 3.2.0 uses), NoResourceFoundException
is thrown if there's no handler. This exception is handled by your infoshare.springboot404.handler.GlobalExceptionHandler#globalExceptionHandler
and translated to a HTTP 500.
See here for more details: https://github.com/spring-projects/spring-framework/wiki/Upgrading-to-Spring-Framework-6.x#web-applications or this issue https://github.com/spring-projects/spring-framework/issues/29491.
Starting with Spring Framework 6.1 (which Boot 3.2.0 uses),
NoResourceFoundException
is thrown if there's no handler. This exception is handled by yourinfoshare.springboot404.handler.GlobalExceptionHandler#globalExceptionHandler
and translated to a HTTP 500.See here for more details: https://github.com/spring-projects/spring-framework/wiki/Upgrading-to-Spring-Framework-6.x#web-applications or this issue spring-projects/spring-framework#29491.
No any exceptions throwed under no any ExceptionHandler configed (version: 3.1.5).
I don't understand. What's the expected outcome and what does happen? Also Boot 3.1.5 doesn't use Spring Framework 6.1.0.
I have not configure any global ExceptionHandler, a json responsed like below and no any exception was threw on server sider:
{ "timestamp": "2023-12-15 09:11:15", "path": "/time", "status": 404, "error": "Not Found", "requestId": "8a3f3980-1" }
It should throw a exception and can be caught by global ExceptionHandler, then the response can be adapted to some customized content.
@BruceAn1978 So this is different from the issue reported here? The project provided by @infoShare has @ExceptionHandler
methods contributed by a controller advice. If this is a different problem, please create a new issue with a minimal sample application.
404 Not found behavior was changed during upgrade from 3.1.6 to 3.2.0.
Previous behavior 404 Not found error returned:
Current behavior: NoResourceFoundException thrown with message "No static resource api/method." thrown.
Here you can find small example: https://github.com/infoShare/code-examples/tree/main/spring-boot-404
Test ApiControllerWithProfileTest is passing on spring boot 3.1.6
but failing on spring boot 3.2.0: