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