Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/java/366.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Java 为什么JBoss JMX控制台不显示Spring定义的MBean的描述?_Java_Spring_Jboss_Jmx - Fatal编程技术网

Java 为什么JBoss JMX控制台不显示Spring定义的MBean的描述?

Java 为什么JBoss JMX控制台不显示Spring定义的MBean的描述?,java,spring,jboss,jmx,Java,Spring,Jboss,Jmx,我有一个Springbean,它使用Spring注释通过JMX公开,但是参数名仍然为空,操作和参数描述也没有显示出来。这可以在不使用冗长的XML定义文件的情况下修复吗 我紧随其后实施了这一计划。以下是我的简化代码: import org.springframework.jmx.export.annotation.ManagedOperation; import org.springframework.jmx.export.annotation.ManagedOperationParameter;

我有一个Springbean,它使用Spring注释通过JMX公开,但是参数名仍然为空,操作和参数描述也没有显示出来。这可以在不使用冗长的XML定义文件的情况下修复吗

我紧随其后实施了这一计划。以下是我的简化代码:

import org.springframework.jmx.export.annotation.ManagedOperation;
import org.springframework.jmx.export.annotation.ManagedOperationParameter;
import org.springframework.jmx.export.annotation.ManagedOperationParameters;
import org.springframework.jmx.export.annotation.ManagedResource;

@ManagedResource(objectName="group:name=foo", description="Does a lot of fooing")
public class Foo {
    @ManagedOperation(description="Changes the period of the given task and applies it immediately if the task is enabled.")
    @ManagedOperationParameters({
        @ManagedOperationParameter(name="index", description="the 0-based index of the fizzle"),
        @ManagedOperationParameter(name="baz", description="the baz value to set on the fizzle")
    })
    public void changeFizzle(int index, long baz) {
        // impl
    }
}

相关的spring应用程序上下文定义是从上面链接的博客文章中逐字复制的。

您需要为MBeanExporter定义正确的MetadataMBeanInfoAssembler,如下所示:

<property name="assembler">
  <bean id="assembler" class="org.springframework.jmx.export.assembler.MetadataMBeanInfoAssembler">
    <property name="attributeSource">
      <bean class="org.springframework.jmx.export.annotation.AnnotationJmxAttributeSource" />
    </property>
  </bean>
</property>


这对我来说很好。这并不是说这对你有多大帮助,但至少你知道它可以起作用。您使用的是哪个版本的Spring和JBoss?这个答案看起来很有希望,但由于我不再与JBoss合作,而且自从我提出这个问题以来,我已经更换了公司,所以我无法验证它是否有效。所以我想我不应该接受这个答案,但我会投赞成票。