码迷,mamicode.com
首页 > 编程语言 > 详细

druid 配置监控页面和开启防火墙,spring

时间:2018-03-08 14:00:40      阅读:338      评论:0      收藏:0      [点我收藏+]

标签:需要   eth   filters   inter   cep   viso   方法   火墙   mon   

1. dataSource中增加

<property name="filters" value="stat,wall"/>

2. spring 中增加(spring的支持)

<!-- druid spring monitor setting -->
<!-- 开启@AspectJ AOP代理 -->
    
    <bean id="druid-stat-interceptor" class="com.alibaba.druid.support.spring.stat.DruidStatInterceptor"/>
    <bean id="druid-stat-pointcut" class="org.springframework.aop.support.JdkRegexpMethodPointcut" scope="prototype">
        <property name="patterns">
            <list>
                <value>com.beta.mss.core.service.*</value>
            </list>
        </property>
    </bean>
    <aop:config proxy-target-class="true">
        <aop:advisor advice-ref="druid-stat-interceptor" pointcut-ref="druid-stat-pointcut"/>
    </aop:config>

需要注意的是这里的patterns中一般只监控service,controller监控不到,同时spring代理使用CGLib的代理方式,但是CGLib不能代理final类或被private,final修饰的方法,CGLib面对具体代理类,不能是接口,jdk的代理是面向接口的。

3. web.xml

<!-- druid url monitor setting start -->
<filter>
<filter-name>DruidWebStatFilter</filter-name>
<filter-class>com.alibaba.druid.support.http.WebStatFilter</filter-class>
<init-param>
<param-name>exclusions</param-name>
<param-value>*.js,*.gif,*.jpg,*.png,*.css,*.ico,/druid/*</param-value>
</init-param>
<init-param>
<param-name>profileEnable</param-name>
<param-value>true</param-value>
</init-param>
</filter>
<filter-mapping>
<filter-name>DruidWebStatFilter</filter-name>
<url-pattern>/*</url-pattern>
</filter-mapping>
<!-- druid url monitor setting end -->
<servlet>
        <servlet-name>DruidStatView</servlet-name>
        <servlet-class>com.alibaba.druid.support.http.StatViewServlet</servlet-class>
        <init-param>  
        <!-- 允许清空统计数据 -->  
            <param-name>resetEnable</param-name>  
            <param-value>true</param-value>  
        </init-param>  
        <!-- <init-param>  
            用户名  
            <param-name>loginUsername</param-name>  
            <param-value>name</param-value>  
        </init-param>  
        <init-param>  
            密码  
            <param-name>loginPassword</param-name>  
            <param-value>pwd</param-value>  
        </init-param>   -->
    </servlet>
    <servlet-mapping>
        <servlet-name>DruidStatView</servlet-name>
        <url-pattern>/druid/*</url-pattern>
    </servlet-mapping>

 

druid 配置监控页面和开启防火墙,spring

标签:需要   eth   filters   inter   cep   viso   方法   火墙   mon   

原文地址:https://www.cnblogs.com/yangfei-beijing/p/8527611.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!