提交 259417a5 编写于 作者: Miykael_xxm's avatar Miykael_xxm 🚴

fix conflict

上级 59cbc8f3
......@@ -154,20 +154,11 @@ module.exports = {
sidebarDepth: 2,
collapsable: false,
children: [
"/en/spring-boot/legal.md",
"/en/spring-boot/getting-help.md",
"/en/spring-boot/documentation-overview.md",
"/en/spring-boot/getting-started.md",
"/en/spring-boot/upgrading-spring-boot-applications.md",
"/en/spring-boot/documentation-overview.md",
"/en/spring-boot/documentation-overview.md",
"/en/spring-boot/documentation-overview.md",
"/en/spring-boot/documentation-overview.md",
"/en/spring-boot/documentation-overview.md",
"/en/spring-boot/documentation-overview.md",
"/en/spring-boot/documentation-overview.md",
"/en/spring-boot/documentation-overview.md",
"/en/spring-boot/documentation-overview.md",
"/en/spring-boot/build-tool-plugins.md",
"/en/spring-boot/container-images.md",
"/en/spring-boot/core-features.md",
"/en/spring-boot/data.md",
"/en/spring-boot/deploying-spring-boot-applications.md"
],
initialOpenGroupIndex: 0 // 可选的, 默认值是 0
}
......@@ -291,11 +282,11 @@ module.exports = {
sidebarDepth: 2,
collapsable: false,
children: [
"/spring-boot/getting-help.md",
"/spring-boot/build-tool-plugins.md",
"/spring-boot/getting-started.md",
"/spring-boot/upgrading.md",
"/spring-boot/documentation.md"
"/spring-boot/container-images.md",
"/spring-boot/core-features.md",
"/spring-boot/data.md",
"/spring-boot/deploying-spring-boot-applications.md"
],
initialOpenGroupIndex: 0 // 可选的, 默认值是 0
}
......
此差异已折叠。
Build Tool Plugins
==========
Table of Contents
[Back to index](index.html)
* [1. Spring Boot Maven Plugin](#build-tool-plugins.maven)
* [2. Spring Boot Gradle Plugin](#build-tool-plugins.gradle)
* [3. Spring Boot AntLib Module](#build-tool-plugins.antlib)
* [3.1. Spring Boot Ant Tasks](#build-tool-plugins.antlib.tasks)
* [3.1.1. Using the “exejar” Task](#build-tool-plugins.antlib.tasks.exejar)
* [3.1.2. Examples](#build-tool-plugins.antlib.tasks.examples)
* [3.2. Using the “findmainclass” Task](#build-tool-plugins.antlib.findmainclass)
* [3.2.1. Examples](#build-tool-plugins.antlib.findmainclass.examples)
* [4. Supporting Other Build Systems](#build-tool-plugins.other-build-systems)
* [4.1. Repackaging Archives](#build-tool-plugins.other-build-systems.repackaging-archives)
* [4.2. Nested Libraries](#build-tool-plugins.other-build-systems.nested-libraries)
* [4.3. Finding a Main Class](#build-tool-plugins.other-build-systems.finding-main-class)
* [4.4. Example Repackage Implementation](#build-tool-plugins.other-build-systems.example-repackage-implementation)
* [5. What to Read Next](#build-tool-plugins.whats-next)
# 1. Build Tool Plugins
Spring Boot provides build tool plugins for Maven and Gradle.
The plugins offer a variety of features, including the packaging of executable jars.
This section provides more details on both plugins as well as some help should you need to extend an unsupported build system.
If you are just getting started, you might want to read “[using.html](using.html#using.build-systems)” from the “[using.html](using.html#using)” section first.
[](#build-tool-plugins.maven)1. Spring Boot Maven Plugin
----------
## 1.1 Spring Boot Maven Plugin
The Spring Boot Maven Plugin provides Spring Boot support in Maven, letting you package executable jar or war archives and run an application “in-place”.
To use it, you must use Maven 3.2 (or later).
......@@ -40,8 +16,7 @@ See the plugin’s documentation to learn more:
* [API](https://docs.spring.io/spring-boot/docs/2.6.4/maven-plugin/api/)
[](#build-tool-plugins.gradle)2. Spring Boot Gradle Plugin
----------
## 1.2. Spring Boot Gradle Plugin
The Spring Boot Gradle Plugin provides Spring Boot support in Gradle, letting you package executable jar or war archives, run Spring Boot applications, and use the dependency management provided by `spring-boot-dependencies`.
It requires Gradle 6.8, 6.9, or 7.x.
......@@ -51,8 +26,7 @@ See the plugin’s documentation to learn more:
* [API](https://docs.spring.io/spring-boot/docs/2.6.4/gradle-plugin/api/)
[](#build-tool-plugins.antlib)3. Spring Boot AntLib Module
----------
## 3. Spring Boot AntLib Module
The Spring Boot AntLib module provides basic Spring Boot support for Apache Ant.
You can use the module to create executable jars.
......@@ -72,10 +46,9 @@ You need to remember to start Ant using the `-lib` option, as shown in the follo
$ ant -lib <directory containing spring-boot-antlib-2.6.4.jar>
```
| |The “Using Spring Boot” section includes a more complete example of [using Apache Ant with `spring-boot-antlib`](using.html#using.build-systems.ant).|
|---|-----------------------------------------------------------------------------------------------------------------------------------------------------|
> The “Using Spring Boot” section includes a more complete example of [using Apache Ant with `spring-boot-antlib`](using.html#using.build-systems.ant).
### [](#build-tool-plugins.antlib.tasks)3.1. Spring Boot Ant Tasks ###
### 3.1. Spring Boot Ant Tasks
Once the `spring-boot-antlib` namespace has been declared, the following additional tasks are available:
......@@ -83,7 +56,7 @@ Once the `spring-boot-antlib` namespace has been declared, the following additio
* [Using the “findmainclass” Task](#build-tool-plugins.antlib.findmainclass)
#### [](#build-tool-plugins.antlib.tasks.exejar)3.1.1. Using the “exejar” Task ####
#### 3.1.1. Using the “exejar” Task
You can use the `exejar` task to create a Spring Boot executable jar.
The following attributes are supported by the task:
......@@ -101,7 +74,7 @@ The following nested elements can be used with the task:
|`resources`|One or more [Resource Collections](https://ant.apache.org/manual/Types/resources.html#collection) describing a set of [Resources](https://ant.apache.org/manual/Types/resources.html) that should be added to the content of the created jar file.|
| `lib` | One or more [Resource Collections](https://ant.apache.org/manual/Types/resources.html#collection) that should be added to the set of jar libraries that make up the runtime dependency classpath of the application. |
#### [](#build-tool-plugins.antlib.tasks.examples)3.1.2. Examples ####
#### 3.1.2. Examples
This section shows two examples of Ant tasks.
......@@ -129,7 +102,7 @@ Detect start-class
</exejar>
```
### [](#build-tool-plugins.antlib.findmainclass)3.2. Using the “findmainclass” Task ###
### 3.2. Using the “findmainclass” Task
The `findmainclass` task is used internally by `exejar` to locate a class declaring a `main`.
If necessary, you can also use this task directly in your build.
......@@ -141,7 +114,7 @@ The following attributes are supported:
| `mainclass` |Can be used to short-circuit the `main` class search| No |
| `property` |The Ant property that should be set with the result |No *(result will be logged if unspecified)*|
#### [](#build-tool-plugins.antlib.findmainclass.examples)3.2.1. Examples ####
#### 3.2.1. Examples
This section contains three examples of using `findmainclass`.
......@@ -163,8 +136,7 @@ Override and set
<findmainclass mainclass="com.example.MainClass" property="main-class" />
```
[](#build-tool-plugins.other-build-systems)4. Supporting Other Build Systems
----------
## 4. Supporting Other Build Systems
If you want to use a build tool other than Maven, Gradle, or Ant, you likely need to develop your own plugin.
Executable jars need to follow a specific format and certain entries need to be written in an uncompressed form (see the “[executable jar format](executable-jar.html#appendix.executable-jar)” section in the appendix for details).
......@@ -172,26 +144,26 @@ Executable jars need to follow a specific format and certain entries need to be
The Spring Boot Maven and Gradle plugins both make use of `spring-boot-loader-tools` to actually generate jars.
If you need to, you may use this library directly.
### [](#build-tool-plugins.other-build-systems.repackaging-archives)4.1. Repackaging Archives ###
### 4.1. Repackaging Archives
To repackage an existing archive so that it becomes a self-contained executable archive, use `org.springframework.boot.loader.tools.Repackager`.
The `Repackager` class takes a single constructor argument that refers to an existing jar or war archive.
Use one of the two available `repackage()` methods to either replace the original file or write to a new destination.
Various settings can also be configured on the repackager before it is run.
### [](#build-tool-plugins.other-build-systems.nested-libraries)4.2. Nested Libraries ###
### 4.2. Nested Libraries
When repackaging an archive, you can include references to dependency files by using the `org.springframework.boot.loader.tools.Libraries` interface.
We do not provide any concrete implementations of `Libraries` here as they are usually build-system-specific.
If your archive already includes libraries, you can use `Libraries.NONE`.
### [](#build-tool-plugins.other-build-systems.finding-main-class)4.3. Finding a Main Class ###
### 4.3. Finding a Main Class
If you do not use `Repackager.setMainClass()` to specify a main class, the repackager uses [ASM](https://asm.ow2.io/) to read class files and tries to find a suitable class with a `public static void main(String[] args)` method.
An exception is thrown if more than one candidate is found.
### [](#build-tool-plugins.other-build-systems.example-repackage-implementation)4.4. Example Repackage Implementation ###
### 4.4. Example Repackage Implementation
The following example shows a typical repackage implementation:
......@@ -230,8 +202,7 @@ public class MyBuildTool {
```
[](#build-tool-plugins.whats-next)5. What to Read Next
----------
## 5. What to Read Next
If you are interested in how the build tool plugins work, you can look at the [`spring-boot-tools`](https://github.com/spring-projects/spring-boot/tree/v2.6.4/spring-boot-project/spring-boot-tools) module on GitHub.
More technical details of the executable jar format are covered in [the appendix](executable-jar.html#appendix.executable-jar).
......
Spring Boot CLI
==========
Table of Contents
[Back to index](index.html)
* [1. Installing the CLI](#cli.installation)
* [2. Using the CLI](#cli.using-the-cli)
* [2.1. Running Applications with the CLI](#cli.using-the-cli.run)
* [2.1.1. Deduced “grab” Dependencies](#cli.using-the-cli.run.deduced-grab-annotations)
* [2.1.2. Deduced “grab” Coordinates](#cli.using-the-cli.run.deduced-grab-coordinates)
* [2.1.3. Default Import Statements](#cli.using-the-cli.run.default-import-statements)
* [2.1.4. Automatic Main Method](#cli.using-the-cli.run.automatic-main-method)
* [2.1.5. Custom Dependency Management](#cli.using-the-cli.run.custom-dependency-management)
* [2.2. Applications with Multiple Source Files](#cli.using-the-cli.multiple-source-files)
* [2.3. Packaging Your Application](#cli.using-the-cli.packaging)
* [2.4. Initialize a New Project](#cli.using-the-cli.initialize-new-project)
* [2.5. Using the Embedded Shell](#cli.using-the-cli.embedded-shell)
* [2.6. Adding Extensions to the CLI](#cli.using-the-cli.extensions)
* [3. Developing Applications with the Groovy Beans DSL](#cli.groovy-beans-dsl)
* [4. Configuring the CLI with settings.xml](#cli.maven-setting)
* [5. What to Read Next](#cli.whats-next)
# Spring Boot CLI
The Spring Boot CLI is a command line tool that you can use if you want to quickly develop a Spring application.
It lets you run Groovy scripts, which means that you have a familiar Java-like syntax without so much boilerplate code.
You can also bootstrap a new project or write your own command for it.
[](#cli.installation)1. Installing the CLI
----------
## 1. Installing the CLI
The Spring Boot CLI (Command-Line Interface) can be installed manually by using SDKMAN! (the SDK Manager) or by using Homebrew or MacPorts if you are an OSX user.
See *[getting-started.html](getting-started.html#getting-started.installing.cli)* in the “Getting started” section for comprehensive installation instructions.
[](#cli.using-the-cli)2. Using the CLI
----------
## 2. Using the CLI
Once you have installed the CLI, you can run it by typing `spring` and pressing Enter at the command line.
If you run `spring` without any arguments, a help screen is displayed, as follows:
......@@ -81,7 +55,7 @@ $ spring version
Spring CLI v2.6.4
```
### [](#cli.using-the-cli.run)2.1. Running Applications with the CLI ###
### 2.1. Running Applications with the CLI
You can compile and run Groovy source code by using the `run` command.
The Spring Boot CLI is completely self-contained, so you do not need any external Groovy installation.
......@@ -124,7 +98,7 @@ $ JAVA_OPTS=-Xmx1024m spring run hello.groovy
| |When setting `JAVA_OPTS` on Microsoft Windows, make sure to quote the entire instruction, such as `set "JAVA_OPTS=-Xms256m -Xmx2048m"`.<br/>Doing so ensures the values are properly passed to the process.|
|---|-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
#### [](#cli.using-the-cli.run.deduced-grab-annotations)2.1.1. Deduced “grab” Dependencies ####
#### 2.1.1. Deduced “grab” Dependencies
Standard Groovy includes a `@Grab` annotation, which lets you declare dependencies on third-party libraries.
This useful technique lets Groovy download jars in the same way as Maven or Gradle would but without requiring you to use a build tool.
......@@ -151,7 +125,7 @@ The following items are used as “grab hints”:
| |See subclasses of [`CompilerAutoConfiguration`](https://github.com/spring-projects/spring-boot/tree/v2.6.4/spring-boot-project/spring-boot-cli/src/main/java/org/springframework/boot/cli/compiler/CompilerAutoConfiguration.java) in the Spring Boot CLI source code to understand exactly how customizations are applied.|
|---|---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
#### [](#cli.using-the-cli.run.deduced-grab-coordinates)2.1.2. Deduced “grab” Coordinates ####
#### 2.1.2. Deduced “grab” Coordinates
Spring Boot extends Groovy’s standard `@Grab` support by letting you specify a dependency without a group or version (for example, `@Grab('freemarker')`).
Doing so consults Spring Boot’s default dependency metadata to deduce the artifact’s group and version.
......@@ -159,7 +133,7 @@ Doing so consults Spring Boot’s default dependency metadata to deduce the arti
| |The default metadata is tied to the version of the CLI that you use.<br/>It changes only when you move to a new version of the CLI, putting you in control of when the versions of your dependencies may change.<br/>A table showing the dependencies and their versions that are included in the default metadata can be found in the [appendix](dependency-versions.html#appendix.dependency-versions).|
|---|---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
#### [](#cli.using-the-cli.run.default-import-statements)2.1.3. Default Import Statements ####
#### 2.1.3. Default Import Statements
To help reduce the size of your Groovy code, several `import` statements are automatically included.
Notice how the preceding example refers to `@Component`, `@RestController`, and `@RequestMapping` without needing to use fully-qualified names or `import` statements.
......@@ -167,12 +141,12 @@ Notice how the preceding example refers to `@Component`, `@RestController`, and
| |Many Spring annotations work without using `import` statements.<br/>Try running your application to see what fails before adding imports.|
|---|-----------------------------------------------------------------------------------------------------------------------------------------|
#### [](#cli.using-the-cli.run.automatic-main-method)2.1.4. Automatic Main Method ####
#### 2.1.4. Automatic Main Method
Unlike the equivalent Java application, you do not need to include a `public static void main(String[] args)` method with your `Groovy` scripts.
A `SpringApplication` is automatically created, with your compiled code acting as the `source`.
#### [](#cli.using-the-cli.run.custom-dependency-management)2.1.5. Custom Dependency Management ####
#### 2.1.5. Custom Dependency Management
By default, the CLI uses the dependency management declared in `spring-boot-dependencies` when resolving `@Grab` dependencies.
Additional dependency management, which overrides the default dependency management, can be configured by using the `@DependencyManagementBom` annotation.
......@@ -201,7 +175,7 @@ The preceding example indicates that the dependency management in `another-bom`
You can use `@DependencyManagementBom` anywhere that you can use `@Grab`.
However, to ensure consistent ordering of the dependency management, you can use `@DependencyManagementBom` at most once in your application.
### [](#cli.using-the-cli.multiple-source-files)2.2. Applications with Multiple Source Files ###
### 2.2. Applications with Multiple Source Files
You can use “shell globbing” with all commands that accept file input.
Doing so lets you use multiple files from a single directory, as shown in the following example:
......@@ -210,7 +184,7 @@ Doing so lets you use multiple files from a single directory, as shown in the fo
$ spring run *.groovy
```
### [](#cli.using-the-cli.packaging)2.3. Packaging Your Application ###
### 2.3. Packaging Your Application
You can use the `jar` command to package your application into a self-contained executable jar file, as shown in the following example:
......@@ -236,7 +210,7 @@ The default excludes are as follows:
Type `spring help jar` on the command line for more information.
### [](#cli.using-the-cli.initialize-new-project)2.4. Initialize a New Project ###
### 2.4. Initialize a New Project
The `init` command lets you create a new project by using [start.spring.io](https://start.spring.io) without leaving the shell, as shown in the following example:
......@@ -283,7 +257,7 @@ Using service at https://start.spring.io
Content saved to 'sample-app.zip'
```
### [](#cli.using-the-cli.embedded-shell)2.5. Using the Embedded Shell ###
### 2.5. Using the Embedded Shell
Spring Boot includes command-line completion scripts for the BASH and zsh shells.
If you do not use either of these shells (perhaps you are a Windows user), you can use the `shell` command to launch an integrated shell, as shown in the following example:
......@@ -305,7 +279,7 @@ The embedded shell supports ANSI color output as well as `tab` completion.
If you need to run a native command, you can use the `!` prefix.
To exit the embedded shell, press `ctrl-c`.
### [](#cli.using-the-cli.extensions)2.6. Adding Extensions to the CLI ###
### 2.6. Adding Extensions to the CLI
You can add extensions to the CLI by using the `install` command.
The command takes one or more sets of artifact coordinates in the format `group:artifact:version`, as shown in the following example:
......@@ -331,8 +305,7 @@ To uninstall all additional dependencies, you can use the `--all` option, as sho
$ spring uninstall --all
```
[](#cli.groovy-beans-dsl)3. Developing Applications with the Groovy Beans DSL
----------
## 3. Developing Applications with the Groovy Beans DSL
Spring Framework 4.0 has native support for a `beans{}` “DSL” (borrowed from [Grails](https://grails.org/)), and you can embed bean definitions in your Groovy application scripts by using the same format.
This is sometimes a good way to include external features like middleware declarations, as shown in the following example:
......@@ -363,8 +336,7 @@ beans {
You can mix class declarations with `beans{}` in the same file as long as they stay at the top level, or, if you prefer, you can put the beans DSL in a separate file.
[](#cli.maven-setting)4. Configuring the CLI with settings.xml
----------
## 4. Configuring the CLI with settings.xml
The Spring Boot CLI uses Maven Resolver, Maven’s dependency resolution engine, to resolve dependencies.
The CLI makes use of the Maven configuration found in `~/.m2/settings.xml` to configure Maven Resolver.
......@@ -388,8 +360,7 @@ The following configuration settings are honored by the CLI:
See [Maven’s settings documentation](https://maven.apache.org/settings.html) for further information.
[](#cli.whats-next)5. What to Read Next
----------
## 5. What to Read Next
There are some [sample groovy scripts](https://github.com/spring-projects/spring-boot/tree/v2.6.4/spring-boot-project/spring-boot-cli/samples) available from the GitHub repository that you can use to try out the Spring Boot CLI.
There is also extensive Javadoc throughout the [source code](https://github.com/spring-projects/spring-boot/tree/v2.6.4/spring-boot-project/spring-boot-cli/src/main/java/org/springframework/boot/cli).
......
Container Images
==========
Table of Contents
[Back to index](index.html)
* [1. Efficient container images](#container-images.efficient-images)
* [1.1. Unpacking the fat jar](#container-images.efficient-images.unpacking)
* [1.2. Layering Docker Images](#container-images.efficient-images.layering)
* [2. Dockerfiles](#container-images.dockerfiles)
* [3. Cloud Native Buildpacks](#container-images.buildpacks)
* [4. What to Read Next](#container-images.whats-next)
# Container Images
Spring Boot applications can be containerized [using Dockerfiles](#container-images.dockerfiles), or by [using Cloud Native Buildpacks to create optimized docker compatible container images that you can run anywhere](#container-images.buildpacks).
[](#container-images.efficient-images)1. Efficient container images
----------
## 1. Efficient container images
It is easily possible to package a Spring Boot fat jar as a docker image.
However, there are various downsides to copying and running the fat jar as is in the docker image.
......@@ -25,7 +12,7 @@ The other issue is that putting your application’s code and all its dependenci
Since you probably recompile your code more often than you upgrade the version of Spring Boot you use, it’s often better to separate things a bit more.
If you put jar files in the layer before your application classes, Docker often only needs to change the very bottom layer and can pick others up from its cache.
### [](#container-images.efficient-images.unpacking)1.1. Unpacking the fat jar ###
### 1.1. Unpacking the fat jar
If you are running your application from a container, you can use an executable jar, but it is also often an advantage to explode it and run it in a different way.
Certain PaaS implementations may also choose to unpack archives before they run.
......@@ -50,7 +37,7 @@ $ java -cp BOOT-INF/classes:BOOT-INF/lib/* com.example.MyApplication
| |Using the `JarLauncher` over the application’s main method has the added benefit of a predictable classpath order.<br/>The jar contains a `classpath.idx` file which is used by the `JarLauncher` when constructing the classpath.|
|---|----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
### [](#container-images.efficient-images.layering)1.2. Layering Docker Images ###
### 1.2. Layering Docker Images
To make it easier to create optimized Docker images, Spring Boot supports adding a layer index file to the jar.
It provides a list of layers and the parts of the jar that should be contained within them.
......@@ -90,8 +77,7 @@ Spring Boot also supports layering for war files with the help of a `layers.idx`
For Maven, see the [packaging layered jar or war section](https://docs.spring.io/spring-boot/docs/2.6.4/maven-plugin/reference/htmlsingle/#repackage-layers) for more details on adding a layer index to the archive.
For Gradle, see the [packaging layered jar or war section](https://docs.spring.io/spring-boot/docs/2.6.4/gradle-plugin/reference/htmlsingle/#packaging-layered-archives) of the Gradle plugin documentation.
[](#container-images.dockerfiles)2. Dockerfiles
----------
## 2. Dockerfiles
While it is possible to convert a Spring Boot fat jar into a docker image with just a few lines in the Dockerfile, we will use the [layering feature](#container-images.efficient-images.layering) to create an optimized docker image.
When you create a jar containing the layers index file, the `spring-boot-jarmode-layertools` jar will be added as a dependency to your jar.
......@@ -150,8 +136,7 @@ Each of the `COPY` commands relates to the layers extracted by the jarmode.
Of course, a Dockerfile can be written without using the jarmode.
You can use some combination of `unzip` and `mv` to move things to the right layer but jarmode simplifies that.
[](#container-images.buildpacks)3. Cloud Native Buildpacks
----------
## 3. Cloud Native Buildpacks
Dockerfiles are just one way to build docker images.
Another way to build docker images is directly from your Maven or Gradle plugin, using buildpacks.
......@@ -171,8 +156,7 @@ See the individual plugin documentation on how to use buildpacks with [Maven](ht
| |In order to achieve reproducible builds and container image caching, Buildpacks can manipulate the application resources metadata (such as the file "last modified" information).<br/>You should ensure that your application does not rely on that metadata at runtime.<br/>Spring Boot can use that information when serving static resources, but this can be disabled with `spring.web.resources.cache.use-last-modified`|
|---|-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
[](#container-images.whats-next)4. What to Read Next
----------
## 4. What to Read Next
Once you’ve learned how to build efficient container images, you can read about [deploying applications to a cloud platform](deployment.html#deployment.cloud.kubernetes), such as Kubernetes.
此差异已折叠。
Deploying Spring Boot Applications
==========
Table of Contents
[Back to index](index.html)
* [1. Deploying to the Cloud](#deployment.cloud)
* [1.1. Cloud Foundry](#deployment.cloud.cloud-foundry)
* [1.1.1. Binding to Services](#deployment.cloud.cloud-foundry.binding-to-services)
* [1.2. Kubernetes](#deployment.cloud.kubernetes)
* [1.2.1. Kubernetes Container Lifecycle](#deployment.cloud.kubernetes.container-lifecycle)
* [1.3. Heroku](#deployment.cloud.heroku)
* [1.4. OpenShift](#deployment.cloud.openshift)
* [1.5. Amazon Web Services (AWS)](#deployment.cloud.aws)
* [1.5.1. AWS Elastic Beanstalk](#deployment.cloud.aws.beanstalk)
* [Using the Tomcat Platform](#deployment.cloud.aws.beanstalk.tomcat-platform)
* [Using the Java SE Platform](#deployment.cloud.aws.beanstalk.java-se-platform)
* [1.5.2. Summary](#deployment.cloud.aws.summary)
* [1.6. CloudCaptain and Amazon Web Services](#deployment.cloud.boxfuse)
* [1.7. Azure](#deployment.cloud.azure)
* [1.8. Google Cloud](#deployment.cloud.google)
* [2. Installing Spring Boot Applications](#deployment.installing)
* [2.1. Supported Operating Systems](#deployment.installing.supported-operating-systems)
* [2.2. Unix/Linux Services](#deployment.installing.nix-services)
* [2.2.1. Installation as an init.d Service (System V)](#deployment.installing.nix-services.init-d)
* [Securing an init.d Service](#deployment.installing.nix-services.init-d.securing)
* [2.2.2. Installation as a systemd Service](#deployment.installing.nix-services.system-d)
* [2.2.3. Customizing the Startup Script](#deployment.installing.nix-services.script-customization)
* [Customizing the Start Script When It Is Written](#deployment.installing.nix-services.script-customization.when-written)
* [Customizing a Script When It Runs](#deployment.installing.nix-services.script-customization.when-running)
* [2.3. Microsoft Windows Services](#deployment.installing.windows-services)
* [3. What to Read Next](#deployment.whats-next)
# Deploying Spring Boot Applications
Spring Boot’s flexible packaging options provide a great deal of choice when it comes to deploying your application.
You can deploy Spring Boot applications to a variety of cloud platforms, to virtual/real machines, or make them fully executable for Unix systems.
This section covers some of the more common deployment scenarios.
[](#deployment.cloud)1. Deploying to the Cloud
----------
## 1. Deploying to the Cloud
Spring Boot’s executable jars are ready-made for most popular cloud PaaS (Platform-as-a-Service) providers.
These providers tend to require that you “bring your own container”.
......@@ -63,7 +22,7 @@ Ideally, your application, like a Spring Boot executable jar, has everything tha
In this section, we look at what it takes to get the [application that we developed](getting-started.html#getting-started.first-application) in the “Getting Started” section up and running in the Cloud.
### [](#deployment.cloud.cloud-foundry)1.1. Cloud Foundry ###
### 1.1. Cloud Foundry
Cloud Foundry provides default buildpacks that come into play if no other buildpack is specified.
The Cloud Foundry [Java buildpack](https://github.com/cloudfoundry/java-buildpack) has excellent support for Spring applications, including Spring Boot.
......@@ -127,7 +86,7 @@ acloudyspringtime started 1/1 512M 1G acloudyspring
Once Cloud Foundry acknowledges that your application has been deployed, you should be able to find the application at the URI given.
In the preceding example, you could find it at `https://acloudyspringtime.cfapps.io/`.
#### [](#deployment.cloud.cloud-foundry.binding-to-services)1.1.1. Binding to Services ####
#### 1.1.1. Binding to Services
By default, metadata about the running application as well as service connection information is exposed to the application as environment variables (for example: `$VCAP_SERVICES`).
This architecture decision is due to Cloud Foundry’s polyglot (any language and platform can be supported as a buildpack) nature.
......@@ -163,14 +122,14 @@ See the [‘CloudFoundryVcapEnvironmentPostProcessor’](https://docs.spring.io/
| |The [Java CFEnv](https://github.com/pivotal-cf/java-cfenv/) project is a better fit for tasks such as configuring a DataSource.|
|---|-------------------------------------------------------------------------------------------------------------------------------|
### [](#deployment.cloud.kubernetes)1.2. Kubernetes ###
### 1.2. Kubernetes
Spring Boot auto-detects Kubernetes deployment environments by checking the environment for `"*_SERVICE_HOST"` and `"*_SERVICE_PORT"` variables.
You can override this detection with the `spring.main.cloud-platform` configuration property.
Spring Boot helps you to [manage the state of your application](features.html#features.spring-application.application-availability) and export it with [HTTP Kubernetes Probes using Actuator](actuator.html#actuator.endpoints.kubernetes-probes).
#### [](#deployment.cloud.kubernetes.container-lifecycle)1.2.1. Kubernetes Container Lifecycle ####
#### 1.2.1. Kubernetes Container Lifecycle
When Kubernetes deletes an application instance, the shutdown process involves several subsystems concurrently: shutdown hooks, unregistering the service, removing the instance from the load-balancer…​
Because this shutdown processing happens in parallel (and due to the nature of distributed systems), there is a window during which traffic can be routed to a pod that has also begun its shutdown processing.
......@@ -195,7 +154,7 @@ Once the pre-stop hook has completed, SIGTERM will be sent to the container and
| |When Kubernetes sends a SIGTERM signal to the pod, it waits for a specified time called the termination grace period (the default for which is 30 seconds).<br/>If the containers are still running after the grace period, they are sent the SIGKILL signal and forcibly removed.<br/>If the pod takes longer than 30 seconds to shut down, which could be because you have increased `spring.lifecycle.timeout-per-shutdown-phase`, make sure to increase the termination grace period by setting the `terminationGracePeriodSeconds` option in the Pod YAML.|
|---|---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
### [](#deployment.cloud.heroku)1.3. Heroku ###
### 1.3. Heroku
Heroku is another popular PaaS platform.
To customize Heroku builds, you provide a `Procfile`, which provides the incantation required to deploy an application.
......@@ -264,7 +223,7 @@ To [email protected]:agile-sierra-1405.git
Your application should now be up and running on Heroku.
For more details, see [Deploying Spring Boot Applications to Heroku](https://devcenter.heroku.com/articles/deploying-spring-boot-apps-to-heroku).
### [](#deployment.cloud.openshift)1.4. OpenShift ###
### 1.4. OpenShift
[OpenShift](https://www.openshift.com/) has many resources describing how to deploy Spring Boot applications, including:
......@@ -276,7 +235,7 @@ For more details, see [Deploying Spring Boot Applications to Heroku](https://dev
* [OpenShift Commons Briefing](https://blog.openshift.com/openshift-commons-briefing-96-cloud-native-applications-spring-rhoar/)
### [](#deployment.cloud.aws)1.5. Amazon Web Services (AWS) ###
### 1.5. Amazon Web Services (AWS)
Amazon Web Services offers multiple ways to install Spring Boot-based applications, either as traditional web applications (war) or as executable jar files with an embedded web server.
The options include:
......@@ -294,18 +253,18 @@ The options include:
Each has different features and pricing models.
In this document, we describe to approach using AWS Elastic Beanstalk.
#### [](#deployment.cloud.aws.beanstalk)1.5.1. AWS Elastic Beanstalk ####
#### 1.5.1. AWS Elastic Beanstalk
As described in the official [Elastic Beanstalk Java guide](https://docs.aws.amazon.com/elasticbeanstalk/latest/dg/create_deploy_Java.html), there are two main options to deploy a Java application.
You can either use the “Tomcat Platform” or the “Java SE platform”.
##### [](#deployment.cloud.aws.beanstalk.tomcat-platform)Using the Tomcat Platform #####
##### Using the Tomcat Platform
This option applies to Spring Boot projects that produce a war file.
No special configuration is required.
You need only follow the official guide.
##### [](#deployment.cloud.aws.beanstalk.java-se-platform)Using the Java SE Platform #####
##### Using the Java SE Platform
This option applies to Spring Boot projects that produce a jar file and run an embedded web container.
Elastic Beanstalk environments run an nginx instance on port 80 to proxy the actual application, running on port 5000.
......@@ -321,12 +280,12 @@ server.port=5000
| |Reduce costs by setting the environment type<br/><br/>By default an Elastic Beanstalk environment is load balanced.<br/>The load balancer has a significant cost.<br/>To avoid that cost, set the environment type to “Single instance”, as described in [the Amazon documentation](https://docs.aws.amazon.com/elasticbeanstalk/latest/dg/environments-create-wizard.html#environments-create-wizard-capacity).<br/>You can also create single instance environments by using the CLI and the following command:<br/><br/>```<br/>eb create -s<br/>```|
|---|-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
#### [](#deployment.cloud.aws.summary)1.5.2. Summary ####
#### 1.5.2. Summary
This is one of the easiest ways to get to AWS, but there are more things to cover, such as how to integrate Elastic Beanstalk into any CI / CD tool, use the Elastic Beanstalk Maven plugin instead of the CLI, and others.
There is a [blog post](https://exampledriven.wordpress.com/2017/01/09/spring-boot-aws-elastic-beanstalk-example/) covering these topics more in detail.
### [](#deployment.cloud.boxfuse)1.6. CloudCaptain and Amazon Web Services ###
### 1.6. CloudCaptain and Amazon Web Services
[CloudCaptain](https://cloudcaptain.sh/) works by turning your Spring Boot executable jar or war into a minimal VM image that can be deployed unchanged either on VirtualBox or on AWS.
CloudCaptain comes with deep integration for Spring Boot and uses the information from your Spring Boot configuration file to automatically configure ports and health check URLs.
......@@ -370,11 +329,11 @@ Your application should now be up and running on AWS.
See the blog post on [deploying Spring Boot apps on EC2](https://cloudcaptain.sh/blog/spring-boot-ec2.html) as well as the [documentation for the CloudCaptain Spring Boot integration](https://cloudcaptain.sh/docs/payloads/springboot.html) to get started with a Maven build to run the app.
### [](#deployment.cloud.azure)1.7. Azure ###
### 1.7. Azure
This [Getting Started guide](https://spring.io/guides/gs/spring-boot-for-azure/) walks you through deploying your Spring Boot application to either [Azure Spring Cloud](https://azure.microsoft.com/en-us/services/spring-cloud/) or [Azure App Service](https://docs.microsoft.com/en-us/azure/app-service/overview).
### [](#deployment.cloud.google)1.8. Google Cloud ###
### 1.8. Google Cloud
Google Cloud has several options that can be used to launch Spring Boot applications.
The easiest to get started with is probably App Engine, but you could also find ways to run Spring Boot in a container with Container Engine or on a virtual machine with Compute Engine.
......@@ -426,8 +385,7 @@ You can deploy the app (for example, with a Maven plugin) by adding the project
Then deploy with `mvn appengine:deploy` (if you need to authenticate first, the build fails).
[](#deployment.installing)2. Installing Spring Boot Applications
----------
## 2. Installing Spring Boot Applications
In addition to running Spring Boot applications by using `java -jar`, it is also possible to make fully executable applications for Unix systems.
A fully executable jar can be executed like any other executable binary or it can be [registered with `init.d` or `systemd`](#deployment.installing.nix-services).
......@@ -462,16 +420,16 @@ bootJar {
You can then run your application by typing `./my-application.jar` (where `my-application` is the name of your artifact).
The directory containing the jar is used as your application’s working directory.
### [](#deployment.installing.supported-operating-systems)2.1. Supported Operating Systems ###
### 2.1. Supported Operating Systems
The default script supports most Linux distributions and is tested on CentOS and Ubuntu.
Other platforms, such as OS X and FreeBSD, require the use of a custom `embeddedLaunchScript`.
### [](#deployment.installing.nix-services)2.2. Unix/Linux Services ###
### 2.2. Unix/Linux Services
Spring Boot application can be easily started as Unix/Linux services by using either `init.d` or `systemd`.
#### [](#deployment.installing.nix-services.init-d)2.2.1. Installation as an init.d Service (System V) ####
#### 2.2.1. Installation as an init.d Service (System V)
If you configured Spring Boot’s Maven or Gradle plugin to generate a [fully executable jar](#deployment.installing), and you do not use a custom `embeddedLaunchScript`, your application can be used as an `init.d` service.
To do so, symlink the jar to `init.d` to support the standard `start`, `stop`, `restart`, and `status` commands.
......@@ -507,7 +465,7 @@ For example, on Debian, you could use the following command:
$ update-rc.d myapp defaults <priority>
```
##### [](#deployment.installing.nix-services.init-d.securing)Securing an init.d Service #####
##### Securing an init.d Service
| |The following is a set of guidelines on how to secure a Spring Boot application that runs as an init.d service.<br/>It is not intended to be an exhaustive list of everything that should be done to harden an application and the environment in which it runs.|
|---|----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
......@@ -552,7 +510,7 @@ $ chmod 400 your-app.conf
$ sudo chown root:root your-app.conf
```
#### [](#deployment.installing.nix-services.system-d)2.2.2. Installation as a systemd Service ####
#### 2.2.2. Installation as a systemd Service
`systemd` is the successor of the System V init system and is now being used by many modern Linux distributions.
Although you can continue to use `init.d` scripts with `systemd`, it is also possible to launch Spring Boot applications by using `systemd` ‘service’ scripts.
......@@ -591,13 +549,13 @@ $ systemctl enable myapp.service
Run `man systemctl` for more details.
#### [](#deployment.installing.nix-services.script-customization)2.2.3. Customizing the Startup Script ####
#### 2.2.3. Customizing the Startup Script
The default embedded startup script written by the Maven or Gradle plugin can be customized in a number of ways.
For most people, using the default script along with a few customizations is usually enough.
If you find you cannot customize something that you need to, use the `embeddedLaunchScript` option to write your own file entirely.
##### [](#deployment.installing.nix-services.script-customization.when-written)Customizing the Start Script When It Is Written #####
##### Customizing the Start Script When It Is Written #####
It often makes sense to customize elements of the start script as it is written into the jar file.
For example, init.d scripts can provide a “description”.
......@@ -627,7 +585,7 @@ The following property substitutions are supported with the default script:
| `useStartStopDaemon` | Whether the `start-stop-daemon` command, when it is available, should be used to control the process | `true` | `true` |
| `stopWaitTime` | Default value for `STOP_WAIT_TIME` in seconds.<br/>Only valid for an `init.d` service | 60 | 60 |
##### [](#deployment.installing.nix-services.script-customization.when-running)Customizing a Script When It Runs #####
##### Customizing a Script When It Runs #####
For items of the script that need to be customized *after* the jar has been written, you can use environment variables or a [config file](#deployment.installing.nix-services.script-customization.when-running.conf-file).
......@@ -669,14 +627,13 @@ LOG_FOLDER=/custom/log/folder
To learn about securing this file appropriately, see [the guidelines for securing an init.d service](#deployment.installing.nix-services.init-d.securing).
### [](#deployment.installing.windows-services)2.3. Microsoft Windows Services ###
### 2.3. Microsoft Windows Services
A Spring Boot application can be started as a Windows service by using [`winsw`](https://github.com/kohsuke/winsw).
A ([separately maintained sample](https://github.com/snicoll/spring-boot-daemon)) describes step-by-step how you can create a Windows service for your Spring Boot application.
[](#deployment.whats-next)3. What to Read Next
----------
## 3. What to Read Next
See the [Cloud Foundry](https://www.cloudfoundry.org/), [Heroku](https://www.heroku.com/), [OpenShift](https://www.openshift.com), and [Boxfuse](https://boxfuse.com) web sites for more information about the kinds of features that a PaaS can offer.
These are just four of the most popular Java PaaS providers.
......
Documentation Overview
==========
Table of Contents
[Back to index](index.html)
* [1. First Steps](#documentation.first-steps)
* [2. Upgrading From an Earlier Version](#documentation.upgrading)
* [3. Developing with Spring Boot](#documentation.using)
* [4. Learning About Spring Boot Features](#documentation.features)
* [5. Web](#documentation.web)
* [6. Data](#documentation.data)
* [7. Messaging](#documentation.messaging)
* [8. IO](#documentation.io)
* [9. Container Images](#documentation.container-images)
* [10. Advanced Topics](#documentation.advanced)
# Documentation Overview
This section provides a brief overview of Spring Boot reference documentation.
It serves as a map for the rest of the document.
The latest copy of this document is available at [docs.spring.io/spring-boot/docs/current/reference/](https://docs.spring.io/spring-boot/docs/current/reference/).
[](#documentation.first-steps)1. First Steps
----------
## 1. First Steps
If you are getting started with Spring Boot or 'Spring' in general, start with [the following topics](getting-started.html#getting-started):
......@@ -32,8 +15,7 @@ If you are getting started with Spring Boot or 'Spring' in general, start with [
* **Running your example:** [Part 1](getting-started.html#getting-started.first-application.run) | [Part 2](getting-started.html#getting-started.first-application.executable-jar)
[](#documentation.upgrading)2. Upgrading From an Earlier Version
----------
## 2. Upgrading From an Earlier Version
You should always ensure that you are running a [supported version](https://github.com/spring-projects/spring-boot/wiki/Supported-Versions) of Spring Boot.
......@@ -45,8 +27,7 @@ Depending on the version that you are upgrading to, you can find some additional
* **Spring Boot CLI:** [Upgrading the Spring Boot CLI](upgrading.html#upgrading.cli)
[](#documentation.using)3. Developing with Spring Boot
----------
## 3. Developing with Spring Boot
Ready to actually start using Spring Boot? [We have you covered](using.html#using):
......@@ -60,8 +41,7 @@ Ready to actually start using Spring Boot? [We have you covered](using.html#usin
* **Spring Boot CLI:** [Using the CLI](cli.html#cli)
[](#documentation.features)4. Learning About Spring Boot Features
----------
## 4. Learning About Spring Boot Features
Need more details about Spring Boot’s core features?[The following content is for you](features.html#features):
......@@ -73,8 +53,7 @@ Need more details about Spring Boot’s core features?[The following content is
* **Logging:** [Logging](features.html#features.logging)
[](#documentation.web)5. Web
----------
## 5. Web-
If you develop Spring Boot web applications, take a look at the following content:
......@@ -90,8 +69,7 @@ If you develop Spring Boot web applications, take a look at the following conten
* **Spring HATEOAS:** [Auto-configuration for Spring HATEOAS](web.html#web.spring-hateoas)
[](#documentation.data)6. Data
----------
## 6. Data
If your application deals with a datastore, you can see how to configure that here:
......@@ -99,8 +77,7 @@ If your application deals with a datastore, you can see how to configure that he
* **NOSQL:** [Auto-configuration for NOSQL stores such as Redis, MongoDB, Neo4j, and others.](data.html#data.nosql)
[](#documentation.messaging)7. Messaging
----------
## 7. Messaging
If your application uses any messaging protocol, see one or more of the following sections:
......@@ -114,8 +91,7 @@ If your application uses any messaging protocol, see one or more of the followin
* **Spring Integration:** [Auto-configuration for Spring Integration](messaging.html#messaging.spring-integration)
[](#documentation.io)8. IO
----------
## 8. IO--
If your application needs IO capabilities, see one or more of the following sections:
......@@ -133,8 +109,7 @@ If your application needs IO capabilities, see one or more of the following sect
* **JTA:** [Distributed Transactions with JTA](io.html#io.jta)
[](#documentation.container-images)9. Container Images
----------
## 9. Container Images
Spring Boot provides first-class support for building efficient container images. You can read more about it here:
......@@ -144,8 +119,7 @@ Spring Boot provides first-class support for building efficient container images
* **Cloud Native Buildpacks:** [Support for Cloud Native Buildpacks with Maven and Gradle](container-images.html#container-images.buildpacks)
[](#documentation.advanced)10. Advanced Topics
----------
## 10. Advanced Topics
Finally, we have a few topics for more advanced users:
......
此差异已折叠。
Getting Help
==========
# Getting Help
If you have trouble with Spring Boot, we would like to help.
......
Getting Started
==========
Table of Contents
[Back to index](index.html)
* [1. Introducing Spring Boot](#getting-started.introducing-spring-boot)
* [2. System Requirements](#getting-started.system-requirements)
* [2.1. Servlet Containers](#getting-started.system-requirements.servlet-containers)
* [3. Installing Spring Boot](#getting-started.installing)
* [3.1. Installation Instructions for the Java Developer](#getting-started.installing.java)
* [3.1.1. Maven Installation](#getting-started.installing.java.maven)
* [3.1.2. Gradle Installation](#getting-started.installing.java.gradle)
* [3.2. Installing the Spring Boot CLI](#getting-started.installing.cli)
* [3.2.1. Manual Installation](#getting-started.installing.cli.manual-installation)
* [3.2.2. Installation with SDKMAN!](#getting-started.installing.cli.sdkman)
* [3.2.3. OSX Homebrew Installation](#getting-started.installing.cli.homebrew)
* [3.2.4. MacPorts Installation](#getting-started.installing.cli.macports)
* [3.2.5. Command-line Completion](#getting-started.installing.cli.completion)
* [3.2.6. Windows Scoop Installation](#getting-started.installing.cli.scoop)
* [3.2.7. Quick-start Spring CLI Example](#getting-started.installing.cli.quick-start)
* [4. Developing Your First Spring Boot Application](#getting-started.first-application)
* [4.1. Creating the POM](#getting-started.first-application.pom)
* [4.2. Adding Classpath Dependencies](#getting-started.first-application.dependencies)
* [4.3. Writing the Code](#getting-started.first-application.code)
* [4.3.1. The @RestController and @RequestMapping Annotations](#getting-started.first-application.code.mvc-annotations)
* [4.3.2. The @EnableAutoConfiguration Annotation](#getting-started.first-application.code.enable-auto-configuration)
* [4.3.3. The “main” Method](#getting-started.first-application.code.main-method)
* [4.4. Running the Example](#getting-started.first-application.run)
* [4.5. Creating an Executable Jar](#getting-started.first-application.executable-jar)
* [5. What to Read Next](#getting-started.whats-next)
# Getting Started
If you are getting started with Spring Boot, or “Spring” in general, start by reading this section.
It answers the basic “what?”, “how?” and “why?” questions.
It includes an introduction to Spring Boot, along with installation instructions.
We then walk you through building your first Spring Boot application, discussing some core principles as we go.
[](#getting-started.introducing-spring-boot)1. Introducing Spring Boot
----------
## 1. Introducing Spring Boot
Spring Boot helps you to create stand-alone, production-grade Spring-based applications that you can run.
We take an opinionated view of the Spring platform and third-party libraries, so that you can get started with minimum fuss.
......@@ -61,8 +24,7 @@ Our primary goals are:
* Absolutely no code generation and no requirement for XML configuration.
[](#getting-started.system-requirements)2. System Requirements
----------
## 2. System Requirements
Spring Boot 2.6.4 requires [Java 8](https://www.java.com) and is compatible up to and including Java 17.[Spring Framework 5.3.16](https://docs.spring.io/spring-framework/docs/5.3.16/reference/html/) or above is also required.
......@@ -73,7 +35,7 @@ Explicit build support is provided for the following build tools:
| Maven | 3.5+ |
| Gradle |6.8.x, 6.9.x, and 7.x|
### [](#getting-started.system-requirements.servlet-containers)2.1. Servlet Containers ###
### 2.1. Servlet Containers
Spring Boot supports the following embedded servlet containers:
......@@ -86,8 +48,7 @@ Spring Boot supports the following embedded servlet containers:
You can also deploy Spring Boot applications to any servlet 3.1+ compatible container.
[](#getting-started.installing)3. Installing Spring Boot
----------
## 3. Installing Spring Boot
Spring Boot can be used with “classic” Java development tools or installed as a command line tool.
Either way, you need [Java SDK v1.8](https://www.java.com) or higher.
......@@ -100,7 +61,7 @@ $ java -version
If you are new to Java development or if you want to experiment with Spring Boot, you might want to try the [Spring Boot CLI](#getting-started.installing.cli) (Command Line Interface) first.
Otherwise, read on for “classic” installation instructions.
### [](#getting-started.installing.java)3.1. Installation Instructions for the Java Developer ###
### 3.1. Installation Instructions for the Java Developer
You can use Spring Boot in the same way as any standard Java library.
To do so, include the appropriate `spring-boot-*.jar` files on your classpath.
......@@ -109,7 +70,7 @@ Also, there is nothing special about a Spring Boot application, so you can run a
Although you *could* copy Spring Boot jars, we generally recommend that you use a build tool that supports dependency management (such as Maven or Gradle).
#### [](#getting-started.installing.java.maven)3.1.1. Maven Installation ####
#### 3.1.1. Maven Installation
Spring Boot is compatible with Apache Maven 3.3 or above.
If you do not already have Maven installed, you can follow the instructions at [maven.apache.org](https://maven.apache.org).
......@@ -123,7 +84,7 @@ Spring Boot also provides an optional [Maven plugin](build-tool-plugins.html#bui
More details on getting started with Spring Boot and Maven can be found in the [Getting Started section](https://docs.spring.io/spring-boot/docs/2.6.4/maven-plugin/reference/htmlsingle/#getting-started) of the Maven plugin’s reference guide.
#### [](#getting-started.installing.java.gradle)3.1.2. Gradle Installation ####
#### 3.1.2. Gradle Installation
Spring Boot is compatible with Gradle 6.8, 6.9, and 7.x.
If you do not already have Gradle installed, you can follow the instructions at [gradle.org](https://gradle.org).
......@@ -140,14 +101,14 @@ See [docs.gradle.org/current/userguide/gradle\_wrapper.html](https://docs.gradle
More details on getting started with Spring Boot and Gradle can be found in the [Getting Started section](https://docs.spring.io/spring-boot/docs/2.6.4/gradle-plugin/reference/htmlsingle/#getting-started) of the Gradle plugin’s reference guide.
### [](#getting-started.installing.cli)3.2. Installing the Spring Boot CLI ###
### 3.2. Installing the Spring Boot CLI
The Spring Boot CLI (Command Line Interface) is a command line tool that you can use to quickly prototype with Spring.
It lets you run [Groovy](https://groovy-lang.org/) scripts, which means that you have a familiar Java-like syntax without so much boilerplate code.
You do not need to use the CLI to work with Spring Boot, but it is a quick way to get a Spring application off the ground without an IDE.
#### [](#getting-started.installing.cli.manual-installation)3.2.1. Manual Installation ####
#### 3.2.1. Manual Installation
You can download the Spring CLI distribution from the Spring software repository:
......@@ -161,7 +122,7 @@ Once downloaded, follow the [INSTALL.txt](https://raw.githubusercontent.com/spri
In summary, there is a `spring` script (`spring.bat` for Windows) in a `bin/` directory in the `.zip` file.
Alternatively, you can use `java -jar` with the `.jar` file (the script helps you to be sure that the classpath is set correctly).
#### [](#getting-started.installing.cli.sdkman)3.2.2. Installation with SDKMAN! ####
#### 3.2.2. Installation with SDKMAN!
SDKMAN! (The Software Development Kit Manager) can be used for managing multiple versions of various binary SDKs, including Groovy and the Spring Boot CLI.
Get SDKMAN! from [sdkman.io](https://sdkman.io) and install Spring Boot by using the following commands:
......@@ -202,7 +163,7 @@ Available Springboot Versions
================================================================================
```
#### [](#getting-started.installing.cli.homebrew)3.2.3. OSX Homebrew Installation ####
#### 3.2.3. OSX Homebrew Installation
If you are on a Mac and use [Homebrew](https://brew.sh/), you can install the Spring Boot CLI by using the following commands:
......@@ -216,7 +177,7 @@ Homebrew installs `spring` to `/usr/local/bin`.
| |If you do not see the formula, your installation of brew might be out-of-date.<br/>In that case, run `brew update` and try again.|
|---|---------------------------------------------------------------------------------------------------------------------------------|
#### [](#getting-started.installing.cli.macports)3.2.4. MacPorts Installation ####
#### 3.2.4. MacPorts Installation
If you are on a Mac and use [MacPorts](https://www.macports.org/), you can install the Spring Boot CLI by using the following command:
......@@ -224,7 +185,7 @@ If you are on a Mac and use [MacPorts](https://www.macports.org/), you can insta
$ sudo port install spring-boot-cli
```
#### [](#getting-started.installing.cli.completion)3.2.5. Command-line Completion ####
#### 3.2.5. Command-line Completion
The Spring Boot CLI includes scripts that provide command completion for the [BASH](https://en.wikipedia.org/wiki/Bash_%28Unix_shell%29) and [zsh](https://en.wikipedia.org/wiki/Z_shell) shells.
You can `source` the script (also named `spring`) in any shell or put it in your personal or system-wide bash completion initialization.
......@@ -240,7 +201,7 @@ $ spring <HIT TAB HERE>
| |If you install the Spring Boot CLI by using Homebrew or MacPorts, the command-line completion scripts are automatically registered with your shell.|
|---|---------------------------------------------------------------------------------------------------------------------------------------------------|
#### [](#getting-started.installing.cli.scoop)3.2.6. Windows Scoop Installation ####
#### 3.2.6. Windows Scoop Installation
If you are on a Windows and use [Scoop](https://scoop.sh/), you can install the Spring Boot CLI by using the following commands:
......@@ -254,7 +215,7 @@ Scoop installs `spring` to `~/scoop/apps/springboot/current/bin`.
| |If you do not see the app manifest, your installation of scoop might be out-of-date.<br/>In that case, run `scoop update` and try again.|
|---|----------------------------------------------------------------------------------------------------------------------------------------|
#### [](#getting-started.installing.cli.quick-start)3.2.7. Quick-start Spring CLI Example ####
#### 3.2.7. Quick-start Spring CLI Example
You can use the following web application to test your installation.
To start, create a file called `app.groovy`, as follows:
......@@ -288,8 +249,7 @@ You should see the following output:
Hello World!
```
[](#getting-started.first-application)4. Developing Your First Spring Boot Application
----------
## 4. Developing Your First Spring Boot Application
This section describes how to develop a small “Hello World!” web application that highlights some of Spring Boot’s key features.
We use Maven to build this project, since most IDEs support it.
......@@ -316,7 +276,7 @@ Java version: 1.8.0_102, vendor: Oracle Corporation
| |This sample needs to be created in its own directory.<br/>Subsequent instructions assume that you have created a suitable directory and that it is your current directory.|
|---|--------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
### [](#getting-started.first-application.pom)4.1. Creating the POM ###
### 4.1. Creating the POM
We need to start by creating a Maven `pom.xml` file.
The `pom.xml` is the recipe that is used to build your project.
......@@ -349,7 +309,7 @@ You can test it by running `mvn package` (for now, you can ignore the “jar wil
| |At this point, you could import the project into an IDE (most modern Java IDEs include built-in support for Maven).<br/>For simplicity, we continue to use a plain text editor for this example.|
|---|------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
### [](#getting-started.first-application.dependencies)4.2. Adding Classpath Dependencies ###
### 4.2. Adding Classpath Dependencies
Spring Boot provides a number of “Starters” that let you add jars to your classpath.
Our applications for smoke tests use the `spring-boot-starter-parent` in the `parent` section of the POM.
......@@ -381,7 +341,7 @@ To add the necessary dependencies, edit your `pom.xml` and add the `spring-boot-
If you run `mvn dependency:tree` again, you see that there are now a number of additional dependencies, including the Tomcat web server and Spring Boot itself.
### [](#getting-started.first-application.code)4.3. Writing the Code ###
### 4.3. Writing the Code
To finish our application, we need to create a single Java file.
By default, Maven compiles sources from `src/main/java`, so you need to create that directory structure and then add a file named `src/main/java/MyApplication.java` to contain the following code:
......@@ -412,7 +372,7 @@ public class MyApplication {
Although there is not much code here, quite a lot is going on.
We step through the important parts in the next few sections.
#### [](#getting-started.first-application.code.mvc-annotations)4.3.1. The @RestController and @RequestMapping Annotations ####
#### 4.3.1. The @RestController and @RequestMapping Annotations ####
The first annotation on our `MyApplication` class is `@RestController`.
This is known as a *stereotype* annotation.
......@@ -426,7 +386,7 @@ The `@RestController` annotation tells Spring to render the resulting string dir
| |The `@RestController` and `@RequestMapping` annotations are Spring MVC annotations (they are not specific to Spring Boot).<br/>See the [MVC section](https://docs.spring.io/spring-framework/docs/5.3.16/reference/html/web.html#mvc) in the Spring Reference Documentation for more details.|
|---|---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
#### [](#getting-started.first-application.code.enable-auto-configuration)4.3.2. The @EnableAutoConfiguration Annotation ####
#### 4.3.2. The @EnableAutoConfiguration Annotation ####
The second class-level annotation is `@EnableAutoConfiguration`.
This annotation tells Spring Boot to “guess” how you want to configure Spring, based on the jar dependencies that you have added.
......@@ -438,7 +398,7 @@ Auto-configuration is designed to work well with “Starters”, but the two con
You are free to pick and choose jar dependencies outside of the starters.
Spring Boot still does its best to auto-configure your application.
#### [](#getting-started.first-application.code.main-method)4.3.3. The “main” Method ####
#### 4.3.3. The “main” Method
The final part of our application is the `main` method.
This is a standard method that follows the Java convention for an application entry point.
......@@ -446,7 +406,7 @@ Our main method delegates to Spring Boot’s `SpringApplication` class by callin
We need to pass `MyApplication.class` as an argument to the `run` method to tell `SpringApplication` which is the primary Spring component.
The `args` array is also passed through to expose any command-line arguments.
### [](#getting-started.first-application.run)4.4. Running the Example ###
### 4.4. Running the Example
At this point, your application should work.
Since you used the `spring-boot-starter-parent` POM, you have a useful `run` goal that you can use to start the application.
......@@ -477,7 +437,7 @@ Hello World!
To gracefully exit the application, press `ctrl-c`.
### [](#getting-started.first-application.executable-jar)4.5. Creating an Executable Jar ###
### 4.5. Creating an Executable Jar
We finish our example by creating a completely self-contained executable jar file that we could run in production.
Executable jars (sometimes called “fat jars”) are archives containing your compiled classes along with all of the jar dependencies that your code needs to run.
......@@ -562,8 +522,7 @@ $ java -jar target/myproject-0.0.1-SNAPSHOT.jar
As before, to exit the application, press `ctrl-c`.
[](#getting-started.whats-next)5. What to Read Next
----------
## 5. What to Read Next
Hopefully, this section provided some of the Spring Boot basics and got you on your way to writing your own applications.
If you are a task-oriented type of developer, you might want to jump over to [spring.io](https://spring.io) and follow some of the [getting started](https://spring.io/guides/) guides that solve specific “How do I do that with Spring?” problems.
......
此差异已折叠。
此差异已折叠。
Legal
==========
# Legal
Copyright © 2012-2022
......
Messaging
==========
Table of Contents
[Back to index](index.html)
* [1. JMS](#messaging.jms)
* [1.1. ActiveMQ Support](#messaging.jms.activemq)
* [1.2. ActiveMQ Artemis Support](#messaging.jms.artemis)
* [1.3. Using a JNDI ConnectionFactory](#messaging.jms.jndi)
* [1.4. Sending a Message](#messaging.jms.sending)
* [1.5. Receiving a Message](#messaging.jms.receiving)
* [2. AMQP](#messaging.amqp)
* [2.1. RabbitMQ support](#messaging.amqp.rabbitmq)
* [2.2. Sending a Message](#messaging.amqp.sending)
* [2.3. Receiving a Message](#messaging.amqp.receiving)
* [3. Apache Kafka Support](#messaging.kafka)
* [3.1. Sending a Message](#messaging.kafka.sending)
* [3.2. Receiving a Message](#messaging.kafka.receiving)
* [3.3. Kafka Streams](#messaging.kafka.streams)
* [3.4. Additional Kafka Properties](#messaging.kafka.additional-properties)
* [3.5. Testing with Embedded Kafka](#messaging.kafka.embedded)
* [4. RSocket](#messaging.rsocket)
* [4.1. RSocket Strategies Auto-configuration](#messaging.rsocket.strategies-auto-configuration)
* [4.2. RSocket server Auto-configuration](#messaging.rsocket.server-auto-configuration)
* [4.3. Spring Messaging RSocket support](#messaging.rsocket.messaging)
* [4.4. Calling RSocket Services with RSocketRequester](#messaging.rsocket.requester)
* [5. Spring Integration](#messaging.spring-integration)
* [6. What to Read Next](#messaging.whats-next)
# Messaging
The Spring Framework provides extensive support for integrating with messaging systems, from simplified use of the JMS API using `JmsTemplate` to a complete infrastructure to receive messages asynchronously.
Spring AMQP provides a similar feature set for the Advanced Message Queuing Protocol.
......@@ -39,15 +6,14 @@ Spring Boot also provides auto-configuration options for `RabbitTemplate` and Ra
Spring WebSocket natively includes support for STOMP messaging, and Spring Boot has support for that through starters and a small amount of auto-configuration.
Spring Boot also has support for Apache Kafka.
[](#messaging.jms)1. JMS
----------
## 1. JMS
The `javax.jms.ConnectionFactory` interface provides a standard method of creating a `javax.jms.Connection` for interacting with a JMS broker.
Although Spring needs a `ConnectionFactory` to work with JMS, you generally need not use it directly yourself and can instead rely on higher level messaging abstractions.
(See the [relevant section](https://docs.spring.io/spring-framework/docs/5.3.16/reference/html/integration.html#jms) of the Spring Framework reference documentation for details.)
Spring Boot also auto-configures the necessary infrastructure to send and receive messages.
### [](#messaging.jms.activemq)1.1. ActiveMQ Support ###
### 1.1. ActiveMQ Support
When [ActiveMQ](https://activemq.apache.org/) is available on the classpath, Spring Boot can also configure a `ConnectionFactory`.
If the broker is present, an embedded broker is automatically started and configured (provided no broker URL is specified through configuration and the embedded broker is not disabled in the configuration).
......@@ -138,7 +104,7 @@ spring:
By default, ActiveMQ creates a destination if it does not yet exist so that destinations are resolved against their provided names.
### [](#messaging.jms.artemis)1.2. ActiveMQ Artemis Support ###
### 1.2. ActiveMQ Artemis Support
Spring Boot can auto-configure a `ConnectionFactory` when it detects that [ActiveMQ Artemis](https://activemq.apache.org/components/artemis/) is available on the classpath.
If the broker is present, an embedded broker is automatically started and configured (unless the mode property has been explicitly set).
......@@ -214,7 +180,7 @@ See [`ArtemisProperties`](https://github.com/spring-projects/spring-boot/tree/v2
No JNDI lookup is involved, and destinations are resolved against their names, using either the `name` attribute in the Artemis configuration or the names provided through configuration.
### [](#messaging.jms.jndi)1.3. Using a JNDI ConnectionFactory ###
### 1.3. Using a JNDI ConnectionFactory
If you are running your application in an application server, Spring Boot tries to locate a JMS `ConnectionFactory` by using JNDI.
By default, the `java:/JmsXA` and `java:/XAConnectionFactory` location are checked.
......@@ -234,7 +200,7 @@ spring:
jndi-name: "java:/MyConnectionFactory"
```
### [](#messaging.jms.sending)1.4. Sending a Message ###
### 1.4. Sending a Message
Spring’s `JmsTemplate` is auto-configured, and you can autowire it directly into your own beans, as shown in the following example:
......@@ -264,7 +230,7 @@ public class MyBean {
| |[`JmsMessagingTemplate`](https://docs.spring.io/spring-framework/docs/5.3.16/javadoc-api/org/springframework/jms/core/JmsMessagingTemplate.html) can be injected in a similar manner.<br/>If a `DestinationResolver` or a `MessageConverter` bean is defined, it is associated automatically to the auto-configured `JmsTemplate`.|
|---|----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
### [](#messaging.jms.receiving)1.5. Receiving a Message ###
### 1.5. Receiving a Message
When the JMS infrastructure is present, any bean can be annotated with `@JmsListener` to create a listener endpoint.
If no `JmsListenerContainerFactory` has been defined, a default one is configured automatically.
......@@ -348,14 +314,13 @@ public class MyBean {
```
[](#messaging.amqp)2. AMQP
----------
## 2. AMQP
The Advanced Message Queuing Protocol (AMQP) is a platform-neutral, wire-level protocol for message-oriented middleware.
The Spring AMQP project applies core Spring concepts to the development of AMQP-based messaging solutions.
Spring Boot offers several conveniences for working with AMQP through RabbitMQ, including the `spring-boot-starter-amqp` “Starter”.
### [](#messaging.amqp.rabbitmq)2.1. RabbitMQ support ###
### 2.1. RabbitMQ support
[RabbitMQ](https://www.rabbitmq.com/) is a lightweight, reliable, scalable, and portable message broker based on the AMQP protocol.
Spring uses `RabbitMQ` to communicate through the AMQP protocol.
......@@ -410,7 +375,7 @@ If a `ConnectionNameStrategy` bean exists in the context, it will be automatical
| |See [Understanding AMQP, the protocol used by RabbitMQ](https://spring.io/blog/2010/06/14/understanding-amqp-the-protocol-used-by-rabbitmq/) for more details.|
|---|--------------------------------------------------------------------------------------------------------------------------------------------------------------|
### [](#messaging.amqp.sending)2.2. Sending a Message ###
### 2.2. Sending a Message
Spring’s `AmqpTemplate` and `AmqpAdmin` are auto-configured, and you can autowire them directly into your own beans, as shown in the following example:
......@@ -475,7 +440,7 @@ You can also customize the `RetryTemplate` programmatically by declaring a `Rabb
If you need to create more `RabbitTemplate` instances or if you want to override the default, Spring Boot provides a `RabbitTemplateConfigurer` bean that you can use to initialize a `RabbitTemplate` with the same settings as the factories used by the auto-configuration.
### [](#messaging.amqp.receiving)2.3. Receiving a Message ###
### 2.3. Receiving a Message
When the Rabbit infrastructure is present, any bean can be annotated with `@RabbitListener` to create a listener endpoint.
If no `RabbitListenerContainerFactory` has been defined, a default `SimpleRabbitListenerContainerFactory` is automatically configured and you can switch to a direct container using the `spring.rabbitmq.listener.type` property.
......@@ -563,8 +528,7 @@ You can also customize the `RetryTemplate` programmatically by declaring a `Rabb
| |By default, if retries are disabled and the listener throws an exception, the delivery is retried indefinitely.<br/>You can modify this behavior in two ways: Set the `defaultRequeueRejected` property to `false` so that zero re-deliveries are attempted or throw an `AmqpRejectAndDontRequeueException` to signal the message should be rejected.<br/>The latter is the mechanism used when retries are enabled and the maximum number of delivery attempts is reached.|
|---|---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
[](#messaging.kafka)3. Apache Kafka Support
----------
## 3. Apache Kafka Support
[Apache Kafka](https://kafka.apache.org/) is supported by providing auto-configuration of the `spring-kafka` project.
......@@ -593,7 +557,7 @@ spring:
See [`KafkaProperties`](https://github.com/spring-projects/spring-boot/tree/v2.6.4/spring-boot-project/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/kafka/KafkaProperties.java) for more supported options.
### [](#messaging.kafka.sending)3.1. Sending a Message ###
### 3.1. Sending a Message
Spring’s `KafkaTemplate` is auto-configured, and you can autowire it directly in your own beans, as shown in the following example:
......@@ -623,7 +587,7 @@ public class MyBean {
| |If the property `spring.kafka.producer.transaction-id-prefix` is defined, a `KafkaTransactionManager` is automatically configured.<br/>Also, if a `RecordMessageConverter` bean is defined, it is automatically associated to the auto-configured `KafkaTemplate`.|
|---|------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
### [](#messaging.kafka.receiving)3.2. Receiving a Message ###
### 3.2. Receiving a Message
When the Apache Kafka infrastructure is present, any bean can be annotated with `@KafkaListener` to create a listener endpoint.
If no `KafkaListenerContainerFactory` has been defined, a default one is automatically configured with keys defined in `spring.kafka.listener.*`.
......@@ -655,7 +619,7 @@ If only a `RecordMessageConverter` bean is present for a batch listener, it is w
| |A custom `ChainedKafkaTransactionManager` must be marked `@Primary` as it usually references the auto-configured `KafkaTransactionManager` bean.|
|---|------------------------------------------------------------------------------------------------------------------------------------------------|
### [](#messaging.kafka.streams)3.3. Kafka Streams ###
### 3.3. Kafka Streams
Spring for Apache Kafka provides a factory bean to create a `StreamsBuilder` object and manage the lifecycle of its streams.
Spring Boot auto-configures the required `KafkaStreamsConfiguration` bean as long as `kafka-streams` is on the classpath and Kafka Streams is enabled by the `@EnableKafkaStreams` annotation.
......@@ -703,7 +667,7 @@ public class MyKafkaStreamsConfiguration {
By default, the streams managed by the `StreamBuilder` object it creates are started automatically.
You can customize this behavior using the `spring.kafka.streams.auto-startup` property.
### [](#messaging.kafka.additional-properties)3.4. Additional Kafka Properties ###
### 3.4. Additional Kafka Properties
The properties supported by auto configuration are shown in the [“Integration Properties”](application-properties.html#appendix.application-properties.integration) section of the Appendix.
Note that, for the most part, these properties (hyphenated or camelCase) map directly to the Apache Kafka dotted properties.
......@@ -794,7 +758,7 @@ spring:
| |Properties set in this way override any configuration item that Spring Boot explicitly supports.|
|---|------------------------------------------------------------------------------------------------|
### [](#messaging.kafka.embedded)3.5. Testing with Embedded Kafka ###
### 3.5. Testing with Embedded Kafka
Spring for Apache Kafka provides a convenient way to test projects with an embedded Apache Kafka broker.
To use this feature, annotate a test class with `@EmbeddedKafka` from the `spring-kafka-test` module.
......@@ -844,8 +808,7 @@ spring:
bootstrap-servers: "${spring.embedded.kafka.brokers}"
```
[](#messaging.rsocket)4. RSocket
----------
## 4. RSocket
[RSocket](https://rsocket.io) is a binary protocol for use on byte stream transports.
It enables symmetric interaction models through async message passing over a single connection.
......@@ -853,7 +816,7 @@ It enables symmetric interaction models through async message passing over a sin
The `spring-messaging` module of the Spring Framework provides support for RSocket requesters and responders, both on the client and on the server side.
See the [RSocket section](https://docs.spring.io/spring-framework/docs/5.3.16/reference/html/web-reactive.html#rsocket-spring) of the Spring Framework reference for more details, including an overview of the RSocket protocol.
### [](#messaging.rsocket.strategies-auto-configuration)4.1. RSocket Strategies Auto-configuration ###
### 4.1. RSocket Strategies Auto-configuration
Spring Boot auto-configures an `RSocketStrategies` bean that provides all the required infrastructure for encoding and decoding RSocket payloads.
By default, the auto-configuration will try to configure the following (in order):
......@@ -868,7 +831,7 @@ See the [Jackson support section](features.html#features.json.jackson) to know m
Developers can customize the `RSocketStrategies` component by creating beans that implement the `RSocketStrategiesCustomizer` interface.
Note that their `@Order` is important, as it determines the order of codecs.
### [](#messaging.rsocket.server-auto-configuration)4.2. RSocket server Auto-configuration ###
### 4.2. RSocket server Auto-configuration
Spring Boot provides RSocket server auto-configuration.
The required dependencies are provided by the `spring-boot-starter-rsocket`.
......@@ -916,13 +879,13 @@ spring:
port: 9898
```
### [](#messaging.rsocket.messaging)4.3. Spring Messaging RSocket support ###
### 4.3. Spring Messaging RSocket support
Spring Boot will auto-configure the Spring Messaging infrastructure for RSocket.
This means that Spring Boot will create a `RSocketMessageHandler` bean that will handle RSocket requests to your application.
### [](#messaging.rsocket.requester)4.4. Calling RSocket Services with RSocketRequester ###
### 4.4. Calling RSocket Services with RSocketRequester
Once the `RSocket` channel is established between server and client, any party can send or receive requests to the other.
......@@ -958,8 +921,7 @@ public class MyService {
```
[](#messaging.spring-integration)5. Spring Integration
----------
## 5. Spring Integration
Spring Boot offers several conveniences for working with [Spring Integration](https://spring.io/projects/spring-integration), including the `spring-boot-starter-integration` “Starter”.
Spring Integration provides abstractions over messaging and also other transports such as HTTP, TCP, and others.
......@@ -1032,8 +994,7 @@ spring:
See the [`IntegrationAutoConfiguration`](https://github.com/spring-projects/spring-boot/tree/v2.6.4/spring-boot-project/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/integration/IntegrationAutoConfiguration.java) and [`IntegrationProperties`](https://github.com/spring-projects/spring-boot/tree/v2.6.4/spring-boot-project/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/integration/IntegrationProperties.java) classes for more details.
[](#messaging.whats-next)6. What to Read Next
----------
## 6. What to Read Next
The next section describes how to enable [IO capabilities](io.html#io) in your application.
You can read about [caching](io.html#io.caching), [mail](io.html#io.email), [validation](io.html#io.validation), [rest clients](io.html#io.rest-client) and more in this section.
Upgrading Spring Boot
==========
Table of Contents
[Back to index](index.html)
* [1. Upgrading from 1.x](#upgrading.from-1x)
* [2. Upgrading to a new feature release](#upgrading.to-feature)
* [3. Upgrading the Spring Boot CLI](#upgrading.cli)
* [4. What to Read Next](#upgrading.whats-next)
# Upgrading Spring Boot
Instructions for how to upgrade from earlier versions of Spring Boot are provided on the project [wiki](https://github.com/spring-projects/spring-boot/wiki).
Follow the links in the [release notes](https://github.com/spring-projects/spring-boot/wiki#release-notes) section to find the version that you want to upgrade to.
......@@ -16,14 +6,12 @@ Follow the links in the [release notes](https://github.com/spring-projects/sprin
Upgrading instructions are always the first item in the release notes.
If you are more than one release behind, please make sure that you also review the release notes of the versions that you jumped.
[](#upgrading.from-1x)1. Upgrading from 1.x
----------
## 1. Upgrading from 1.x
If you are upgrading from the `1.x` release of Spring Boot, check the [“migration guide” on the project wiki](https://github.com/spring-projects/spring-boot/wiki/Spring-Boot-2.0-Migration-Guide) that provides detailed upgrade instructions.
Check also the [“release notes”](https://github.com/spring-projects/spring-boot/wiki) for a list of “new and noteworthy” features for each release.
[](#upgrading.to-feature)2. Upgrading to a new feature release
----------
## 2. Upgrading to a new feature release
When upgrading to a new feature release, some properties may have been renamed or removed.
Spring Boot provides a way to analyze your application’s environment and print diagnostics at startup, but also temporarily migrate properties at runtime for you.
......@@ -43,14 +31,12 @@ To enable that feature, add the following dependency to your project:
| |Once you finish the migration, please make sure to remove this module from your project’s dependencies.|
|---|-------------------------------------------------------------------------------------------------------|
[](#upgrading.cli)3. Upgrading the Spring Boot CLI
----------
## 3. Upgrading the Spring Boot CLI
To upgrade an existing CLI installation, use the appropriate package manager command (for example, `brew upgrade`).
If you manually installed the CLI, follow the [standard instructions](getting-started.html#getting-started.installing.cli.manual-installation), remembering to update your `PATH` environment variable to remove any older references.
[](#upgrading.whats-next)4. What to Read Next
----------
## 4. What to Read Next
Once you’ve decided to upgrade your application, you can find detailed information regarding specific features in the rest of the document.
......
此差异已折叠。
此差异已折叠。
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册