Open In App

Creating Spring Boot Project Using STS

Last Updated : 28 Dec, 2023
Improve
Improve
Like Article
Like
Save
Share
Report

Spring Boot is one of the favorite items of Spring Framework, as it requires very minimal configuration, unlike Spring MVC. Spring Boot applications are easily configurable and have several other benefits to use for developing stand-alone Java applications. Spring Boot comes with,

  • Embedded Tomcat
  • Starter‘ dependency for easy configuration
  • Automatically configures other third-party libraries.
  • Provides production features
  • No need for XML configuration

Spring Tool Suite

Spring tool suite is an eclipse-based IDE built to develop Spring-framework applications.

Spring Tool Suite

Creating Spring Boot Project

If you haven’t installed the Spring tool suite, you can check here, how to install sts in your system.

Step 1: Once sts is ready in your system, click on the executable (.exe) file and it will open a prompt to select project location.

Creating a Workspace in STS

Step 2: You can leave this directory as it is or can change it accordingly. Click on OK and the Spring tool suite’s home screen will open.

Workspace view

Step 3: On the left side, click on file -> new -> spring starter project.

Directory Structure

Step 4: A new window will open now, asking details for about your project

Maven bootstrap window

Description for each options shown in the above image is as follows-

  1. Let the service URL be the same as start.spring.io.
  2. Name your project anything you want to.
  3. Choose the type as maven
  4. Packaging as jar.
  5. Java version will be available based on the JDK installed on your device.
  6. Name group as com.<Enter a name accordingly>
  7. The default version will be ‘0.0.1’
  8. You can write your project description according to your project.

Step 5: Once these things are done, click on Next.

Dependency Bootstrap

Step 6: You can leave the spring boot version as it is. Use the search box given to search for dependencies to add to the project as per your need. for the time being you can search ‘web‘ and select ‘Spring web‘ and ‘Spring web services‘.

Let’s say you want to perform any database operation in the project then you can go ahead and search for ‘SQL‘ and select ‘Spring data JPA‘ and ‘MySql driver‘. However, you can also add dependencies later using the Maven repository.

Note: Don’t add the JPA, MySQL dependencies if you don’t have MySQL configured in your system.

Step 7: Once you are done click on Finish.

Url config for spring boot project

Step 8: Now click on finish and wait till Spring boot configures all your dependencies. Now it completely depends on your device and internet speed and how much time it will take to finish the build. You can see the progress at the bottom of the window.

Package in workspace

Step 9: Once it has completed the build, go ahead and check out your project.

GFG Application

Note: You can see the @SpringBootApplication annotation in the GfgApplication.java file denoting it as a Spring Boot Application. you can change dependencies by going to the pom.xml file and adding dependencies manually from mvn repository.

Step 10: Now, right-click on the blank portion and select run as, you should get an option of Spring Boot App, select that.

Run instruction for Project

Step 11: Allow the Windows security prompt (if pops up).

Windows firewall allow

Step 12: Now wait for the deployment on the local host, you will be able to see the port number, on which the application is running. (for most cases it is 8080).

Console Log

Step 13: It’s showing Tomcat started on port 8080, which means your application is running locally on port no 8080. Now head over to your web browser and go to http://localhost:8080/ to check it.

Application Up

If you can see this Whitelabel error page that means your spring application is successfully running. As there is no controller configured for routing and no views exist that’s why this page is showing up. Now can add your controllers and views as per your requirements and run your application.



Like Article
Suggest improvement
Share your thoughts in the comments

Similar Reads