package com.durgasoft.test;
import org.springframework.context.ApplicationContext;
import org.springframework.context.support.ClassPathXmlApplicationContext;
import com.durgasoft.beans.HelloBean;
/*
2 types of container
---------------------
bean factory
application context
*/
public class Test {
public static void main(String[] args)
{
ApplicationContext context = new ClassPathXmlApplicationContext("appplicationContext.xml"); //container created
HelloBean bean = (HelloBean)context.getBean("helloBean");
String message = bean.sayHello();
System.out.println(message);
}
}
======================================================================
package com.durgasoft.beans;
public class HelloBean
{
public String sayHello()
{
return "Hello User!";
}
}
import org.springframework.context.ApplicationContext;
import org.springframework.context.support.ClassPathXmlApplicationContext;
import com.durgasoft.beans.HelloBean;
/*
2 types of container
---------------------
bean factory
application context
*/
public class Test {
public static void main(String[] args)
{
ApplicationContext context = new ClassPathXmlApplicationContext("appplicationContext.xml"); //container created
HelloBean bean = (HelloBean)context.getBean("helloBean");
String message = bean.sayHello();
System.out.println(message);
}
}
======================================================================
package com.durgasoft.beans;
public class HelloBean
{
public String sayHello()
{
return "Hello User!";
}
}
=====================================================================
<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns="http://www.springframework.org/schema/beans"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://www.springframework.org/schema/beans
http://www.springframework.org/schema/beans/spring-beans.xsd">
<bean id="helloBean" class="com.durgasoft.beans.HelloBean"/>
</beans>
No comments:
Post a Comment