Installing and Getting Started with Spring Tool Suite (STS) in Windows

Prerequisites

  1. Knowledge of Eclipse IDE (Refer to http://javajee.com/eclipse-ide-notes)

  2. Knowledge of Gradle (Refer to http://javajee.com/build-tools-for-java-applications)

 

Installing and setting up STS

  1. Download Spring Tool Suite latest version. Current download link is: http://spring.io/tools. Click to download ‘SPRING TOOL SUITE’.

  2. Once downloaded, double click to install. Click next, Accept License, Click Next, Select Installation Path, Click Next.

  3. Select defaults including tc server and click next. STS includes its own version of Tomcat called tc-server.

  4. Select a JDK (not JRE) and click Next.

  5. Continue to Click Next leaving defaults until the last page, where you can select Launch STS and click finish.

  6. While starting, STS will ask for workspace, like eclipse. STS is built on top of eclipse.

 

Configuring STS for Projects

You can configure STS for various projects such as Cloud Foundry Integration for eclipse, Spring Roo, Grails, Gradle etc. from the extension manager. You can go to extension manager by clicking ‘Manage Extensions’ in the Dashboard page. You can reach the Dashboard from the Help menu. We will see how to configure STS for Gradle projects and configuring for other projects will be similar.

 

Configuring STS for Gradle Projects

Step 1: To install Gradle support, from the Dashboard tab, click ‘Manage Extensions’. STS will show you a list of extensions in a separate tab.

Step 2: In the extensions tab, search for gradle (in the Find box on top of the tab page), select Gradle support and click install on bottom right. It will take some time to install.

In certain cases, your installation might fail due to time out or connectivity as: Communication with repository at http://dist.springsource.com/release/TOOLS/update/e4.3 failed. Most such issue are related to Internet security and firewall. I had to disable all internet security to install successfully.

Step 3: If step 2 succeed, continue to Click Next, reading and accepting the license agreements and click Finish. The Gradle plugin should now start downloading and installing. Once it finishes, you will be asked to restart—click Yes.

Workaround Alternative if step 2 or 3 fail

If previous steps fail even after disabling internet security, you can try steps 4 and 5 as workaround:

Step 4: If step 2 or 3 fail, Go to ‘Help’ > ‘Install new software’ > ‘work with’ and give the eclipse update site url in the ‘work with’ box (e.g. http://dist.springsource.com/release/TOOLS/update/3.4.0.RELEASE/e4.3). Now click ADD giving some name as STS Tools.

Step 5: From the list of modules from the update site, select the one you need. (E.g. Eclipse integration for Gradle). STS will now calculate the requirements and dependencies, and ask to Review the items to be installed. Click Next, Accept the license agreement, and click Finish. Installation may take some time depending on your network speed. Once it finishes, you will be asked to restart—click Yes.

Note: After following steps 4 and 5, you might face issues if the update site version is not same as that of your eclipse version.

 

Creating a new Gradle Project

Step 1: Once the plugin is installed successfully, you can create a Gradle project going to New > Project > Gradle > Gradle Project.

Step 2: You also need to select a Sample project to get started. Three samples are available as of this writing. Java Quickstart is a 'single project' sample project from the official Gradle distribution. Java API and Implementation is another 'single project' sample from the official Gradle distribution. It shows you how to customize your project's layout. Last one, Flat Java Multi Project, is a sample we created to demonstrates the 'multi-project' layout within Eclipse. There is a single root project that has most of the build logic, and a number of sub-projects containing the actual source code of the project. Many SpringSource projects such as spring-integration, spring-framework, spring-security etc. have Gradle builds that use this layout. The project name will go to root folder and you can’t select names for subprojects, but are given hardcoded names.

 

Importing a Gradle Project

Step 1: Once the plugin is installed successfully, you can create a Gradle project going to Import > Project > Gradle > Gradle Project.

Step 2: You need to ask Gradle to create project/subproject model by clicking Build Model button.  This model is needed to populate the project selection area below. Building the model may take some time.

Step 3: Once building model is done, you can select the project; if there are more than one projects, you can select the required projects.

Step 4: Finally click finish to do the importing. It might also take time if there are dependencies that need to be downloaded.

 

Issues and Resolutions

Issue 1

After installing STS and creating your first Gradle project as: New > Project > Gradle > Gradle Project, selecting sample project as "Java Quickstart", you might get build errors, including below errors:

Illegal entry in Gradle Dependencies: C:/Program Files/eclipse/unresolved dependency - commons-collections commons-collections 3.2

Illegal entry in Gradle Dependencies: C:/Program Files/eclipse/unresolved dependency - junit junit 4.+

 

Solution

Possible issue for the above error is that you are connecting to internet through a proxy. This happens if you are working from your company from behind the company firewall. You can either connect directly to internet without proxy (if possible) or tell gradle about your proxy as described in the page http://www.gradle.org/docs/current/userguide/build_environment.html.

After connecting to internet directly or configuring proxy, right click the project or the build.gradle file and  go to Gradle > Refresh All.  

It will download all the dependencies and you should see no errors. Refresh workspace or restart eclipse if the changes are not reflecting immediately after you see Build successful.

 

Summary

You can create and import gradle projects easily using the gradle project plugin. You can also run the build.gradle file from within STS.

You can use the gradle eclipse plugin to convert an existing gradle project into an eclipse project generating the eclipse required files. After converting you can import it into an eclipse workspace. You can read about the plugin @ http://www.gradle.org/docs/current/userguide/eclipse_plugin.html.  

JavaJee Checks: 
Steps verified for versions: 3.5.1. Steps last verified on: 7/JUN/2014.

Search the Web

Custom Search

Searches whole web. Use the search in the right sidebar to search only within javajee.com!!!