# Spring Initializer 源码 **Repository Path**: i_sxt/spring_initializer_source_code ## Basic Information - **Project Name**: Spring Initializer 源码 - **Description**: No description available - **Primary Language**: Unknown - **License**: Apache-2.0 - **Default Branch**: master - **Homepage**: None - **GVP Project**: No ## Statistics - **Stars**: 3 - **Forks**: 5 - **Created**: 2020-07-20 - **Last Updated**: 2024-11-21 ## Categories & Tags **Categories**: Uncategorized **Tags**: None ## README = Spring Initializr image:https://ci.spring.io/api/v1/teams/initializr/pipelines/initializr/jobs/build/badge["Build Status", link="https://ci.spring.io/teams/initializr/pipelines/initializr?groups=Build"] image:https://badges.gitter.im/spring-io/initializr.svg[link="https://gitter.im/spring-io/initializr?utm_source=badge&utm_medium=badge&utm_campaign=pr-badge&utm_content=badge"] :引导文档: https://docs.spring.io/spring-boot/docs/current/reference/htmlsingle (就是简单的Spring Boot参考文档) :代码: https://github.com/spring-io/initializr/ (本项目spring放在github上的源码,你读的就是) :文档: https://docs.spring.io/initializr/docs/current-SNAPSHOT/reference (Spring Initializr 参考文档) :服务: https://github.com/spring-io/start.spring.io (生成SpringBoot项目的web网页) Spring Initializr 工具提供了一个可扩展的 API,用于通过实现的几个常见概念来生成基于 JVM 的项目。 * 生成的项目支持Java、Kotlin和Groovy语言。 * 使用Apache Maven 和 Gradle的实现构建系统抽象。 * 支持'. gitignore' 。 * 具有一些自定义资源生成的挂钩点(hook-points)。 项目的各种选项以元数据模型表示,该模型允许您配置:一系列的依赖项、支持的 JVM 和平台版本等。 Spring Initializr 还公开 Web 站点来生成实际项目,此外以众所周知的格式提供元数据,从而允许第三方客户端提供必要的援助。 提供了一组用于SpringBoot项目的可选的约定,并用于我们的链接中的生产实例:https://start.spring.io. To better understand how our 为了更好地了解我们的服务是怎样被配置的,您可能需要特别地检查 [服务] [配套项目], the {service}/blob/master/start-site/src/main/resources/application.yml[配置我们的实例]. 此类配置也在文档中详细介绍。 注:虽然Spring Initializr现在在 Maven Central 上可以获取,但它仍然处于 1.0 之前 状态,在这期间,仍然可能会对本项目进行主要的重构。访问: https://github.com/spring-io/initializr/milestones[milestones page] 查看变化的概述 == 安装并且开始使用 参考文档可在 {docs}/html/[HTML format] 处查看. == 各个模块 Spring Initializr 具有以下模块: * `initializr-actuator`: * "初始执行器":可选模块,用于在项目生成时提供额外的信息和统计信息。 * `initializr-bom`:提供物料清单,以便您在项目中进行依赖性管理。 * `initializr-docs`: 文档. * `initializr-generator`: 项目生成的核心类库. * `initializr-generator-spring`: 为特定项目定义典型、特别约定的可选模块 可以重复使用或使用您自己的约定来替换 * `initializr-generator-test`: 项目生成测试基础设施 * `initializr-metadata`: 项目各个方面的元数据基础结构 * `initializr-service-sample`: 展示基本的自定义实例 * `initializr-version-resolver`: 初始化版本解析器 可选模块,用于从任意 POM 中提取版本号 * `initializr-web`: 第三方客户端的 Web 站点 == 支持的接口 Spring Initializr 能够按下列方式来使用: * 在命令行上使用, {boot-doc}/#cli-init[the Spring Boot CLI] or simply with `cURL` or `HTTPie`. *在编辑器中使用, 其中: STS, IntelliJ IDEA Ultimate, NetBeans (with https://github.com/AlexFalappa/nb-springboot[this plugin]) VSCode (with https://github.com/microsoft/vscode-spring-initializr[the `vscode-spring-initializr` plugin]). * Web网页中使用来构建项目 (link:https://start.spring.io). 还有其他的命令行集成,您也可以以此来构建自己的应用! == 生成一个工程 由于 Spring Initializr 不具有 Web UI,因此您可以使用任何开箱即用的内容集的成来生成项目。例如,以下"curl"命令下载 一个包含基于 Maven 的项目和启动所需的基础结构的项目,以此来启动Spring Boot应用程序。 [source,bash] ---- $ curl https://start.spring.io/starter.zip -o demo.zip ---- 当然,你可以自定义要生成的项目,并具有多种选项: * 你要生成项目的基本信息: `groupId`, `artifactId`, `version`, `name`, `description` and `packageName` ** "name"属性还用于生成默认应用程序名称。逻辑是:应用程序的名称等于具有 "Application"后缀的"name"属性(除非已存在后缀)。当然,如果 指定名称包含 java 标识符的无效字符,"应用程序"可用作回退。 ** "artifactId"属性不仅定义了你要编译的工程的识别信息,也作为了工程本身的名称。 * `dependencies`: 你所要添加到项目的依赖标识符。 这些个标识符通过configuration被定义,且被暴露在<> * `type`: 你所想要生成项目的类型(e.g. `maven-project`) 同样,每个服务公开支持数十亿的类型,这些在<>可以见到. * `javaVersion`: JVM语言版本 (e.g. `1.8`). * `bootVersion`: SpringBoot的版本 (e.g. `2.1.0.RELEASE`). * `language`: 编码时要使用的语言 (e.g. `java`). * `packaging`: 项目的包结构 (e.g. `jar`). * `applicationName`: application class 的名字 (默认情况下,通过`name`属性推断). * `baseDir`: 项目创建的基本的目录的名字. 默认情况下, 项目保存在根路径(root) 一下为一些具体的命令行代码示例: [TIP] ==== You can "curl" an instance to get a usage page with examples (try `curl https://start.spring.io`) ==== This command generates an `another-project` directory holding a Gradle web-based Groovy project using the actuator: [source,bash] ---- $ curl https://start.spring.io/starter.tgz -d dependencies=web,actuator \ -d language=groovy -d type=gradle-project -d baseDir=another-project | tar -xzvf - ---- NOTE: The `/starter.tgz` endpoint offers the same feature as `/starter.zip` but generates a compressed tarball instead. You could use this infrastructure to create your own client since the project is generated via a plain HTTP call. [[metadata]] == Service metadata The service metadata is used by all clients to know which values they should expose for the standard attributes of a project. For instance, a custom version can specify that the default `groupId` is `com.example.acme`. You can grab the metadata on the root endpoint with the appropriate `Accept` header: [source,bash] ---- $ curl -H 'Accept: application/json' https://start.spring.io ---- NOTE: As stated above, if you use `curl` without an accept header, you'll retrieve a human readable text version of the metadata. `HTTPie` is also supported: [source,bash] ---- $ http https://start.spring.io Accept:application/json ---- The metadata basically lists the _capabilities_ of the service, that is the available options for all request parameters (`dependencies`, `type`, `bootVersion`, etc.) A client to the service uses that information to initialize the select options and the tree of available dependencies. The metadata also lists the default values for simple _text_ parameter (i.e. the default `name` for the project). NOTE: More details about the structure of the metadata are {docs}/html/#metadata-format[available in the documentation]. == Running your own instance You can easily run your own instance. The `initializr-web` modules uses Spring Boot so when it is added to a project, it will trigger the necessary auto-configuration to deploy the service. The `initializr-service-sample` showcases a basic custom instance with dedicated metadata. If you want to run our instance at https://start.spring.io, refer to https://github.com/spring-io/start.spring.io#run-app[run the default instance locally]. [[build]] == Building from Source You need Java 1.8 and a bash-like shell. [[building]] === Building Invoke the build at the root of the project: [indent=0] ---- $ ./mvnw clean install ---- To generate the docs as well, you should enable the `full` profile: [indent=0] ---- $ ./mvnw clean install -Pfull ---- == License Spring Initializr is Open Source software released under the https://www.apache.org/licenses/LICENSE-2.0.html[Apache 2.0 license].