A first Spring Boot web application
Summary
The first-application tutorial builds a small web app with Maven or Gradle. A starter brings an embedded server and Spring MVC. One class is the entry point and the controller. Auto-configuration sets the web stack up from those jars. Run it from the build tool, or package an executable jar and start it with java.
Project and code
Check Java with java -version. The tutorial's sample is OpenJDK 17. Work in a fresh directory, or generate the project at start.spring.io with the Web starter.
Maven uses spring-boot-starter-parent. The tutorial pins that parent at 4.1.2, group com.example, artifact myproject. Gradle applies the Spring Boot plugin at that same version, the dependency-management plugin, and a Java toolchain of 17. Add spring-boot-starter-webmvc with no version of its own. A dependency tree then includes Tomcat and Spring Boot.
Put MyApplication under src/main/java/com/example. Mark it @RestController and @SpringBootApplication. @RequestMapping("/") returns the hello-world string. main calls SpringApplication.run. @RestController marks a web bean and writes the string back as the body. Those annotations are Spring MVC. Auto-configuration sees Tomcat and Spring MVC on the classpath and sets up a web app.
Run, package, and the servlet layer
mvn spring-boot:run or gradle bootRun starts it. The tutorial expects the hello-world text at localhost:8080. ctrl-c stops it. Add spring-boot-maven-plugin so mvn package repackages an executable jar under target. java -jar runs that file. Gradle uses gradle bootJar and the jar under build/libs.
@Controller or @RestController beans handle HTTP, mapped with @RequestMapping. Do not combine MVC auto-configuration with @EnableWebMvc. Static files come from /static, /public, /resources, or /META-INF/resources. The embedded server listens on port 8080. Tomcat and Jetty are the embedded containers. A single servlet bean maps to /. Filters map to /*.
Claims
- id: C1 claim: The first application can be built with either Maven or Gradle. source: S1 evidence: "You can choose between Maven or Gradle as the build system."
- id: C2 claim: Starters add the jars you are likely to need for one kind of application onto the classpath. source: S1 evidence: "Spring Boot provides a number of starters that let you add jars to your classpath."
- id: C3 claim: SpringApplication.run starts Spring, which then starts the auto-configured Tomcat web server. source: S1 evidence: "SpringApplication bootstraps our application, starting Spring, which, in turn, starts the auto-configured Tomcat web server."
- id: C4 claim: An executable jar is produced for Maven by adding the spring-boot-maven-plugin to the POM. source: S1 evidence: "To create an executable jar, we need to add the spring-boot-maven-plugin to our pom.xml"
- id: C5 claim: Spring MVC controller beans handle incoming HTTP requests, and @RequestMapping maps methods to those requests. source: S2 evidence: "Spring MVC lets you create special @Controller or @RestController beans to handle incoming HTTP requests."
- id: C6 claim: Spring Boot MVC auto-configuration takes the place of @EnableWebMvc, and you should not turn both on. source: S2 evidence: "It replaces the need for @EnableWebMvc and the two cannot be used together."
- id: C7 claim: By default the embedded servlet server accepts HTTP on port 8080. source: S2 evidence: "By default, the embedded server listens for HTTP requests on port 8080"
License: CC-BY-4.0 · Summary by iinventedlight (AI-assisted). Sources: Spring (Broadcom), Developing Your First Spring Boot Application, Apache-2.0 (spring-boot docs); Spring (Broadcom), Servlet Web Applications, Apache-2.0 (spring-boot docs).
Cite this
iinventedlight. 2026. "A first Spring Boot web application." iinventedlight Library, iil:note:yk0d0x72, version of 2026-11-03. https://iinventedlight.com/library/notes/spring-boot-first-app/. License: CC-BY-4.0.
@misc{iil_note_yk0d0x72,
author = {{iinventedlight}},
title = {{A first Spring Boot web application}},
howpublished = {iinventedlight Library},
year = {2026},
date = {2026-11-03},
url = {https://iinventedlight.com/library/notes/spring-boot-first-app/},
note = {Permanent ID iil:note:yk0d0x72. License: CC-BY-4.0.},
}
Spotted a mistake? Use the MCP feedback tool or email hello@iinventedlight.com.
For language models and agents: start at /llms.txt. This page in Markdown: /library/notes/spring-boot-first-app.md.