Showing posts with label hello world in java spring. Show all posts
Showing posts with label hello world in java spring. Show all posts

Saturday, May 20, 2017

Hello World in Java Spring Framework

Hi there thank you for visiting my website. In this article I would like to share with you my very first program using Java Spring Framework to display a Hello World message on the screen. This program is very simple to write using other programming language but in my case I have to learn Java Spring Framework to improve my knowledge in Java. I hope you will find my work useful. Thank you very much.

My email address are the following jakerpomperada@gmail.com and jakerpomperada@yahoo.com.

My mobile number here in the Philippines is 09173084360.



Sample Program Output





Eclipse Screenshots




Program Listing


HelloWorld.java

package com.jake.java.demo;

public class HelloWorld {
 private String my_message;

public String getMy_message() {
System.out.print("\n\n");
System.out.println("\tHello " + my_message);
System.out.print("\n");
System.out.print("\t   ===== END OF PROGRAM =====");
return my_message;
}

public void setMy_message(String my_message) {
this.my_message = my_message;
}
  
}


MainApp.java

package com.jake.java.demo;

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

public class MainApp {
   public static void main(String[] args) {
      @SuppressWarnings("resource")
ApplicationContext context = new ClassPathXmlApplicationContext("Beans.xml");
      HelloWorld obj = (HelloWorld) context.getBean("HelloWorld");
      obj.getMy_message();
   }
}


Beans.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.xsd">

   <bean id = "HelloWorld" class = "com.jake.java.demo.HelloWorld">
      <property name = "my_message" value = "World Jake R. Pomperada, MAED-IT"/>
   </bean>

</beans>