单机监控
在javaconfig类中开启注解
@EnableMBeanExport
或者 在传统的xml中添加
<context:mbean-export server="mbeanServer" />
来看看如何使用注解吧
@ManagedResource 将MBeanController导出为MBean
@ManagedAttribute 将bean的方法暴露为MBean托管操作
@ManagedOperation 将bean的属性暴露为MBean托管属性
@Controller
@ManagedResource(objectName="spittr:name=MBeanController")
public class MBeanController {
private static int i= 100;
@ManagedAttribute
public int getI() {
return i;
}
@ManagedAttribute
public void setI(int i) {
this.i = i;
}
}
这样就可以在 jconsole 中监控了