You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

31 lines
1.2 KiB

  1. package com.mdp;
  2. import com.alibaba.druid.support.http.StatViewServlet;
  3. import org.springframework.boot.web.servlet.ServletRegistrationBean;
  4. import org.springframework.context.annotation.Bean;
  5. import org.springframework.context.annotation.Configuration;
  6. /**
  7. * 要使用mdp平台功能必须 扫码com.mdp包
  8. * 一些默认公共配置
  9. */
  10. @Configuration
  11. public class DruidConfig {
  12. /**
  13. * @description 注册一个StatViewServlet,进行druid监控页面配置
  14. * @return servlet registration bean
  15. */
  16. @Bean
  17. public ServletRegistrationBean<StatViewServlet> druidStatViewServlet() {
  18. ServletRegistrationBean<StatViewServlet> registrationBean = new ServletRegistrationBean<>(new StatViewServlet(), "/druid/*");
  19. registrationBean.addInitParameter("allow", "127.0.0.1");// IP白名单 (没有配置或者为空,则允许所有访问)
  20. registrationBean.addInitParameter("deny", "");// IP黑名单 (存在共同时,deny优先于allow)
  21. registrationBean.addInitParameter("loginUsername", "root");
  22. registrationBean.addInitParameter("loginPassword", "1234");
  23. registrationBean.addInitParameter("resetEnable", "false");
  24. return registrationBean;
  25. }
  26. }