Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How can I view the Bean Graph for @Autowired beans in Spring STS?

I am able to view the Bean Graph for any beans wired through XML, but when I have beans that are @Autowired through annotations, it doesn't show any arrows between them.


According to STS #171 and STS #1066 it was implemented a long time ago.

Note: Last tested with STS 3.4.0.RELEASE


If I deploy to tcServer and do Live Bean Graph, then it works, but not using regular view.

like image 727
Mike R Avatar asked Sep 26 '13 21:09

Mike R


People also ask

How do you view beans in Spring?

Ways to get loaded beans in Spring / Spring boot ApplicationContext. getBeanDefinitionNames() will return names of beans which is correctly loaded. getBean(String name) method using that we can get particular bean using bean name. * Created by JavaDeveloperZone on 07-13-2019.

How do you list all beans loaded in the application context?

In Spring Boot, you can use appContext. getBeanDefinitionNames() to get all the beans loaded by the Spring container.

How do I use Autowire in beans?

Autowiring by property name. Spring container looks at the properties of the beans on which autowire attribute is set to byName in the XML configuration file. It then tries to match and wire its properties with the beans defined by the same names in the configuration file. Autowiring by property datatype.

Does Spring @autowired inject beans by name or by type?

if Spring encounters multiple beans with same type it checks field name. if it finds a bean with the name of the target field, it injects that bean into the field.


1 Answers

The improvement feature was requested and even closed; but new tickets still say that feature is requested - and not closed yet even (STS-2396) in 2.8. I haven't succeeded getting there. No joy :(

Issue says - "When STS is resolving autowired beans for either validation purposes or for the bean graph, it seems to only to be able to find beans that have their type explicitly defined."

like image 64
Peter Avatar answered Oct 12 '22 04:10

Peter