ローカルのTomcatサーバー上のEclipse内で単純なSpringJMXアプリケーションを試してみましたが、mbeanを登録できないため、Eclipseコンテキスト内でjconsole内で表示できるようになりました:component-scanは私が作成したBeanを取得するように見えますただし、これらは登録されていません。プログラムでmbeanを登録すると、機能します。
これが私のconfigxmlファイルです。
<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns="http://www.springframework.org/schema/beans"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:p="http://www.springframework.org/schema/p"
xmlns:context="http://www.springframework.org/schema/context"
xsi:schemaLocation="http://www.springframework.org/schema/beans
http://www.springframework.org/schema/beans/spring-beans-3.0.xsd
http://www.springframework.org/schema/context
http://www.springframework.org/schema/context/spring-context-3.0.xsd">
<bean id="mbeanServer" class="java.lang.management.ManagementFactory"
lazy-init="false" factory-method="getPlatformMBeanServer">
</bean>
<context:component-scan base-package="com.jmx.beans" />
<context:mbean-export server="mbeanServer" />
</beans>
アノテーションで登録しようとしている単純なBean
package com.jmx.beans;
import org.springframework.jmx.export.annotation.ManagedAttribute;
import org.springframework.jmx.export.annotation.ManagedResource;
import org.springframework.stereotype.Component;
@Component
@ManagedResource(objectName="bean:name=Hello")
public class Hello{
String message = null;
@ManagedAttribute(description="get the message")
public String getMessage(){
return this.message;
}
@ManagedAttribute(description="set the message")
public void setMessage(String Message){
this.message = Message;
}
}
また、Tomcatサーバーの引数を次のように設定しました
-Dcom.sun.management.jmxremote
-Dcom.sun.management.jmxremote.port=9990
-Dcom.sun.management.jmxremote.ssl=false
-Dcom.sun.management.jmxremote.authenticate=false
-Dcom.sun.management.jmxremote.hostname="localhost"
これに関する助けをいただければ幸いです、ありがとう