Configuring IDE Spring Tool Suite

Let's start developing our blog application—Blogpress. As described, we will start creating the application with Spring Boot first. Developing an application with an IDE is the most straightforward, easy, convenient, and favorable approach preferred by the majority of developers today. We use IDEs to develop our application.

Spring provides an Eclipse-based IDE called Spring Tool Suite (STS) to develop any Spring-based application with ease. Download the latest version of STS from the link https://spring.io/tools.

The STS is available with Eclipse, along with Visual Studio and Atom-based code editors. You can use either of them for your convenience.

We will use the STS (an Eclipse-based IDE) to build the application in this chapter. Download STS, unzip it in your local folder, and open the .exe file to start the STS. Once started, create a new Spring Starter Project of the Spring Boot type with the following attributes:

  • Name: blogpress
  • Type: Maven (you can also select Gradle)
  • Packaging: Jar
  • Java Version: 8 (or above)
  • Language: Java
  • Group: This would be a Maven groupId, so give the appropriate value
  • Artifact: This would be a Maven artifactId, so give the appropriate value
  • Version: 0.0.1-SNAPSHOT—the build version of our application build
  • Description: A simple blog management system
You can create a Spring Boot application from a command window as well. Spring provides a tool called Spring command-line interface (CLI) for this. Another way of creating a Spring Boot starter project is with https://start.spring.io/. You need to define the dependencies and it will allow users to download the entire project structure from the web.

Keeping all default options, click Finish to create the Spring Boot application. You will see the following dependencies in pom.xml:

<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-web</artifactId>
</dependency>

<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-test</artifactId>
<scope>test</scope>
</dependency>

Spring Boot provides various starters, specific for each dependency so that their JARs are available in the classpath. Since we want to develop a web application (Spring MVC), we keep the starter spring-boot-starter-web in the previous code (in fact, it is added while creating a project in the STS).

Spring provides a set of dependencies for a specific functionality in the form of a starter. It is a convenient way of managing dependencies in a Spring Boot application. When you specify a particular starter, Spring Boot will pull all (recursive) dependencies in your application for you. For example, if you wish to add a data store to your application with JPA, simply add spring-boot-starter-jpa to pom.xml in your Spring Boot application. All dependency will be carried out by Spring Boot so that you can focus on business implementations.

You will see spring-boot-starter-parent in the parent element of pom.xml. This is the magic of Spring Boot. Your application extends all Spring Boot capabilities by this declaration, as following snippet shows:

<parent>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-parent</artifactId>
<version>2.1.0.BUILD-SNAPSHOT</version>
<relativePath/>
</parent>
..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset
3.21.93.44