0% found this document useful (0 votes)
2 views1 page

Hello World Example in Spring

The document contains Java code for a simple Spring application with three components: MainApp, HelloWorld, and Beans.xml. MainApp initializes the Spring application context and retrieves a HelloWorld bean, which prints a message. Beans.xml defines the HelloWorld bean and sets its message property to 'Hello World!'.

Uploaded by

Minu Poulose
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as ODT, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
2 views1 page

Hello World Example in Spring

The document contains Java code for a simple Spring application with three components: MainApp, HelloWorld, and Beans.xml. MainApp initializes the Spring application context and retrieves a HelloWorld bean, which prints a message. Beans.xml defines the HelloWorld bean and sets its message property to 'Hello World!'.

Uploaded by

Minu Poulose
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as ODT, PDF, TXT or read online on Scribd

MainApp.

java

package [Link];

import [Link];
import [Link];

public class MainApp {


public static void main(String args[])
{
ApplicationContext context = new ClassPathXmlApplicationContext("[Link]");
HelloWorld obj = (HelloWorld)[Link]("helloWorld");
[Link]();

}
}

[Link]

package [Link];

public class HelloWorld {


private String message;

public void setMessage(String message){


[Link] = message;
}
public void getMessage(){
[Link]("Your Message : " + message);
}

[Link]

<?xml version = "1.0" encoding = "UTF-8"?>

<beans xmlns = "[Link]


xmlns:xsi = "[Link]
xsi:schemaLocation = "[Link]
[Link]

<bean id = "helloWorld" class = "[Link]">


<property name = "message" value = "Hello World!"/>
</bean>

</beans>

You might also like