我有一个Spring Boot
Web应用程序,我在ControllerAdvice
类中捕获我的自定义异常。问题是如果没有找到处理程序,Spring Boot
默认不抛出异常(它将json
发送回客户端)。
我想要的是在我的NoHandlerFoundException
课程中捕捉ControllerAdvice
。为了实现这一点,我明确配置了
spring.mvc.throw-exception-if-no-handler-found=true
spring.resources.add-mappings=false
这个技巧完成了工作,我现在可以捕获NoHandlerFoundException
,但它禁用Spring
来自动配置静态资源的路径。所以我的所有静态资源现在都不能用于客户端。我试图使用一个没有帮助的配置来解决这个问题
spring.resources.static-locations=classpath:/resources/static/
当使用Spring Boot
禁用自动配置时,有人可以建议如何在spring.resources.add-mappings=false
中映射静态资源吗?
谢谢!