package com.amit.bean;
public class HelloBean
{
private String message;
public void setMessage(String s)
{
this.message = s;
}
public String getMessage()
{
return message;
}
}
public class HelloBean
{
private String message;
public void setMessage(String s)
{
this.message = s;
}
public String getMessage()
{
return message;
}
}
\===========================================================
package com.amit.test;
import org.springframework.context.ApplicationContext;
import org.springframework.context.support.ClassPathXmlApplicationContext;
import com.amit.bean.HelloBean;
public class Test {
public static void main(String[] args)
{
ApplicationContext context = new ClassPathXmlApplicationContext("applicationContext.xml");
HelloBean hello = (HelloBean)context.getBean("hb");
hello.setMessage("Amit");
String message = hello.getMessage();
System.out.println("Welcome Dear "+message);
}
}
============================================================
<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 ="hb" class="com.amit.bean.HelloBean">
</bean>
</beans>
No comments:
Post a Comment