We can also use Spring Tool Suite to create a Spring project. In this section, we will create a Maven Project using STS.
- Spring Tool Suite Download For Java 8
- Spring Tool Suite For Java 8 Free
- Spring Tool Suite For Java 8 64-bit
Step 1: Open the Spring Tool Suite.
Step 2: Click on the File menu -> New -> Maven Project
It shows the New Maven Project wizard. Click on the Next button.
Spring Tool Suite 3.8.1/3.8.0: New and Noteworthy. Updates and Fixes in 3.8.1. Pivotal tc Server updated to 3.1.5. The latest Pivotal tc Server release 3.1.5 is now included in the STS distribution bundle. Important Changes and Fixes. Spring Boot Dashboard works behind a proxy again. It is asking for jdk 1.8 to open and run the STS (eclipse). It will still allow you to build your project/code with whatever JDK version you want. Install jdk1.8, set your JAVAHOME and PATH env variables so that 1.8 becomes your default jdk. After this your should be able to open STS.
Step 3: Select the maven-archetype-quickstart and click on the Next button.
Step 4: Provide the Group Id and Artifact Id. We have provided Group Id com.javatpoint and Artifact Id spring-boot-example-sts. Now click on the Finish button.
When we click on the Finish button, it creates the project directory, as shown in the following image.
Step 5: Open the App.java file. We found the following code that is by default.
The Maven project has a pom.xml file which contains the following default configuration.
Step 6: Add Java version inside the <properties> tag.
Step 7: In order to make a Spring Boot Project, we need to configure it. So, we are adding spring boot starter parent dependency in pom.xml file. Parent is used to declare that our project is a child to this parent project.
Step 8: Add the spring-boot-starter-web dependency in pom.xml file.
Note: When we add the dependencies in the pom file, it downloads the related jar file. We can see the downloaded jar files in the Maven Dependencies folder of the project directory.
After adding all the dependencies, the pom.xml file looks like the following:
Step 9: Create a class with the name SpringBootExampleSts in the package com.javatpoint.
Right-click on the package name -> New -> Class -> provide the class name -> Finish
Step 10: After creating the class file, call the static method run() of the SpringApplication class. In the following code, we are calling the run() method and passing the class name as an argument.
Step 11: Annotate the class by adding an annotation @SpringBootApplication.
A single @SpringBootApplication annotation is used to enable the following annotations:
- @EnableAutoConfiguration: It enables the Spring Boot auto-configuration mechanism.
- @ComponentScan: It scans the package where the application is located.
- @Configuration: It allows us to register extra beans in the context or import additional configuration classes.
Step: Run the file SpringBootExampleSts.java, as Java Application. It displays the following in the console.
The line Started SpringBootExampleSts in 5.038 seconds (JVM running for 6.854) in the console shows that the application is up and running.
Creating a basic Spring MVC project was a difficult thing for beginners because it involves so many steps from configuring all spring dependencies to deploying into some server. But once Spring Tool Suite introduced, creating a Spring MVC application has become a very simple process. In this post we are going to see how to create Spring MVC application using Spring Tool Suite within a minute.
Before going to start first let me tell you what are all the Pre-requisite software or jars which is required to develop the Spring MVC.
- Spring Tool Suite IDE 3.7.2 (Based on Eclipse Mars.1 (4.5.1)) – Download here
- Spring 4.1.1 – Maven is sufficient, no download is required.
- JDK 1.8 – Download from here
How to Create Spring MVC Application using Java Configuration
First Create a New Project. Plex ipad free.
In some of the STS IDE, we can able to select Spring Project directly. If your STS are not having an option then got with this approach. Select Spring Legacy Project from the menu.
Once you select and click on next we will see a window to select Spring MVC Project. At the top we are required to give project name and click next. I have given as STSSpringMVCHelloWorld.
Followed by that we will get a window to give high level package name.
That’s it. We will get a project like this.
In some times we will get a project with errors. To avoid those errors, update the project using maven by following the below image. Right click the project, go to Maven and Update Project.
Once you click Update Project, we will get a window to select the project to Update. Also make sure Force Update of Snapshots/Releases checkbox is unchecked.
This STS bundled with Tomcat 7 and Tomcat 8, so by default we could see Server window in the STS Eclipse (See below Image). So we just have to add the project and start the server. That’s it.
How to add Project to the Server
Follow the below steps and add a Project to the Server which is bundled with STS.
Right click the Server and Click on Add and Remove.
We will see a window like this. Add our project and click on “Finish” and start the server. That’s it.
Open the browser and hit the URL as below.
Spring Tool Suite Download For Java 8
Spring Tool Suite For Java 8 Free
I have added my message in HomeController.java and displayed it in home.jsp
We will see in detail about all the files in our next tutorials blogs. This How to Create Spring MVC application using Spring Tool Suite is available in my repository also, to download please click the link below.