By Troy giunipero and Craig macay, 1/13/08 |
|
|
This article describes how to install the Spring framework and how to run it in netbeans IDE. Spring framework is a popular open-source application framework that makes development of J2EE easier. It includes a container, a framework for managing components, and a set of snap-in services for Web user interfaces, transactions, and persistence.
This tutorial will use the spring netbeans module compiled by Craig macay and use the flash demonstration provided by Craig to guide you through the installation process. At the end of this tutorial, We will install a module in the IDE that provides the following support for the Spring framework:
- Web Framework Support (Spring framework options can be used when creating new Web applications)
- Spring XML directory (provides spring-related XSD and DTD to support XML Code Completion)
- Integrated Library Management (Libraries required for installing the Spring framework and other required libraries)
- Supports hyperlinks in bean XML files (link beans to project artifacts)
For more information about the Spring framework, visit the http://www.springframework.org. For more information about how Spring framework artifacts work and how to interact with other objects in the application, visit the official Spring framework reference documentation or refer to the Spring framework API.
Many spring netbeans module functions can also be applied to non-Web-based Spring framework applications. For more information about the spring netbeans module, visit the http://spring-netbeans.sourceforge.net. If you are familiar with the Spring framework, you are welcome to join spring netbeans module development.
Estimated time: 20 minutes
This article covers the following topics:
- Obtain Software
- Installation Module
- Create a new project
- Run the project
- Browse project structure
- More information
Obtain Software
Before you start, you need to download and install the following software on your computer:
- Netbeans ide 6.0 (download ).
- Spring netbeans module (download ).
Note:To install and run netbeans ide 6.0, we also need Java SE Development Kit (JDK) version 5.0 or later. You can download the JDK version suitable for your platform at http://java.sun.com/javase/downloads/index.jsp.
Installation Module
First, install spring netbeans module in IDE:
- Start netbeans IDE and select Tools> plugins from the main menu. Plugins manager will open in a new window.
- Select the downloaded tab at the top of the project manager and click Add ins. In the Add plugins dialog box, navigate to the storage path after the spring netbeans module is downloaded .. Select a module and click OK. Note that the Plugins manager has now recognized the Spring framework support module.
- Click the Install button. The netbeans ide installer is enabled, and the spring framework support plug-in to be installed is listed. Click Next. By accepting the displayed License Agreement, the installer automatically starts to download and verify the plug-in installation. If the plug-in is not registered, you may need to receive a verification warning. Click the continue button (this plug-in can be trusted ). After the plugin is successfully installed in IDE, click Finish.
Create a new project
After installing the module, we can use the Spring framework to create a new project for the Web application:
- Select File> New Project (CTRL-shift-N) from the File menu of IDE. In the categories list, select the web option. In the projects list, select the web application option. Click Next.
- In the Project Name field, enter springwebapp. Select the expected server from the server drop-down list. Keep other settings unchanged as default values, and then click Next.
- In step 3, since the spring netbeans module was installed just now, the list of frameworks panels now contains Spring framework 2.5.
Select the check box and click Finish. IDE will create a project template for the entire project, including all metadata and the ant build script of the project. You can view the template structure in the projects window. Also noted that the project root fileIndex. jspThe source editor of IDE is enabled by default.
Run the project
Try to run new projects in IDE:
Browse project structure
Now that IDE can successfully deploy and run the project, we will see how the Spring framework is integrated with the project structure:
- In the projects window, expand web pages> WEB-INF nodes completely. As you can see, IDE has created the following spring framework artifacts for us:
|
Spring framework artifacts:JSP /: Contains the JSP page used to present the application view.Applicationcontext. xml: Provide beans that constitute the application context for the framework and provide their availability to all dispatcherservlet. Dispatcher-servlet.xml: Defines the bean used to specify the controller and spring MVC-related features. JDBC. properties: The configuration data can be applied to values of other XML documents. Web. xml: Define the application listener and path for the XML file of the specified bean. |
- Expand the libraries node. Note that the Spring framework JAR file is included in the new project:
|
Note:We can also add new libraries and jar files on the libraries node. To do this, right-click the libraries node and select an appropriate action from the pop-up menu. To remove any jar files, right-click the selected JAR file and select the remove option from the pop-up menu. Another way to modify the library is to perform the Project Properties dialog box for the project node (right-click the project node, select the properties option from the pop-up menu, and then select the libraries option from the categories list ). |
Now, we can start developing applications as needed. For example, we can start (Application-context.xml), Or add some new controllers to the dispatcherservlet (Dispatcher-servlet.xml).
More information
This is the end of the introduction to the Spring framework in netbeans IDE. This document demonstrates how to install the Spring framework to netbeans IDE and introduces the development interface of the Framework in IDE.
We recommend that you continue to learn the Spring framework through other tutorials in netbeans IDE, for example, the developer of risberg teaches you how to develop the Spring framework MVC application.
For more information, see the following references:
- Spring framework hands-on lab. A series of comprehensive courses and labs using the Spring framework in netbeans IDE.
- Use netbeans ide 6.0 to develop Web applications. This detailed tutorial will guide you through building a complete Web application using a composite view, front-end controller, JSP page, and servlet.
- Getting started with developing JAX-WS web services with netbeans ide 6.0. This article describes how to develop JAX-WS Web Services for Web applications in netbeans IDE.
Note: The above content comes from the Internet and I am not liable for any joint liability.
Article transferred from: http://blog.csdn.net/DL88250/archive/2008/01/14/2042707.aspx