The Spring IDE Plug-In for Eclipse

The Spring IDE Plug-In for Eclipse

Minter_685-4App.fm Page 229 Wednesday, November 7, 2007 1:49 PM APPENDIX ■ ■ ■ The Spring IDE Plug-in for Eclipse The Spring IDE plug-in for Eclipse enhances the Eclipse environment by providing a variety of features that make it easier to work with Spring projects. The Spring IDE provides tools for creating, validating, viewing, and editing your Spring configuration files. A particu- larly attractive feature is the provision of autocompletion when editing bean definitions. Although the Spring IDE is a separate project from Spring itself, there are developers who participate in both projects, so there is excellent support for the latest Spring features. In this appendix, I discuss the installation of the Spring IDE and then briefly present the features related to editing and viewing bean and Spring Web Flow definitions. It is not possible to discuss all of the Spring IDE features in depth in this appendix. I would recommend installing and working with the plug-in initially as an aid to the creation of bean definition files. The autocompletion feature works in a manner nearly identical to the Java source autocompletion features. After you are familiar with these aspects of the plug-in, you should visit the Spring IDE website (http://springide.org/) to learn more about the tool. Installing the Plug-in Although it is possible to download the Spring IDE components and install them manually, by far the easiest way to install the Spring IDE into Eclipse is to use the built-in Software Updates feature of the Eclipse environment. Version 2 of the Spring IDE supports versions of Spring up to and including Spring 2.1 and up to version 1 of Spring Web Flow. You will need at least version 3.2 of the Eclipse IDE in order to use version 2 of the Spring IDE, but unless you already have an established 3.2 Eclipse environment, you should start with version 3.3 of Eclipse released as a set of inte- grated environments called Europa. I would not advocate a migration to Eclipse 3.3 unless you are confident that all of your plug-ins are compatible with the newer version; Spring IDE works well in the Eclipse 3.2 environment if you are in this position, so it is safer to stay 229 Minter_685-4App.fm Page 230 Wednesday, November 7, 2007 1:49 PM 230 APPENDIX ■ THE SPRING IDE PLUG-IN FOR ECLIPSE with a known-good environment. To use Spring IDE to its fullest potential, you should install the Eclipse IDE for Java EE Developers Europa release because this includes Web Standard Tools (WST) components that support XML parsing—necessary for use of the bean editing support. As Figure A-1 shows, the Software Updates feature is accessed from the Eclipse Help menu. Choose Software Updates ➤ Find and Install to start the installation wizard. Figure A-1. Starting the installation process The first page of the installation wizard, shown in Figure A-2, prompts you to select updates to existing features or to search for new features. To acquire the latest updates to an already-installed Spring IDE environment, you would select the first of these options. However, upon the initial installation you should select the Search for New Features to Install option and click the Next button. Figure A-2. Installing new features In the next wizard (not shown), click the New Remote Site button and then enter the details exactly as shown in Figure A-3. Minter_685-4App.fm Page 231 Wednesday, November 7, 2007 1:49 PM APPENDIX ■ THE SPRING IDE PLUG-IN FOR ECLIPSE 231 Figure A-3. Specifying the update site details The Name field in Figure A-3 is an arbitrary name that will be shown in subsequent pages of the installer, but the URL field is used to obtain the installation files and must be entered verbatim as http://springide.org/updatesite/. After you click the OK button, the next page will show a list of the update sites known to the Eclipse update installer, with only the Spring IDE site selected (if any other entries are selected, deselect them). Click Finish, and the installer will check the Spring IDE site for the features that are available from it. After the installer has obtained the list of features, they will be shown in the Updates dialog box. If you expand the tree view of features to install, the dialog should look much like Figure A-4, but with the Integrations features selected. If the page presents any error messages, deselect the tools that cannot be installed. Figure A-4. Selecting the feature set to install Minter_685-4App.fm Page 232 Wednesday, November 7, 2007 1:49 PM 232 APPENDIX ■ THE SPRING IDE PLUG-IN FOR ECLIPSE At the time of this writing, the AspectJ Development Tools component (AJDT) is not compatible with the Europa release of Eclipse, and the Mylyn integration tool is unlikely to be of immediate interest, so I have disabled their installation as shown in Figure A-4. Click Next, and you will be prompted to accept the license agreement for the tools. After you have accepted this, the installation will proceed. The installation files are not “signed,” so you will need to click Install when a dialog warns you of this. Finally, select Yes when you are asked whether you would like to restart the Eclipse environment. The Spring IDE plug- in is now installed. Managing Bean Configurations As you have seen throughout this book, a large part of your work with Spring involves either the editing of conventional Java code (for which existing language support in most IDEs is adequate) or the editing of XML bean definition files. To gain the benefits of the Spring IDE in managing these files, you need to add the Spring Project Nature to your Eclipse projects. Figure A-5 shows the standard Eclipse Project Explorer view of a set of projects gener- ated by using Maven’s eclipse:eclipse target. Currently these are decorated with two icons, a J symbol at the top right indicating that they are Java projects, and a standard warning symbol at the bottom left indicating that there are minor problems with the project configuration. Figure A-5. An Eclipse project without the Spring Project Nature ■Caution Although you can generate Eclipse-compatible project definitions by using the Maven tool’s eclipse:eclipse build target, it cannot currently generate Spring IDE–compatible projects. You will need to apply and configure the Spring Project Nature manually. Once configured, the eclipse:eclipse target will not overwrite these settings, but the eclipse:clean build target to remove stale project definitions will remove them, which is often undesirable, so you may want to avoid using this target unless your project configuration has become irretrievably corrupt. Minter_685-4App.fm Page 233 Wednesday, November 7, 2007 1:49 PM APPENDIX ■ THE SPRING IDE PLUG-IN FOR ECLIPSE 233 Right-click on each project in turn and choose the Apply Spring Project Nature option from the context menu. After performing this action, you will see the decoration in the top- right corner change from the J to an S, indicating that this is now a Spring project (a Spring project is always a Java project also, so the J decoration is no longer required). The resulting look is shown in Figure A-6. Figure A-6. An Eclipse project with the Spring Project Nature If you open one of the projects, as shown in Figure A-7, you will see that an additional entry has been added to the project details in the Project Explorer. This will represent the Spring-specific configuration details of your project. However, it is not automatically populated with entries. Figure A-7. The Spring Elements node within a Spring project Although the Spring Elements option is shown by default as a branch of the Project Explorer, it can be opened as a view in its own right by choosing the Window ➤ Show View ➤ Other ➤ Spring ➤ Spring Explorer menu option. To configure your bean configuration files for inclusion in the Spring Elements view, choose the Properties option from the Spring Elements leaf’s context menu, or open the project’s context menu, choose Properties, and select the Spring node in the tree on the left-hand side. Either way, you will be presented with a dialog box corresponding to Figure A-8. Minter_685-4App.fm Page 234 Wednesday, November 7, 2007 1:49 PM 234 APPENDIX ■ THE SPRING IDE PLUG-IN FOR ECLIPSE Figure A-8. Configuring the Spring-specific project properties The default page for this menu option allows you to enable and disable the various types of validation that will be used to check your bean definition files for errors. Usually you will leave the default options for validation and for the (hidden) project builders options. However, on large projects you may find that the validation can make the IDE less respon- sive, so you may want to disable some of the more rigorous options in this situation. Select the Beans Support option from the left-hand menu, and you will be presented with the Beans Support dialog box. Click the Add button to select the bean configuration files. This action tells the Spring IDE which bean configurations are relevant to your project (and indeed which XML files are bean configurations in the first place—the IDE does not attempt to autodetect bean configuration files). Figure A-9 shows the bean configuration files of the timesheets-webapp project selected from the Beans Support menu. Returning from this dialog to the Project Explorer window shown in Figure A-10, the Spring Elements branch of the project’s tree has been populated with the details of the configuration files, of the Spring beans defined within them, and of the properties assigned to those beans.

View Full Text

Details

  • File Type
    pdf
  • Upload Time
    -
  • Content Languages
    English
  • Upload User
    Anonymous/Not logged-in
  • File Pages
    43 Page
  • File Size
    -

Download

Channel Download Status
Express Download Enable

Copyright

We respect the copyrights and intellectual property rights of all users. All uploaded documents are either original works of the uploader or authorized works of the rightful owners.

  • Not to be reproduced or distributed without explicit permission.
  • Not used for commercial purposes outside of approved use cases.
  • Not used to infringe on the rights of the original creators.
  • If you believe any content infringes your copyright, please contact us immediately.

Support

For help with questions, suggestions, or problems, please contact us