Spring container and sequential steps
package com.mgt.springdemo;
import org.springframework.context.support.ClassPathXmlApplicationContext;
public class SpringApp {
public static void main(String[] args) {
// load the spring configuration file
ClassPathXmlApplicationContext context =
new ClassPathXmlApplicationContext("applicationContext.xml");
// retrieve bean from spring container
Book b= context.getBean("myBook", Book.class);
// call methods on the bean
System.out.println(b.getBookDetail());
// close the context
context.close();
}
}
import org.springframework.context.support.ClassPathXmlApplicationContext;
public class SpringApp {
public static void main(String[] args) {
// load the spring configuration file
ClassPathXmlApplicationContext context =
new ClassPathXmlApplicationContext("applicationContext.xml");
// retrieve bean from spring container
Book b= context.getBean("myBook", Book.class);
// call methods on the bean
System.out.println(b.getBookDetail());
// close the context
context.close();
}
}
Comments
Post a Comment