← 返回命令列表

Linux command

spring 命令

文本

复制后可按需替换文件名、目录或参数。

常用示例

Create new project

spring init --dependencies=[web,data-jpa,postgresql] [myapp]

Create with specific options

spring init --build=[gradle] --java-version=[17] --packaging=[war] [myapp.zip]

List available dependencies and options

spring init --list

Encode a password

spring encodepassword [password]

Run Spring Boot application

./mvnw spring-boot:run

Run with Gradle

./gradlew bootRun

Package as executable JAR

./mvnw package

Show CLI version

spring --version

说明

spring CLI and Spring Boot Maven/Gradle plugins manage Spring Boot applications. The CLI scaffolds new projects and encodes passwords; plugins handle building and running. The run command was removed in Spring Boot 3.0. 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.

FAQ

What is the spring command used for?

spring CLI and Spring Boot Maven/Gradle plugins manage Spring Boot applications. The CLI scaffolds new projects and encodes passwords; plugins handle building and running. The run command was removed in Spring Boot 3.0. 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.

How do I run a basic spring example?

Run `spring init --dependencies=[web,data-jpa,postgresql] [myapp]` in a terminal, then adjust file names, paths, flags, or remote targets for your system.

Where can I find more spring examples?

This page includes 8 examples for spring, plus related commands for nearby Linux tasks.