SpringBoot代码方式禁用Druid Monitor

时间:2021-07-02 16:10:44   收藏:0   阅读:0

第一种方式:

@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 })

 

评论(0
© 2014 mamicode.com 版权所有 京ICP备13008772号-2  联系我们:gaon5@hotmail.com
迷上了代码!