Introduction to the Spring Framework
This document shows you how to install the Spring Framework and run it in NetBeans IDE. The Spring Framework is a popular open source application framework that can make J2EE development easier. It consists of a container, a framework for managing components, and a set of snap-in services for web user interfaces, transactions, and persistence.
This tutorial takes advantage of Craig MacKay's Spring NetBeans Module, and documents the flash demo he has prepared that guides you through the installation process. At the end of this tutorial, you will have a module installed in your IDE that provides the following support for the Spring Framework:
Web Framework Support (enables the Spring Framework as an option when creating a new web application) Spring XML Catalog (provides Spring related XSD and DTD's to enable XML code completion) Integrated Library Management (installs libraries required for the Spring Framework, as well as additional required libraries) Hyperlinking support in bean xml files (links beans to project artifacts)
For more information on the Spring Framework, visit http://www.springframework.org. For a more fine-grained explanation of how Spring Framework artifacts behave and interact with other objects in an application, visit the official Spring Framework Reference Documentation, or consult the Spring Framework API.
Many of the Spring NetBeans Module capabilities can also be applied to non-web based Spring framework applications. For details on the Spring NetBeans Module, see http://spring-netbeans.sourceforge.net. If you are familiar with the Spring Framework, you are welcome to contribute to the development of the Spring NetBeans Module.
Contents

To complete this tutorial, you need the following software and resources.
Java Development Kit (JDK) version 6 or version 5
Spring Plugin for NetBeans blah
Notes:
The Web and Java EE installation enables you to optionally install the GlassFish V2 application server and the Apache Tomcat servlet container 6.0.x. You must have a server registered in the IDE to work through this tutorial. You can download the Spring Plugin for NetBeans directly through the Plugin Manager (Tools > Plugins from the IDE's main menu), as described in Installing the Module below.
Installing the Module
Begin by downloading and installing the Spring plugin into the IDE:
Start NetBeans IDE and choose Tools > Plugins from the main menu. The Plugins Manager opens in a new window. Select the Available Plugins tab at the top of the Manager, then in the Search text field located in the upper right corner, type in 'spring'. The Search field serves as a filter, eliminating all plugin entries that do not contain the entered characters. You should see the Spring NetBeans Module as the only remaining entry:
Click Install. The NetBeans IDE Installer opens, listing the Spring Framework Support plugin that is about to be installed. Click Next. Accept the license agreement that displays, and the Installer automatically begins downloading and validating the plugin for installation. When the plugin is successfully installed into the IDE, click Finish.
Creating a New Project
Now that the module is installed, you can create a new project for a web application using the Spring Framework:
Choose New Project (Ctrl-Shift-N) from the IDE's File menu. Under Categories select Web. Under Projects select Web Application. Click Next. In Project Name, type in SpringWebApp. From the Server drop-down list, select the server you plan to work with. Leave all other settings at their defaults and click Next. In Step 3, the Frameworks panel, notice that because you just installed the Spring NetBeans Module, Spring Framework 2.5 is now listed:

Select the corresponding checkbox and click Finish. The IDE creates a project template for the entire application, including all metadata, as well as the project's Ant build script. You can view the template structure from the Projects window. Also note that the project's top level index.jsp file opens by default in the IDE's Source Editor.
Running the Project
Try running the new project in the IDE to see what happens:
In the Projects window, right-click the project node and choose Run Project (alternately, press F6). The IDE automatically starts your server if it is not already running, and deploys the application to it. The application runs and employs the Spring MVC DispatcherServlet using the configuration data contained in dispatcher-servlet.xml. Note any output displayed in the IDE's Output window (Ctrl-4). The generated output should complete with a BUILD SUCCESSFUL message:

The IDE's default browser starts up, and you see the generated output of the welcome page view (/WEB-INF/jsp/index.jsp):

Browsing the Project's Structure
Now that you know the project can be deployed and run successfully, look at how the Spring Framework is integrated in the project's structure:
In the Projects window, completely expand the Web Pages > WEB-INF node. Note that the following Spring Framework artifacts have been created for you:
Spring Framework artifacts:
jsp/:
contains JSP pages used to render views for the application.
applicationContext.xml:
defines beans which make up the application context for the framework and provides their availability to all dispatcher servlets.
dispatcher-servlet.xml:
defines beans used for specifying controllers and Spring MVC related features.
jdbc.properties:
contains configuration data which can be applied to values of other XML documents.
web.xml:
defines application listeners and paths to XML files that specify beans.
Expand the Libraries node. Note that the Spring Framework JAR files have been included in the new project:
Note: From the Libraries node, you can also add new libraries and JAR files. To do so, choose the appropriate action from the Libraries node's right-click menu.
To remove any JAR files, choose Remove from the right-click menu of a selected JAR file. Alternatively, you can make any changes to libraries by accessing the Project Properties dialog (choose Properties from the right-click menu of the project node, then under Categories, select Libraries).
You can now begin developing the application according to your needs. For example, you can start modifying the application context (application-context.xml) to add new services and DAO objects, or add new controllers to the application's dispatcher servlet (dispatcher-servlet.xml).
See Also
This concludes the Introduction to the Spring Framework in NetBeans IDE tutorial. This document demonstrated how to install the Spring Framework into NetBeans IDE, and introduced you to the IDE's interface for developing in the framework.
You are encouraged to continue learning about the Spring Framework by working through other tutorials in NetBeans IDE, such as Developing a Spring Framework MVC Application Step-by-Step using NetBeans and GlassFish. This is the official Spring Framework tutorial by Thomas Risberg which has been adapted for NetBeans IDE by Arulazi Dhesiaseelan.
For other related tutorials, see the following resources: