Debug while bean creation

1.7k Views Asked by At

I know how to debug a normal program flow in eclipse. I want to know if there a way to debug the bean formation in eclipse using the spring framework.

2

There are 2 best solutions below

1
On

Just debug the constructor. If there is none, create a default constructor and set a breakpoint into it.

0
On

In order to make a bean aware of its initialization you can implements InitializingBean interface and then implements

public void afterPropertiesSet() throws Exception {
      // I'm initializing
}

Could be a little "invasive" if it's only for debug reason, but this could be a way.

Another less invasive solution could be annotate a bean method with @PostConstruct.