Your First Spring Boot 4 Project: Create It in IntelliJ, Run It, and the Four Files That Matter
New project, Spring Boot generator, Maven, one dependency (Spring Web), Run. Tomcat starts on 8080 and shows a Whitelabel 404 until you drop an index.html into static. Then the four files that matter: pom.xml, the main class, application.yaml and static/.
What you will learn
- Generate a Spring Boot 4 Maven project with Spring Web from IntelliJ or start.spring.io
- Run the main class and read the Whitelabel 404 correctly
- Serve a first page from the static folder
- Explain the job of pom.xml, the main class, application.yaml and static/
Before you start
- Spring MVC and SQLite Without Spring Boot
- JDK 25 and IntelliJ IDEA installed
Let's create a Spring Boot project in IntelliJ IDEA, see what it generates, run it, and serve a small page of our own. Then we'll look at the few files that actually matter, because a new Boot project looks like a lot of files and really isn't.
Step 1: generate the project
In IntelliJ, click New Project and pick Spring Boot under Generators. The server URL at the top is start.spring.io, the service that builds these starter projects; IntelliJ just talks to it for you. Open start.spring.io in a browser and you get the same generator as a website, which gives you a zip to open in your IDE. Both give the same project.
- Language Java, type Maven.
- Name
Chand, grouporg.studyeasy, so the package becomesorg.studyeasy.chand. - JDK 25 to run it; the project's Java version stays at 17 in this demo.
- Packaging jar: a jar runs on its own, with the web server packed inside.
- Configuration YAML. Properties would work too.
On the next page Spring Boot 4.1.2 is selected. Under Web, tick Spring Web ("build web applications using Spring MVC, with Apache Tomcat as the embedded server"). That's the only dependency. Click Create.
Step 2: run it
Click the green arrow next to main and choose Run. The Spring Boot banner prints, and after a few seconds the log says Tomcat started on port 8080 and the application started. Open http://localhost:8080 and you get a Whitelabel Error Page: Not Found, status 404. That's expected. The server works; there's just nothing at that address yet.
Step 3: a first page
Right-click src/main/resources/static, New, HTML File, name it index. Type something in the body and save:
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>Title</title>
</head>
<body>
Hi!
</body>
</html>
The running app still has the old files, so stop it and run it again. This time the log has a line about adding a welcome page from static/index.html: Boot found the file. Refresh localhost:8080 and the page says "Hi!".
The four files that matter
pom.xml: the shopping list
<parent>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-parent</artifactId>
<version>4.1.2</version>
<relativePath/>
</parent>
<groupId>org.studyeasy</groupId>
<artifactId>Chand</artifactId>
<properties>
<java.version>17</java.version>
</properties>
<dependencies>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-webmvc</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-webmvc-test</artifactId>
<scope>test</scope>
</dependency>
</dependencies>
<build>
<plugins>
<plugin>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-maven-plugin</artifactId>
</plugin>
</plugins>
</build>
The parent, spring-boot-starter-parent 4.1.2, picks matching versions for every jar, which is why the dependencies have no version numbers. The one line spring-boot-starter-webmvc brings Spring MVC, an embedded Tomcat and Jackson. The test starter is only used by tests. The Boot Maven plugin packs everything into a jar you can run.
ChandApplication.java: the start button
package org.studyeasy.chand;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
@SpringBootApplication
public class ChandApplication {
public static void main(String[] args) {
SpringApplication.run(ChandApplication.class, args);
}
}
A plain Java main, the same one you know from any Java program. Inside it, SpringApplication.run starts Spring and the server. Read @SpringBootApplication as "this is the app: scan this package, and set things up from the jars you find".
application.yaml: the settings
spring:
application:
name: Chand
One setting for now, the app's name. You'll see Chand in square brackets in the log. This is also where you change Boot's defaults, and only when you want to: server: port: 9090 would move the app to another port. .yaml or .properties are two formats for the same thing.
static/ and templates/
Anything in static goes to the browser as it is. index.html opens at / with no Java code behind it. templates is empty for now; it's for pages the server fills with data, which come later with Thymeleaf.
Run joins them up
mainruns and callsSpringApplication.run.- Boot reads
application.yaml; the name in the log comes from there. - It looks at the jars the pom brought in, finds Spring MVC and Tomcat, and gets Tomcat ready.
- Tomcat starts on 8080.
- The browser asks for
/, Boot servesstatic/index.htmlas the welcome page, and you see "Hi!".
Try it yourself: change the text in index.html and restart, then add server: / port: 9090 to application.yaml and open port 9090 instead. From the terminal, mvnw spring-boot:run (mvnw.cmd on Windows) runs the same app.
StudyEasy AI Community
Learn AI engineering, share what you build, and connect with other learners.
Free resources: lesson files, notebooks and code
Ask questions and join engineering discussions
Meet real people learning and building with AI
Related course on Udemy
FULL STACK JAVA : JAVA + JSP + SPRING BOOT AI + REACT + VIBE
Java 25, JSP, Hibernate, Spring Boot 4, REST APIs, React and Spring AI.View on Udemy ↗: FULL STACK JAVA : JAVA + JSP + SPRING BOOT AI + REACT + VIBE (paid course, opens in a new tab)Related posts
Why Spring in 2026: What the Container Does and What Spring Framework 7 Changed
Spring in one line: a container that creates your classes and hands each one what it needs. Plus the Spring Framework 7 baseline (JDK 17 to 25, Jakarta EE 11, Tomcat 11, JUnit 6), what got better than Spring 6, and a two-line version check.
A Plain Spring Project, No Boot: Your First Bean With spring-context
One dependency, one recipe, one getBean: a Maven project with spring-context 7.0.9, a Blog record, an AppConfig with @Bean, and a main that asks the container for the Blog. Then delete @Bean and meet NoSuchBeanDefinitionException.
Inversion of Control and Dependency Injection in Spring: One Program, Built Three Ways
A PostService needs a PostRepository. Build it three ways: the service calls new itself (tight coupling), main hands it in through the constructor (DI by hand), and the Spring container does the wiring from a @Configuration recipe.
Spring Component Scanning: @Component and @ComponentScan Instead of @Bean Methods
Instead of one @Bean method per class, put @Component on EmailNotifier and PostService and @ComponentScan on an empty BlogConfig. Spring walks the package, finds the stickers and builds the beans; main doesn't change.
