Installation
Spring CLI 提供了多种格式,让您可以选择喜欢的安装方法。可从 Release Page 下载工件。
The Spring CLI is available in various formats that let you pick your favorite installation method. Downloadable artifacts are available from the Release Page.
Binary Release
- Windows
-
- Manually
-
-
spring-cli-standalone-<version>-windows.x86_64.zip - bundled x86 JDK
-
spring-cli-installer-<version>-windows-x86_64.msi - msi installation with bundled x86 JDK
-
- Linux
-
- Manually
-
-
spring-cli-standalone-<version>-linux.x86_64.zip - bundled x86 JDK
-
spring-cli-installer-<version>-1.x86_64.rpm - rpm installation with bundled x86 JDK
-
spring-cli-installer<version>-1_amd64.deb_ - dep installation with bundled x86 JDK
-
- Homebrew Tap
brew tap spring-cli-projects/spring-cli
brew install spring-cli
- Mac
-
- Manually
-
-
spring-cli-standalone-<version>-osx.x86_64.zip - bundled x86 JDK
-
spring-cli-standalone-<version>-osx.aarch64.zip - bundled arm JDK
-
- Homebrew Tap
-
The Tap formula chooses between x86 and aarch64, depending on your brew setup.
brew tap spring-cli-projects/spring-cli
brew install spring-cli
- Generic
-
- Manually
-
-
spring-cli-<version>.jar - plain fat jar, needs separate JDK17 installation
-
spring-cli-<version>.zip - plain fat jar with start scripts, needs separate JDK17 installation
-
Getting Snapshot Binaries
可在 GitHub Releases early-access 中获得最新的快照二进制文件。
Latest snapshot binaries are available in a GitHub Releases early-access.
您也可以按照[本页后面内容中所述的安装构建说明]根据源代码构建 Uber-jar。
You can also build the uber-jar from source code, as described installation-build-instructions.
Building from source
Java 17 Installation Required
即使您在 Java 11 或 Java 8 项目上使用 Spring CLI,CLI 本身也需要访问 Java 17 安装程序。
Even if you use the Spring CLI on a Java 11 or Java 8 project, the CLI itself needs to have access to an installation of Java 17.
创建一个指向 Java 17 安装程序的 JAVA_HOME
环境变量。例如,对于 bash
shell,您可以运行以下命令:
Create a JAVA_HOME
environment variable that points to your Java 17 installation.
For example, for bash
shells, you can run the following commands:
export JAVA_HOME=jdk-install-dir
export PATH=$JAVA_HOME/bin:$PATH
这是内部使用的 OpenRewrite 所需的。
This is required by OpenRewrite, which is used internally.
Build Instructions
若要自己构建 jar,请运行以下命令:
To build the jar yourself, run the following commands:
git clone https://github.com/spring-projects/spring-cli $HOME/temp/spring-cli
cd $HOME/temp/spring-cli
./gradlew clean build -x test
现在,创建一个别名,以便使用命令“spring”来调用 CLI:
Now create an alias to invoke the CLI with a command of 'spring':
alias spring='java -jar $HOME/temp/spring-cli/build/libs/spring-cli-{project-version}.jar'
Interactive Mode
除了使用别名运行 Spring Boot Uber-jar 或使用命令行上的“spring”运行原生二进制文件外,还可以进入交互模式,其中 Spring CLI 将继续运行。在这种情况下,您无需添加“spring”关键字即可运行命令。
In addition to running the Spring Boot uber-jar with an alias or running the native binary by using spring
at the command line, you can enter an interactive mode where the Spring CLI continues to run. In this case, you need not add the spring
keyword to run the commands.
交互模式提供命令选项完成功能,但您也可以依赖于位置选项值。
The interactive mode provides command option completion, but you can also rely on positional option values.
Command Completion
在非交互模式下,可以通过运行以下命令来在 shell 中获取命令完成:
In non-interactive mode, you can get command completion in your shell by running the following command:
eval "$(java -jar $HOME/temp/spring-cli/build/libs/spring-cli-{project-version}.jar completion bash)"
如果您配置了[role="bare"]https://docs.brew.sh/Shell-Completion,则 Homebrew 公式将设置 bash 自动完成。 |
The Homebrew formula sets bash completion if you have configured [role="bare"]https://docs.brew.sh/Shell-Completion. |