简体   繁体   中英

Practise to Load Spring Beans

Folks,

What's the recommended practise to load spring beans from ApplicationContext ? Do we write ServletContextListener to load this when server starts up takes And save bean info in the context?

Or write some static method to do:

ApplicationContext context = new ClassPathXmlApplicationContext("spring-beans.xml");

And call this static method all the time?

Or write a public void method and call it all the time? In this case are spring beans initialized everytime? this looks too much of work by the container.

Please suggests, thanks.

Use the context loader listener that's provided. Configure it in the web.xml, as recommended. You should neither think this much about it nor work this hard to load your beans.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM