javamelody如何集成到springmvc框架中

maven的springmvc项目需要在pom.xml中加入以下依赖:

<!-- javamelody资源监控 -->
    <dependency>
      <groupId>net.bull.javamelody</groupId>
      <artifactId>javamelody-core</artifactId>
      <version>1.60.0</version>
    </dependency>

将javamelody的监听器和过滤器注册到你的应用中修改web.xml

<!-- javamelody -->
  <filter>
    <filter-name>monitoring</filter-name>
    <filter-class>net.bull.javamelody.MonitoringFilter</filter-class>
  </filter>
  <filter-mapping>
    <filter-name>monitoring</filter-name>
    <url-pattern>/*</url-pattern>
  </filter-mapping>
  <listener>
    <listener-class>net.bull.javamelody.SessionListener</listener-class>
  </listener>

启动服务后,直接访问即可:http://localhost:8088/yourapp/monitoring

开启对sql的监控,同样在web.xml文件中添加参数文件读取:classpath:net/bull/javamelody/monitoring-spring-datasource.xml;

如图所示:

亦或

<context-param>
    <param-name>contextConfigLocation</param-name>
    <param-value>
        classpath:net/bull/javamelody/monitoring-spring-datasource.xml,
        classpath:applacationContext.xml  <!-- heihei this is have mybatis-config.xml -->
    </param-value>
  </context-param>

图中applicationContext.xml和spring-mybatis.xml是你的服务原本就有的配置文件。

大功告成。接下来启动服务,可以开始监控了。
 

  • 1
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值