Spring Boot Local Development Guide

Run Java Web applications and REST APIs on localhost:8080 using Spring Boot, with support for hot reloading via devtools.


Spring Boot is the most popular web and microservices framework in the Java ecosystem, with embedded Tomcat/Jetty. By default, it runs locally at http://localhost:8080.

Quick Start

Generate a project using Spring Initializr, or:

# Requires JDK 17+ and Maven/Gradle
./mvnw spring-boot:run
# or
./gradlew bootRun

Access http://localhost:8080.

Change Port

In src/main/resources/application.properties:

server.port=8081

Or in application.yml:

server:
  port: 8081

Common localhost Paths

PathDescription
/Home page or API root
/actuator/healthHealth check (requires actuator)
/h2-consoleEmbedded H2 console (if enabled)

Local Database

For development, use the H2 in-memory database or connect to a local MySQL/PostgreSQL:

spring.datasource.url=jdbc:postgresql://localhost:5432/mydb
spring.datasource.username=postgres
spring.datasource.password=secret

DevTools Hot Reload

After including spring-boot-devtools, code changes will automatically restart (for resources in the classpath).

Frequently Asked Questions

Port 8080 is occupied by Tomcat/other Java services
Change server.port or stop other services.

Slow builds
The first dependency download may be slow; consider using a domestic Maven mirror.

Summary

Spring Boot defaults to http://localhost:8080, making it the standard localhost entry point for Java backends and REST APIs.

访客计数:------ Best viewed in Netscape Navigator · 800×600 © LocalHost Run