here i describe a very simple Spring project. let me describe the working environment. my another blog shows how to set up your environment.
Eclipse 3.4: Ganymede;
Plugs in: svn, Maven, spring-ide, tomcat lunher, ant.
Tomcat: 5.5
FireFox: 3
Create a new project in Eclipse;

Eclipse create new project

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. this class looks
——————Information.java
package com.rajib.spring.samplespring.model;
public class Information {
private String projectName = “Spring demo1″;
private String version = ” 1.1″;
public String getProjectName() {
return projectName;
}
public void setProjectName(String projectName) {
this.projectName = projectName;
}
public String getVersion() {
return version;
}
public void setVersion(String version) {
this.version = version;
}
}
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.
————- applicationContext.xml
<?xml version=”1.0″ encoding=”UTF-8″?>
<!DOCTYPE beans PUBLIC “-//SPRING//DTD BEAN//EN” “http://www.springframework.org/dtd/spring-beans.dtd”>
<beans>
<bean id=”information” class=”com.rajib.spring.samplespring.model.Information”/>
</beans>
we will show infromation.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
log4j.logger.java.sql=DEBUG, STDOUT
log4j.logger.com.ibatis=DEBUG, STDOUT
log4j.logger.java.sql.Statement=INFO,STDOUT
log4j.rootLogger=ERROR,STDOUT
log4j.appender.STDOUT=org.apache.log4j.ConsoleAppender
log4j.appender.STDOUT.layout=org.apache.log4j.PatternLayout
log4j.appender.STDOUT.layout.conversionPattern=%-5p – %-26.26c{1} – %m\n
————————- web.xml
<?xml version=”1.0″ encoding=”UTF-8″?>
<web-app version=”2.4″ xmlns=”http://java.sun.com/xml/ns/j2ee”
xmlns:xsi=”http://www.w3.org/2001/XMLSchema-instance” xsi:schemaLocation=”http://java.sun.com/xml/ns/j2ee http://java.sun.com/xml/ns/j2ee/web-app_2_4.xsd”>
<description>Spring simple example</description>
<display-name>simplespring</display-name>
<context-param>
<param-name>webAppRootKey</param-name>
<param-value>simplespring</param-value>
</context-param>
<context-param>
<param-name>log4jConfigLocation</param-name>
<param-value>/WEB-INF/log4j.properties</param-value>
</context-param>
<context-param>
<param-name>ADMIN_EMAIL_ADDRESS</param-name>
<param-value>rajib_info@yahoo.com</param-value>
</context-param>
<context-param>
<param-name>contextConfigLocation</param-name>
<param-value>/WEB-INF/classes/applicationContext.xml</param-value>
</context-param>
<listener>
<listener-class>org.springframework.web.util.Log4jConfigListener</listener-class>
</listener>
<listener>
<listener-class>org.springframework.web.context.ContextLoaderListener</listener-class>
</listener>
<session-config>
<session-timeout>10</session-timeout>
</session-config>
<welcome-file-list>
<welcome-file>index.jsp</welcome-file>
</welcome-file-list>
</web-app>
Create index.jsp file under WebContent folder.
———– index.jsp
<%@ page language=”java” contentType=”text/html; charset=ISO-8859-1″ pageEncoding=”ISO-8859-1″%>
<%@ page import=”org.springframework.beans.factory.BeanFactory,
org.springframework.beans.factory.xml.XmlBeanFactory,
org.springframework.core.io.ClassPathResource,
com.rajib.spring.samplespring.model.Information”%>
<head>
<title>Simple Spring example</title>
</head>
<body bgcolor=”white”>
<h2>(Spring example by rajib_info@yahoo.com)</h2>
<%
BeanFactory beanFactory = new XmlBeanFactory( new ClassPathResource(“applicationContext.xml”));
Information info = (Information)beanFactory.getBean(“information”);
%>
Hello, this is sample spring project! <br />
Project Name is : <b> <%=info.getProjectName() %> </b>
Project Version is : <b> <%=info.getVersion() %> </b>
</body>
to make the build path to do the following

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
<project name=”simplespring” basedir=”.” default=”deploy”>
<!– Project settings –>
<property name=”project.distname” value=”simplespring”/>
<!– Local system paths –>
<property file=”${basedir}/build.properties”/>
<property name=”webroot.dir” value=”${basedir}/WebContent”/>
<property name=”webinf.dir” value=”${webroot.dir}/WEB-INF”/>
<property name=”build.dir” value=”target”/>
<!– classpath for WEB-INF/lib –>
<path id=”compile.classpath”>
<pathelement path =”${webinf.dir}/lib/acegi-security-1.0.3.jar”/>
<pathelement path =”${webinf.dir}/lib/activation.jar”/>
<pathelement path =”${webinf.dir}/lib/antlr-2.7.6.jar”/>
<pathelement path =”${webinf.dir}/lib/aopalliance.jar”/>
<pathelement path =”${webinf.dir}/lib/avalon-framework-4.2.0.jar”/>
<pathelement path =”${webinf.dir}/lib/barbecue-1.1.jar”/>
<pathelement path =”${webinf.dir}/lib/bsf-2.3.jar”/>
<pathelement path =”${webinf.dir}/lib/bsh-2.0b4.jar”/>
<pathelement path =”${webinf.dir}/lib/cglib-nodep-2.1_3.jar”/>
<pathelement path =”${webinf.dir}/lib/commons-annotations.jar”/>
<pathelement path =”${webinf.dir}/lib/commons-beanutils.jar”/>
<pathelement path =”${webinf.dir}/lib/commons-codec.jar”/>
<pathelement path =”${webinf.dir}/lib/commons-collections.jar”/>
<pathelement path =”${webinf.dir}/lib/commons-dbcp.jar”/>
<pathelement path =”${webinf.dir}/lib/commons-digester-1.8.jar”/>
<pathelement path =”${webinf.dir}/lib/commons-discovery-0.4.jar”/>
<pathelement path =”${webinf.dir}/lib/commons-fileupload.jar”/>
<pathelement path =”${webinf.dir}/lib/commons-io.jar”/>
<pathelement path =”${webinf.dir}/lib/commons-javaflow-20060411.jar”/>
<pathelement path =”${webinf.dir}/lib/commons-lang.jar”/>
<pathelement path =”${webinf.dir}/lib/commons-logging-1.1.1.jar”/>
<pathelement path =”${webinf.dir}/lib/commons-pool.jar”/>
<pathelement path =”${webinf.dir}/lib/commons-validator-1.3.1.jar”/>
<pathelement path =”${webinf.dir}/lib/dom4j-1.6.1.jar”/>
<pathelement path =”${webinf.dir}/lib/dwr.jar”/>
<pathelement path =”${webinf.dir}/lib/EasySI-0.9.0.jar”/>
<pathelement path =”${webinf.dir}/lib/ehcache-1.2.3.jar”/>
<pathelement path =”${webinf.dir}/lib/fop.jar”/>
<pathelement path =”${webinf.dir}/lib/ibatis-common-2.jar”/>
<pathelement path =”${webinf.dir}/lib/ibatis-sqlmap-2.jar”/>
<pathelement path =”${webinf.dir}/lib/iReport.jar”/>
<pathelement path =”${webinf.dir}/lib/itext-1.3.1.jar”/>
<pathelement path =”${webinf.dir}/lib/jakarta-oro-2.0.8.jar”/>
<pathelement path =”${webinf.dir}/lib/jaxen-1.1-beta-7.jar”/>
<pathelement path =”${webinf.dir}/lib/jazzy-core.jar”/>
<pathelement path =”${webinf.dir}/lib/jsf-facelets.jar”/>
<pathelement path =”${webinf.dir}/lib/jsf-impl.jar”/>
<pathelement path =”${webinf.dir}/lib/jstl.jar”/>
<pathelement path =”${webinf.dir}/lib/jta.jar”/>
<pathelement path =”${webinf.dir}/lib/log4j-1.2.14.jar”/>
<pathelement path =”${webinf.dir}/lib/mail.jar”/>
<pathelement path =”${webinf.dir}/lib/myfaces-api-1.2.5.jar”/>
<pathelement path =”${webinf.dir}/lib/myfaces-impl-1.2.5.jar”/>
<pathelement path =”${webinf.dir}/lib/myfaces-shared-impl-3.0.5.jar”/>
<pathelement path =”${webinf.dir}/lib/ojdbc14.jar”/>
<pathelement path =”${webinf.dir}/lib/poi-3.0.1-FINAL-20070705.jar”/>
<pathelement path =”${webinf.dir}/lib/quartz-all-1.6.1-RC1.jar”/>
<pathelement path =”${webinf.dir}/lib/serializer-2.7.0.jar”/>
<pathelement path =”${webinf.dir}/lib/spring-aop.jar”/>
<pathelement path =”${webinf.dir}/lib/spring-beans.jar”/>
<pathelement path =”${webinf.dir}/lib/spring-core.jar”/>
<pathelement path =”${webinf.dir}/lib/spring-context.jar”/>
<pathelement path =”${webinf.dir}/lib/spring-dao.jar”/>
<pathelement path =”${webinf.dir}/lib/spring-ibatis.jar”/>
<pathelement path =”${webinf.dir}/lib/spring-jdbc.jar”/>
<pathelement path =”${webinf.dir}/lib/spring-support.jar”/>
<pathelement path =”${webinf.dir}/lib/spring-web.jar”/>
<pathelement path =”${webinf.dir}/lib/spring-webmvc.jar”/>
<pathelement path =”${webinf.dir}/lib/standard.jar”/>
<pathelement path =”${webinf.dir}/lib/tomahawk12-1.1.8.jar”/>
<pathelement path =”${webinf.dir}/lib/xalan-2.7.0.jar”/>
<pathelement path =”${webinf.dir}/lib/xercesImpl-2.7.1.jar”/>
<pathelement path =”${webinf.dir}/lib/xml-apis-1.3.02.jar”/>
<pathelement path =”${webinf.dir}/lib/xmlgraphics-commons-1.1.jar”/>
<pathelement path =”${webinf.dir}/classes”/>
<pathelement path =”${classpath.external}”/>
<pathelement path =”${classpath}”/>
</path>
<!– define your folder for deployment –>
<property name=”deploy.dir” value=”deploy”/>
<!– Check timestamp on files –>
<target name=”prepare”>
<tstamp/>
</target>
<!– Copy any resource or configuration files –>
<target name=”resources”>
<copy todir=”${webinf.dir}/classes” includeEmptyDirs=”no”>
<fileset dir=”src”>
<patternset>
<include name=”**/*.conf”/>
<include name=”**/*.properties”/>
<include name=”**/*.xml”/>
</patternset>
</fileset>
</copy>
</target>
<!– Normal build of application –>
<target name=”compile” depends=”prepare,resources”>
<javac srcdir=”src” destdir=”${webinf.dir}/classes” encoding=”UTF-8″>
<classpath refid=”compile.classpath”/>
</javac>
</target>
<!– Remove classes directory for clean build –>
<target name=”clean”
description=”Prepare for clean build”>
<delete dir=”${webinf.dir}/classes”/>
<mkdir dir=”${webinf.dir}/classes”/>
</target>
<!– Build entire project –>
<target name=”build” depends=”prepare,compile”/>
<target name=”rebuild” depends=”clean,prepare,compile”/>
<!– Create binary distribution –>
<target name=”war” depends=”build”>
<mkdir dir=”${build.dir}”/>
<war
basedir=”${webroot.dir}”
warfile=”${build.dir}/${project.distname}.war”
webxml=”${webinf.dir}/web.xml”>
<exclude name=”WEB-INF/${build.dir}/**”/>
<exclude name=”WEB-INF/src/**”/>
<exclude name=”WEB-INF/web.xml”/>
</war>
</target>
<target name=”deploy” depends=”war”>
<delete file=”${deploy.dir}/${project.distname}.war”/>
<delete dir=”${deploy.dir}/${project.distname}”/>
<copy file=”${build.dir}/${project.distname}.war” todir=”${deploy.dir}”/>
</target>
</project>
there are some supporting file exist for this build.xml these are -
————————- build.properties
classpath.external=external-lib/servlet-api.jar;external-lib/jsp-api.jar;
so we need to create another folder external-lib and put these 2 jar files.
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
<?xml version=”1.0″ encoding=”UTF-8″?>
<Context docBase=”D:/workspace/simplespring/WebContent”
privileged=”true” antiResourceLocking=”false” antiJARLocking=”false”>
</Context>
if your eclipse has tomcat lunch plugs in so you can deploy from eclipse. click on as picture

The output looks —

the source code is located at -
http://code.google.com/p/simplespringproject/