QUOTE(junaidjee @ 14 Sep, 2008 - 04:26 AM)

Please give me steps to print "Hello World!" using spring...
Same as in ordinary Java:
java
public static void main(String[] args) {
System.out.println("Hello world!");
}
So, assuming you know what you want to use Spring for, which part of Spring are we talking about exactly? Inversion of Control?
java
class HelloWorld {
private HelloFactory bean;
public void setHelloFactory (HelloFactory bean) {
this.bean = bean;
}
public HelloWorld() {
}
public void doHello() {
System.out.println(bean.createHello());
}
}
class HelloFactory {
public HelloFactory() {
}
public String createHello() {
return "Hello world!";
}
}
class HelloProgram {
public static void main(String[] args) {
ApplicationContext context = new ClassPathXmlApplicationContext(
new String[] {"hello.xml"});
// an ApplicationContext is also a BeanFactory (via inheritance)
BeanFactory factory = context;
HelloWorld hw = (HelloWorld) factory.getBean("hello");
hw.doHello();
}
}
xml
<?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/bean...5.xsd">
<bean name="hello" class="HelloWorld">
<property name="HelloFactory" ref="factory"/>
</bean>
<bean name="factory" class="HelloFactory">
</bean>
</beans>