Spring tutorial

Spring tutorial

Here I will describe on Spring tutorial. let me describe the working environment. my another blog shows how to set up your environment. To know more on springframework please visit here.

Spring tutorial – step by step

In this example we are using following tools

Eclipse 3.4: Ganymede;

Plugs in: svn, Maven, spring-ide, tomcat lunher, ant.

Tomcat: 5.5

FireFox: 3

Create a new project in Eclipse;

Spring tutorial - Eclipse create new project

Spring tutorial – Eclipse create new project

Spring tutorial - set project name

Spring tutorial – set project name

create one package name:  click the right button on the src folder and select new -> Package and put  com.rajib.spring.samplespring.model value.

create a class Information under the model folder. In this Spring tutorial have used couple of java classes, here are they

——————Information.java

create an xml file  applicationContext.xml under the src file. by default spring is looking this under web-inf folder but we put his under class path intentionally thats why we will mention the conetx file location at the web.xml. In this spring tutorial, I am trying to show you can create a spring application. We can mention all beans under <beans> tag.

————- applicationContext.xml

we will show information.project name and information.version at index.jsp page. we used the information class as bean.

Create WebContent folder under the project. create WEB-INF folder under the WebContent folder. Create lib folder under WEB-INF folder. I used lot of jar files as library file. My lib contains jarlist jar files.

Create log4j.properties and web.xml file under WEB-INF folder.

————–log4j.properties

————————- web.xml

Create index.jsp file under WebContent folder.

———– index.jsp

to make the build path to do the following

Spring tutorial - eclipse build path

Spring tutorial – eclipse build path

-click right button on the project and select properties select the Java Build Path from the left side. click – Library tab from right side , click Add jar select all jars of  (SimpleSpring->WebContent->lib all jars). click the Ordre and Ecports tab and click on  Select All button.

How to run this project:

for building this project we need buld.xml

 

—————————- build.xml

there are some supporting file exist for this build.xml these are –

————————- build.properties

so we need to create another folder external-lib and put these 2 jar files.

Spring tutorial - build

Spring tutorial

to build this project use these stepts – open build.xml. click – window->show view -> outline . click the right button on rebuild select – Run As -> 1 Ant Build.

set a context configaration file at {Tomcat folder}/conf/Catalina/localhost. lest assume this file name is – simplespring.xml and its looks –

 

 

————-simplespring.xml

if your eclipse has tomcat lunch plugs in so you can deploy from eclipse. click on as picture

Spring tutorial - run-tomcat

Spring tutorial

 

The output looks —

Spring tutorial - output

Spring tutorial

Download Spring tutorial

Click here to download this project.

One thought on “Spring tutorial

  1. Pingback: Complete example/error-solution of jdbc connection wOracle,MSSql,MySql

Leave a Reply

Your email address will not be published. Required fields are marked *