Quickly Set Up a Spring Boot Project in IntelliJ IDEA
This step‑by‑step guide shows how to configure JDK 1.8 and Maven 3.6.2, create a new Spring Boot project in IntelliJ IDEA using Spring Initializr, examine the generated pom.xml, add a simple HelloController, and verify that the application runs successfully.
Environment requirements: JDK 1.8 and Maven 3.6.2.
Creating the Project
In IntelliJ IDEA choose File → New → Project and select Spring Initializr . The built‑in plugin requires an internet connection; if the UI cannot load, download a starter zip from https://start.spring.io/ and import it manually.
After confirming the project metadata (group, artifact, packaging, Java version), click Next and finish the wizard. IDEA generates the standard Spring Boot directory layout, which can be inspected in the Project view.
Inspecting pom.xml
The generated pom.xml already contains the Spring Boot parent, core starter dependencies, and the Maven plugin configuration needed to package an executable jar. Comments in the file explain each section.
Adding a Simple Controller
Create a new Java class HelloController.java under the package com.example.springbootproject.controller with the following content:
package com.example.springbootproject.controller;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;
@Controller
public class HelloController {
@RequestMapping("/hello")
@ResponseBody
public String hello(){
return "hello";
}
}Building and Running the Application
From the IDE or the command line, build the project with Maven: mvn clean package Run the generated jar (or use the IDE’s Run configuration):
java -jar target/<em>your-artifact-id</em>-0.0.1-SNAPSHOT.jarOpen a browser and navigate to http://localhost:8080/hello. The response should be the plain text string hello , confirming that the Spring Boot application is correctly set up.
These steps produce a minimal, runnable Spring Boot project that can be extended with additional controllers, services, and configuration as needed.
Signed-in readers can open the original source through BestHub's protected redirect.
This article has been distilled and summarized from source material, then republished for learning and reference. If you believe it infringes your rights, please contactand we will review it promptly.
How this landed with the community
Was this worth your time?
0 Comments
Thoughtful readers leave field notes, pushback, and hard-won operational detail here.
