By Mike Hubbartt, © Copyright 2012, All Rights Reserved.
Spring is a nice Java framework that simplifies J2E tasks, and is in wide use in many real-world business development environments. If you don’t know it and want to do dynamic web development with Java, this is a good time to learn it.
You need a couple of things to do Spring development. A good IDE, Tomcat for local development, and a good database for dynamic content. I enjoy using Eclipse IDEs, so this Spring setup procedure covers Eclipse Indigo.
Spring Configuration
- Download and install Eclipse Indigo from http://www.eclipse.org.
- Download and install Tomcat 6 from http://tomcat.apache.org/.
- Download and install a relational DBMS like MySQL or SQL Anywhere for Developers.
- Download the Spring framework with dependencies (for this example, I downloaded Spring 2.5 RC2) from http://www.springsource.org/download and then unzip the file into a folder. I keep all of my Spring files a folder surprisingly called Spring – it holds the Spring framework files and any Spring-specific articles I find to be useful as references.
- Download the Spring plug-ins by
- Using Help – Install New Software.
- At the Install popup, select the Add button.
- At the Add Repository popup, use Spring for the name and http://dist.springframework.org/release/IDE as the location.
- Select Core/Spring IDE and Resources/Spring IDE, then press the Next button.
- Select the Next button.
- Select the ‘I accept…’ licensing option and then press the Finish button.
- Restart Eclipse when prompted after the plugin is installed.
- In Eclipse, select File – New – Other, then select Dynamic Web Project, then press the Next button.
- Enter a Project Name, then press the Finish button.
- Create a war directory in the project – this is where non-Java source (.JSPs, XML, etc) are stored. In Eclipse, use File – New – Folder, and enter ‘war’ as the folder name, then press the Finish button.
- In the new war folder, create a WEB-INF folder using File – New – Folder just as you did in step 8.
- In the new WEB-INF folder, create a lib folder using File – New – Folder just as your in step 8.
- Time to configure the build path:
- Highlight the project name in the IDE, right mouse click, then select build path/configure build path.
- At the Properties dialog box, select the Java Build Path option at the left of the dialog, then select the Source tab.
- Select the ‘Add Folder’ button, then select the ‘war’ folder – do not select the folders below war, then select the OK button.
- Now add 2 JARs to the project.
- Using Windows Explorer, locate the Spring.jar file, then drag and drop it onto the war/WEB-INF/lib folder in the IDE..
- Using Windows Explorer, locate the commons-logging.jar file, then drag and drop it onto the war/WEB-INF/lib folder in the IDE.
- With the project name highlighted, select File – Refresh from the IDE meu options.
- You are done – the project is ready to be used as a blank Spring project.
Really simply superb article….