Spring First Application

Files Required For Spring Application Are

  • Spring Jar Files
  • MyApp Class
  • Triangle Class
  • Spring.xml

First Create New Java Project SpringDemo1 in Eclipse

Spring Application

Copy jar files to project and add jar files to build path

Spring Application

Create MyApp class in org.manish.javasafari package

Spring Application Example

Create Triangle class in org.manish.javasafari package

Spring Application Example

Add code to Tringle Class

Spring Application Example

Create spring.xml file and add code to it

Spring Application Example

Add code to MyApp class

In MyApp class we are not hard coding triangle object instead using bean factory for creating object from configuration file i.e. spring.xml.This is how we are decoupling dependency.

Spring Application Example

Run the application and see the output

Spring Application Example