I’ve been a long time Java developer and have always used Eclipse. Eclipse on it’s own though doesn’t always come with all the plugins you want. Eclipse has gotten better over time with adding new plugins, but it used to be kind of painful to add new plugins as you’d have to also satisfy the plugin’s dependencies as well. I have always like to start off using SpringSource Tool Suite. It comes with plugins for Spring IDE, M2Eclipse for Maven projects, AspectJ tools, the web platform tools.
This post will detail getting started with Spring Source Tool Suite and creating an initial Maven project. I will detail all the steps necessary.
- If you haven’t already, get the JDK and not just a JRE. In Windows, set an environment variable JAVA_HOME to the directory where the JDK is installed. In my case I like to install a lot of things in an apps directory. Many tools do not like a space in the path, so you don’t want to put it in Program Files. In my case JAVA_HOME is set to C:\apps\Java\jdk1.7.0_10. Next add %JAVA_HOME%\bin to your path.
- Download and install Spring Source Tool Suite (SSTS) for your platform.
- The installer will prompt you to install Maven which you should. I also like to install Maven locally on my computer so I can run it from the command line. Follow the instructions for installing Maven outside of Eclipse.
- Once everything is installed, open SSTS. To get started with Maven, you’ll want to ensure you index the Maven Repositories. The repositories are where many of the libraries you’ll want to use are made available. For instance Apache has a repository. You can browse it here. Indexing the repository in Eclipse helps you to search for artifacts you will want to add to your project.
- You need to open the Maven Repositories view. To do so, go to the Window->Show View->Other menu.
- In the filter box type Maven. Maven Repositories will be shown in the list. Select it and press OK.
- Now you will see the Maven Repositories. There should be one entry called central under Global Repositories which you will see once you expand that view. Right click on central and select Enable Full Index. This will take a while. While updating, the entry will show in italics and the word updating will show within brackets.
- Once the repository is finished updating, you are ready to create your first project using Maven.
- Go to File->New->Other menu.
- In the filter text box, type Maven. Select Maven Project and click Next.
- Leave the defaults on the next screen and click Next.
- Now you will be on the screen where you pick your archetype. In Maven, an archetype is like a template for creating a project. In this example we will leave the default which is maven-archetype-quickstart. This archetype is for a simple Java project. I will use this in future posts that I am going to do about Spring Integration. From here click Next
- Now you will be asked to enter the GroupId, ArtifactId, Version and Package. The first three are the coordinates that another project would use if they wanted to reference your project. GroupId is similar to a Java Package. I would usually put com.yourorg. ArtifactId would be your project name. Version is used to create different versions for your application. If it is not an official release, you would typically have -SNAPSHOT appended to the end as it does when you create your first application. Package I would leave the default. After entering these, click Finish.
- Now you have your first Maven application. To test your configuration, you can build it in Eclipse. Right click your project and select Run As -> and the second Maven Build. This will bring up the Edit Configuration window. Under Goals, type package. Then click the Run button. In the Console window you will notice Maven downloading a bunch of packages. If you go to the target folder in Maven and refresh it, you should see a new Jar file for your project.