我可以在 MBean 中注册一个类,但无法通过 jconsole 连接。为什么我通过 JVM 参数禁用了 jmx 身份验证,但无法连接运行此应用程序。
这是我的 java 类、spring 属性文件和 JVM 参数
package com.mkyong.jmx;
public interface JmxCoreComands {
public void start();
public void stop();
public void report();
}
package com.mkyong.jmx;
import org.springframework.stereotype.Service;
@Service
public class JmxService implements JmxCoreComands {
@Override
public void start() {
System.out.println("Jmx Service start");
}
@Override
public void stop() {
System.out.println("jmx service stop");
}
@Override
public void report() {
System.out.println("jmx service report");
}
}
弹簧属性 XML:
<bean id="jmxAdapter" class="org.springframework.jmx.export.MBeanExporter" lazy-init="false">
<property name="beans">
<map>
<entry key="SPRING:Name=TestRun">
<ref bean="jmxService" />
</entry>
</map>
</property>
<!-- managemethods property starts -->
<property name="assembler">
<bean
class="org.springframework.jmx.export.assembler.InterfaceBasedMBeanInfoAssembler">
<property name="managedInterfaces">
<value>com.mkyong.jmx.JmxCoreComands</value>
</property>
</bean>
</property>
<!-- managemethods property ends -->
</bean>
JVM参数:
-Dcom.sun.management.jmxremote -Dcom.sun.management.jmxremote.port=8014
-Dcom.sun.management.jmxremote.authenticate=false
-Xmx1024M
-Xdebug
-Xnoagent
-Xrunjdwp:transport=dt_socket,address=8454,server=y,suspend=n
-Djava.compiler=NONE