1package com.tutorialspoint;
2
3import org.springframework.context.ApplicationContext;
4import org.springframework.context.support.ClassPathXmlApplicationContext;
5
6public class MainApp {
7 public static void main(String[] args) {
8 ApplicationContext context = new ClassPathXmlApplicationContext("Beans.xml");
9 HelloWorld obj = (HelloWorld) context.getBean("helloWorld");
10 obj.getMessage();
11 }
12}
1<?xml version = "1.0" encoding = "UTF-8"?>
2
3<beans xmlns = "http://www.springframework.org/schema/beans"
4 xmlns:xsi = "http://www.w3.org/2001/XMLSchema-instance"
5 xsi:schemaLocation = "http://www.springframework.org/schema/beans
6 http://www.springframework.org/schema/beans/spring-beans-3.0.xsd">
7
8 <bean id = "helloWorld" class = "com.tutorialspoint.HelloWorld">
9 <property name = "message" value = "Hello World!"/>
10 </bean>
11
12</beans>