SpringBoot代码方式禁用Druid Monitor

第一种方式:

@Configuration
public class DruidConfig {

    @Bean
    public ServletRegistrationBean druidServlet() {
        ServletRegistrationBean servletRegistrationBean = new ServletRegistrationBean();
        servletRegistrationBean.setServlet(new StatViewServlet());
        servletRegistrationBean.setEnabled(false);
        return servletRegistrationBean;
    }
}

第二种方式

启动类上加排除servlet,老项目担心影响别的功能,慎用

@SpringBootApplication(exclude = { DispatcherServletAutoConfiguration.class })

 

posted @ 2021-07-02 10:12  jiapeng  阅读(2134)  评论(0编辑  收藏  举报