Spring 3 Framework Demo



Folder Structrue

springConfig.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/beans/spring-beans-3.0.xsd">
    <bean id="restBean" class="com.cloud.spring.Restu"></bean>
</beans>

Restu.java
package com.cloud.spring;

public class Restu {

    public void greetCust() {
        System.out.println("This is Ram Pukar");
    }
}

Main.java

package com.cloud.spring;

import org.springframework.context.ApplicationContext;
import org.springframework.context.support.ClassPathXmlApplicationContext;

public class Main {

    public static void main(String[] args) {
        ApplicationContext context = new ClassPathXmlApplicationContext("springConfig.xml");
        Restu rest = (Restu) context.getBean("restBean");
        rest.greetCust();
    }
}

Output:




    

Share on Google Plus

About Ram Pukar

This is a short description in the author block about the author. You edit it by entering text in the "Biographical Info" field in the user admin panel.
    Blogger Comment

0 comments:

Post a Comment