I am one of the eclipse fans, in other words, who don’t run applications with command prompt or console with explicit PATH and CLASSPATH 🙂 But there comes a situation, I need to run manually some class files that uses spring beans for some upgrading purpose.
Loading a application context file is what I done, safely ignoring the other parts when I looked into Spring.
ClassPathXmlApplicationContext context = new ClassPathXmlApplicationContext(“classpath:spring-common-dao.xml”);
will do for that. But as any other web app, I broke the files into pieces as per modules. So, here comes the method that will load all your config files.
ClassPathXmlApplicationContext context = new ClassPathXmlApplicationContext(new String []{“classpath:spring-common-dao.xml”,
“classpath:spring-common-service.xml”,”classpath:spring-license-dao.xml”,”classpath:spring-license-view.xml”,
“classpath:spring-license-service.xml”,”classpath:spring-license-schedule.xml”});
Then go with your own way of invoking the beans!
ILicenseService licenseService = (ILicenseService) context.getBean(“licenseService”);
Have a nice day!