开发者

Finding out order of bean creation in the spring IOC

开发者 https://www.devze.com 2023-01-06 23:23 出处:网络
How can i find out in what order my beans were created? +1 for anyone who can recomme开发者_如何学Pythonnd a tool to display it visually. If you want to find out the order of bean creation, you can

How can i find out in what order my beans were created?

+1 for anyone who can recomme开发者_如何学Pythonnd a tool to display it visually.


If you want to find out the order of bean creation, you can register a custom BeanPostProcessor that prints out the info you are interested in. Follow the link for a Spring 2.5.x example.

If you want to view the bean configuration before any actual bean creation, then register a custom BeanFactoryPostProcessor that prints out the info you are interested in. Follow the link for a Spring 2.5.x example.

In either case, if you want to display the info visually then your PostProcessors could easily create a JFrame with a JList and add the info to that.


How can i find out in what order my beans were created?

One way would be to set the log4j logging level to DEBUG and trawl through the chatter in the log files. Not elegant, I'll grant you.


I believe spring creates beans in the order it finds them in the spring cfg files unless u explicitly state dependencies among them using depends-on.


Best way is to put the log4j log level to DEBUG mode and use grep to filter out only lines showing bean creation 'completion'.

0

精彩评论

暂无评论...
验证码 换一张
取 消