Skip to content

Launching a Spring Boot Application: A Guide

Comprehensive Online Learning Hub: This platform serves as a versatile educational tool, catering to learners in various fields such as computer science, programming, traditional education, professional development, commerce, digital tools, competitive exams, and more, offering a one-stop...

Instructions for Executing a Spring Boot Application
Instructions for Executing a Spring Boot Application

Launching a Spring Boot Application: A Guide

Running a Spring Boot Project in IntelliJ IDEA and Spring Tool Suite (STS)

If you're looking to create, set up, and run a Spring Boot project, this guide will walk you through the process for both IntelliJ IDEA and Spring Tool Suite (STS).

Creating a Spring Boot Project

To get started, use Spring Initializr. Open a web browser and navigate to Spring Initializr. Fill in the project details, including the build tool, language, Spring Boot version, and metadata. Don't forget to add any necessary dependencies, such as Spring Web or Spring Data JPA. Once you've filled out the form, click the Generate button to download a ZIP file containing your project.

Importing the Project

For IntelliJ IDEA, ensure the software is installed on your system. Open the software, go to File > Open, locate the extracted project folder, and open it. IntelliJ IDEA will automatically import the project and download the required dependencies.

For STS, you can create a project directly or generate one in Spring Initializr and import it. To import a project, go to File > Open Project from File System and select your project directory.

Setting Up SDK and Java Version

Confirm that the project is using a compatible JDK, preferably Java 17. In IntelliJ IDEA, you can check and change this in Project Structure > Project settings.

Running the Spring Boot Application

In IntelliJ IDEA, open the main application file, typically named or (if using Kotlin), which contains the method annotated with . Click the green Run icon next to the method or press Shift + F10 to start the app.

In STS, open , right-click and Run As ->Spring Boot App. The console will show the Tomcat server started on the specified port.

Testing the Application

Access the default URL (e.g., ) in your browser or use tools like Postman to test REST endpoints. If you added a simple REST controller returning "Hello World", you should see that response.

Changing the Port Number

If you encounter an error, it's recommended to change the port number. In the application.properties file, use the line to change the default port from 8080 to 8989.

Accessing the Output Screen

The output screen can be accessed through the URL: (e.g., ).

For beginners, using Spring Initializr via the web and importing the ZIP project into IntelliJ or STS is straightforward and efficient. For more experienced users, creating a new Spring Boot project directly within IntelliJ or STS may be preferred.

Read also:

Latest