We installed Java and Maven to compile and package our Java source code and installed Tomcat to deploy and run our application. So now we have to start write Spring MVC code so that we can compile, package, and run the code. We can use any simple text editor on our computer to write our code, but that won't help us much with features like finding syntax errors as we type, auto-suggesting important key words, syntax highlighting, easy navigation, and so on.
An integrated development environment (IDE) can help us with these features to develop the code faster and error free. We are going to use Spring Tool Suite (STS) as our IDE.
STS is the best Eclipse-powered development environment to build Spring applications. Let's take a look at how we can install STS:
.zip
file into a convenient directory of your choice.sts-bundle
directory, you will find a directory called sts-3.7.3.RELEASE
. Just open that directory and create a desktop shortcut for the STS.exe
We have almost installed all the tools and software required to develop a Spring MVC application; so now, we can create our Spring MVC project on STS. However, before jumping into creating a project, we need to perform the following two final configurations on our STS in order to use STS effectively:
The aforementioned settings are just a one-time configuration that you need to set up on your newly installed STS; you need not perform this configuration every time you open STS
To build our projects, STS uses Maven build tool internally. But we have to tell STS where Maven has been installed so that it can use the Maven installation to build our projects. Let's take a look at how we can configure Maven on STS:
When you open STS for the very first time after installing, it will ask you to provide a workspace location. This is because when you create a project on STS, all your project files will be created under this location only. Provide a workspace directory path as you wish and click on the OK button.
As mentioned previously, we can use the Tomcat web server to deploy our application, but we have to inform STS about the location of the Tomcat container so that we can easily deploy our project in to Tomcat. Let's configure Tomcat on STS:
You may also see Pivotal tc Server Developer Edition (Runtime) v3.1 listed under the available servers, which comes along with the STS installation. Although STS might come with an internal Pivotal tc Server, we chose to use the Tomcat web server as our server runtime environment because of its popularity.
tomcat
in the Select the type of runtime environment: text box, and a list of available Tomcat versions will be shown. Just select Tomcat v8.0 and select the Create a new local server checkbox. Finally, click on the Next button, as shown in the following screenshot:C:Program FilesApache Software FoundationTomcat 8.0
if you have installed Tomcat in the default location. Then, click on the Finish button, as shown in the following screenshot: