Win a copy of Programmer's Guide to Java SE 8 Oracle Certified Associate (OCA) this week in the OCAJP forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

When to use different ways to load config files in spring???

 
kandy pal
Greenhorn
Posts: 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi All,

I am new to Spring. I have query regarding the ways to load the config file in spring.

What is the difference between

ApplicationContext context = new ClassPathXmlApplicationContext("AppConfig.xml");

And

Resource res = new ClassPathResource("spconfig.xml");
BeanFactory factory = new XmlBeanFactory(res);

Thanks
 
Bill Gorder
Bartender
Posts: 1682
7
Android IntelliJ IDE Linux Mac OS X Spring
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
BeanFactory should rarely if ever be used in application code with modern versions of Spring. If you are loading a context XML in a standalone Spring application then you should use the first approach.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic