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 中显示?
谢谢。
最佳答案
<context:mbean-export/>
适合你。
<int-jmx:mbean-export>
是定制MBeanExporter
用于 Spring 集成组件。其他一切都应该由标准 Spring <context:mbean-export/>
管理.
关于java - MBean 未显示在 jvisualVM 中,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/37734269/