Java Spring Framework jmx managed annotation @ManagedAttribute does not show a method in the list MBeanServerConnection / Jconsole / Visual vm / bean

Ive Added Spring annotation to my code but when connected via visual vm the method "myExample ()" does not appear in the JMX bean list

My code is:

import org.springframework.beans.factory.annotation.Autowired; import org.springframework.jmx.export.annotation.ManagedAttribute; import org.springframework.jmx.export.annotation.ManagedResource; import org.springframework.stereotype.Component; @Component @ManagedResource public class MyClass { @Autowired private Example exampleService; @ManagedAttribute public String myExample() { return exampleService.getSomething().toString(); } } 

any idea why this is happening?

+4
source share
1 answer

Instead, use @ManagedOperation . @ManagedAttribute is for getter / setter methods only.

+5
source

Source: https://habr.com/ru/post/1498322/


All Articles