4
回答
MBeanServer 启动之后,无法访问
华为云4核8G,高性能云服务器,免费试用   

代码如下:

package com.lala.jmx;

public interface ConfigMBean {

	public String getBind();
	
	public void setBind(String bind);
	
	public Integer getPort();
	
	public void setPort(Integer port);
}



package com.lala.jmx;

public class Config implements ConfigMBean {
	private String bind;
	private Integer port;
	public String getBind() {
		return bind;
	}

	public void setBind(String bind) {
		this.bind = bind;
	}

	public Integer getPort() {
		return port;
	}

	public void setPort(Integer port) {
		this.port = port;
	}
}



package com.lala.jmx;

import javax.management.MBeanServer;
import javax.management.MBeanServerFactory;
import javax.management.ObjectName;

import com.sun.jdmk.comm.HtmlAdaptorServer;

public class ConfigAgent
{
	public static void main(String[] args)throws Exception
	{
		int port = 8282;
		MBeanServer server = MBeanServerFactory.createMBeanServer("config");
        ObjectName configName = new ObjectName("config:name=configure");
        server.registerMBean(new Config(), configName);
        ObjectName adapterName = new ObjectName("config:name=htmladapter,port="+port);
        HtmlAdaptorServer adapter = new HtmlAdaptorServer();
        server.registerMBean(adapter, adapterName);
        adapter.start();
        System.out.println("server start on port "+port+" .....");
	}
}



启动main方法之后,

在浏览器中输入

http://127.0.0.1:8282

页面显示无法访问

请问,哪里错误了

JMX
举报
顶部