1package com.javatpoint;
2
3import org.springframework.beans.factory.BeanFactory;
4import org.springframework.beans.factory.xml.XmlBeanFactory;
5import org.springframework.core.io.ClassPathResource;
6import org.springframework.core.io.Resource;
7
8public class Test {
9public static void main(String[] args) {
10 Resource resource=new ClassPathResource("applicationContext.xml");
11 BeanFactory factory=new XmlBeanFactory(resource);
12
13 Student student=(Student)factory.getBean("studentbean");
14 student.displayInfo();
15}
16}
1package com.javatpoint;
2
3public class Student {
4private String name;
5
6public String getName() {
7 return name;
8}
9
10public void setName(String name) {
11 this.name = name;
12}
13
14public void displayInfo(){
15 System.out.println("Hello: "+name);
16}
17}
18This is simp
1<?xml version="1.0" encoding="UTF-8"?>
2<beans
3 xmlns="http://www.springframework.org/schema/beans"
4 xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
5 xmlns:p="http://www.springframework.org/schema/p"
6 xsi:schemaLocation="http://www.springframework.org/schema/beans
7 http://www.springframework.org/schema/beans/spring-beans-3.0.xsd">
8
9<bean id="studentbean" class="com.javatpoint.Student">
10<property name="name" value="Vimal Jaiswal"></property>
11</bean>
12
13</beans>
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>