commit
d678961a60
7 changed files with 3719 additions and 69 deletions
@ -0,0 +1,65 @@ |
|||||||
|
package net.mingsoft.config; |
||||||
|
|
||||||
|
import com.alibaba.druid.support.http.WebStatFilter; |
||||||
|
import com.alibaba.druid.support.spring.stat.DruidStatInterceptor; |
||||||
|
import org.springframework.aop.Advisor; |
||||||
|
import org.springframework.aop.support.DefaultPointcutAdvisor; |
||||||
|
import org.springframework.aop.support.JdkRegexpMethodPointcut; |
||||||
|
import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty; |
||||||
|
import org.springframework.boot.web.servlet.FilterRegistrationBean; |
||||||
|
import org.springframework.context.annotation.Bean; |
||||||
|
import org.springframework.context.annotation.Configuration; |
||||||
|
|
||||||
|
/** |
||||||
|
* @author by 铭飞开源团队 |
||||||
|
* @Description TODO |
||||||
|
* @date 2020/1/10 11:21 |
||||||
|
*/ |
||||||
|
@Configuration |
||||||
|
@ConditionalOnProperty(prefix="spring",name = "datasource.druid.stat-view-servlet.enabled", havingValue = "true") |
||||||
|
public class DruidConfig { |
||||||
|
/** |
||||||
|
* druid监控 配置URI拦截策略 |
||||||
|
*/ |
||||||
|
@Bean |
||||||
|
public FilterRegistrationBean druidStatFilter() { |
||||||
|
FilterRegistrationBean filterRegistrationBean = new FilterRegistrationBean(new WebStatFilter()); |
||||||
|
// 添加过滤规则.
|
||||||
|
filterRegistrationBean.addUrlPatterns("/*"); |
||||||
|
// 添加不需要忽略的格式信息.
|
||||||
|
filterRegistrationBean.addInitParameter("exclusions", |
||||||
|
"/static/*,*.js,*.gif,*.jpg,*.png,*.css,*.ico,/druid,/druid/*"); |
||||||
|
// 用于session监控页面的用户名显示 需要登录后主动将username注入到session里
|
||||||
|
filterRegistrationBean.addInitParameter("principalSessionName", "username"); |
||||||
|
return filterRegistrationBean; |
||||||
|
} |
||||||
|
|
||||||
|
/** |
||||||
|
* druid数据库连接池监控 |
||||||
|
*/ |
||||||
|
@Bean |
||||||
|
public DruidStatInterceptor druidStatInterceptor() { |
||||||
|
return new DruidStatInterceptor(); |
||||||
|
} |
||||||
|
|
||||||
|
@Bean |
||||||
|
public JdkRegexpMethodPointcut druidStatPointcut() { |
||||||
|
JdkRegexpMethodPointcut druidStatPointcut = new JdkRegexpMethodPointcut(); |
||||||
|
String patterns = "net.mingsoft.*.biz.*"; |
||||||
|
// 可以set多个
|
||||||
|
druidStatPointcut.setPatterns(patterns); |
||||||
|
return druidStatPointcut; |
||||||
|
} |
||||||
|
|
||||||
|
/** |
||||||
|
* druid 为druidStatPointcut添加拦截 |
||||||
|
* |
||||||
|
* @return |
||||||
|
*/ |
||||||
|
@Bean |
||||||
|
public Advisor druidStatAdvisor() { |
||||||
|
return new DefaultPointcutAdvisor(druidStatPointcut(), druidStatInterceptor()); |
||||||
|
} |
||||||
|
|
||||||
|
|
||||||
|
} |
||||||
@ -1,6 +1,6 @@ |
|||||||
spring: |
spring: |
||||||
datasource: |
datasource: |
||||||
url: jdbc:mysql://localhost:3306/db-mcms-open?autoReconnect=true&useUnicode=true&characterEncoding=utf8&useSSL=false&allowMultiQueries=true |
url: jdbc:mysql://localhost:3306/db-mcms-open?autoReconnect=true&useUnicode=true&characterEncoding=utf8&useSSL=false&allowMultiQueries=true&serverTimezone=Asia/Shanghai |
||||||
username: root |
username: root |
||||||
password: root |
password: root |
||||||
filters: wall,mergeStat |
filters: wall,mergeStat |
||||||
|
|||||||
File diff suppressed because it is too large
Load Diff
File diff suppressed because one or more lines are too long
Loading…
Reference in new issue