LinuxCommandLibrary

spring

Spring Boot application framework CLI

TLDR

Create new project (via start.spring.io)

$ spring init --dependencies=[web,data-jpa,postgresql] [myapp]
copy
Create with specific options
$ spring init --build=[gradle] --java-version=[17] --name=[myapp] [myapp]
copy
Run Spring Boot application
$ ./mvnw spring-boot:run
copy
Run with Gradle
$ ./gradlew bootRun
copy
Package as JAR
$ ./mvnw package
copy
Build native image
$ ./mvnw -Pnative native:compile
copy
List available dependencies
$ spring init --list
copy
Show version
$ spring --version
copy

SYNOPSIS

spring command [options] [args...]
./mvnw spring-boot:goal
./gradlew bootTask

DESCRIPTION

spring CLI and Spring Boot Maven/Gradle plugins manage Spring Boot applications. The CLI scaffolds new projects; plugins handle building and running.
spring init fetches project templates from start.spring.io with selected dependencies. Dependencies like web, data-jpa, security add starters that auto-configure functionality.
Running applications during development uses bootRun (Gradle) or spring-boot:run (Maven). DevTools enables hot reload when included as dependency.
bootJar / package creates an executable JAR with embedded server. Run with java -jar app.jar. bootBuildImage creates OCI container images without Dockerfile.
Native image support via GraalVM compiles to native executables with -Pnative profile. Requires GraalVM and produces fast-startup binaries.

SPRING CLI COMMANDS

init [options] [location]

Create new project from start.spring.io.
shell
Start interactive shell.
version
Show CLI version.
help [command]
Display help.

INIT OPTIONS

-d, --dependencies list

Project dependencies.
-b, --build type
Build system: maven, gradle.
-j, --java-version version
Java version: 17, 21.
-l, --language lang
Language: java, kotlin, groovy.
-n, --name name
Project name.
-g, --group-id group
Maven group ID.
-a, --artifact-id artifact
Maven artifact ID.
-p, --packaging type
Packaging: jar, war.
--boot-version version
Spring Boot version.
--list
List available options.

MAVEN/GRADLE GOALS

spring-boot:run / bootRun

Run application.
spring-boot:build-image / bootBuildImage
Build container image.
package / bootJar
Create executable JAR.
spring-boot:start / bootStart
Start application in background.
spring-boot:stop / bootStop
Stop background application.

CAVEATS

CLI primarily for project creation; Maven/Gradle for ongoing development. Auto-configuration may conflict with custom config. Native image requires additional metadata. DevTools should be excluded from production.

HISTORY

Spring Boot was created by Pivotal (now VMware) team led by Phil Webb and released in 2014. It simplified Spring Framework development with convention over configuration. Spring Boot 2.0 (2018) updated to Spring Framework 5. Version 3.0 (2022) required Java 17 and added native compilation support. Spring Boot is the most widely used Java application framework.

SEE ALSO

mvn(1), gradle(1), micronaut(1), quarkus(1)

> TERMINAL_GEAR

Curated for the Linux community

Copied to clipboard

> TERMINAL_GEAR

Curated for the Linux community