【问题标题】:MBeans are not being shown in jvisualVMJvisualVM 中未显示 MBean
【发布时间】:2016-06-09 19:07:00
【问题描述】:

Gary Russels's Monitoring Spring Integration 应用程序很棒。

我想添加简单的 MBean 来监控应用程序。 这是我的代码:

package com.example;

import org.springframework.jmx.export.annotation.ManagedOperation;
import org.springframework.jmx.export.annotation.ManagedResource;
import org.springframework.stereotype.Component;

@Component
@ManagedResource(objectName="myapp:application=hello")

public class HelloBean {

    @ManagedOperation
    public String sayHello(String name) {
       return "Hello " + name;
    }
}

我还在 spring-context xml 文件中添加了以下内容:

<context:mbean-server />
<int-jmx:mbean-export id="integrationMBeanExporter" default-domain="spring.application" />

<bean id="helloBean" class="com.example.HelloBean" />

当我查看 jVisualVM 时,我没有看到 bean。我可以在 spring.application 域中看到 MessageChannel,但看不到我的 MBean。

要让带注释的 MBean 显示在 visualVM 中,还有什么要做的吗?

谢谢。

【问题讨论】:

    标签: java spring-integration mbeans spring-jmx


    【解决方案1】:

    &lt;context:mbean-export/&gt; 适合你。

    &lt;int-jmx:mbean-export&gt; 是用于 Spring 集成组件的自定义 MBeanExporter。其他一切都应由标准 Spring &lt;context:mbean-export/&gt; 管理。

    【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2015-03-10
    相关资源
    最近更新 更多