Skip to content

Your first Spring Boot app

Start with an empty directory. By the end you’ll have a local HTTP endpoint, a passing test and a JAR you can run with Java.

Install jpm

Use Windows, macOS or Linux with Node.js 22 or newer. The alpha supports new, single-module Spring MVC applications. Allow network access for the first setup.

npm install -g java-npm-cli
jpm --version

In PowerShell, if script execution is restricted, use npm.cmd and jpm.cmd. See the PowerShell commands for selecting Java in your shell.

On Homebrew, brew install coderserio/tap/jpm installs the CLI and Node together.

Create the project

jpm create hello-jpm --java 21 -y
cd hello-jpm
jpm jdk use 21
jpm install

Spring Initializr supplies the template and Maven Wrapper. jpm adds a controller and an HTTP test. It picks up a local JDK 21 or downloads Temurin, then Maven resolves your project’s dependencies.

Troubleshoot a slow or failed first download

See a change in your browser

Start the application and leave this terminal running.

jpm dev

Once Spring Boot starts, open localhost:8080 or try the endpoint in a second terminal.

$ curl http://localhost:8080/
{"message":"Hello from jpm!"}

Open src/main/java/com/example/hellojpm/HelloController.java and edit the greeting. Save, wait for compilation and the DevTools restart, then run curl again. Restore the greeting before running tests, or update the matching expectation in JpmHelloTests.java.

Add a dependency and build

Stop the dev server with Ctrl+C. In the project directory, add Spring’s validation starter and run the tests.

jpm add org.springframework.boot:spring-boot-starter-validation
jpm test
jpm build

jpm add updates java.dependencies in package.json and regenerates pom.xml. jpm build runs Maven’s package phase, including tests. To launch the resulting JAR from bash or zsh, select the project’s JDK in this shell.

eval "$(jpm jdk env)"
java -jar target/hello-jpm-0.0.1-SNAPSHOT.jar

Keep going

Run jpm doctor from the project directory for an environment check. These references cover the individual commands and common setup problems.