← All notes

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

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

Permanent ID: iil:note:yk0d0x72

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.},
}

Markdown

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.