Spring Framework Tutorial
Software Setup and Configuration (STS/Eclipse/IntelliJ)
Core Spring
Spring Annotations
Spring Data
Spring JDBC
Spring Security
Running a Spring Boot application in IntelliJ IDEA is straightforward due to the excellent integration between the two. Here's a step-by-step guide to run your first Spring Boot application in IntelliJ IDEA:
Open the Project:
File
> Open
, navigate to your project's root directory, and click OK
.Maven/Gradle Dependencies:
Once the project is opened, IntelliJ IDEA will automatically start downloading the required dependencies if it's a Maven or Gradle project. You can see the progress at the bottom of the IDE. If for some reason it doesn't start:
pom.xml
file > Reload Project
.build.gradle
file > Reload Project
.Locate the Main Class:
Navigate to the main application class. This is the class with the @SpringBootApplication
annotation. It contains the main method which looks like this:
public static void main(String[] args) { SpringApplication.run(YourApplicationName.class, args); }
Run the Application:
Run 'YourApplicationName'
.Alternatively, in the top-right corner of the editor, you'll notice a green play button (▶️) beside the main method. You can click that button to run the application.
Check the Console:
After you run the application, switch to the Run
window at the bottom of IntelliJ IDEA. Here, you can see the console output of your application. If everything is set up correctly, you'll see log messages from Spring, and towards the end, something similar to:
Started YourApplicationName in X seconds (JVM running for Y).
This indicates that the Spring Boot application has started successfully.
Access the Application:
If your Spring Boot application has a web component (e.g., a REST API or a web frontend), you can now access it by opening a web browser and navigating to:
http://localhost:8080
Change the port number if you've configured a different one in application.properties
or application.yml
.
Stopping the Application:
To stop the application, go to the Run
window at the bottom and click the red square stop button (⏹️).
Remember, IntelliJ IDEA provides many tools and features to make Spring Boot development easier, such as autocompletion, integrated debugging, database tools, and more. Familiarizing yourself with these features will help streamline your development process.
Executing Your First Spring Boot RESTful Service in IntelliJ:
@RestController public class HelloWorldController { @GetMapping("/hello") public String hello() { return "Hello, World!"; } }