当前位置: 首页 > news >正文

Spring Boot CLI命令行工具

Spring Boot CLI适应各命令行工具,你可以使用它快速创建spring项目,通常我们都是使用idea等工具来创建项目,用不到CLI,但这提供了一种在没有IDE的情况下快速创建启动spring应用的方法。

  • 官方文档

https://docs.spring.io/spring-boot/installing.html#getting-started.installing.cli

  • 使用SDKMAN!安装Spring Boot CLI并且可以管理多个版本
sdk install springboot 3.3.3
  • 如果你为CLI开发了新特性并且想访问自己构建的版本,可以使用如下版本
$ sdk install springboot dev /path/to/spring-boot/spring-boot-cli/target/spring-boot-cli-3.3.3-bin/spring-3.3.3/
$ sdk default springboot dev
$ spring --version
Spring CLI v3.3.3
  • 安装好springboot就可以使用spring命令行工具
xx:raccoon-docs xx$ spring
usage: spring [--help] [--version] <command> [<args>]Available commands are:init [options] [location]Initialize a new project using Spring Initializr (start.spring.io)encodepassword [options] <password to encode>Encode a password for use with Spring Securityshell                Start a nested shellCommon options:--debug Verbose mode   Print additional status information for the command you are runningSee 'spring help <command>' for more information on a specific command.
  • 通过spring help init指令获取更详细的信息
xx:raccoon-docs xx$ spring help init
spring init - Initialize a new project using Spring Initializr (start.spring.io)usage: spring init [options] [location]Option                       Description                                       
------                       -----------                                       
-a, --artifact-id <String>   Project coordinates; infer archive name (for      example 'test')                                 
-b, --boot-version <String>  Spring Boot version (for example '1.2.0.RELEASE') 
--build <String>             Build system to use (for example 'maven' or       'gradle') (default: gradle)                     
-d, --dependencies <String>  Comma-separated list of dependency identifiers to include in the generated project                
--description <String>       Project description                               
-f, --force                  Force overwrite of existing files                 
--format <String>            Format of the generated content (for example      'build' for a build file, 'project' for a       project archive) (default: project)             
-g, --group-id <String>      Project coordinates (for example 'org.test')      
-j, --java-version <String>  Language level (for example '1.8')                
-l, --language <String>      Programming language  (for example 'java')        
--list                       List the capabilities of the service. Use it to   discover the dependencies and the types that areavailable                                       
-n, --name <String>          Project name; infer application name              
-p, --packaging <String>     Project packaging (for example 'jar')             
--package-name <String>      Package name                                      
-t, --type <String>          Project type. Not normally needed if you use --   build and/or --format. Check the capabilities ofthe service (--list) for more details           
--target <String>            URL of the service to use (default: https://start.spring.io)                                      
-v, --version <String>       Project version (for example '0.0.1-SNAPSHOT')    
-x, --extract                Extract the project archive. Inferred if a        location is specified without an extension      examples:To list all the capabilities of the service:$ spring init --listTo creates a default project:$ spring initTo create a web my-app.zip:$ spring init -d=web my-app.zipTo create a web/data-jpa gradle project unpacked:$ spring init -d=web,jpa --build=gradle my-dir
  • 查看spring boot CLI版本
spring version
  • 查看支持的依赖项
xx:workplace-java xx$ spring init --list.   ____          _            __ _ _/\\ / ___'_ __ _ _(_)_ __  __ _ \ \ \ \
( ( )\___ | '_ | '_| | '_ \/ _` | \ \ \ \\\/  ___)| |_)| | | | | || (_| |  ) ) ) )'  |____| .__|_| |_|_| |_\__, | / / / /=========|_|==============|___/=/_/_/_/
:: Service capabilities ::  https://start.spring.ioSupported dependencies
+--------------------------------------+--------------------------------------------------------------+-----------------------+
| Id                                   | Description                                                  | Required version      |
+--------------------------------------+--------------------------------------------------------------+-----------------------+
| activemq                             | Spring JMS support with Apache ActiveMQ 'Classic'.           |                       |
|                                      |                                                              |                       |
| actuator                             | Supports built in (or custom) endpoints that let you monitor |                       |
|                                      | and manage your application - such as application health,    |                       |
|                                      | metrics, sessions, etc.                                      |                       |
|                                      |                                                              |                       |
+--------------------------------------+--------------------------------------------------------------+-----------------------+Project types (* denotes the default)
+-----------------------+--------------------------------------------------------------+--------------------------------------------+
| Id                    | Description                                                  | Tags                                       |
+-----------------------+--------------------------------------------------------------+--------------------------------------------+
| gradle-build          | Generate a Gradle build file.                                | build:gradle,format:build                  |
|                       |                                                              |                                            |
| gradle-project *      | Generate a Gradle based project archive using the Groovy     | build:gradle,dialect:groovy,format:project |
|                       | DSL.                                                         |                                            |
|                       |                                                              |                                            |
| gradle-project-kotlin | Generate a Gradle based project archive using the Kotlin     | build:gradle,dialect:kotlin,format:project |
|                       | DSL.                                                         |                                            |
|                       |                                                              |                                            |
| maven-build           | Generate a Maven pom.xml.                                    | build:maven,format:build                   |
|                       |                                                              |                                            |
| maven-project         | Generate a Maven based project archive.                      | build:maven,format:project                 |
+-----------------------+--------------------------------------------------------------+--------------------------------------------+Parameters
+-------------+------------------------------------------+------------------------------+
| Id          | Description                              | Default value                |
+-------------+------------------------------------------+------------------------------+
| artifactId  | project coordinates (infer archive name) | demo                         |
| bootVersion | spring boot version                      | 3.3.3                        |
| description | project description                      | Demo project for Spring Boot |
| groupId     | project coordinates                      | com.example                  |
| javaVersion | language level                           | 17                           |
| language    | programming language                     | java                         |
| name        | project name (infer application name)    | demo                         |
| packageName | root package                             | com.example.demo             |
| packaging   | project packaging                        | jar                          |
| type        | project type                             | gradle-project               |
| version     | project version                          | 0.0.1-SNAPSHOT               |
+-------------+------------------------------------------+------------------------------+
  • 创建一个简单的项目
xx:workplace-java xx$ spring init --dependencies=web,data-jpa my-project
Using service at https://start.spring.io
Project extracted to '/Users/xx/Documents/IDE/workplace-java/my-project'

示例创建项目my-project,默认gradle依赖spring-boot-starter-web和spring-boot-starter-data-jpa

  • spring shell命令
xx:raccoon-docs xx$ spring shell
Spring Boot (v3.3.3)
Hit TAB to complete. Type 'help' and hit RETURN for help, and 'exit' to quit.
$ 
clear            encodepassword   exit             help             init             prompt           version          
$ 

开源SDK:https://github.com/mingyang66/spring-parent

相关文章:

  • Java中的PriorityQueue详解
  • 爬虫库是什么?是ip吗
  • 分享国产RISC-V单片机通用
  • 【MySQL】视图、用户和权限管理
  • 每一个云手机的ip是独立的吗
  • 【2025】基于Django的鱼类科普网站(源码+文档+调试+答疑)
  • 观测云链路追踪分析最佳实践
  • 升级 Windows 后如何恢复丢失的文件
  • I/O中断处理过程
  • websocket初识
  • 华为云LTS日志上报至观测云最佳实践
  • EXEAL无法使用宏处理办法
  • chatgpt的ai导师风格设置
  • uniapp修改uni-ui组件样式(对微信小程序/H5有效,vue3)
  • iOS 提取图片的主题色,并支持灵活提取
  • 【跃迁之路】【519天】程序员高效学习方法论探索系列(实验阶段276-2018.07.09)...
  • Bootstrap JS插件Alert源码分析
  • ComponentOne 2017 V2版本正式发布
  • conda常用的命令
  • ECMAScript6(0):ES6简明参考手册
  • python docx文档转html页面
  • SpringCloud(第 039 篇)链接Mysql数据库,通过JpaRepository编写数据库访问
  • Spring声明式事务管理之一:五大属性分析
  • vue-router 实现分析
  • 分享自己折腾多时的一套 vue 组件 --we-vue
  • 七牛云假注销小指南
  • 嵌入式文件系统
  • 算法-图和图算法
  • 完善智慧办公建设,小熊U租获京东数千万元A+轮融资 ...
  • ###项目技术发展史
  • #Lua:Lua调用C++生成的DLL库
  • $(function(){})与(function($){....})(jQuery)的区别
  • (Ruby)Ubuntu12.04安装Rails环境
  • (规划)24届春招和25届暑假实习路线准备规划
  • (亲测有效)解决windows11无法使用1500000波特率的问题
  • (三)Hyperledger Fabric 1.1安装部署-chaincode测试
  • (四)JPA - JQPL 实现增删改查
  • (图)IntelliTrace Tools 跟踪云端程序
  • .NET C# 使用 SetWindowsHookEx 监听鼠标或键盘消息以及此方法的坑
  • .Net Core与存储过程(一)
  • .Net Core中Quartz的使用方法
  • .NET 程序如何获取图片的宽高(框架自带多种方法的不同性能)
  • .NET/C#⾯试题汇总系列:⾯向对象
  • .Net+SQL Server企业应用性能优化笔记4——精确查找瓶颈
  • .NET建议使用的大小写命名原则
  • .NET开源全面方便的第三方登录组件集合 - MrHuo.OAuth
  • .Net下的签名与混淆
  • .php文件都打不开,打不开php文件怎么办
  • @antv/g6 业务场景:流程图
  • @data注解_一枚 架构师 也不会用的Lombok注解,相见恨晚
  • @Value获取值和@ConfigurationProperties获取值用法及比较(springboot)
  • [4.9福建四校联考]
  • [CF407E]k-d-sequence
  • [Git场景]常用工作场景演练
  • [hdu2196]Computer树的直径