Spring Boot Actuator javax.servlet.ServletException:圆形视图路径[错误]

时间:2015-10-15 17:24:43

标签: spring spring-boot spring-boot-actuator

我已将Spring Boot Actuator添加到我的项目中并配置为:

#Spring Boot Actuator
management.contextPath: /actuator

另外,我在Spring Security中添加了以下规则:

.antMatchers("/actuator/health").permitAll()
.antMatchers("/actuator/**").hasAuthority("PERMISSION_READ_ACTUATOR_DATA")

现在,当我访问/actuator/health时,一切正常,但当我尝试访问例如/actuator/autoconfig和403 Forbidden(完全没问题!)时,我也会在控制台中收到以下异常:

javax.servlet.ServletException: Circular view path [error]: would dispatch back to the current handler URL [/error] again. Check your ViewResolver setup! (Hint: This may be the result of an unspecified view, due to default view name generation.)
    at org.springframework.web.servlet.view.InternalResourceView.prepareForRendering(InternalResourceView.java:205) ~[spring-webmvc-4.2.1.RELEASE.jar:4.2.1.RELEASE]
    at org.springframework.web.servlet.view.InternalResourceView.renderMergedOutputModel(InternalResourceView.java:145) ~[spring-webmvc-4.2.1.RELEASE.jar:4.2.1.RELEASE]
    at org.springframework.web.servlet.view.AbstractView.render(AbstractView.java:303) ~[spring-webmvc-4.2.1.RELEASE.jar:4.2.1.RELEASE]
    at org.springframework.web.servlet.DispatcherServlet.render(DispatcherServlet.java:1244) ~[spring-webmvc-4.2.1.RELEASE.jar:4.2.1.RELEASE]
    at org.springframework.web.servlet.DispatcherServlet.processDispatchResult(DispatcherServlet.java:1027) ~[spring-webmvc-4.2.1.RELEASE.jar:4.2.1.RELEASE]
    at org.springframework.web.servlet.DispatcherServlet.doDispatch(DispatcherServlet.java:971) ~[spring-webmvc-4.2.1.RELEASE.jar:4.2.1.RELEASE]
    at org.springframework.web.servlet.DispatcherServlet.doService(DispatcherServlet.java:893) ~[spring-webmvc-4.2.1.RELEASE.jar:4.2.1.RELEASE]
    at org.springframework.web.servlet.FrameworkServlet.processRequest(FrameworkServlet.java:970) ~[spring-webmvc-4.2.1.RELEASE.jar:4.2.1.RELEASE]
    at org.springframework.web.servlet.FrameworkServlet.doGet(FrameworkServlet.java:861) ~[spring-webmvc-4.2.1.RELEASE.jar:4.2.1.RELEASE]
    at javax.servlet.http.HttpServlet.service(HttpServlet.java:622) ~[tomcat-embed-core-8.0.26.jar:8.0.26]

如果没有我的控制台/日志轰炸而上面有例外,如何正确处理此异常?是否可以返回一些JSON错误而不是查找错误路径?

0 个答案:

没有答案