Spring Boot Cloud ACTUATOR /刷新端点:例外:由于上下文已初始化,因此无法将过滤器添加到上下文/ ROOT

时间:2017-06-22 18:37:35

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

从ACTUATOR(/ Refresh)刷新spring boot云应用程序时出现以下异常。它运行在独立的tomcat服务器上。它使用的是SpringBootServletInitializer。 :

constructor (@Inject(DOCUMENT) private document: any, private titleService: Title){

    /**
     * get the <head> Element
     * @type {any}
     */
    this.dom = document;

    this.headElement = this.dom.getSelection('head');
    this.metaDescription = this.getOrCreateMetaElement('description');
    this.robots = this.getOrCreateMetaElement('robots');
}

1 个答案:

答案 0 :(得分:0)

Spring Boot Cloud ACTUATOR / restart endpoint:例外:当上下文已初始化时,无法将过滤器添加到上下文/ ROOT

以下4个过滤器产生了问题:errorPageFilter,metricsFilter,webRequestLoggingFilter,applicationContextIdFilter

以下是解决方案:

public class XXXSpringBootServletInitializer  extends SpringBootServletInitializer {
     @Override
     public WebApplicationContext createRootApplicationContext(ServletContext servletContext) {
          // Disable errorPageFilter
          setRegisterErrorPageFilter(false);
          // Disable metricsFilter
          System.setProperty("endpoints.metrics.filter.enabled", "false");
          // Disable applicationContextIdFilter
          System.setProperty("management.addApplicationContextHeader", "false");
          WebApplicationContext oWebApplicationContext = super.createRootApplicationContext(servletContext);    
          return oWebApplicationContext;
     }
}

禁用webRequestLoggingFilter:

@SpringBootApplication(exclude={TraceWebFilterAutoConfiguration.class})
public class SIGBootApplication {
    ........
}