AI Hints
Home›Spring Boot Tutorial›The Main Class, Running the App and Your First Endpoint
Spring Boot · Lesson 8 of 120

Running the App

Start, stop, restart.

⏱ 2 min read▶ Video at 9:40🎓 Free
Watch this lesson in the Spring Boot courseWatch on YouTube ↗Full Spring Boot course

A web server is different from most programs. It doesn't finish. It keeps running, and waits for requests.

  • Not like a script
  • It keeps running
  • Waiting for requests

Ways to run it

From a terminal, dot slash m v n w spring boot colon run builds and starts the app. On Windows, it's m v n w dot cmd. In your editor, you can press the green run button, next to main. All of them do the same thing.

WhereHow
Mac / Linux terminal./mvnw spring-boot:run
Windows terminalmvnw.cmd spring-boot:run
IntelliJ or VS Codethe ▶ button next to main

Stopping and restarting

To stop the app, press control C in its terminal, or the red stop button in your editor. After you change your code, stop the app, and start it again. Your changes only apply after a restart. If the port is already in use, an old copy is probably still running. Stop it first.

keyvalue
StopCtrl+C or ■ stop
Changed code?restart the app
Port 8080 in usean old copy is running
Fixstop it, then start again

How the lessons run

In this course, every example really runs. We start the real app, then send real requests with curl, in a second terminal. Then we stop it. You'll see the responses, and the app's own log lines, below them.

keyvalue
1./mvnw spring-boot:run
2curl in a second terminal
3see the response
4app log lines below

Summary

Run the app with the Maven wrapper, or your editor's run button. Stop it with control C, and restart after every change. Next, your first endpoint.

Key takeaways
  • ./mvnw spring-boot:run
  • Ctrl+C to stop
  • Restart after changes
Next up: Your First Endpoint — hello, world