From cebb4d98b5fa559e5e9a4f1ddfbe18545b501b9c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E7=83=AD=E5=BF=83=E5=B8=82=E6=B0=91=E9=92=9F=E5=B0=8F?= =?UTF-8?q?=E5=BC=BA?= Date: Wed, 21 Mar 2018 00:34:03 +0900 Subject: [PATCH 001/865] Update and rename 11.2. Adding classpath dependencies.md to 11.2. Adding Classpath Dependencies.md --- ...dependencies.md => 11.2. Adding Classpath Dependencies.md} | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) rename II. Getting Started/{11.2. Adding classpath dependencies.md => 11.2. Adding Classpath Dependencies.md} (70%) diff --git a/II. Getting Started/11.2. Adding classpath dependencies.md b/II. Getting Started/11.2. Adding Classpath Dependencies.md similarity index 70% rename from II. Getting Started/11.2. Adding classpath dependencies.md rename to II. Getting Started/11.2. Adding Classpath Dependencies.md index 6919f826..06743854 100644 --- a/II. Getting Started/11.2. Adding classpath dependencies.md +++ b/II. Getting Started/11.2. Adding Classpath Dependencies.md @@ -2,12 +2,12 @@ Spring Boot提供很多"Starters",用来简化添加jars到classpath的操作。示例程序中已经在POM的`parent`节点使用了`spring-boot-starter-parent`,它是一个特殊的starter,提供了有用的Maven默认设置。同时,它也提供一个`dependency-management`节点,这样对于期望(”blessed“)的依赖就可以省略version标记了。 -其他”Starters“只简单提供开发特定类型应用所需的依赖。由于正在开发web应用,我们将添加`spring-boot-starter-web`依赖-但在此之前,让我们先看下目前的依赖: +其他”Starters“提供开发特定类型应用所需的依赖。由于正在开发web应用,我们添加`spring-boot-starter-web`依赖。在此之前,我们可以运行下面的命令,先看一下目前的依赖: ```shell $ mvn dependency:tree [INFO] com.example:myproject:jar:0.0.1-SNAPSHOT ``` -`mvn dependency:tree`命令可以将项目依赖以树形方式展现出来,你可以看到`spring-boot-starter-parent`本身并没有提供依赖。编辑`pom.xml`,并在`parent`节点下添加`spring-boot-starter-web`依赖: +`mvn dependency:tree`命令可以将项目依赖以树形方式展现出来,你可以看到`spring-boot-starter-parent`本身并没有提供依赖。为了添加需要的依赖,编辑你的`pom.xml`,并在`parent`节点下添加`spring-boot-starter-web`依赖: ```xml From da1a5d1bbd9fd798e2fb32df7169f37a1d9ab4a7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E7=83=AD=E5=BF=83=E5=B8=82=E6=B0=91=E9=92=9F=E5=B0=8F?= =?UTF-8?q?=E5=BC=BA?= Date: Wed, 21 Mar 2018 00:34:52 +0900 Subject: [PATCH 002/865] Update SUMMARY.md --- SUMMARY.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/SUMMARY.md b/SUMMARY.md index badadb75..80d46bd5 100644 --- a/SUMMARY.md +++ b/SUMMARY.md @@ -26,7 +26,7 @@ * [10.3. 从Spring Boot早期版本升级](II. Getting Started/10.3. Upgrading from an Earlier Version of Spring Boot.md) * [11. 开发你的第一个Spring Boot应用](II. Getting Started/11. Developing Your First Spring Boot Application.md) * [11.1. 创建POM](II. Getting Started/11.1. Creating the POM.md) - * [11.2. 添加classpath依赖](II. Getting Started/11.2. Adding classpath dependencies.md) + * [11.2. 添加classpath依赖](II. Getting Started/11.2. Adding Classpath Dependencies.md) * [11.3. 编写代码](II. Getting Started/11.3. Writing the code.md) * [11.3.1. @RestController和@RequestMapping注解](II. Getting Started/11.3.1. The @RestController and @RequestMapping annotations.md) * [11.3.2. @EnableAutoConfiguration注解](II. Getting Started/11.3.2. The @EnableAutoConfiguration annotation.md) From c6fa06fe0206b369fc24286fa36a6f9124bc75e8 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E7=83=AD=E5=BF=83=E5=B8=82=E6=B0=91=E9=92=9F=E5=B0=8F?= =?UTF-8?q?=E5=BC=BA?= Date: Wed, 21 Mar 2018 00:41:39 +0900 Subject: [PATCH 003/865] Update and rename 11.3. Writing the code.md to 11.3. Writing the Code.md --- II. Getting Started/11.3. Writing the Code.md | 24 ++++++++++++++++++ II. Getting Started/11.3. Writing the code.md | 25 ------------------- 2 files changed, 24 insertions(+), 25 deletions(-) create mode 100644 II. Getting Started/11.3. Writing the Code.md delete mode 100644 II. Getting Started/11.3. Writing the code.md diff --git a/II. Getting Started/11.3. Writing the Code.md b/II. Getting Started/11.3. Writing the Code.md new file mode 100644 index 00000000..061b09f2 --- /dev/null +++ b/II. Getting Started/11.3. Writing the Code.md @@ -0,0 +1,24 @@ +### 11.3. 编写代码 + +为了完成应用程序,我们需要创建一个单独的Java文件。默认地,Maven会编译`src/main/java`下的源码,所以你需要创建那样的文件结构,然后添加一个名为`src/main/java/Example.java`的文件: +```java +import org.springframework.boot.*; +import org.springframework.boot.autoconfigure.*; +import org.springframework.web.bind.annotation.*; + +@RestController +@EnableAutoConfiguration +public class Example { + + @RequestMapping("/") + String home() { + return "Hello World!"; + } + + public static void main(String[] args) throws Exception { + SpringApplication.run(Example.class, args); + } + +} +``` +尽管代码不多,但已经发生了很多事情。我们在接下来的几节里分步探讨重要的部分。 diff --git a/II. Getting Started/11.3. Writing the code.md b/II. Getting Started/11.3. Writing the code.md deleted file mode 100644 index 3bfa38a6..00000000 --- a/II. Getting Started/11.3. Writing the code.md +++ /dev/null @@ -1,25 +0,0 @@ -### 11.3. 编写代码 - -为了完成应用程序,我们需要创建一个单独的Java文件。Maven默认会编译`src/main/java`下的源码,所以你需要创建那样的文件结构,并添加一个名为`src/main/java/Example.java`的文件: -```java -import org.springframework.boot.*; -import org.springframework.boot.autoconfigure.*; -import org.springframework.stereotype.*; -import org.springframework.web.bind.annotation.*; - -@RestController -@EnableAutoConfiguration -public class Example { - - @RequestMapping("/") - String home() { - return "Hello World!"; - } - - public static void main(String[] args) throws Exception { - SpringApplication.run(Example.class, args); - } - -} -``` -尽管代码不多,但已经发生了很多事情,让我们分步探讨重要的部分吧! From 862393c26cb78224d9092528fab86d88a5c6528d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E7=83=AD=E5=BF=83=E5=B8=82=E6=B0=91=E9=92=9F=E5=B0=8F?= =?UTF-8?q?=E5=BC=BA?= Date: Wed, 21 Mar 2018 00:42:39 +0900 Subject: [PATCH 004/865] Update SUMMARY.md --- SUMMARY.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/SUMMARY.md b/SUMMARY.md index 80d46bd5..3dce4fa0 100644 --- a/SUMMARY.md +++ b/SUMMARY.md @@ -27,7 +27,7 @@ * [11. 开发你的第一个Spring Boot应用](II. Getting Started/11. Developing Your First Spring Boot Application.md) * [11.1. 创建POM](II. Getting Started/11.1. Creating the POM.md) * [11.2. 添加classpath依赖](II. Getting Started/11.2. Adding Classpath Dependencies.md) - * [11.3. 编写代码](II. Getting Started/11.3. Writing the code.md) + * [11.3. 编写代码](II. Getting Started/11.3. Writing the Code.md) * [11.3.1. @RestController和@RequestMapping注解](II. Getting Started/11.3.1. The @RestController and @RequestMapping annotations.md) * [11.3.2. @EnableAutoConfiguration注解](II. Getting Started/11.3.2. The @EnableAutoConfiguration annotation.md) * [11.3.3. main方法](II. Getting Started/11.3.3. The “main” method.md) From 3b14d8c1145e88fe27fc51a7b1ef5ee9b50d0ca9 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E7=83=AD=E5=BF=83=E5=B8=82=E6=B0=91=E9=92=9F=E5=B0=8F?= =?UTF-8?q?=E5=BC=BA?= Date: Wed, 21 Mar 2018 00:50:55 +0900 Subject: [PATCH 005/865] Update and rename 11.3.1. The @RestController and @RequestMapping annotations.md to 11.3.1. The @RestController and @RequestMapping Annotations.md --- ...1. The @RestController and @RequestMapping Annotations.md} | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) rename II. Getting Started/{11.3.1. The @RestController and @RequestMapping annotations.md => 11.3.1. The @RestController and @RequestMapping Annotations.md} (60%) diff --git a/II. Getting Started/11.3.1. The @RestController and @RequestMapping annotations.md b/II. Getting Started/11.3.1. The @RestController and @RequestMapping Annotations.md similarity index 60% rename from II. Getting Started/11.3.1. The @RestController and @RequestMapping annotations.md rename to II. Getting Started/11.3.1. The @RestController and @RequestMapping Annotations.md index 86e4cc07..687a9726 100644 --- a/II. Getting Started/11.3.1. The @RestController and @RequestMapping annotations.md +++ b/II. Getting Started/11.3.1. The @RestController and @RequestMapping Annotations.md @@ -3,6 +3,6 @@ Example类上使用的第一个注解是`@RestController`,这被称为构造型(stereotype)注解。它为阅读代码的人提供暗示(这是一个支持REST的控制器),对于Spring,该类扮演了一个特殊角色。在本示例中,我们的类是一个web `@Controller`,所以当web请求进来时,Spring会考虑是否使用它来处理。 -`@RequestMapping`注解提供路由信息,它告诉Spring任何来自"/"路径的HTTP请求都应该被映射到`home`方法。`@RestController`注解告诉Spring以字符串的形式渲染结果,并直接返回给调用者。 +`@RequestMapping`注解提供路由信息,它告诉Spring任何来自/路径的HTTP请求都应该被映射到`home`方法。`@RestController`注解告诉Spring以字符串的形式渲染结果,并直接返回给调用者。 -**注**:`@RestController`和`@RequestMapping`是Spring MVC中的注解(它们不是Spring Boot的特定部分),具体参考Spring文档的[MVC章节](http://mvc.linesh.tw)。 +**注**:`@RestController`和`@RequestMapping`是Spring MVC中的注解(它们不是Spring Boot的特定部分)。具体参考Spring文档的[MVC章节](https://docs.spring.io/spring/docs/5.0.4.RELEASE/spring-framework-reference/web.html#mvc)。 From 57a2dc495f5dd3b434bd5c5a5876f547fb1e1ee3 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E7=83=AD=E5=BF=83=E5=B8=82=E6=B0=91=E9=92=9F=E5=B0=8F?= =?UTF-8?q?=E5=BC=BA?= Date: Wed, 21 Mar 2018 00:53:09 +0900 Subject: [PATCH 006/865] Update SUMMARY.md --- SUMMARY.md | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/SUMMARY.md b/SUMMARY.md index 3dce4fa0..9ef05a43 100644 --- a/SUMMARY.md +++ b/SUMMARY.md @@ -28,9 +28,9 @@ * [11.1. 创建POM](II. Getting Started/11.1. Creating the POM.md) * [11.2. 添加classpath依赖](II. Getting Started/11.2. Adding Classpath Dependencies.md) * [11.3. 编写代码](II. Getting Started/11.3. Writing the Code.md) - * [11.3.1. @RestController和@RequestMapping注解](II. Getting Started/11.3.1. The @RestController and @RequestMapping annotations.md) - * [11.3.2. @EnableAutoConfiguration注解](II. Getting Started/11.3.2. The @EnableAutoConfiguration annotation.md) - * [11.3.3. main方法](II. Getting Started/11.3.3. The “main” method.md) + * [11.3.1. @RestController和@RequestMapping注解](II. Getting Started/11.3.1. The @RestController and @RequestMapping Annotations.md) + * [11.3.2. @EnableAutoConfiguration注解](II. Getting Started/11.3.2. The @EnableAutoConfiguration Annotations.md) + * [11.3.3. main方法](II. Getting Started/11.3.3. The “main” Method.md) * [11.4. 运行示例](II. Getting Started/11.4. Running the example.md) * [11.5. 创建一个可执行jar](II. Getting Started/11.5. Creating an executable jar.md) * [12. 接下来阅读什么](II. Getting Started/12. What to read next.md) From 1b8203c5eaf37f8e70038a7937becd5689a58cbb Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E7=83=AD=E5=BF=83=E5=B8=82=E6=B0=91=E9=92=9F=E5=B0=8F?= =?UTF-8?q?=E5=BC=BA?= Date: Wed, 21 Mar 2018 00:57:03 +0900 Subject: [PATCH 007/865] Update and rename 11.3.2. The @EnableAutoConfiguration annotation.md to 11.3.2. The @EnableAutoConfiguration Annotation.md --- ...on.md => 11.3.2. The @EnableAutoConfiguration Annotation.md} | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) rename II. Getting Started/{11.3.2. The @EnableAutoConfiguration annotation.md => 11.3.2. The @EnableAutoConfiguration Annotation.md} (80%) diff --git a/II. Getting Started/11.3.2. The @EnableAutoConfiguration annotation.md b/II. Getting Started/11.3.2. The @EnableAutoConfiguration Annotation.md similarity index 80% rename from II. Getting Started/11.3.2. The @EnableAutoConfiguration annotation.md rename to II. Getting Started/11.3.2. The @EnableAutoConfiguration Annotation.md index 4e2f0ec5..6451ae85 100644 --- a/II. Getting Started/11.3.2. The @EnableAutoConfiguration annotation.md +++ b/II. Getting Started/11.3.2. The @EnableAutoConfiguration Annotation.md @@ -1,5 +1,5 @@ ### 11.3.2. @EnableAutoConfiguration注解 -第二个类级别的注解是`@EnableAutoConfiguration`,这个注解告诉Spring Boot根据添加的jar依赖猜测你想如何配置Spring。由于`spring-boot-starter-web`添加了Tomcat和Spring MVC,所以auto-configuration将假定你正在开发一个web应用,并对Spring进行相应地设置。 +第二个类级别的注解是`@EnableAutoConfiguration`,这个注解告诉Spring Boot根据添加的jar依赖猜测你想如何配置Spring。由于`spring-boot-starter-web`添加了Tomcat和Spring MVC,所以auto-configuration假定你正在开发一个web应用,并对Spring进行相应地设置。 **Starters和Auto-Configuration**:Auto-configuration设计成可以跟"Starters"一起很好的使用,但这两个概念没有直接的联系。你可以自由地挑选starters以外的jar依赖,Spring Boot仍会尽最大努力去自动配置你的应用。 From 12645a370fa487ebb4f227622e4578d4cd9e2ed2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E7=83=AD=E5=BF=83=E5=B8=82=E6=B0=91=E9=92=9F=E5=B0=8F?= =?UTF-8?q?=E5=BC=BA?= Date: Wed, 21 Mar 2018 01:01:54 +0900 Subject: [PATCH 008/865] =?UTF-8?q?Update=20and=20rename=2011.3.3.=20The?= =?UTF-8?q?=20=E2=80=9Cmain=E2=80=9D=20method.md=20to=2011.3.3.=20The=20?= =?UTF-8?q?=E2=80=9Cmain=E2=80=9D=20Method.md?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../11.3.3. The \342\200\234main\342\200\235 Method.md" | 0 1 file changed, 0 insertions(+), 0 deletions(-) rename "II. Getting Started/11.3.3. The \342\200\234main\342\200\235 method.md" => "II. Getting Started/11.3.3. The \342\200\234main\342\200\235 Method.md" (100%) diff --git "a/II. Getting Started/11.3.3. The \342\200\234main\342\200\235 method.md" "b/II. Getting Started/11.3.3. The \342\200\234main\342\200\235 Method.md" similarity index 100% rename from "II. Getting Started/11.3.3. The \342\200\234main\342\200\235 method.md" rename to "II. Getting Started/11.3.3. The \342\200\234main\342\200\235 Method.md" From 1558fcd1bbfbcd72bdd9e70a1b4cc73abffddf12 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E7=83=AD=E5=BF=83=E5=B8=82=E6=B0=91=E9=92=9F=E5=B0=8F?= =?UTF-8?q?=E5=BC=BA?= Date: Wed, 21 Mar 2018 19:57:03 +0900 Subject: [PATCH 009/865] Update and rename 11.4. Running the example.md to 11.4. Running the Example.md --- ...4. Running the example.md => 11.4. Running the Example.md} | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) rename II. Getting Started/{11.4. Running the example.md => 11.4. Running the Example.md} (72%) diff --git a/II. Getting Started/11.4. Running the example.md b/II. Getting Started/11.4. Running the Example.md similarity index 72% rename from II. Getting Started/11.4. Running the example.md rename to II. Getting Started/11.4. Running the Example.md index 1f47da8d..e8e20a76 100644 --- a/II. Getting Started/11.4. Running the example.md +++ b/II. Getting Started/11.4. Running the Example.md @@ -1,6 +1,6 @@ ### 11.4. 运行示例 -到此,示例应用可以工作了。由于使用了`spring-boot-starter-parent` POM,这样我们就有了一个非常有用的run目标来启动程序。在项目根目录下输入`mvn spring-boot:run`启动应用: +到此,示例应用可以工作了。由于使用了`spring-boot-starter-parent` POM,这样你就有了一个非常有用的run目标来启动程序。在项目根目录下输入`mvn spring-boot:run`启动应用。你会看到如下的输出: ```shell $ mvn spring-boot:run @@ -20,4 +20,4 @@ $ mvn spring-boot:run ```shell Hello World! ``` -点击`ctrl-c`温雅地关闭应用程序。 +点击`ctrl-c`温柔地关闭应用程序。 From 2684208948390450f696135b7e96ebdcf9a56da9 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E7=83=AD=E5=BF=83=E5=B8=82=E6=B0=91=E9=92=9F=E5=B0=8F?= =?UTF-8?q?=E5=BC=BA?= Date: Wed, 21 Mar 2018 19:59:14 +0900 Subject: [PATCH 010/865] =?UTF-8?q?=E6=9B=B4=E6=96=B011.5.=20=E5=88=9B?= =?UTF-8?q?=E5=BB=BA=E4=B8=80=E4=B8=AA=E5=8F=AF=E6=89=A7=E8=A1=8Cjar?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- SUMMARY.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/SUMMARY.md b/SUMMARY.md index 9ef05a43..ac5caa31 100644 --- a/SUMMARY.md +++ b/SUMMARY.md @@ -31,8 +31,8 @@ * [11.3.1. @RestController和@RequestMapping注解](II. Getting Started/11.3.1. The @RestController and @RequestMapping Annotations.md) * [11.3.2. @EnableAutoConfiguration注解](II. Getting Started/11.3.2. The @EnableAutoConfiguration Annotations.md) * [11.3.3. main方法](II. Getting Started/11.3.3. The “main” Method.md) - * [11.4. 运行示例](II. Getting Started/11.4. Running the example.md) - * [11.5. 创建一个可执行jar](II. Getting Started/11.5. Creating an executable jar.md) + * [11.4. 运行示例](II. Getting Started/11.4. Running the Example.md) + * [11.5. 创建一个可执行jar](II. Getting Started/11.5. Creating an Executable Jar.md) * [12. 接下来阅读什么](II. Getting Started/12. What to read next.md) * [III. 使用Spring Boot](III. Using Spring Boot/README.md) * [13. 构建系统](III. Using Spring Boot/13. Build systems.md) From dcc6e34e0315a5c2f9eb930ab84d03d49aa942dd Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E7=83=AD=E5=BF=83=E5=B8=82=E6=B0=91=E9=92=9F=E5=B0=8F?= =?UTF-8?q?=E5=BC=BA?= Date: Wed, 21 Mar 2018 20:12:04 +0900 Subject: [PATCH 011/865] Update and rename 11.5. Creating an executable jar.md to 11.5. Creating an Executable Jar.md --- ...xecutable jar.md => 11.5. Creating an Executable Jar.md} | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) rename II. Getting Started/{11.5. Creating an executable jar.md => 11.5. Creating an Executable Jar.md} (76%) diff --git a/II. Getting Started/11.5. Creating an executable jar.md b/II. Getting Started/11.5. Creating an Executable Jar.md similarity index 76% rename from II. Getting Started/11.5. Creating an executable jar.md rename to II. Getting Started/11.5. Creating an Executable Jar.md index 4ae086e0..4406f4ec 100644 --- a/II. Getting Started/11.5. Creating an executable jar.md +++ b/II. Getting Started/11.5. Creating an Executable Jar.md @@ -1,8 +1,8 @@ ### 11.5. 创建可执行jar -让我们通过创建一个完全自包含,并可以在生产环境运行的可执行jar来结束示例吧!可执行jars(有时被称为胖jars "fat jars")是包含编译后的类及代码运行所需依赖jar的存档。 +我们通过创建一个完全自包含,并可以在生产环境运行的可执行jar来结束示例。可执行jars(有时被称为胖jars "fat jars")是包含编译后的类及代码运行所需依赖jar的存档。 -**可执行jars和Java**:Java没有提供任何标准方式,用于加载内嵌jar文件(即jar文件中还包含jar文件),这对分发自包含应用来说是个问题。为了解决该问题,很多开发者采用"共享的"jars。共享的jar只是简单地将所有jars的类打包进一个单独的存档,这种方式存在的问题是,很难区分应用程序中使用了哪些库。在多个jars中如果存在相同的文件名(但内容不一样)也会是一个问题。Spring Boot采取一个[不同的方式](../X. Appendices/D. The executable jar format.md),允许你真正的直接内嵌jars。 +**可执行jars和Java**:Java没有提供一个标准方式,用于加载内嵌jar文件(即jar文件中还包含jar文件),这对分发自包含应用来说是个问题。为了解决该问题,很多开发者采用"共享的"jars。共享的jar只是将所有应用依赖的类打包进一个单独的存档,这种方式存在的问题是,很难区分应用程序中使用了哪些库。在多个jars中如果存在相同的文件名(但内容不一样)也会是一个问题。Spring Boot采取一个[不同的方式](../X. Appendices/D. The executable jar format.md),让你真正的直接内嵌jars。 为了创建可执行的jar,我们需要将`spring-boot-maven-plugin`添加到`pom.xml`中,在dependencies节点后面插入以下内容: ```xml @@ -57,4 +57,4 @@ $ java -jar target/myproject-0.0.1-SNAPSHOT.jar ....... . . . ........ Started Example in 2.536 seconds (JVM running for 2.864) ``` -如上所述,点击`ctrl-c`可以温雅地退出应用。 +如前所述,点击`ctrl-c`退出应用。 From c784778444738d22588d658695c20258fb59ff18 Mon Sep 17 00:00:00 2001 From: Jack Zhong Date: Wed, 21 Mar 2018 20:40:44 +0900 Subject: [PATCH 012/865] =?UTF-8?q?=E6=9B=B4=E6=96=B011.3.2.=20@EnableAuto?= =?UTF-8?q?Configuration=E6=B3=A8=E8=A7=A3?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- SUMMARY.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/SUMMARY.md b/SUMMARY.md index ac5caa31..6f070294 100644 --- a/SUMMARY.md +++ b/SUMMARY.md @@ -29,7 +29,7 @@ * [11.2. 添加classpath依赖](II. Getting Started/11.2. Adding Classpath Dependencies.md) * [11.3. 编写代码](II. Getting Started/11.3. Writing the Code.md) * [11.3.1. @RestController和@RequestMapping注解](II. Getting Started/11.3.1. The @RestController and @RequestMapping Annotations.md) - * [11.3.2. @EnableAutoConfiguration注解](II. Getting Started/11.3.2. The @EnableAutoConfiguration Annotations.md) + * [11.3.2. @EnableAutoConfiguration注解](II. Getting Started/11.3.2. The @EnableAutoConfiguration Annotation.md) * [11.3.3. main方法](II. Getting Started/11.3.3. The “main” Method.md) * [11.4. 运行示例](II. Getting Started/11.4. Running the Example.md) * [11.5. 创建一个可执行jar](II. Getting Started/11.5. Creating an Executable Jar.md) From 1372004d5870d81b2322cf06ef0f273c5482958b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E7=83=AD=E5=BF=83=E5=B8=82=E6=B0=91=E9=92=9F=E5=B0=8F?= =?UTF-8?q?=E5=BC=BA?= Date: Sun, 25 Mar 2018 00:02:21 +0900 Subject: [PATCH 013/865] Update and rename 12. What to read next.md to 12. What to Read Next.md --- .../{12. What to read next.md => 12. What to Read Next.md} | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) rename II. Getting Started/{12. What to read next.md => 12. What to Read Next.md} (55%) diff --git a/II. Getting Started/12. What to read next.md b/II. Getting Started/12. What to Read Next.md similarity index 55% rename from II. Getting Started/12. What to read next.md rename to II. Getting Started/12. What to Read Next.md index bdd34414..5855d166 100644 --- a/II. Getting Started/12. What to read next.md +++ b/II. Getting Started/12. What to Read Next.md @@ -1,6 +1,6 @@ ### 12. 接下来阅读什么 -希望本章节已为你提供一些Spring Boot的基础部分,并帮你找到开发自己应用的方式。如果你是任务驱动型的开发者,那可以直接跳到[spring.io](http://spring.io/),check out一些[入门指南](http://spring.io/guides/),以解决特定的"使用Spring如何做"的问题;我们也有Spring Boot相关的[How-to](../IX. ‘How-to’ guides/README.md)参考文档。 +希望本章节已提供一些Spring Boot的基础部分,并帮你找到开发自己应用的方式。如果你是任务驱动型的开发者,那可以直接跳到[spring.io](http://spring.io/),check out一些[入门指南](http://spring.io/guides/),以解决特定的"使用Spring如何做"的问题;我们也有Spring Boot相关的[How-to](../IX. ‘How-to’ guides/README.md)参考文档。 [Spring Boot仓库](http://github.com/spring-projects/spring-boot)有大量可以运行的[示例](https://github.com/spring-projects/spring-boot/tree/master/spring-boot-samples),这些示例代码是彼此独立的(运行或使用示例的时候不需要构建其他示例)。 From 53fe7f4d3301281a6b66dd12f3d12f4970b1735a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E7=83=AD=E5=BF=83=E5=B8=82=E6=B0=91=E9=92=9F=E5=B0=8F?= =?UTF-8?q?=E5=BC=BA?= Date: Sun, 25 Mar 2018 00:03:29 +0900 Subject: [PATCH 014/865] Update SUMMARY.md --- SUMMARY.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/SUMMARY.md b/SUMMARY.md index 6f070294..7a5f28c0 100644 --- a/SUMMARY.md +++ b/SUMMARY.md @@ -33,7 +33,7 @@ * [11.3.3. main方法](II. Getting Started/11.3.3. The “main” Method.md) * [11.4. 运行示例](II. Getting Started/11.4. Running the Example.md) * [11.5. 创建一个可执行jar](II. Getting Started/11.5. Creating an Executable Jar.md) - * [12. 接下来阅读什么](II. Getting Started/12. What to read next.md) + * [12. 接下来阅读什么](II. Getting Started/12. What to Read Next.md) * [III. 使用Spring Boot](III. Using Spring Boot/README.md) * [13. 构建系统](III. Using Spring Boot/13. Build systems.md) * [13.1. 依赖管理](III. Using Spring Boot/13.1. Dependency management.md) From 92739dbea0a8eafa73e2e253dbc891ee0820cfdb Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E7=83=AD=E5=BF=83=E5=B8=82=E6=B0=91=E9=92=9F=E5=B0=8F?= =?UTF-8?q?=E5=BC=BA?= Date: Sun, 25 Mar 2018 23:19:28 +0900 Subject: [PATCH 015/865] Update README.md From 3dcc177da907585d42606527d371ec7026641875 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E7=83=AD=E5=BF=83=E5=B8=82=E6=B0=91=E9=92=9F=E5=B0=8F?= =?UTF-8?q?=E5=BC=BA?= Date: Sun, 25 Mar 2018 23:24:55 +0900 Subject: [PATCH 016/865] Update and rename 13. Build systems.md to 13. Build Systems.md --- .../{13. Build systems.md => 13. Build Systems.md} | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) rename III. Using Spring Boot/{13. Build systems.md => 13. Build Systems.md} (82%) diff --git a/III. Using Spring Boot/13. Build systems.md b/III. Using Spring Boot/13. Build Systems.md similarity index 82% rename from III. Using Spring Boot/13. Build systems.md rename to III. Using Spring Boot/13. Build Systems.md index b6a7cfa0..5c2c2184 100644 --- a/III. Using Spring Boot/13. Build systems.md +++ b/III. Using Spring Boot/13. Build Systems.md @@ -1,3 +1,3 @@ ### 13. 构建系统 -强烈建议你选择一个支持依赖管理,能消费发布到"Maven中央仓库"的artifacts的构建系统,比如Maven或Gradle。使用其他构建系统也是可以的,比如Ant,但它们可能得不到很好的支持。 +强烈建议你选择一个支持依赖管理,能消费发布到"Maven中央仓库"的artifacts的构建系统,比如Maven或Gradle。使用其他构建系统也是可以的,比如Ant,但它们得不到特别好的支持。 From 6ae8b8796b62d4435c2103cb13dd58492649d054 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E7=83=AD=E5=BF=83=E5=B8=82=E6=B0=91=E9=92=9F=E5=B0=8F?= =?UTF-8?q?=E5=BC=BA?= Date: Sun, 25 Mar 2018 23:26:15 +0900 Subject: [PATCH 017/865] Update SUMMARY.md --- SUMMARY.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/SUMMARY.md b/SUMMARY.md index 7a5f28c0..f1c593b2 100644 --- a/SUMMARY.md +++ b/SUMMARY.md @@ -35,7 +35,7 @@ * [11.5. 创建一个可执行jar](II. Getting Started/11.5. Creating an Executable Jar.md) * [12. 接下来阅读什么](II. Getting Started/12. What to Read Next.md) * [III. 使用Spring Boot](III. Using Spring Boot/README.md) - * [13. 构建系统](III. Using Spring Boot/13. Build systems.md) + * [13. 构建系统](III. Using Spring Boot/13. Build Systems.md) * [13.1. 依赖管理](III. Using Spring Boot/13.1. Dependency management.md) * [13.2. Maven](III. Using Spring Boot/13.2. Maven.md) * [13.2.1. 继承starter parent](III. Using Spring Boot/13.2.1. Inheriting the starter parent.md) From 84e4334155ac280f4cc401c81a83d0773429782b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E7=83=AD=E5=BF=83=E5=B8=82=E6=B0=91=E9=92=9F=E5=B0=8F?= =?UTF-8?q?=E5=BC=BA?= Date: Mon, 26 Mar 2018 22:56:46 +0900 Subject: [PATCH 018/865] Update and rename 13.1. Dependency management.md to 13.1. Dependency Management.md --- ... Dependency management.md => 13.1. Dependency Management.md} | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) rename III. Using Spring Boot/{13.1. Dependency management.md => 13.1. Dependency Management.md} (93%) diff --git a/III. Using Spring Boot/13.1. Dependency management.md b/III. Using Spring Boot/13.1. Dependency Management.md similarity index 93% rename from III. Using Spring Boot/13.1. Dependency management.md rename to III. Using Spring Boot/13.1. Dependency Management.md index ce75a35d..e720b69f 100644 --- a/III. Using Spring Boot/13.1. Dependency management.md +++ b/III. Using Spring Boot/13.1. Dependency Management.md @@ -6,4 +6,4 @@ Spring Boot每次发布时都会提供一个它所支持的精选依赖列表。 精选列表包括所有能够跟Spring Boot一起使用的Spring模块及第三方库,该列表支持[Maven](http://docs.spring.io/spring-boot/docs/current-SNAPSHOT/reference/htmlsingle/#using-boot-maven-parent-pom)和[Gradle](http://docs.spring.io/spring-boot/docs/current-SNAPSHOT/reference/htmlsingle/#build-tool-plugins-gradle-dependency-management),可以作为一份标准的[材料清单(spring-boot-dependencies)](http://docs.spring.io/spring-boot/docs/current-SNAPSHOT/reference/htmlsingle/#using-boot-maven-without-a-parent)。 -**注** Spring Boot每次发布都关联一个Spring框架的基础版本,所以强烈建议你不要自己指定Spring版本。 +**注** Spring Boot每次发布都关联一个Spring框架的基础版本。强烈建议你不要自己指定Spring版本。 From 5a553a4a18790d6eae0a59af4887a797853981de Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E7=83=AD=E5=BF=83=E5=B8=82=E6=B0=91=E9=92=9F=E5=B0=8F?= =?UTF-8?q?=E5=BC=BA?= Date: Mon, 26 Mar 2018 22:57:24 +0900 Subject: [PATCH 019/865] Update SUMMARY.md --- SUMMARY.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/SUMMARY.md b/SUMMARY.md index f1c593b2..7d0a76f2 100644 --- a/SUMMARY.md +++ b/SUMMARY.md @@ -36,7 +36,7 @@ * [12. 接下来阅读什么](II. Getting Started/12. What to Read Next.md) * [III. 使用Spring Boot](III. Using Spring Boot/README.md) * [13. 构建系统](III. Using Spring Boot/13. Build Systems.md) - * [13.1. 依赖管理](III. Using Spring Boot/13.1. Dependency management.md) + * [13.1. 依赖管理](III. Using Spring Boot/13.1. Dependency Management.md) * [13.2. Maven](III. Using Spring Boot/13.2. Maven.md) * [13.2.1. 继承starter parent](III. Using Spring Boot/13.2.1. Inheriting the starter parent.md) * [13.2.2. 在不使用parent POM的情况下玩转Spring Boot](III. Using Spring Boot/13.2.2. Using Spring Boot without the parent POM.md) From 533c80dfd3a1a29659e3855478452da2a7be3658 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E7=83=AD=E5=BF=83=E5=B8=82=E6=B0=91=E9=92=9F=E5=B0=8F?= =?UTF-8?q?=E5=BC=BA?= Date: Mon, 26 Mar 2018 23:07:16 +0900 Subject: [PATCH 020/865] Update 13.2. Maven.md --- III. Using Spring Boot/13.2. Maven.md | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/III. Using Spring Boot/13.2. Maven.md b/III. Using Spring Boot/13.2. Maven.md index 5c98c2b4..f2ebaead 100644 --- a/III. Using Spring Boot/13.2. Maven.md +++ b/III. Using Spring Boot/13.2. Maven.md @@ -3,9 +3,9 @@ Maven用户可以继承`spring-boot-starter-parent`项目来获取合适的默认设置。该parent项目提供以下特性: - 默认编译级别为Java 1.8 - 源码编码为UTF-8 -- 一个[Dependency management](./13.1. Dependency management.md)节点,允许你省略常见依赖的``标签,继承自`spring-boot-dependencies` POM。 +- 一个[Dependency management](./13.1. Dependency management.md)节选,管理着常见依赖的版本。允许你省略常见依赖的``标签,继承自`spring-boot-dependencies` POM。 - 恰到好处的[资源过滤](https://maven.apache.org/plugins/maven-resources-plugin/examples/filter.html) - 恰到好处的插件配置([exec插件](http://mojo.codehaus.org/exec-maven-plugin/),[Git commit ID](https://github.com/ktoso/maven-git-commit-id-plugin),[shade](http://maven.apache.org/plugins/maven-shade-plugin/)) -- 恰到好处的对`application.properties`和`application.yml`进行筛选,包括特定profile(profile-specific)的文件,比如`application-foo.properties`和`application-foo.yml` +- 恰到好处的对`application.properties`和`application.yml`进行筛选,包括特定profile(profile-specific)的文件,比如`application-dev.properties`和`application-dev.yml` -最后一点:由于配置文件默认接收Spring风格的占位符(`${...}`),所以Maven filtering需改用`@..@`占位符(你可以使用Maven属性`resource.delimiter`来覆盖它)。 +最后一点:由于`application.properties`和`application.yml`接收Spring风格的占位符(`${...}`),所以Maven filtering需改用`@..@`占位符(你可以通过设置Maven属性`resource.delimiter`来覆盖它)。 From 8722bc3d79e1f8f475b0d62ba5df37f5acd6d622 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E7=83=AD=E5=BF=83=E5=B8=82=E6=B0=91=E9=92=9F=E5=B0=8F?= =?UTF-8?q?=E5=BC=BA?= Date: Mon, 26 Mar 2018 23:09:52 +0900 Subject: [PATCH 021/865] Update and rename 13.2.1. Inheriting the starter parent.md to 13.2.1. Inheriting the Starter Parent.md --- ...starter parent.md => 13.2.1. Inheriting the Starter Parent.md} | 0 1 file changed, 0 insertions(+), 0 deletions(-) rename III. Using Spring Boot/{13.2.1. Inheriting the starter parent.md => 13.2.1. Inheriting the Starter Parent.md} (100%) diff --git a/III. Using Spring Boot/13.2.1. Inheriting the starter parent.md b/III. Using Spring Boot/13.2.1. Inheriting the Starter Parent.md similarity index 100% rename from III. Using Spring Boot/13.2.1. Inheriting the starter parent.md rename to III. Using Spring Boot/13.2.1. Inheriting the Starter Parent.md From 84a118e82ab73ff6b5cd7aca16f979b253c1064a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E7=83=AD=E5=BF=83=E5=B8=82=E6=B0=91=E9=92=9F=E5=B0=8F?= =?UTF-8?q?=E5=BC=BA?= Date: Mon, 26 Mar 2018 23:12:51 +0900 Subject: [PATCH 022/865] Update SUMMARY.md --- SUMMARY.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/SUMMARY.md b/SUMMARY.md index 7d0a76f2..4ae4e88e 100644 --- a/SUMMARY.md +++ b/SUMMARY.md @@ -38,7 +38,7 @@ * [13. 构建系统](III. Using Spring Boot/13. Build Systems.md) * [13.1. 依赖管理](III. Using Spring Boot/13.1. Dependency Management.md) * [13.2. Maven](III. Using Spring Boot/13.2. Maven.md) - * [13.2.1. 继承starter parent](III. Using Spring Boot/13.2.1. Inheriting the starter parent.md) + * [13.2.1. 继承starter parent](III. Using Spring Boot/13.2.1. Inheriting the Starter Parent.md) * [13.2.2. 在不使用parent POM的情况下玩转Spring Boot](III. Using Spring Boot/13.2.2. Using Spring Boot without the parent POM.md) * [13.2.3. 使用Spring Boot Maven插件](III. Using Spring Boot/13.2.3. Using the Spring Boot Maven plugin.md) * [13.3. Gradle](III. Using Spring Boot/13.3. Gradle.md) From c397781c973d1bd8d0a6e8fda4808be59909845b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E7=83=AD=E5=BF=83=E5=B8=82=E6=B0=91=E9=92=9F=E5=B0=8F?= =?UTF-8?q?=E5=BC=BA?= Date: Thu, 29 Mar 2018 00:53:53 +0900 Subject: [PATCH 023/865] Update and rename 13.2.2. Using Spring Boot without the parent POM.md to 13.2.2. Using Spring Boot without the Parent POM.md --- ...M.md => 13.2.2. Using Spring Boot without the Parent POM.md} | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) rename III. Using Spring Boot/{13.2.2. Using Spring Boot without the parent POM.md => 13.2.2. Using Spring Boot without the Parent POM.md} (92%) diff --git a/III. Using Spring Boot/13.2.2. Using Spring Boot without the parent POM.md b/III. Using Spring Boot/13.2.2. Using Spring Boot without the Parent POM.md similarity index 92% rename from III. Using Spring Boot/13.2.2. Using Spring Boot without the parent POM.md rename to III. Using Spring Boot/13.2.2. Using Spring Boot without the Parent POM.md index 76d0eaa8..68a75b72 100644 --- a/III. Using Spring Boot/13.2.2. Using Spring Boot without the parent POM.md +++ b/III. Using Spring Boot/13.2.2. Using Spring Boot without the Parent POM.md @@ -1,6 +1,6 @@ ### 13.2.2. 在不使用parent POM的情况下玩转Spring Boot -不是每个人都喜欢继承`spring-boot-starter-parent` POM,比如你可能需要使用公司的标准parent,或只是倾向于显式声明所有的Maven配置。 +不是每个人都喜欢继承`spring-boot-starter-parent` POM,比如你可能需要使用公司的标准parent,或倾向于显式声明所有的Maven配置。 如果你不想使用`spring-boot-starter-parent`,通过设置`scope=import`的依赖,你仍能获取到依赖管理的好处: ```xml From c57c0f577e8d591b980c409b872dbe8ec1372625 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E7=83=AD=E5=BF=83=E5=B8=82=E6=B0=91=E9=92=9F=E5=B0=8F?= =?UTF-8?q?=E5=BC=BA?= Date: Thu, 29 Mar 2018 00:55:05 +0900 Subject: [PATCH 024/865] Update SUMMARY.md --- SUMMARY.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/SUMMARY.md b/SUMMARY.md index 4ae4e88e..9c2257e3 100644 --- a/SUMMARY.md +++ b/SUMMARY.md @@ -39,8 +39,8 @@ * [13.1. 依赖管理](III. Using Spring Boot/13.1. Dependency Management.md) * [13.2. Maven](III. Using Spring Boot/13.2. Maven.md) * [13.2.1. 继承starter parent](III. Using Spring Boot/13.2.1. Inheriting the Starter Parent.md) - * [13.2.2. 在不使用parent POM的情况下玩转Spring Boot](III. Using Spring Boot/13.2.2. Using Spring Boot without the parent POM.md) - * [13.2.3. 使用Spring Boot Maven插件](III. Using Spring Boot/13.2.3. Using the Spring Boot Maven plugin.md) + * [13.2.2. 在不使用parent POM的情况下玩转Spring Boot](III. Using Spring Boot/13.2.2. Using Spring Boot without the Parent POM.md) + * [13.2.3. 使用Spring Boot Maven插件](III. Using Spring Boot/13.2.3. Using the Spring Boot Maven Plugin.md) * [13.3. Gradle](III. Using Spring Boot/13.3. Gradle.md) * [13.4. Ant](III. Using Spring Boot/13.4. Ant.md) * [13.5. Starters](III. Using Spring Boot/13.5. Starters.md) From 91d1b2979135f659a42708aa5e49a170a314f35d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E7=83=AD=E5=BF=83=E5=B8=82=E6=B0=91=E9=92=9F=E5=B0=8F?= =?UTF-8?q?=E5=BC=BA?= Date: Thu, 29 Mar 2018 00:57:15 +0900 Subject: [PATCH 025/865] Update and rename 13.2.3. Using the Spring Boot Maven plugin.md to 13.2.3. Using the Spring Boot Maven Plugin.md --- ...en plugin.md => 13.2.3. Using the Spring Boot Maven Plugin.md} | 0 1 file changed, 0 insertions(+), 0 deletions(-) rename III. Using Spring Boot/{13.2.3. Using the Spring Boot Maven plugin.md => 13.2.3. Using the Spring Boot Maven Plugin.md} (100%) diff --git a/III. Using Spring Boot/13.2.3. Using the Spring Boot Maven plugin.md b/III. Using Spring Boot/13.2.3. Using the Spring Boot Maven Plugin.md similarity index 100% rename from III. Using Spring Boot/13.2.3. Using the Spring Boot Maven plugin.md rename to III. Using Spring Boot/13.2.3. Using the Spring Boot Maven Plugin.md From 2893a8e594168e4c9aadcefa1ba7503ecb5fcc5c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E7=83=AD=E5=BF=83=E5=B8=82=E6=B0=91=E9=92=9F=E5=B0=8F?= =?UTF-8?q?=E5=BC=BA?= Date: Thu, 29 Mar 2018 01:01:41 +0900 Subject: [PATCH 026/865] Update 13.3. Gradle.md --- III. Using Spring Boot/13.3. Gradle.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/III. Using Spring Boot/13.3. Gradle.md b/III. Using Spring Boot/13.3. Gradle.md index 25de92cf..a556ef91 100644 --- a/III. Using Spring Boot/13.3. Gradle.md +++ b/III. Using Spring Boot/13.3. Gradle.md @@ -2,5 +2,5 @@ 想要学习用Gradle配置Spring Boot,请参考Spring Boot的Gradle插件的文档。 - - Reference ( [HTML](http://docs.spring.io/spring-boot/docs/2.0.0.M3/gradle-plugin//reference/html) and [PDF](http://docs.spring.io/spring-boot/docs/2.0.0.M3/gradle-plugin//reference/pdf/spring-boot-gradle-plugin-reference.pdf) ) - - [API](http://docs.spring.io/spring-boot/docs/2.0.0.M3/gradle-plugin//api) \ No newline at end of file + - 参考 ( [HTML](https://docs.spring.io/spring-boot/docs/2.0.0.RELEASE/gradle-plugin/reference/html) and [PDF](https://docs.spring.io/spring-boot/docs/2.0.0.RELEASE/gradle-plugin/reference/pdf/spring-boot-gradle-plugin-reference.pdf) ) + - [API](https://docs.spring.io/spring-boot/docs/2.0.0.RELEASE/gradle-plugin/api) From 1f50d9f1d3041c67f6ad127526bfe3da79fd4070 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E7=83=AD=E5=BF=83=E5=B8=82=E6=B0=91=E9=92=9F=E5=B0=8F?= =?UTF-8?q?=E5=BC=BA?= Date: Thu, 29 Mar 2018 01:02:07 +0900 Subject: [PATCH 027/865] Update 13.3. Gradle.md --- III. Using Spring Boot/13.3. Gradle.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/III. Using Spring Boot/13.3. Gradle.md b/III. Using Spring Boot/13.3. Gradle.md index a556ef91..1a9ed782 100644 --- a/III. Using Spring Boot/13.3. Gradle.md +++ b/III. Using Spring Boot/13.3. Gradle.md @@ -2,5 +2,5 @@ 想要学习用Gradle配置Spring Boot,请参考Spring Boot的Gradle插件的文档。 - - 参考 ( [HTML](https://docs.spring.io/spring-boot/docs/2.0.0.RELEASE/gradle-plugin/reference/html) and [PDF](https://docs.spring.io/spring-boot/docs/2.0.0.RELEASE/gradle-plugin/reference/pdf/spring-boot-gradle-plugin-reference.pdf) ) +  - 参考 ( [HTML](https://docs.spring.io/spring-boot/docs/2.0.0.RELEASE/gradle-plugin/reference/html) 与 [PDF](https://docs.spring.io/spring-boot/docs/2.0.0.RELEASE/gradle-plugin/reference/pdf/spring-boot-gradle-plugin-reference.pdf) ) - [API](https://docs.spring.io/spring-boot/docs/2.0.0.RELEASE/gradle-plugin/api) From cf2eb4cb169aa1928510b768df2b6d1c54ea860f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E7=83=AD=E5=BF=83=E5=B8=82=E6=B0=91=E9=92=9F=E5=B0=8F?= =?UTF-8?q?=E5=BC=BA?= Date: Thu, 29 Mar 2018 01:03:29 +0900 Subject: [PATCH 028/865] Update 13.3. Gradle.md --- III. Using Spring Boot/13.3. Gradle.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/III. Using Spring Boot/13.3. Gradle.md b/III. Using Spring Boot/13.3. Gradle.md index 1a9ed782..b47a24f1 100644 --- a/III. Using Spring Boot/13.3. Gradle.md +++ b/III. Using Spring Boot/13.3. Gradle.md @@ -2,5 +2,5 @@ 想要学习用Gradle配置Spring Boot,请参考Spring Boot的Gradle插件的文档。 -  - 参考 ( [HTML](https://docs.spring.io/spring-boot/docs/2.0.0.RELEASE/gradle-plugin/reference/html) 与 [PDF](https://docs.spring.io/spring-boot/docs/2.0.0.RELEASE/gradle-plugin/reference/pdf/spring-boot-gradle-plugin-reference.pdf) ) + - 参考([HTML](https://docs.spring.io/spring-boot/docs/2.0.0.RELEASE/gradle-plugin/reference/html) 与 [PDF](https://docs.spring.io/spring-boot/docs/2.0.0.RELEASE/gradle-plugin/reference/pdf/spring-boot-gradle-plugin-reference.pdf)) - [API](https://docs.spring.io/spring-boot/docs/2.0.0.RELEASE/gradle-plugin/api) From 66783a1c31c909f476be5fd3c7e9f2ee99f06061 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E7=83=AD=E5=BF=83=E5=B8=82=E6=B0=91=E9=92=9F=E5=B0=8F?= =?UTF-8?q?=E5=BC=BA?= Date: Thu, 29 Mar 2018 01:06:53 +0900 Subject: [PATCH 029/865] Update 13.2.3. Using the Spring Boot Maven Plugin.md From aa2c7f4d39a9e4637098b67da1116131b208203f Mon Sep 17 00:00:00 2001 From: Jack Zhong Date: Sun, 8 Apr 2018 13:05:16 +0800 Subject: [PATCH 030/865] =?UTF-8?q?=E6=9B=B4=E6=96=B013.4=20Ant?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- III. Using Spring Boot/13.4. Ant.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/III. Using Spring Boot/13.4. Ant.md b/III. Using Spring Boot/13.4. Ant.md index 747e725c..fa538582 100644 --- a/III. Using Spring Boot/13.4. Ant.md +++ b/III. Using Spring Boot/13.4. Ant.md @@ -21,7 +21,7 @@ xmlns:spring-boot="antlib:org.springframework.boot.ant" name="myapp" default="build"> - + @@ -51,4 +51,4 @@ ``` -**注** 如果你不想使用`spring-boot-antlib`模块,那查看[章节 85.9,使用Ant构建可执行存档(不使用spring-boot-antlib)](../IX. ‘How-to’ guides/85.9 Build an executable archive from Ant without using spring-boot-antlib.md)获取更多指导。 +**注** 如果你不想使用`spring-boot-antlib`模块,那查看[章节 86.9,使用Ant构建可执行存档(不使用spring-boot-antlib)](../IX. ‘How-to’ guides/86.9 Build an Executable Archive from Ant without Using spring-boot-antlib.md)获取更多指导。 \ No newline at end of file From bc1aee9d8954b190336510e86a60d461f97851db Mon Sep 17 00:00:00 2001 From: Jack Zhong Date: Sun, 8 Apr 2018 13:35:16 +0800 Subject: [PATCH 031/865] =?UTF-8?q?=E5=B0=86BOM=E6=94=B9=E4=B8=BA=E6=9D=90?= =?UTF-8?q?=E6=96=99=E6=B8=85=E5=8D=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../13.2.2. Using Spring Boot without the Parent POM.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/III. Using Spring Boot/13.2.2. Using Spring Boot without the Parent POM.md b/III. Using Spring Boot/13.2.2. Using Spring Boot without the Parent POM.md index 68a75b72..db20b7b5 100644 --- a/III. Using Spring Boot/13.2.2. Using Spring Boot without the Parent POM.md +++ b/III. Using Spring Boot/13.2.2. Using Spring Boot without the Parent POM.md @@ -40,4 +40,4 @@ ``` -**注** 示例中,我们指定了一个BOM,但任何的依赖类型都可以通过这种方式覆盖。 +**注** 示例中,我们指定了一个材料清单,但任何的依赖类型都可以通过这种方式覆盖。 From cc0b34e57880b76a1230140c5b8a6c225ef124af Mon Sep 17 00:00:00 2001 From: Jack Zhong Date: Sun, 8 Apr 2018 23:36:49 +0800 Subject: [PATCH 032/865] =?UTF-8?q?=E6=9B=B4=E6=96=B013.5.=20Starters?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- III. Using Spring Boot/13.5. Starters.md | 13 ++++++------- 1 file changed, 6 insertions(+), 7 deletions(-) diff --git a/III. Using Spring Boot/13.5. Starters.md b/III. Using Spring Boot/13.5. Starters.md index 98ac09dd..eb350159 100644 --- a/III. Using Spring Boot/13.5. Starters.md +++ b/III. Using Spring Boot/13.5. Starters.md @@ -1,10 +1,11 @@ ### 13.5. Starters -Starters是一个依赖描述符的集合,你可以将它包含进项目中,这样添加依赖就非常方便。你可以获取所有Spring及相关技术的一站式服务,而不需要翻阅示例代码,拷贝粘贴大量的依赖描述符。例如,如果你想使用Spring和JPA进行数据库访问,只需要在项目中包含`spring-boot-starter-data-jpa`依赖,然后你就可以开始了。 +Starters是一个依赖描述符的集合,你可以将它包含进项目中,这样添加依赖就非常方便。你可以获取所有Spring及相关技术的一站式服务,而不需要翻阅示例代码,拷贝粘贴大量的依赖描述符。例如,如果你想使用Spring和JPA进行数据库访问,需要在项目中包含`spring-boot-starter-data-jpa`依赖。 该starters包含很多搭建,快速运行项目所需的依赖,并提供一致的,可管理传递性的依赖集。 -**名字有什么含义**:所有官方starters遵循相似的命名模式:`spring-boot-starter-*`,在这里`*`是一种特殊的应用程序类型。该命名结构旨在帮你找到需要的starter。很多集成于IDEs中的Maven插件允许你通过名称name搜索依赖。例如,使用相应的Eclipse或STS插件,你可以简单地在POM编辑器中点击`ctrl-space`,然后输入"spring-boot-starter"就可以获取一个完整列表。正如[Creating your own starter](https://docs.spring.io/spring-boot/docs/2.0.0.RELEASE/reference/htmlsingle/#boot-features-custom-starter)章节中讨论的,第三方starters不应该以`spring-boot`开头,因为它跟Spring Boot官方artifacts冲突。一个acme的第三方starter通常命名为`acme-spring-boot-starter`。 +**名字有什么含义**:所有官方starters遵循相似的命名模式:`spring-boot-starter-*`,在这里`*`是一种特殊的应用程序类型。该命名结构旨在帮你找到需要的starter。很多集成于IDEs中的Maven插件让你通过名称搜索依赖。例如,使用相应的Eclipse或STS插件,你可以在POM编辑器中点击`ctrl-space`,然后输入"spring-boot-starter"就可以获取一个完整列表。 +正如[创建自己的starter](https://docs.spring.io/spring-boot/docs/2.0.0.RELEASE/reference/htmlsingle/#boot-features-custom-starter)章节中讨论的,第三方starters不应该以`spring-boot`开头,因为它跟Spring Boot官方artifacts冲突。第三方starter通常会用项目的名称开头。例如,一个叫做`thirdpartyproject`的第三方starter项目,通常会被命名为`thirdpartyproject-spring-boot-starter`。 以下应用程序starters是Spring Boot在`org.springframework.boot` group下提供的: @@ -23,6 +24,7 @@ Starters是一个依赖描述符的集合,你可以将它包含进项目中, |spring-boot-starter-data-cassandra|用于使用分布式数据库Cassandra和Spring Data Cassandra|[Pom](https://github.com/spring-projects/spring-boot/tree/v2.0.0.RELEASE/spring-boot-project/spring-boot-starters/spring-boot-starter-data-cassandra/pom.xml)| |spring-boot-starter-data-cassandra-reactive|用于使用分布式数据库Cassandra和Spring Data Cassandra Reactive|[Pom](https://github.com/spring-projects/spring-boot/tree/v2.0.0.RELEASE/spring-boot-project/spring-boot-starters/spring-boot-starter-data-cassandra-reactive/pom.xml)| |spring-boot-starter-data-couchbase|用于使用基于文档的数据库Couchbase和Spring Data Couchbase|[Pom](https://github.com/spring-projects/spring-boot/tree/v2.0.0.RELEASE/spring-boot-project/spring-boot-starters/spring-boot-starter-data-couchbase/pom.xml)| +|spring-boot-starter-data-couchbase-reactive|用于使用基于文档的数据库Couchbase和Spring Data Couchbase Reactive|[Pom](https://github.com/spring-projects/spring-boot/tree/v2.0.0.RELEASE/spring-boot-project/spring-boot-starters/spring-boot-starter-data-couchbase-reactive/pom.xml)| |spring-boot-starter-data-elasticsearch|用于使用Elasticsearch搜索,分析引擎和Spring Data Elasticsearch|[Pom](https://github.com/spring-projects/spring-boot/tree/v2.0.0.RELEASE/spring-boot-project/spring-boot-starters/spring-boot-starter-data-elasticsearch/pom.xml)| |spring-boot-starter-data-jpa|用于使用Hibernate实现Spring Data JPA|[Pom](https://github.com/spring-projects/spring-boot/tree/v2.0.0.RELEASE/spring-boot-project/spring-boot-starters/spring-boot-starter-data-jpa/pom.xml)| |spring-boot-starter-data-ldap|用于Spring Data LDAP|[Pom](https://github.com/spring-projects/spring-boot/tree/v2.0.0.RELEASE/spring-boot-project/spring-boot-starters/spring-boot-starter-data-ldap/pom.xml)| @@ -30,6 +32,7 @@ Starters是一个依赖描述符的集合,你可以将它包含进项目中, |spring-boot-starter-data-mongodb-reactive|用于使用基于文档的数据库MongoDB和Spring Data MongoDB Reactive|[Pom](https://github.com/spring-projects/spring-boot/tree/v2.0.0.RELEASE/spring-boot-project/spring-boot-starters/spring-boot-starter-data-mongodb-reactive/pom.xml)| |spring-boot-starter-data-neo4j|用于使用图数据库Neo4j和Spring Data Neo4j|[Pom](https://github.com/spring-projects/spring-boot/tree/v2.0.0.RELEASE/spring-boot-project/spring-boot-starters/spring-boot-starter-data-neo4j/pom.xml)| |spring-boot-starter-data-redis|用于使用Spring Data Redis和Lettuce客户端操作键-值存储的Redis|[Pom](https://github.com/spring-projects/spring-boot/tree/v2.0.0.RELEASE/spring-boot-project/spring-boot-starters/spring-boot-starter-redis/pom.xml)| +|spring-boot-starter-data-redis-reactive|用于使用Spring Data Redis reactive和Lettuce客户端操作键-值存储的Redis|[Pom](https://github.com/spring-projects/spring-boot/tree/v2.0.0.RELEASE/spring-boot-project/spring-boot-starters/spring-boot-starter-data-redis-reactive/pom.xml)| |spring-boot-starter-data-rest|用于使用Spring Data REST暴露基于REST的Spring Data仓库|[Pom](https://github.com/spring-projects/spring-boot/tree/v2.0.0.RELEASE/spring-boot-project/spring-boot-starters/spring-boot-starter-data-rest/pom.xml)| |spring-boot-starter-data-solr|通过Spring Data Solr使用Apache Solr搜索平台|[Pom](https://github.com/spring-projects/spring-boot/tree/v2.0.0.RELEASE/spring-boot-project/spring-boot-starters/spring-boot-starter-data-solr/pom.xml)| |spring-boot-starter-freemarker|用于使用FreeMarker模板引擎构建MVC web应用|[Pom](https://github.com/spring-projects/spring-boot/tree/v2.0.0.RELEASE/spring-boot-project/spring-boot-starters/spring-boot-starter-freemarker/pom.xml)| @@ -44,14 +47,10 @@ Starters是一个依赖描述符的集合,你可以将它包含进项目中, |spring-boot-starter-jta-bitronix|用于使用Bitronix实现JTA事务|[Pom](https://github.com/spring-projects/spring-boot/tree/v2.0.0.RELEASE/spring-boot-project/spring-boot-starters/spring-boot-starter-jta-bitronix/pom.xml)| |spring-boot-starter-jta-narayana|Spring Boot Narayana JTA Starter|[Pom](https://github.com/spring-projects/spring-boot/tree/v2.0.0.RELEASE/spring-boot-project/spring-boot-starters/spring-boot-starter-jta-narayana/pom.xml)| |spring-boot-starter-mail|用于使用Java Mail和Spring框架email发送支持|[Pom](https://github.com/spring-projects/spring-boot/tree/v2.0.0.RELEASE/spring-boot-project/spring-boot-starters/spring-boot-starter-mail/pom.xml)| -|spring-boot-starter-mobile|用于使用Spring Mobile开发web应用|[Pom](https://github.com/spring-projects/spring-boot/tree/v2.0.0.RELEASE/spring-boot-project/spring-boot-starters/spring-boot-starter-mobile/pom.xml)| |spring-boot-starter-mustache|用于使用Mustache模板引擎构建MVC web应用|[Pom](https://github.com/spring-projects/spring-boot/tree/v2.0.0.RELEASE/spring-boot-project/spring-boot-starters/spring-boot-starter-mustache/pom.xml)| |spring-boot-starter-quartz|Spring Boot Quartz Starter|[Pom](https://github.com/spring-projects/spring-boot/tree/v2.0.0.RELEASE/spring-boot-project/spring-boot-starters/spring-boot-starter-quartz/pom.xml)| |spring-boot-starter-security|对Spring Security的支持|[Pom](https://github.com/spring-projects/spring-boot/tree/v2.0.0.RELEASE/spring-boot-project/spring-boot-starters/spring-boot-starter-security/pom.xml)| |spring-boot-starter-security-reactive|对响应式Spring Security的支持|[Pom](https://github.com/spring-projects/spring-boot/tree/v2.0.0.RELEASE/spring-boot-project/spring-boot-starters/spring-boot-starter-security-reactive/pom.xml)| -|spring-boot-starter-social-facebook|用于使用Spring Social Facebook|[Pom](https://github.com/spring-projects/spring-boot/tree/v2.0.0.RELEASE/spring-boot-project/spring-boot-starters/spring-boot-starter-social-facebook/pom.xml)| -|spring-boot-starter-social-linkedin|用于使用Spring Social LinkedIn|[Pom](https://github.com/spring-projects/spring-boot/tree/v2.0.0.RELEASE/spring-boot-project/spring-boot-starters/spring-boot-starter-social-linkedin/pom.xml)| -|spring-boot-starter-social-twitter|对使用Spring Social Twitter的支持|[Pom](https://github.com/spring-projects/spring-boot/tree/v2.0.0.RELEASE/spring-boot-project/spring-boot-starters/spring-boot-starter-social-twitter/pom.xml)| |spring-boot-starter-test|用于测试Spring Boot应用,支持常用测试类库,包括JUnit, Hamcrest和Mockito|[Pom](https://github.com/spring-projects/spring-boot/tree/v2.0.0.RELEASE/spring-boot-project/spring-boot-starters/spring-boot-starter-test/pom.xml)| |spring-boot-starter-thymeleaf|用于使用Thymeleaf模板引擎构建MVC web应用|[Pom](https://github.com/spring-projects/spring-boot/tree/v2.0.0.RELEASE/spring-boot-project/spring-boot-starters/spring-boot-starter-thymeleaf/pom.xml)| |spring-boot-starter-validation|用于使用Hibernate Validator实现Java Bean校验|[Pom](https://github.com/spring-projects/spring-boot/tree/v2.0.0.RELEASE/spring-boot-project/spring-boot-starters/spring-boot-starter-validation/pom.xml)| @@ -70,7 +69,7 @@ Starters是一个依赖描述符的集合,你可以将它包含进项目中, |spring-boot-starter-actuator|用于使用Spring Boot的Actuator,它提供了production ready功能来帮助你监控和管理应用程序|[Pom](https://github.com/spring-projects/spring-boot/tree/v2.0.0.RELEASE/spring-boot-project/spring-boot-starters/spring-boot-starter-actuator/pom.xml)| -最后,Spring Boot还包含一些用于排除或交换某些特定技术方面的starters: +最后,Spring Boot还包含以下用于排除或交换某些特定技术方面的starters: **表 13.3. Spring Boot技术性starters** From c0bdec94af06ac5a8f3e4eab7ebf80e01aecb222 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E7=83=AD=E5=BF=83=E5=B8=82=E6=B0=91=E9=92=9F=E5=B0=8F?= =?UTF-8?q?=E5=BC=BA?= Date: Sun, 8 Apr 2018 23:39:03 +0800 Subject: [PATCH 033/865] Update and rename 14. Structuring your code.md to 14. Structuring Your Code.md --- ...4. Structuring your code.md => 14. Structuring Your Code.md} | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) rename III. Using Spring Boot/{14. Structuring your code.md => 14. Structuring Your Code.md} (56%) diff --git a/III. Using Spring Boot/14. Structuring your code.md b/III. Using Spring Boot/14. Structuring Your Code.md similarity index 56% rename from III. Using Spring Boot/14. Structuring your code.md rename to III. Using Spring Boot/14. Structuring Your Code.md index 7ad1771a..dcced825 100644 --- a/III. Using Spring Boot/14. Structuring your code.md +++ b/III. Using Spring Boot/14. Structuring Your Code.md @@ -1,3 +1,3 @@ ### 14. 组织你的代码 -Spring Boot不要求使用任何特殊的代码结构,不过,遵循以下的一些最佳实践还是挺有帮助的。 +Spring Boot不要求使用任何特殊的代码结构。不过,遵循以下的一些最佳实践还是挺有帮助的。 From f61cfae5185de2480817fee716f2dea32359f5cb Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E7=83=AD=E5=BF=83=E5=B8=82=E6=B0=91=E9=92=9F=E5=B0=8F?= =?UTF-8?q?=E5=BC=BA?= Date: Sun, 8 Apr 2018 23:40:35 +0800 Subject: [PATCH 034/865] Update SUMMARY.md --- SUMMARY.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/SUMMARY.md b/SUMMARY.md index 9c2257e3..5d846b73 100644 --- a/SUMMARY.md +++ b/SUMMARY.md @@ -44,7 +44,7 @@ * [13.3. Gradle](III. Using Spring Boot/13.3. Gradle.md) * [13.4. Ant](III. Using Spring Boot/13.4. Ant.md) * [13.5. Starters](III. Using Spring Boot/13.5. Starters.md) - * [14. 组织你的代码](III. Using Spring Boot/14. Structuring your code.md) + * [14. 组织你的代码](III. Using Spring Boot/14. Structuring Your Code.md) * [14.1. 使用"default"包](III. Using Spring Boot/14.1. Using the “default” package.md) * [14.2. 放置应用的main类](III. Using Spring Boot/14.2. Locating the main application class.md) * [15. 配置类](III. Using Spring Boot/15. Configuration classes.md) From d0daa263742c9d3d7db7e5fb29b5f37b322119e0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E7=83=AD=E5=BF=83=E5=B8=82=E6=B0=91=E9=92=9F=E5=B0=8F?= =?UTF-8?q?=E5=BC=BA?= Date: Mon, 9 Apr 2018 22:31:31 +0800 Subject: [PATCH 035/865] =?UTF-8?q?Update=20and=20rename=2014.1.=20Using?= =?UTF-8?q?=20the=20=E2=80=9Cdefault=E2=80=9D=20package.md=20to=2014.1.=20?= =?UTF-8?q?Using=20the=20=E2=80=9Cdefault=E2=80=9D=20Package.md?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../14.1. Using the \342\200\234default\342\200\235 Package.md" | 0 1 file changed, 0 insertions(+), 0 deletions(-) rename "III. Using Spring Boot/14.1. Using the \342\200\234default\342\200\235 package.md" => "III. Using Spring Boot/14.1. Using the \342\200\234default\342\200\235 Package.md" (100%) diff --git "a/III. Using Spring Boot/14.1. Using the \342\200\234default\342\200\235 package.md" "b/III. Using Spring Boot/14.1. Using the \342\200\234default\342\200\235 Package.md" similarity index 100% rename from "III. Using Spring Boot/14.1. Using the \342\200\234default\342\200\235 package.md" rename to "III. Using Spring Boot/14.1. Using the \342\200\234default\342\200\235 Package.md" From 96c207d40ec2b40cc1f52d61f0c29ea562c785c0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E7=83=AD=E5=BF=83=E5=B8=82=E6=B0=91=E9=92=9F=E5=B0=8F?= =?UTF-8?q?=E5=BC=BA?= Date: Mon, 9 Apr 2018 22:32:02 +0800 Subject: [PATCH 036/865] Update SUMMARY.md --- SUMMARY.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/SUMMARY.md b/SUMMARY.md index 5d846b73..4062e188 100644 --- a/SUMMARY.md +++ b/SUMMARY.md @@ -45,7 +45,7 @@ * [13.4. Ant](III. Using Spring Boot/13.4. Ant.md) * [13.5. Starters](III. Using Spring Boot/13.5. Starters.md) * [14. 组织你的代码](III. Using Spring Boot/14. Structuring Your Code.md) - * [14.1. 使用"default"包](III. Using Spring Boot/14.1. Using the “default” package.md) + * [14.1. 使用"default"包](III. Using Spring Boot/14.1. Using the “default” Package.md) * [14.2. 放置应用的main类](III. Using Spring Boot/14.2. Locating the main application class.md) * [15. 配置类](III. Using Spring Boot/15. Configuration classes.md) * [15.1. 导入其他配置类](III. Using Spring Boot/15.1. Importing additional configuration classes.md) From 2ba354e254766d364e528b792bba4a3eb2a19ca7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E7=83=AD=E5=BF=83=E5=B8=82=E6=B0=91=E9=92=9F=E5=B0=8F?= =?UTF-8?q?=E5=BC=BA?= Date: Tue, 10 Apr 2018 20:50:07 +0800 Subject: [PATCH 037/865] Update and rename 14.2. Locating the main application class.md to 14.2. Locating the Main Application Class.md --- ...tion class.md => 14.2. Locating the Main Application Class.md} | 0 1 file changed, 0 insertions(+), 0 deletions(-) rename III. Using Spring Boot/{14.2. Locating the main application class.md => 14.2. Locating the Main Application Class.md} (100%) diff --git a/III. Using Spring Boot/14.2. Locating the main application class.md b/III. Using Spring Boot/14.2. Locating the Main Application Class.md similarity index 100% rename from III. Using Spring Boot/14.2. Locating the main application class.md rename to III. Using Spring Boot/14.2. Locating the Main Application Class.md From b7e23ecab1e907825a96e3ad60579c5dddd09c70 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E7=83=AD=E5=BF=83=E5=B8=82=E6=B0=91=E9=92=9F=E5=B0=8F?= =?UTF-8?q?=E5=BC=BA?= Date: Tue, 10 Apr 2018 20:52:52 +0800 Subject: [PATCH 038/865] Update SUMMARY.md --- SUMMARY.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/SUMMARY.md b/SUMMARY.md index 4062e188..d8af9bb4 100644 --- a/SUMMARY.md +++ b/SUMMARY.md @@ -46,7 +46,7 @@ * [13.5. Starters](III. Using Spring Boot/13.5. Starters.md) * [14. 组织你的代码](III. Using Spring Boot/14. Structuring Your Code.md) * [14.1. 使用"default"包](III. Using Spring Boot/14.1. Using the “default” Package.md) - * [14.2. 放置应用的main类](III. Using Spring Boot/14.2. Locating the main application class.md) + * [14.2. 放置应用的main类](III. Using Spring Boot/14.2. Locating the Main Application Class.md) * [15. 配置类](III. Using Spring Boot/15. Configuration classes.md) * [15.1. 导入其他配置类](III. Using Spring Boot/15.1. Importing additional configuration classes.md) * [15.2. 导入XML配置](III. Using Spring Boot/15.2. Importing XML configuration.md) From 01a25500bea09f1591716a0df1566a6aeb01f14b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E7=83=AD=E5=BF=83=E5=B8=82=E6=B0=91=E9=92=9F=E5=B0=8F?= =?UTF-8?q?=E5=BC=BA?= Date: Thu, 12 Apr 2018 21:48:34 +0800 Subject: [PATCH 039/865] Update and rename 15. Configuration classes.md to 15. Configuration Classes.md --- ...5. Configuration classes.md => 15. Configuration Classes.md} | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) rename III. Using Spring Boot/{15. Configuration classes.md => 15. Configuration Classes.md} (83%) diff --git a/III. Using Spring Boot/15. Configuration classes.md b/III. Using Spring Boot/15. Configuration Classes.md similarity index 83% rename from III. Using Spring Boot/15. Configuration classes.md rename to III. Using Spring Boot/15. Configuration Classes.md index b655b3e1..8f39dbec 100644 --- a/III. Using Spring Boot/15. Configuration classes.md +++ b/III. Using Spring Boot/15. Configuration Classes.md @@ -1,5 +1,5 @@ ### 15. 配置类 -Spring Boot提倡基于Java的配置。尽管你可以通过XML源来使用`SpringApplication`,不过还是建议你使用`@Configuration`类作为主要配置源。通常定义了`main`方法的类也是使用`@Configuration`注解的一个很好的替补。 +Spring Boot提倡基于Java的配置。尽管你可以通过XML源来使用`SpringApplication`,不过还是建议你使用`@Configuration`类作为主要配置源。通常定义了`main`方法的类是使用`@Configuration`注解的一个很好的替补。 **注**:虽然网络上有很多使用XML配置的Spring示例,但你应该尽可能的使用基于Java的配置,搜索查看`Enable*`注解就是一个好的开端。 From 1a681e47b294df9b799d8c44f2a996046a05daa0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E7=83=AD=E5=BF=83=E5=B8=82=E6=B0=91=E9=92=9F=E5=B0=8F?= =?UTF-8?q?=E5=BC=BA?= Date: Thu, 12 Apr 2018 21:51:24 +0800 Subject: [PATCH 040/865] Update and rename 15.1. Importing additional configuration classes.md to 15.1. Importing Additional Configuration Classes.md --- ...ses.md => 15.1. Importing Additional Configuration Classes.md} | 0 1 file changed, 0 insertions(+), 0 deletions(-) rename III. Using Spring Boot/{15.1. Importing additional configuration classes.md => 15.1. Importing Additional Configuration Classes.md} (100%) diff --git a/III. Using Spring Boot/15.1. Importing additional configuration classes.md b/III. Using Spring Boot/15.1. Importing Additional Configuration Classes.md similarity index 100% rename from III. Using Spring Boot/15.1. Importing additional configuration classes.md rename to III. Using Spring Boot/15.1. Importing Additional Configuration Classes.md From f181240b7e9b99b3f0268c2185baa7057ef95d20 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E7=83=AD=E5=BF=83=E5=B8=82=E6=B0=91=E9=92=9F=E5=B0=8F?= =?UTF-8?q?=E5=BC=BA?= Date: Thu, 12 Apr 2018 21:52:27 +0800 Subject: [PATCH 041/865] Update SUMMARY.md --- SUMMARY.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/SUMMARY.md b/SUMMARY.md index d8af9bb4..a1b1548c 100644 --- a/SUMMARY.md +++ b/SUMMARY.md @@ -47,8 +47,8 @@ * [14. 组织你的代码](III. Using Spring Boot/14. Structuring Your Code.md) * [14.1. 使用"default"包](III. Using Spring Boot/14.1. Using the “default” Package.md) * [14.2. 放置应用的main类](III. Using Spring Boot/14.2. Locating the Main Application Class.md) - * [15. 配置类](III. Using Spring Boot/15. Configuration classes.md) - * [15.1. 导入其他配置类](III. Using Spring Boot/15.1. Importing additional configuration classes.md) +   * [15. 配置类](III. Using Spring Boot/15. Configuration Classes.md) + * [15.1. 导入其他配置类](III. Using Spring Boot/15.1. Importing Additional Configuration Classes.md) * [15.2. 导入XML配置](III. Using Spring Boot/15.2. Importing XML configuration.md) * [16. 自动配置](III. Using Spring Boot/16. Auto-configuration.md) * [16.1. 逐步替换自动配置](III. Using Spring Boot/16.1. Gradually replacing auto-configuration.md) From 30e1a81ce18c4cb464146bad4568d9bf3614318c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E7=83=AD=E5=BF=83=E5=B8=82=E6=B0=91=E9=92=9F=E5=B0=8F?= =?UTF-8?q?=E5=BC=BA?= Date: Fri, 13 Apr 2018 18:53:00 +0800 Subject: [PATCH 042/865] Update and rename 15.2. Importing XML configuration.md to 15.2. Importing XML Configuration.md --- ... XML configuration.md => 15.2. Importing XML Configuration.md} | 0 1 file changed, 0 insertions(+), 0 deletions(-) rename III. Using Spring Boot/{15.2. Importing XML configuration.md => 15.2. Importing XML Configuration.md} (100%) diff --git a/III. Using Spring Boot/15.2. Importing XML configuration.md b/III. Using Spring Boot/15.2. Importing XML Configuration.md similarity index 100% rename from III. Using Spring Boot/15.2. Importing XML configuration.md rename to III. Using Spring Boot/15.2. Importing XML Configuration.md From 9e76ceecf5f713c3e5ae929e6aab8ddd7c17ac96 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E7=83=AD=E5=BF=83=E5=B8=82=E6=B0=91=E9=92=9F=E5=B0=8F?= =?UTF-8?q?=E5=BC=BA?= Date: Fri, 13 Apr 2018 18:53:48 +0800 Subject: [PATCH 043/865] Update SUMMARY.md --- SUMMARY.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/SUMMARY.md b/SUMMARY.md index a1b1548c..f2e4d57f 100644 --- a/SUMMARY.md +++ b/SUMMARY.md @@ -49,7 +49,7 @@ * [14.2. 放置应用的main类](III. Using Spring Boot/14.2. Locating the Main Application Class.md)   * [15. 配置类](III. Using Spring Boot/15. Configuration Classes.md) * [15.1. 导入其他配置类](III. Using Spring Boot/15.1. Importing Additional Configuration Classes.md) - * [15.2. 导入XML配置](III. Using Spring Boot/15.2. Importing XML configuration.md) + * [15.2. 导入XML配置](III. Using Spring Boot/15.2. Importing XML Configuration.md) * [16. 自动配置](III. Using Spring Boot/16. Auto-configuration.md) * [16.1. 逐步替换自动配置](III. Using Spring Boot/16.1. Gradually replacing auto-configuration.md) * [16.2. 禁用特定的自动配置](III. Using Spring Boot/16.2. Disabling specific auto-configuration.md) From fa09a22ba0a7ed26566b8b63e27615e55add90c0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E7=83=AD=E5=BF=83=E5=B8=82=E6=B0=91=E9=92=9F=E5=B0=8F?= =?UTF-8?q?=E5=BC=BA?= Date: Fri, 13 Apr 2018 23:54:51 +0800 Subject: [PATCH 044/865] Update and rename 16.1. Gradually replacing auto-configuration.md to 16.1. Gradually Replacing Auto-configuration.md --- ...ation.md => 16.1. Gradually Replacing Auto-configuration.md} | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) rename III. Using Spring Boot/{16.1. Gradually replacing auto-configuration.md => 16.1. Gradually Replacing Auto-configuration.md} (81%) diff --git a/III. Using Spring Boot/16.1. Gradually replacing auto-configuration.md b/III. Using Spring Boot/16.1. Gradually Replacing Auto-configuration.md similarity index 81% rename from III. Using Spring Boot/16.1. Gradually replacing auto-configuration.md rename to III. Using Spring Boot/16.1. Gradually Replacing Auto-configuration.md index d0794200..eaa69040 100644 --- a/III. Using Spring Boot/16.1. Gradually replacing auto-configuration.md +++ b/III. Using Spring Boot/16.1. Gradually Replacing Auto-configuration.md @@ -2,4 +2,4 @@ 自动配置(Auto-configuration)是非侵入性的,任何时候你都可以定义自己的配置类来替换自动配置的特定部分。例如,如果你添加自己的`DataSource` bean,默认的内嵌数据库支持将不被考虑。 -如果需要查看当前应用启动了哪些自动配置项,你可以在运行应用时打开`--debug`开关,这将为核心日志开启debug日志级别,并将自动配置相关的日志输出到控制台。 +如果需要查看当前应用启动了哪些自动配置项,你可以在运行应用时打开`--debug`开关,这将为核心日志开启debug日志级别,并将配置情况输出到控制台。 From bb0ee74933c5164fd8ca53d7439da49048440750 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E7=83=AD=E5=BF=83=E5=B8=82=E6=B0=91=E9=92=9F=E5=B0=8F?= =?UTF-8?q?=E5=BC=BA?= Date: Fri, 13 Apr 2018 23:57:45 +0800 Subject: [PATCH 045/865] Update SUMMARY.md --- SUMMARY.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/SUMMARY.md b/SUMMARY.md index f2e4d57f..c4ed529b 100644 --- a/SUMMARY.md +++ b/SUMMARY.md @@ -51,8 +51,8 @@ * [15.1. 导入其他配置类](III. Using Spring Boot/15.1. Importing Additional Configuration Classes.md) * [15.2. 导入XML配置](III. Using Spring Boot/15.2. Importing XML Configuration.md) * [16. 自动配置](III. Using Spring Boot/16. Auto-configuration.md) - * [16.1. 逐步替换自动配置](III. Using Spring Boot/16.1. Gradually replacing auto-configuration.md) - * [16.2. 禁用特定的自动配置](III. Using Spring Boot/16.2. Disabling specific auto-configuration.md) + * [16.1. 逐步替换自动配置](III. Using Spring Boot/16.1. Gradually Replacing Auto-configuration.md) +      * [16.2. 禁用特定的自动配置类](III. Using Spring Boot/16.2. Disabling Specific Auto-configuration Classes.md) * [17. Spring Beans和依赖注入](III. Using Spring Boot/17. Spring Beans and dependency injection.md) * [18. 使用@SpringBootApplication注解](III. Using Spring Boot/18. Using the @SpringBootApplication annotation.md) * [19. 运行应用程序](III. Using Spring Boot/19. Running your application.md) From d31dd879614dad75ad2aae8f7f6d94513969c11c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E7=83=AD=E5=BF=83=E5=B8=82=E6=B0=91=E9=92=9F=E5=B0=8F?= =?UTF-8?q?=E5=BC=BA?= Date: Sat, 14 Apr 2018 00:01:37 +0800 Subject: [PATCH 046/865] Update and rename 16.2. Disabling specific auto-configuration.md to 16.2. Disabling Specific Auto-configuration Classes.md --- ...=> 16.2. Disabling Specific Auto-configuration Classes.md} | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) rename III. Using Spring Boot/{16.2. Disabling specific auto-configuration.md => 16.2. Disabling Specific Auto-configuration Classes.md} (84%) diff --git a/III. Using Spring Boot/16.2. Disabling specific auto-configuration.md b/III. Using Spring Boot/16.2. Disabling Specific Auto-configuration Classes.md similarity index 84% rename from III. Using Spring Boot/16.2. Disabling specific auto-configuration.md rename to III. Using Spring Boot/16.2. Disabling Specific Auto-configuration Classes.md index 2807663f..b56a20fb 100644 --- a/III. Using Spring Boot/16.2. Disabling specific auto-configuration.md +++ b/III. Using Spring Boot/16.2. Disabling Specific Auto-configuration Classes.md @@ -1,6 +1,6 @@ -### 16.2. 禁用特定的自动配置项 +### 16.2. 禁用特定的自动配置类 -如果发现启用了不想要的自动配置项,你可以使用`@EnableAutoConfiguration`注解的exclude属性禁用它们: +如果发现启用了不想要的自动配置类,你可以使用`@EnableAutoConfiguration`注解的exclude属性禁用它们: ```java import org.springframework.boot.autoconfigure.*; import org.springframework.boot.autoconfigure.jdbc.*; From 93f36c926e211d26519d1a599f259497b028f463 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E7=83=AD=E5=BF=83=E5=B8=82=E6=B0=91=E9=92=9F=E5=B0=8F?= =?UTF-8?q?=E5=BC=BA?= Date: Mon, 16 Apr 2018 18:38:50 +0800 Subject: [PATCH 047/865] Update and rename 17. Spring Beans and dependency injection.md to 17. Spring Beans and Dependency Injection.md --- ...ection.md => 17. Spring Beans and Dependency Injection.md} | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) rename III. Using Spring Boot/{17. Spring Beans and dependency injection.md => 17. Spring Beans and Dependency Injection.md} (83%) diff --git a/III. Using Spring Boot/17. Spring Beans and dependency injection.md b/III. Using Spring Boot/17. Spring Beans and Dependency Injection.md similarity index 83% rename from III. Using Spring Boot/17. Spring Beans and dependency injection.md rename to III. Using Spring Boot/17. Spring Beans and Dependency Injection.md index d08ad1a4..c54c5519 100644 --- a/III. Using Spring Boot/17. Spring Beans and dependency injection.md +++ b/III. Using Spring Boot/17. Spring Beans and Dependency Injection.md @@ -1,10 +1,10 @@ ### 17. Spring Beans和依赖注入 -你可以自由地使用任何标准的Spring框架技术去定义beans和它们注入的依赖。简单起见,我们经常使用`@ComponentScan`注解搜索beans,并结合`@Autowired`构造器注入。 +你可以自由地使用任何标准的Spring框架技术去定义bean和它们注入的依赖。简单起见,我们经常发现使用`@ComponentScan`(用来注解搜索bean)和`@Autowired`(用来构造器注入)能够很好地工作。 如果遵循以上的建议组织代码结构(将应用的main类放到包的最上层,即root package),那么你就可以添加`@ComponentScan`注解而不需要任何参数,所有应用组件(`@Component`, `@Service`, `@Repository`, `@Controller`等)都会自动注册成Spring Beans。 -下面是一个`@Service` Bean的示例,它使用构建器注入获取一个需要的`RiskAssessor` bean。 +下面是一个`@Service` Bean的示例,它使用构建器注入获取一个需要的`RiskAssessor` bean: ```java package com.example.service; From 213748a3da72837526990c96a455e2e3c75cb4c2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E7=83=AD=E5=BF=83=E5=B8=82=E6=B0=91=E9=92=9F=E5=B0=8F?= =?UTF-8?q?=E5=BC=BA?= Date: Mon, 16 Apr 2018 18:41:26 +0800 Subject: [PATCH 048/865] Update SUMMARY.md --- SUMMARY.md | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/SUMMARY.md b/SUMMARY.md index c4ed529b..faea4f75 100644 --- a/SUMMARY.md +++ b/SUMMARY.md @@ -53,9 +53,9 @@ * [16. 自动配置](III. Using Spring Boot/16. Auto-configuration.md) * [16.1. 逐步替换自动配置](III. Using Spring Boot/16.1. Gradually Replacing Auto-configuration.md)      * [16.2. 禁用特定的自动配置类](III. Using Spring Boot/16.2. Disabling Specific Auto-configuration Classes.md) - * [17. Spring Beans和依赖注入](III. Using Spring Boot/17. Spring Beans and dependency injection.md) - * [18. 使用@SpringBootApplication注解](III. Using Spring Boot/18. Using the @SpringBootApplication annotation.md) - * [19. 运行应用程序](III. Using Spring Boot/19. Running your application.md) +   * [17. Spring Beans和依赖注入](III. Using Spring Boot/17. Spring Beans and Dependency Injection.md) + * [18. 使用@SpringBootApplication注解](III. Using Spring Boot/18. Using the @SpringBootApplication Annotation.md) + * [19. 运行应用程序](III. Using Spring Boot/19. Running Your Application.md) * [19.1. 从IDE中运行](III. Using Spring Boot/19.1. Running from an IDE.md) * [19.2. 作为一个打包后的应用运行](III. Using Spring Boot/19.2. Running as a packaged application.md) * [19.3. 使用Maven插件运行](III. Using Spring Boot/19.3. Using the Maven plugin.md) From 92ef00b9554fc9dec75199691727dbfd5641ddd5 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E7=83=AD=E5=BF=83=E5=B8=82=E6=B0=91=E9=92=9F=E5=B0=8F?= =?UTF-8?q?=E5=BC=BA?= Date: Mon, 16 Apr 2018 18:45:10 +0800 Subject: [PATCH 049/865] Update and rename 18. Using the @SpringBootApplication annotation.md to 18. Using the @SpringBootApplication Annotation.md --- ...tion.md => 18. Using the @SpringBootApplication Annotation.md} | 0 1 file changed, 0 insertions(+), 0 deletions(-) rename III. Using Spring Boot/{18. Using the @SpringBootApplication annotation.md => 18. Using the @SpringBootApplication Annotation.md} (100%) diff --git a/III. Using Spring Boot/18. Using the @SpringBootApplication annotation.md b/III. Using Spring Boot/18. Using the @SpringBootApplication Annotation.md similarity index 100% rename from III. Using Spring Boot/18. Using the @SpringBootApplication annotation.md rename to III. Using Spring Boot/18. Using the @SpringBootApplication Annotation.md From 5ff371067b9b577cc2192a3f1224742f9915365f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E7=83=AD=E5=BF=83=E5=B8=82=E6=B0=91=E9=92=9F=E5=B0=8F?= =?UTF-8?q?=E5=BC=BA?= Date: Mon, 16 Apr 2018 18:47:40 +0800 Subject: [PATCH 050/865] Update and rename 19. Running your application.md to 19. Running Your Application.md --- ...ng your application.md => 19. Running Your Application.md} | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) rename III. Using Spring Boot/{19. Running your application.md => 19. Running Your Application.md} (58%) diff --git a/III. Using Spring Boot/19. Running your application.md b/III. Using Spring Boot/19. Running Your Application.md similarity index 58% rename from III. Using Spring Boot/19. Running your application.md rename to III. Using Spring Boot/19. Running Your Application.md index b7b6c8d3..a6e5505b 100644 --- a/III. Using Spring Boot/19. Running your application.md +++ b/III. Using Spring Boot/19. Running Your Application.md @@ -1,5 +1,5 @@ ### 19. 运行应用程序 -将应用打包成jar,并使用内嵌HTTP服务器的一个最大好处是,你可以像其他方式那样运行你的应用程序。调试Spring Boot应用也很简单,你都不需要任何特殊IDE插件或扩展! +将应用打包成jar,并使用内嵌HTTP服务器的一个最大好处是,你可以像其他方式那样运行你的应用程序。调试Spring Boot应用也很简单。你都不需要任何特殊IDE插件或扩展。 -**注**:本章节只覆盖基于jar的打包,如果选择将应用打包成war文件,你最好参考相关的服务器和IDE文档。 +**注**:本章节只覆盖基于jar的打包。如果选择将应用打包成war文件,你最好参考相关的服务器和IDE文档。 From 7118600e19dd00e6a61a27c2af848e3cc603fe0a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E7=83=AD=E5=BF=83=E5=B8=82=E6=B0=91=E9=92=9F=E5=B0=8F?= =?UTF-8?q?=E5=BC=BA?= Date: Thu, 19 Apr 2018 23:12:08 +0800 Subject: [PATCH 051/865] Update 19.1. Running from an IDE.md --- III. Using Spring Boot/19.1. Running from an IDE.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/III. Using Spring Boot/19.1. Running from an IDE.md b/III. Using Spring Boot/19.1. Running from an IDE.md index a2d272de..3f7c2d8f 100644 --- a/III. Using Spring Boot/19.1. Running from an IDE.md +++ b/III. Using Spring Boot/19.1. Running from an IDE.md @@ -1,7 +1,7 @@ ### 19.1. 从IDE中运行 -你可以从IDE中运行Spring Boot应用,就像一个简单的Java应用,但首先需要导入项目。导入步骤取决于你的IDE和构建系统,大多数IDEs能够直接导入Maven项目,例如Eclipse用户可以选择`File`菜单的`Import…​` --> `Existing Maven Projects`。 +你可以从IDE中运行Spring Boot应用,就像一个简单的Java应用。但首先需要导入项目。导入步骤取决于你的IDE和构建系统,大多数IDEs能够直接导入Maven项目。例如Eclipse用户可以选择`File`菜单的`Import…` --> `Existing Maven Projects`。 -如果不能直接将项目导入IDE,你可以使用构建系统生成IDE的元数据。Maven有针对[Eclipse](http://maven.apache.org/plugins/maven-eclipse-plugin/)和[IDEA](http://maven.apache.org/plugins/maven-idea-plugin/)的插件;Gradle为[各种IDEs](http://www.gradle.org/docs/current/userguide/ide_support.html)提供插件。 +如果不能直接将项目导入IDE,你可以使用构建系统生成IDE的元数据。Maven有针对[Eclipse](http://maven.apache.org/plugins/maven-eclipse-plugin/)和[IDEA](http://maven.apache.org/plugins/maven-idea-plugin/)的插件。Gradle为[各种IDEs](http://www.gradle.org/docs/current/userguide/ide_support.html)提供插件。 **注** 如果意外地多次运行一个web应用,你将看到一个"端口已被占用"的错误。STS用户可以使用`Relaunch`而不是`Run`按钮,以确保任何存在的实例是关闭的。 From fefe6a62442091e17982b8e68983277eeaf51247 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E7=83=AD=E5=BF=83=E5=B8=82=E6=B0=91=E9=92=9F=E5=B0=8F?= =?UTF-8?q?=E5=BC=BA?= Date: Thu, 19 Apr 2018 23:14:35 +0800 Subject: [PATCH 052/865] Update and rename 19.2. Running as a packaged application.md to 19.2. Running as a Packaged Application.md --- ... application.md => 19.2. Running as a Packaged Application.md} | 0 1 file changed, 0 insertions(+), 0 deletions(-) rename III. Using Spring Boot/{19.2. Running as a packaged application.md => 19.2. Running as a Packaged Application.md} (100%) diff --git a/III. Using Spring Boot/19.2. Running as a packaged application.md b/III. Using Spring Boot/19.2. Running as a Packaged Application.md similarity index 100% rename from III. Using Spring Boot/19.2. Running as a packaged application.md rename to III. Using Spring Boot/19.2. Running as a Packaged Application.md From ea487f5948251830f3196e4b4bdaef3b7148acd8 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E7=83=AD=E5=BF=83=E5=B8=82=E6=B0=91=E9=92=9F=E5=B0=8F?= =?UTF-8?q?=E5=BC=BA?= Date: Thu, 19 Apr 2018 23:23:25 +0800 Subject: [PATCH 053/865] Update and rename 19.3. Using the Maven plugin.md to 19.3. Using the Maven Plugin.md --- ...ng the Maven plugin.md => 19.3. Using the Maven Plugin.md} | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) rename III. Using Spring Boot/{19.3. Using the Maven plugin.md => 19.3. Using the Maven Plugin.md} (59%) diff --git a/III. Using Spring Boot/19.3. Using the Maven plugin.md b/III. Using Spring Boot/19.3. Using the Maven Plugin.md similarity index 59% rename from III. Using Spring Boot/19.3. Using the Maven plugin.md rename to III. Using Spring Boot/19.3. Using the Maven Plugin.md index d4351558..a91f3eab 100644 --- a/III. Using Spring Boot/19.3. Using the Maven plugin.md +++ b/III. Using Spring Boot/19.3. Using the Maven Plugin.md @@ -1,10 +1,10 @@ ### 19.3. 使用Maven插件运行 -Spring Boot Maven插件包含一个`run`目标,可用来快速编译和运行应用程序,并且跟在IDE运行一样支持热加载。 +Spring Boot Maven插件包含一个`run`目标,可用来快速编译和运行应用程序,并且跟在IDE运行一样支持热加载。下面的例子展示了运行Spring Boot应用的一个典型的Maven命令: ```shell $ mvn spring-boot:run ``` -你可以使用一些有用的操作系统环境变量: +你可能还会想使用操作系统环境变量`MAVEN_OPTS`: ```shell $ export MAVEN_OPTS=-Xmx1024m ``` From d842aaa3a8ac6631ba5afbf03d25944abbbc57bf Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E7=83=AD=E5=BF=83=E5=B8=82=E6=B0=91=E9=92=9F=E5=B0=8F?= =?UTF-8?q?=E5=BC=BA?= Date: Thu, 19 Apr 2018 23:25:54 +0800 Subject: [PATCH 054/865] Update and rename 19.4. Using the Gradle plugin.md to 19.4. Using the Gradle Plugin.md --- ...ng the Gradle plugin.md => 19.4. Using the Gradle Plugin.md} | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) rename III. Using Spring Boot/{19.4. Using the Gradle plugin.md => 19.4. Using the Gradle Plugin.md} (80%) diff --git a/III. Using Spring Boot/19.4. Using the Gradle plugin.md b/III. Using Spring Boot/19.4. Using the Gradle Plugin.md similarity index 80% rename from III. Using Spring Boot/19.4. Using the Gradle plugin.md rename to III. Using Spring Boot/19.4. Using the Gradle Plugin.md index 6372fb55..b1fc822e 100644 --- a/III. Using Spring Boot/19.4. Using the Gradle plugin.md +++ b/III. Using Spring Boot/19.4. Using the Gradle Plugin.md @@ -4,7 +4,7 @@ Spring Boot Gradle插件也包含一个`bootRun`任务,可用来运行你的 ```shell $ gradle bootRun ``` -你可能想使用一些有用的操作系统环境变量: +你可能还会想使用操作系统环境变量`JAVA_OPTS`: ```shell $ export JAVA_OPTS=-Xmx1024m ``` From cd49a067b6f52e7f7925b4f7a463291794216c98 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E7=83=AD=E5=BF=83=E5=B8=82=E6=B0=91=E9=92=9F=E5=B0=8F?= =?UTF-8?q?=E5=BC=BA?= Date: Thu, 19 Apr 2018 23:27:29 +0800 Subject: [PATCH 055/865] Update SUMMARY.md --- SUMMARY.md | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/SUMMARY.md b/SUMMARY.md index faea4f75..b3647de8 100644 --- a/SUMMARY.md +++ b/SUMMARY.md @@ -57,9 +57,9 @@ * [18. 使用@SpringBootApplication注解](III. Using Spring Boot/18. Using the @SpringBootApplication Annotation.md) * [19. 运行应用程序](III. Using Spring Boot/19. Running Your Application.md) * [19.1. 从IDE中运行](III. Using Spring Boot/19.1. Running from an IDE.md) - * [19.2. 作为一个打包后的应用运行](III. Using Spring Boot/19.2. Running as a packaged application.md) - * [19.3. 使用Maven插件运行](III. Using Spring Boot/19.3. Using the Maven plugin.md) - * [19.4. 使用Gradle插件运行](III. Using Spring Boot/19.4. Using the Gradle plugin.md) + * [19.2. 作为一个打包后的应用运行](III. Using Spring Boot/19.2. Running as a Packaged Application.md) + * [19.3. 使用Maven插件运行](III. Using Spring Boot/19.3. Using the Maven Plugin.md) + * [19.4. 使用Gradle插件运行](III. Using Spring Boot/19.4. Using the Gradle Plugin.md) * [19.5. 热交换](III. Using Spring Boot/19.5. Hot swapping.md) * [20. 开发者工具](III. Using Spring Boot/20. Developer tools.md) * [20.1. 默认属性](III. Using Spring Boot/20.1. Property defaults.md) From 3225690a224b77604dcbaf8ed4d83d532f879822 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E7=83=AD=E5=BF=83=E5=B8=82=E6=B0=91=E9=92=9F=E5=B0=8F?= =?UTF-8?q?=E5=BC=BA?= Date: Fri, 20 Apr 2018 10:09:56 +0800 Subject: [PATCH 056/865] Update SUMMARY.md --- SUMMARY.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/SUMMARY.md b/SUMMARY.md index b3647de8..fa29fe73 100644 --- a/SUMMARY.md +++ b/SUMMARY.md @@ -60,7 +60,7 @@ * [19.2. 作为一个打包后的应用运行](III. Using Spring Boot/19.2. Running as a Packaged Application.md) * [19.3. 使用Maven插件运行](III. Using Spring Boot/19.3. Using the Maven Plugin.md) * [19.4. 使用Gradle插件运行](III. Using Spring Boot/19.4. Using the Gradle Plugin.md) - * [19.5. 热交换](III. Using Spring Boot/19.5. Hot swapping.md) + * [19.5. 热交换](III. Using Spring Boot/19.5. Hot Swapping.md) * [20. 开发者工具](III. Using Spring Boot/20. Developer tools.md) * [20.1. 默认属性](III. Using Spring Boot/20.1. Property defaults.md) * [20.2. 自动重启](III. Using Spring Boot/20.2. Automatic restart.md) From f2e78e3d5bd8f0078d432b8bd992a7c39add8a1e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E7=83=AD=E5=BF=83=E5=B8=82=E6=B0=91=E9=92=9F=E5=B0=8F?= =?UTF-8?q?=E5=BC=BA?= Date: Fri, 20 Apr 2018 10:13:39 +0800 Subject: [PATCH 057/865] Update and rename 19.5. Hot swapping.md to 19.5. Hot Swapping.md --- III. Using Spring Boot/19.5. Hot Swapping.md | 5 +++++ III. Using Spring Boot/19.5. Hot swapping.md | 5 ----- 2 files changed, 5 insertions(+), 5 deletions(-) create mode 100644 III. Using Spring Boot/19.5. Hot Swapping.md delete mode 100644 III. Using Spring Boot/19.5. Hot swapping.md diff --git a/III. Using Spring Boot/19.5. Hot Swapping.md b/III. Using Spring Boot/19.5. Hot Swapping.md new file mode 100644 index 00000000..45ce21f6 --- /dev/null +++ b/III. Using Spring Boot/19.5. Hot Swapping.md @@ -0,0 +1,5 @@ +### 19.5. 热交换 + +由于Spring Boot应用只是普通的Java应用,所以JVM热交换(hot-swapping)也能开箱即用。不过JVM热交换能替换的字节码有限制。想要更彻底的解决方案可以使用[JRebel](http://zeroturnaround.com/software/jrebel/)。 + +`spring-boot-devtools`模块也支持应用快速重启(restart)。详情参考下面的[章节 20,开发者工具](http://docs.spring.io/spring-boot/docs/current-SNAPSHOT/reference/htmlsingle/#using-boot-devtools)和[“How-to”](../IX. ‘How-to’ guides/README.md)章节。 diff --git a/III. Using Spring Boot/19.5. Hot swapping.md b/III. Using Spring Boot/19.5. Hot swapping.md deleted file mode 100644 index b5a8f9b0..00000000 --- a/III. Using Spring Boot/19.5. Hot swapping.md +++ /dev/null @@ -1,5 +0,0 @@ -### 19.5. 热交换 - -由于Spring Boot应用只是普通的Java应用,所以JVM热交换(hot-swapping)也能开箱即用。不过JVM热交换能替换的字节码有限制,想要更彻底的解决方案可以使用[JRebel](http://zeroturnaround.com/software/jrebel/)。`spring-boot-devtools`模块也支持应用快速重启(restart)。 - -详情参考下面的[Chapter 20, Developer tools](http://docs.spring.io/spring-boot/docs/current-SNAPSHOT/reference/htmlsingle/#using-boot-devtools)和[“How-to”](../IX. ‘How-to’ guides/README.md)章节。 From bd4f160fbec66ea1f83329e3609340dcfdca33d9 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E7=83=AD=E5=BF=83=E5=B8=82=E6=B0=91=E9=92=9F=E5=B0=8F?= =?UTF-8?q?=E5=BC=BA?= Date: Sun, 22 Apr 2018 19:53:02 +0800 Subject: [PATCH 058/865] Update and rename 20. Developer tools.md to 20. Developer Tools.md --- .../{20. Developer tools.md => 20. Developer Tools.md} | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) rename III. Using Spring Boot/{20. Developer tools.md => 20. Developer Tools.md} (77%) diff --git a/III. Using Spring Boot/20. Developer tools.md b/III. Using Spring Boot/20. Developer Tools.md similarity index 77% rename from III. Using Spring Boot/20. Developer tools.md rename to III. Using Spring Boot/20. Developer Tools.md index d26286f5..19b5040f 100644 --- a/III. Using Spring Boot/20. Developer tools.md +++ b/III. Using Spring Boot/20. Developer Tools.md @@ -1,5 +1,6 @@ ###20. 开发者工具 -Spring Boot包含了一些额外的工具集,用于提升Spring Boot应用的开发体验。`spring-boot-devtools`模块可以included到任何模块中,以提供development-time特性,你只需简单的将该模块的依赖添加到构建中: + +Spring Boot包含了一些额外的工具集,用于提升Spring Boot应用的开发体验。`spring-boot-devtools`模块可以included到任何模块中,以提供development-time特性,你只需将该模块的依赖添加到构建中: **Maven** ```xml @@ -17,4 +18,6 @@ dependencies { compile("org.springframework.boot:spring-boot-devtools") } ``` -**注** 在运行一个完整的,打包过的应用时,开发者工具(devtools)会被自动禁用。如果应用使用`java -jar`或特殊的类加载器启动,都会被认为是一个产品级的应用(production application),从而禁用开发者工具。为了防止devtools传递到项目中的其他模块,设置该依赖级别为optional是个不错的实践。不过Gradle不支持`optional`依赖,所以你可能要了解下[propdeps-plugin](https://github.com/spring-projects/gradle-plugins/tree/master/propdeps-plugin)。重新打包的归档文件默认不包含开发者工具。如果你想使用某些远程的开发者工具特性,你需要禁用`excludeDevtools`构建属性。Maven和Gradle都支持该属性。 +**注** 在运行一个完整的,打包过的应用时,开发者工具(devtools)会被自动禁用。如果应用使用`java -jar`或特殊的类加载器启动,都会被认为是一个产品级的应用(production application),从而禁用开发者工具。为了防止devtools传递到项目中的其他模块,设置该依赖级别为optional是个不错的实践。不过Gradle不支持`optional`依赖,所以你可能要了解下[propdeps-plugin](https://github.com/spring-projects/gradle-plugins/tree/master/propdeps-plugin)。 + +**注** 重新打包的归档文件默认不包含开发者工具。如果你想使用某些远程的开发者工具特性,你需要禁用`excludeDevtools`构建属性。Maven和Gradle都支持该属性。 From 86404e7731571136ea3944e7246f1df4b60284ed Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E7=83=AD=E5=BF=83=E5=B8=82=E6=B0=91=E9=92=9F=E5=B0=8F?= =?UTF-8?q?=E5=BC=BA?= Date: Sun, 22 Apr 2018 19:53:35 +0800 Subject: [PATCH 059/865] Update SUMMARY.md --- SUMMARY.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/SUMMARY.md b/SUMMARY.md index fa29fe73..4b34de93 100644 --- a/SUMMARY.md +++ b/SUMMARY.md @@ -61,7 +61,7 @@ * [19.3. 使用Maven插件运行](III. Using Spring Boot/19.3. Using the Maven Plugin.md) * [19.4. 使用Gradle插件运行](III. Using Spring Boot/19.4. Using the Gradle Plugin.md) * [19.5. 热交换](III. Using Spring Boot/19.5. Hot Swapping.md) - * [20. 开发者工具](III. Using Spring Boot/20. Developer tools.md) +   * [20. 开发者工具](III. Using Spring Boot/20. Developer Tools.md) * [20.1. 默认属性](III. Using Spring Boot/20.1. Property defaults.md) * [20.2. 自动重启](III. Using Spring Boot/20.2. Automatic restart.md) * [20.2.1. 排除资源](III. Using Spring Boot/20.2.1. Excluding resources.md) From db46b1ce76f38bc9f7f2fcf65f510bf2746be9e0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E7=83=AD=E5=BF=83=E5=B8=82=E6=B0=91=E9=92=9F=E5=B0=8F?= =?UTF-8?q?=E5=BC=BA?= Date: Sun, 22 Apr 2018 19:55:09 +0800 Subject: [PATCH 060/865] Update SUMMARY.md --- SUMMARY.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/SUMMARY.md b/SUMMARY.md index 4b34de93..fe0b6cdd 100644 --- a/SUMMARY.md +++ b/SUMMARY.md @@ -61,7 +61,7 @@ * [19.3. 使用Maven插件运行](III. Using Spring Boot/19.3. Using the Maven Plugin.md) * [19.4. 使用Gradle插件运行](III. Using Spring Boot/19.4. Using the Gradle Plugin.md) * [19.5. 热交换](III. Using Spring Boot/19.5. Hot Swapping.md) -   * [20. 开发者工具](III. Using Spring Boot/20. Developer Tools.md) + * [20. 开发者工具](III. Using Spring Boot/20. Developer Tools.md) * [20.1. 默认属性](III. Using Spring Boot/20.1. Property defaults.md) * [20.2. 自动重启](III. Using Spring Boot/20.2. Automatic restart.md) * [20.2.1. 排除资源](III. Using Spring Boot/20.2.1. Excluding resources.md) From 9c0fc02cecc806aba4ba7c0b39e8ca5051249bbf Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E7=83=AD=E5=BF=83=E5=B8=82=E6=B0=91=E9=92=9F=E5=B0=8F?= =?UTF-8?q?=E5=BC=BA?= Date: Sun, 22 Apr 2018 20:04:35 +0800 Subject: [PATCH 061/865] Update and rename 20.1. Property defaults.md to 20.1. Property Defaults.md --- ...20.1. Property defaults.md => 20.1. Property Defaults.md} | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) rename III. Using Spring Boot/{20.1. Property defaults.md => 20.1. Property Defaults.md} (71%) diff --git a/III. Using Spring Boot/20.1. Property defaults.md b/III. Using Spring Boot/20.1. Property Defaults.md similarity index 71% rename from III. Using Spring Boot/20.1. Property defaults.md rename to III. Using Spring Boot/20.1. Property Defaults.md index 3b8812a0..1fa55953 100644 --- a/III. Using Spring Boot/20.1. Property defaults.md +++ b/III. Using Spring Boot/20.1. Property Defaults.md @@ -1,6 +1,7 @@ -###20.1 默认属性 +### 20.1 默认属性 -Spring Boot支持的一些库使用缓存提高性能,比如模板引擎将缓存编译完的模板以避免重复解析模板文件。另外,当服务静态资源时,Spring MVC能够加入HTTP缓存头来进行回应。虽然缓存在产品中很有用,但开发期间就是个累赘了,因为缓存会阻碍你看到在应用中刚刚做出的修改。正是因为这个原因,`spring-boot-devtools`将会默认禁用那些缓存选项。 +Spring Boot支持的一些库使用缓存提高性能,比如模板引擎将缓存编译完的模板以避免重复解析模板文件。另外,当服务静态资源时,Spring MVC能够加入HTTP缓存头来进行回应。 +虽然缓存在产品中很有用,但开发期间就是个累赘了,因为缓存会阻碍你看到在应用中刚刚做出的修改。正是因为这个原因,`spring-boot-devtools`默认禁用那些缓存选项。 缓存选项通常配置在`application.properties`文件中,比如Thymeleaf提供了`spring.thymeleaf.cache`属性,`spring-boot-devtools`模块会自动应用敏感的`development-time`配置,而不是手动设置这些属性。 **注** 查看[DevToolsPropertyDefaultsPostProcessor](https://github.com/spring-projects/spring-boot/tree/master/spring-boot-devtools/src/main/java/org/springframework/boot/devtools/env/DevToolsPropertyDefaultsPostProcessor.java)获取完整的被应用的属性列表。 From 4e365a01e8bd2d4852f704a77b1e27205391641a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E7=83=AD=E5=BF=83=E5=B8=82=E6=B0=91=E9=92=9F=E5=B0=8F?= =?UTF-8?q?=E5=BC=BA?= Date: Sun, 22 Apr 2018 20:06:32 +0800 Subject: [PATCH 062/865] Update SUMMARY.md --- SUMMARY.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/SUMMARY.md b/SUMMARY.md index fe0b6cdd..c5d5329a 100644 --- a/SUMMARY.md +++ b/SUMMARY.md @@ -62,8 +62,8 @@ * [19.4. 使用Gradle插件运行](III. Using Spring Boot/19.4. Using the Gradle Plugin.md) * [19.5. 热交换](III. Using Spring Boot/19.5. Hot Swapping.md) * [20. 开发者工具](III. Using Spring Boot/20. Developer Tools.md) - * [20.1. 默认属性](III. Using Spring Boot/20.1. Property defaults.md) - * [20.2. 自动重启](III. Using Spring Boot/20.2. Automatic restart.md) + * [20.1. 默认属性](III. Using Spring Boot/20.1. Property Defaults.md) + * [20.2. 自动重启](III. Using Spring Boot/20.2. Automatic Restart.md) * [20.2.1. 排除资源](III. Using Spring Boot/20.2.1. Excluding resources.md) * [20.2.2. 查看其他路径](III. Using Spring Boot/20.2.2. Watching additional paths.md) * [20.2.3. 禁用重启](III. Using Spring Boot/20.2.3. Disabling restart.md) From 631edfdc5546f44d0e19b36f8d5c027d415de28b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E7=83=AD=E5=BF=83=E5=B8=82=E6=B0=91=E9=92=9F=E5=B0=8F?= =?UTF-8?q?=E5=BC=BA?= Date: Sun, 22 Apr 2018 20:21:07 +0800 Subject: [PATCH 063/865] Update 20.2. Automatic restart.md --- III. Using Spring Boot/20.2. Automatic restart.md | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-) diff --git a/III. Using Spring Boot/20.2. Automatic restart.md b/III. Using Spring Boot/20.2. Automatic restart.md index 5a88550f..3272682b 100644 --- a/III. Using Spring Boot/20.2. Automatic restart.md +++ b/III. Using Spring Boot/20.2. Automatic restart.md @@ -1,12 +1,12 @@ -###20.2 自动重启 +### 20.2 自动重启 如果应用使用`spring-boot-devtools`,则只要classpath下的文件有变动,它就会自动重启。这在使用IDE时非常有用,因为可以很快得到代码改变的反馈。默认情况下,classpath下任何指向文件夹的实体都会被监控,注意一些资源的修改比如静态assets,视图模板不需要重启应用。 -**触发重启** 由于DevTools监控classpath下的资源,所以唯一触发重启的方式就是更新classpath。引起classpath更新的方式依赖于你使用的IDE,在Eclipse里,保存一个修改的文件将引起classpath更新,并触发重启。在IntelliJ IDEA中,构建工程(Build → Make Project)有同样效果。 +**触发重启** 由于DevTools监控classpath下的资源,所以唯一触发重启的方式就是更新classpath。引起classpath更新的方式依赖于你使用的IDE,在Eclipse里,保存一个修改的文件会引起classpath更新,并触发重启。在IntelliJ IDEA中,构建工程(Build → Make Project)有同样效果。 -**注** 你也可以通过支持的构建工具(比如,Maven和Gradle)启动应用,只要开启fork功能,因为DevTools需要一个隔离的应用类加载器执行正确的操作。当发现类路径中存在DevTools时,Gradle和Maven会默认执行该行为, +**注** 只要开启了fork功能,你也可以通过支持的构建工具(Maven和Gradle)启动应用。因为DevTools需要一个隔离的应用类加载器执行正确的操作。当发现类路径中存在DevTools时,Gradle和Maven会默认执行该行为。 -自动重启跟LiveReload可以一起很好的工作,具体参考[下面章节](http://docs.spring.io/spring-boot/docs/current-SNAPSHOT/reference/htmlsingle/#using-boot-devtools-livereload)。如果你使用JRebel,自动重启将禁用以支持动态类加载,其他devtools特性,比如LiveReload,属性覆盖仍旧可以使用。 +自动重启跟LiveReload可以一起很好的工作,具体参考[LiveReload章节](http://docs.spring.io/spring-boot/docs/current-SNAPSHOT/reference/htmlsingle/#using-boot-devtools-livereload)。如果你使用JRebel,自动重启会被禁用以支持动态类加载,其他devtools特性(比如,LiveReload和属性覆盖)仍旧可以使用。 DevTools依赖应用上下文的shutdown钩子来关闭处于重启过程的应用,如果禁用shutdown钩子(`SpringApplication.setRegisterShutdownHook(false)`),它将不能正常工作。 @@ -14,7 +14,6 @@ DevTools依赖应用上下文的shutdown钩子来关闭处于重启过程的应 DevTools需要自定义`ApplicationContext`使用的资源加载器。如果你的应用已经提供了一个,它将会被覆盖。直接覆盖`ApplicationContext`的getResource方法不被支持。 -**Restart vs Reload** Spring Boot提供的重启技术是通过使用两个类加载器实现的。没有变化的类(比如那些第三方jars)会加载进一个基础(basic)classloader,正在开发的类会加载进一个重启(restart)classloader。当应用重启时,restart类加载器会被丢弃,并创建一个新的。这种方式意味着应用重启通常比冷启动(cold starts)快很多,因为基础类加载器已经可用,并且populated(意思是基础类加载器加载的类比较多?)。 +**Restart vs Reload** Spring Boot提供的重启技术是通过使用两个类加载器实现的。没有变化的类(比如那些第三方jars)会加载进一个基础的类加载器,正在开发的类会加载进一个重启的类加载器。当应用重启时,重启的类加载器会被丢弃,并创建一个新的。这种方式意味着应用重启通常比冷启动快很多,因为基础类加载器已经可用并且填充完成。 如果发现重启对于你的应用来说不够快,或遇到类加载的问题,那你可以考虑reload技术,比如[JRebel](http://zeroturnaround.com/software/jrebel/),这些技术是通过重写它们加载过的类实现的。 - From ff6db8a0d5063d412e0c7b3a240c27d25c906533 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E7=83=AD=E5=BF=83=E5=B8=82=E6=B0=91=E9=92=9F=E5=B0=8F?= =?UTF-8?q?=E5=BC=BA?= Date: Sun, 22 Apr 2018 20:21:45 +0800 Subject: [PATCH 064/865] Rename 20.2. Automatic restart.md to 20.2. Automatic Restart.md --- .../{20.2. Automatic restart.md => 20.2. Automatic Restart.md} | 0 1 file changed, 0 insertions(+), 0 deletions(-) rename III. Using Spring Boot/{20.2. Automatic restart.md => 20.2. Automatic Restart.md} (100%) diff --git a/III. Using Spring Boot/20.2. Automatic restart.md b/III. Using Spring Boot/20.2. Automatic Restart.md similarity index 100% rename from III. Using Spring Boot/20.2. Automatic restart.md rename to III. Using Spring Boot/20.2. Automatic Restart.md From 501846791c89ce50b95909cd5f0c92d981240049 Mon Sep 17 00:00:00 2001 From: Jack Zhong Date: Wed, 25 Apr 2018 00:28:37 +0800 Subject: [PATCH 065/865] =?UTF-8?q?=E7=BF=BB=E8=AF=9120.2.1=20=E5=9C=A8?= =?UTF-8?q?=E7=8A=B6=E5=86=B5=E8=AF=84=E4=BC=B0=E9=87=8C=E8=AE=B0=E5=BD=95?= =?UTF-8?q?=E6=9B=B4=E6=94=B9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../20.2.1. Logging changes in condition evaluation.md | 8 ++++++++ SUMMARY.md | 1 + 2 files changed, 9 insertions(+) create mode 100644 III. Using Spring Boot/20.2.1. Logging changes in condition evaluation.md diff --git a/III. Using Spring Boot/20.2.1. Logging changes in condition evaluation.md b/III. Using Spring Boot/20.2.1. Logging changes in condition evaluation.md new file mode 100644 index 00000000..ffb89675 --- /dev/null +++ b/III. Using Spring Boot/20.2.1. Logging changes in condition evaluation.md @@ -0,0 +1,8 @@ +### 20.2.1 在状况评估里记录更改 + +默认地,每次应用重启,都会记录一份展示状况评估差量的报告。报告展示了对应用的自动配置所做的更改,比如添加或者移除bean、设置配置属性。 + +禁用记录报告,设置以下属性: +```properties +spring.devtools.restart.log-condition-evaluation-delta=false +``` \ No newline at end of file diff --git a/SUMMARY.md b/SUMMARY.md index b3647de8..ec82027b 100644 --- a/SUMMARY.md +++ b/SUMMARY.md @@ -64,6 +64,7 @@ * [20. 开发者工具](III. Using Spring Boot/20. Developer tools.md) * [20.1. 默认属性](III. Using Spring Boot/20.1. Property defaults.md) * [20.2. 自动重启](III. Using Spring Boot/20.2. Automatic restart.md) + * [20.2.1. 在状况评估里记录更改](III. Using Spring Boot/20.2.1. Logging changes in condition evaluation.md) * [20.2.1. 排除资源](III. Using Spring Boot/20.2.1. Excluding resources.md) * [20.2.2. 查看其他路径](III. Using Spring Boot/20.2.2. Watching additional paths.md) * [20.2.3. 禁用重启](III. Using Spring Boot/20.2.3. Disabling restart.md) From d002b5784e5f04cb13cf753cea6110bf685f2631 Mon Sep 17 00:00:00 2001 From: Jack Zhong Date: Wed, 25 Apr 2018 01:14:23 +0800 Subject: [PATCH 066/865] =?UTF-8?q?=E4=B8=8A=E4=BC=A0=E4=B8=A2=E5=A4=B1?= =?UTF-8?q?=E7=9A=8419.5.=20=E7=83=AD=E4=BA=A4=E6=8D=A2?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- III. Using Spring Boot/19.5. Hot Swapping.md | 5 +++++ 1 file changed, 5 insertions(+) create mode 100755 III. Using Spring Boot/19.5. Hot Swapping.md diff --git a/III. Using Spring Boot/19.5. Hot Swapping.md b/III. Using Spring Boot/19.5. Hot Swapping.md new file mode 100755 index 00000000..45ce21f6 --- /dev/null +++ b/III. Using Spring Boot/19.5. Hot Swapping.md @@ -0,0 +1,5 @@ +### 19.5. 热交换 + +由于Spring Boot应用只是普通的Java应用,所以JVM热交换(hot-swapping)也能开箱即用。不过JVM热交换能替换的字节码有限制。想要更彻底的解决方案可以使用[JRebel](http://zeroturnaround.com/software/jrebel/)。 + +`spring-boot-devtools`模块也支持应用快速重启(restart)。详情参考下面的[章节 20,开发者工具](http://docs.spring.io/spring-boot/docs/current-SNAPSHOT/reference/htmlsingle/#using-boot-devtools)和[“How-to”](../IX. ‘How-to’ guides/README.md)章节。 From f6c44f2404a693d5d8986c0aa79c2a859618689f Mon Sep 17 00:00:00 2001 From: Jack Zhong Date: Thu, 26 Apr 2018 15:08:50 +0800 Subject: [PATCH 067/865] =?UTF-8?q?=E4=BF=AE=E6=94=B9=E7=AB=A0=E8=8A=82?= =?UTF-8?q?=E5=8F=B7=E7=A0=81?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- ...g resources.md => 20.2.2. Excluding resources.md} | 0 ...paths.md => 20.2.3. Watching additional paths.md} | 0 ...bling restart.md => 20.2.4. Disabling restart.md} | 0 ...igger file.md => 20.2.5. Using a trigger file.md} | 0 ...> 20.2.6. Customizing the restart classloader.md} | 0 ...n limitations.md => 20.2.7. Known limitations.md} | 0 SUMMARY.md | 12 ++++++------ 7 files changed, 6 insertions(+), 6 deletions(-) rename III. Using Spring Boot/{20.2.1. Excluding resources.md => 20.2.2. Excluding resources.md} (100%) rename III. Using Spring Boot/{20.2.2. Watching additional paths.md => 20.2.3. Watching additional paths.md} (100%) rename III. Using Spring Boot/{20.2.3. Disabling restart.md => 20.2.4. Disabling restart.md} (100%) rename III. Using Spring Boot/{20.2.4. Using a trigger file.md => 20.2.5. Using a trigger file.md} (100%) rename III. Using Spring Boot/{20.2.5. Customizing the restart classloader.md => 20.2.6. Customizing the restart classloader.md} (100%) rename III. Using Spring Boot/{20.2.6. Known limitations.md => 20.2.7. Known limitations.md} (100%) diff --git a/III. Using Spring Boot/20.2.1. Excluding resources.md b/III. Using Spring Boot/20.2.2. Excluding resources.md similarity index 100% rename from III. Using Spring Boot/20.2.1. Excluding resources.md rename to III. Using Spring Boot/20.2.2. Excluding resources.md diff --git a/III. Using Spring Boot/20.2.2. Watching additional paths.md b/III. Using Spring Boot/20.2.3. Watching additional paths.md similarity index 100% rename from III. Using Spring Boot/20.2.2. Watching additional paths.md rename to III. Using Spring Boot/20.2.3. Watching additional paths.md diff --git a/III. Using Spring Boot/20.2.3. Disabling restart.md b/III. Using Spring Boot/20.2.4. Disabling restart.md similarity index 100% rename from III. Using Spring Boot/20.2.3. Disabling restart.md rename to III. Using Spring Boot/20.2.4. Disabling restart.md diff --git a/III. Using Spring Boot/20.2.4. Using a trigger file.md b/III. Using Spring Boot/20.2.5. Using a trigger file.md similarity index 100% rename from III. Using Spring Boot/20.2.4. Using a trigger file.md rename to III. Using Spring Boot/20.2.5. Using a trigger file.md diff --git a/III. Using Spring Boot/20.2.5. Customizing the restart classloader.md b/III. Using Spring Boot/20.2.6. Customizing the restart classloader.md similarity index 100% rename from III. Using Spring Boot/20.2.5. Customizing the restart classloader.md rename to III. Using Spring Boot/20.2.6. Customizing the restart classloader.md diff --git a/III. Using Spring Boot/20.2.6. Known limitations.md b/III. Using Spring Boot/20.2.7. Known limitations.md similarity index 100% rename from III. Using Spring Boot/20.2.6. Known limitations.md rename to III. Using Spring Boot/20.2.7. Known limitations.md diff --git a/SUMMARY.md b/SUMMARY.md index 41d4d059..3fb8e55a 100644 --- a/SUMMARY.md +++ b/SUMMARY.md @@ -65,12 +65,12 @@ * [20.1. 默认属性](III. Using Spring Boot/20.1. Property Defaults.md) * [20.2. 自动重启](III. Using Spring Boot/20.2. Automatic Restart.md) * [20.2.1. 在状况评估里记录更改](III. Using Spring Boot/20.2.1. Logging changes in condition evaluation.md) - * [20.2.1. 排除资源](III. Using Spring Boot/20.2.1. Excluding resources.md) - * [20.2.2. 查看其他路径](III. Using Spring Boot/20.2.2. Watching additional paths.md) - * [20.2.3. 禁用重启](III. Using Spring Boot/20.2.3. Disabling restart.md) - * [20.2.4. 使用触发器文件](III. Using Spring Boot/20.2.4. Using a trigger file.md) - * [20.2.5. 自定义restart类加载器](III. Using Spring Boot/20.2.5. Customizing the restart classloader.md) - * [20.2.6. 已知限制](III. Using Spring Boot/20.2.6. Known limitations.md) + * [20.2.2. 排除资源](III. Using Spring Boot/20.2.2. Excluding resources.md) + * [20.2.3. 查看其他路径](III. Using Spring Boot/20.2.3. Watching additional paths.md) + * [20.2.4. 禁用重启](III. Using Spring Boot/20.2.4. Disabling restart.md) + * [20.2.5. 使用触发器文件](III. Using Spring Boot/20.2.5. Using a trigger file.md) + * [20.2.6. 自定义restart类加载器](III. Using Spring Boot/20.2.6. Customizing the restart classloader.md) + * [20.2.7. 已知限制](III. Using Spring Boot/20.2.7. Known limitations.md) * [20.3. LiveReload](III. Using Spring Boot/20.3. LiveReload.md) * [20.4. 全局设置](III. Using Spring Boot/20.4. Global settings.md) * [20.5. 远程应用](III. Using Spring Boot/20.5. Remote applications.md) From 6fda3e783205a4b242d739655037f02e58af72fc Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E7=83=AD=E5=BF=83=E5=B8=82=E6=B0=91=E9=92=9F=E5=B0=8F?= =?UTF-8?q?=E5=BC=BA?= Date: Thu, 26 Apr 2018 17:09:57 +0800 Subject: [PATCH 068/865] Update and rename 20.2.2. Excluding resources.md to 20.2.2. Excluding Resources.md --- ...2. Excluding resources.md => 20.2.2. Excluding Resources.md} | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) rename III. Using Spring Boot/{20.2.2. Excluding resources.md => 20.2.2. Excluding Resources.md} (81%) diff --git a/III. Using Spring Boot/20.2.2. Excluding resources.md b/III. Using Spring Boot/20.2.2. Excluding Resources.md similarity index 81% rename from III. Using Spring Boot/20.2.2. Excluding resources.md rename to III. Using Spring Boot/20.2.2. Excluding Resources.md index 41d7ca5d..f9da03e7 100644 --- a/III. Using Spring Boot/20.2.2. Excluding resources.md +++ b/III. Using Spring Boot/20.2.2. Excluding Resources.md @@ -1,6 +1,6 @@ ### 20.2.1 排除资源 -某些资源的变化没必要触发重启,比如Thymeleaf模板可以随时编辑。默认情况下,位于`/META-INF/maven`,`/META-INF/resources`,`/resources`,`/static`,`/public`或`/templates`下的资源变更不会触发重启,但会触发实时加载(live reload)。你可以使用`spring.devtools.restart.exclude`属性自定义这些排除规则,比如,为了只排除`/static`和`/public`,你可以这样设置: +某些资源的变化没必要触发重启,比如Thymeleaf模板可以随时编辑。默认情况下,位于`/META-INF/maven`,`/META-INF/resources`,`/resources`,`/static`,`/public`或`/templates`下的资源变更不会触发重启,但会触发实时重载(live reload)。你可以使用`spring.devtools.restart.exclude`属性自定义这些排除规则,比如,为了只排除`/static`和`/public`,你可以设置如下属性: ```properties spring.devtools.restart.exclude=static/**,public/** ``` From d47a5e966fc2844c04c4c49c2657cf136b6cd833 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E7=83=AD=E5=BF=83=E5=B8=82=E6=B0=91=E9=92=9F=E5=B0=8F?= =?UTF-8?q?=E5=BC=BA?= Date: Thu, 26 Apr 2018 17:12:49 +0800 Subject: [PATCH 069/865] Update and rename 20.2.3. Watching additional paths.md to 20.2.3. Watching Additional Paths.md --- ...ditional paths.md => 20.2.3. Watching Additional Paths.md} | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) rename III. Using Spring Boot/{20.2.3. Watching additional paths.md => 20.2.3. Watching Additional Paths.md} (59%) diff --git a/III. Using Spring Boot/20.2.3. Watching additional paths.md b/III. Using Spring Boot/20.2.3. Watching Additional Paths.md similarity index 59% rename from III. Using Spring Boot/20.2.3. Watching additional paths.md rename to III. Using Spring Boot/20.2.3. Watching Additional Paths.md index b2145a57..2a1ec55d 100644 --- a/III. Using Spring Boot/20.2.3. Watching additional paths.md +++ b/III. Using Spring Boot/20.2.3. Watching Additional Paths.md @@ -1,3 +1,3 @@ -###20.2.2 查看其他路径 +### 20.2.2 查看其他路径 -如果想让应用在改变没有位于classpath下的文件时也会重启或重新加载,你可以使用`spring.devtools.restart.additional-paths`属性来配置监控变化的额外路径。你可以使用[上面描述](./20.2.1 Excluding resources.md)过的`spring.devtools.restart.exclude`属性去控制额外路径下的变化是否触发一个完整重启或只是一个实时重新加载。 +如果想让应用在改变没有位于classpath下的文件时也会重启或重新加载,你可以使用`spring.devtools.restart.additional-paths`属性来配置监控变化的额外路径。你可以使用[之前描述](./20.2.2 Excluding Resources.md)过的`spring.devtools.restart.exclude`属性去控制额外路径下的变化是否触发一个完整重启或一个实时重新加载。 From e791e89ca0ff8e82d17c6123a33251f98a9b2500 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E7=83=AD=E5=BF=83=E5=B8=82=E6=B0=91=E9=92=9F=E5=B0=8F?= =?UTF-8?q?=E5=BC=BA?= Date: Thu, 26 Apr 2018 17:13:19 +0800 Subject: [PATCH 070/865] Update 20.2.3. Watching Additional Paths.md --- III. Using Spring Boot/20.2.3. Watching Additional Paths.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/III. Using Spring Boot/20.2.3. Watching Additional Paths.md b/III. Using Spring Boot/20.2.3. Watching Additional Paths.md index 2a1ec55d..dda43811 100644 --- a/III. Using Spring Boot/20.2.3. Watching Additional Paths.md +++ b/III. Using Spring Boot/20.2.3. Watching Additional Paths.md @@ -1,3 +1,3 @@ -### 20.2.2 查看其他路径 +### 20.2.3 查看其他路径 如果想让应用在改变没有位于classpath下的文件时也会重启或重新加载,你可以使用`spring.devtools.restart.additional-paths`属性来配置监控变化的额外路径。你可以使用[之前描述](./20.2.2 Excluding Resources.md)过的`spring.devtools.restart.exclude`属性去控制额外路径下的变化是否触发一个完整重启或一个实时重新加载。 From 129151e9a5d992c63d864a8b859a4c4d35bf9649 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E7=83=AD=E5=BF=83=E5=B8=82=E6=B0=91=E9=92=9F=E5=B0=8F?= =?UTF-8?q?=E5=BC=BA?= Date: Thu, 26 Apr 2018 17:13:50 +0800 Subject: [PATCH 071/865] Update 20.2.2. Excluding Resources.md --- III. Using Spring Boot/20.2.2. Excluding Resources.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/III. Using Spring Boot/20.2.2. Excluding Resources.md b/III. Using Spring Boot/20.2.2. Excluding Resources.md index f9da03e7..0ae04c9f 100644 --- a/III. Using Spring Boot/20.2.2. Excluding Resources.md +++ b/III. Using Spring Boot/20.2.2. Excluding Resources.md @@ -1,4 +1,4 @@ -### 20.2.1 排除资源 +### 20.2.2 排除资源 某些资源的变化没必要触发重启,比如Thymeleaf模板可以随时编辑。默认情况下,位于`/META-INF/maven`,`/META-INF/resources`,`/resources`,`/static`,`/public`或`/templates`下的资源变更不会触发重启,但会触发实时重载(live reload)。你可以使用`spring.devtools.restart.exclude`属性自定义这些排除规则,比如,为了只排除`/static`和`/public`,你可以设置如下属性: ```properties From 909489fc1894a5c7b094c7c35e716edcb1786c4f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E7=83=AD=E5=BF=83=E5=B8=82=E6=B0=91=E9=92=9F=E5=B0=8F?= =?UTF-8?q?=E5=BC=BA?= Date: Thu, 26 Apr 2018 17:23:14 +0800 Subject: [PATCH 072/865] Update and rename 20.2.4. Disabling restart.md to 20.2.4. Disabling Restart.md --- ...4. Disabling restart.md => 20.2.4. Disabling Restart.md} | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) rename III. Using Spring Boot/{20.2.4. Disabling restart.md => 20.2.4. Disabling Restart.md} (53%) diff --git a/III. Using Spring Boot/20.2.4. Disabling restart.md b/III. Using Spring Boot/20.2.4. Disabling Restart.md similarity index 53% rename from III. Using Spring Boot/20.2.4. Disabling restart.md rename to III. Using Spring Boot/20.2.4. Disabling Restart.md index fe0e1796..56aefed9 100644 --- a/III. Using Spring Boot/20.2.4. Disabling restart.md +++ b/III. Using Spring Boot/20.2.4. Disabling Restart.md @@ -1,8 +1,8 @@ -###20.2.3 禁用重启 +### 20.2.4 禁用重启 -如果不想使用重启特性,你可以通过`spring.devtools.restart.enabled`属性来禁用它,通常情况下可以在`application.properties`文件中设置(依旧会初始化重启类加载器,但它不会监控文件变化)。 +如果不想使用重启特性,你可以通过`spring.devtools.restart.enabled`属性来禁用它。通常情况下可以在`application.properties`文件中设置(依旧会初始化重启类加载器,但它不会监控文件变化)。 -如果需要彻底禁用重启支持,比如,不能跟某个特殊库一块工作,你需要在调用`SpringApplication.run(…​)`之前设置一个系统属性,如下: +如果需要彻底禁用重启支持(比如,不能跟某个特殊库一块工作),你需要在调用`SpringApplication.run(…)`之前,把系统属性`spring.devtools.restart.enabled`设置为`false`,如下: ```java public static void main(String[] args) { System.setProperty("spring.devtools.restart.enabled", "false"); From 405c346603a9448483ba0ee2da5de8f50120e931 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E7=83=AD=E5=BF=83=E5=B8=82=E6=B0=91=E9=92=9F=E5=B0=8F?= =?UTF-8?q?=E5=BC=BA?= Date: Thu, 26 Apr 2018 17:27:37 +0800 Subject: [PATCH 073/865] Update SUMMARY.md --- SUMMARY.md | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/SUMMARY.md b/SUMMARY.md index 3fb8e55a..bcbd4801 100644 --- a/SUMMARY.md +++ b/SUMMARY.md @@ -65,9 +65,9 @@ * [20.1. 默认属性](III. Using Spring Boot/20.1. Property Defaults.md) * [20.2. 自动重启](III. Using Spring Boot/20.2. Automatic Restart.md) * [20.2.1. 在状况评估里记录更改](III. Using Spring Boot/20.2.1. Logging changes in condition evaluation.md) - * [20.2.2. 排除资源](III. Using Spring Boot/20.2.2. Excluding resources.md) - * [20.2.3. 查看其他路径](III. Using Spring Boot/20.2.3. Watching additional paths.md) - * [20.2.4. 禁用重启](III. Using Spring Boot/20.2.4. Disabling restart.md) + * [20.2.2. 排除资源](III. Using Spring Boot/20.2.2. Excluding Resources.md) + * [20.2.3. 查看其他路径](III. Using Spring Boot/20.2.3. Watching Additional Paths.md) + * [20.2.4. 禁用重启](III. Using Spring Boot/20.2.4. Disabling Restart.md) * [20.2.5. 使用触发器文件](III. Using Spring Boot/20.2.5. Using a trigger file.md) * [20.2.6. 自定义restart类加载器](III. Using Spring Boot/20.2.6. Customizing the restart classloader.md) * [20.2.7. 已知限制](III. Using Spring Boot/20.2.7. Known limitations.md) From 86b3678abac97236cfd062163aeaeb6d69ab7d30 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E7=83=AD=E5=BF=83=E5=B8=82=E6=B0=91=E9=92=9F=E5=B0=8F?= =?UTF-8?q?=E5=BC=BA?= Date: Thu, 26 Apr 2018 18:00:49 +0800 Subject: [PATCH 074/865] Update and rename 20.2.5. Using a trigger file.md to 20.2.5. Using a Trigger File.md --- ... a trigger file.md => 20.2.5. Using a Trigger File.md} | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) rename III. Using Spring Boot/{20.2.5. Using a trigger file.md => 20.2.5. Using a Trigger File.md} (51%) diff --git a/III. Using Spring Boot/20.2.5. Using a trigger file.md b/III. Using Spring Boot/20.2.5. Using a Trigger File.md similarity index 51% rename from III. Using Spring Boot/20.2.5. Using a trigger file.md rename to III. Using Spring Boot/20.2.5. Using a Trigger File.md index 4bc94c30..a349eb2f 100644 --- a/III. Using Spring Boot/20.2.5. Using a trigger file.md +++ b/III. Using Spring Boot/20.2.5. Using a Trigger File.md @@ -1,7 +1,7 @@ -###20.2.4 使用触发器文件 +### 20.2.4 使用触发器文件 -如果使用一个IDE连续不断地编译变化的文件,你可能倾向于只在特定时间触发重启,触发器文件可以帮你实现该功能。触发器文件是一个特殊的文件,只有修改它才能实际触发一个重启检测。改变该文件只会触发检测,实际的重启只会在Devtools发现它必须这样做的时候,触发器文件可以手动更新,也可以通过IDE插件更新。 +如果使用一个IDE连续不断地编译变化的文件,你可能倾向于只在特定时间触发重启,触发器文件可以帮你实现该功能。触发器文件是一个特殊的文件,只有修改它才能实际触发一个重启检测。改变该文件只会触发检测,实际的重启只会在Devtools发现它必须这样做的时候。触发器文件可以手动更新,也可以通过IDE插件更新。 -使用`spring.devtools.restart.trigger-file`属性可以指定触发器文件。 +为了使用触发器文件,把`spring.devtools.restart.trigger-file`属性设置为你的触发器文件的路径。 -**注** 你可能想将`spring.devtools.restart.trigger-file`属性设置为[全局设置](http://docs.spring.io/spring-boot/docs/current-SNAPSHOT/reference/htmlsingle/#using-boot-devtools-globalsettings),这样所有的工程表现都会相同。 +**注** 你可能想将`spring.devtools.restart.trigger-file`属性设置为[全局设置](https://docs.spring.io/spring-boot/docs/2.0.0.RELEASE/reference/htmlsingle/#using-boot-devtools-globalsettings),这样所有的工程表现都会相同。 From 3e4254aae86e9518b7a3970e03acf41c0937a4c9 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E7=83=AD=E5=BF=83=E5=B8=82=E6=B0=91=E9=92=9F=E5=B0=8F?= =?UTF-8?q?=E5=BC=BA?= Date: Thu, 26 Apr 2018 18:01:54 +0800 Subject: [PATCH 075/865] Update 20.2.5. Using a Trigger File.md --- III. Using Spring Boot/20.2.5. Using a Trigger File.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/III. Using Spring Boot/20.2.5. Using a Trigger File.md b/III. Using Spring Boot/20.2.5. Using a Trigger File.md index a349eb2f..ff9d4f6d 100644 --- a/III. Using Spring Boot/20.2.5. Using a Trigger File.md +++ b/III. Using Spring Boot/20.2.5. Using a Trigger File.md @@ -1,4 +1,4 @@ -### 20.2.4 使用触发器文件 +### 20.2.5 使用触发器文件 如果使用一个IDE连续不断地编译变化的文件,你可能倾向于只在特定时间触发重启,触发器文件可以帮你实现该功能。触发器文件是一个特殊的文件,只有修改它才能实际触发一个重启检测。改变该文件只会触发检测,实际的重启只会在Devtools发现它必须这样做的时候。触发器文件可以手动更新,也可以通过IDE插件更新。 From 11365212f6f2645658c4245925bc7303abf794f3 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E7=83=AD=E5=BF=83=E5=B8=82=E6=B0=91=E9=92=9F=E5=B0=8F?= =?UTF-8?q?=E5=BC=BA?= Date: Thu, 26 Apr 2018 18:07:23 +0800 Subject: [PATCH 076/865] Update and rename 20.2.6. Customizing the restart classloader.md to 20.2.6. Customizing the Restart Classloader.md --- ...> 20.2.6. Customizing the Restart Classloader.md} | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) rename III. Using Spring Boot/{20.2.6. Customizing the restart classloader.md => 20.2.6. Customizing the Restart Classloader.md} (59%) diff --git a/III. Using Spring Boot/20.2.6. Customizing the restart classloader.md b/III. Using Spring Boot/20.2.6. Customizing the Restart Classloader.md similarity index 59% rename from III. Using Spring Boot/20.2.6. Customizing the restart classloader.md rename to III. Using Spring Boot/20.2.6. Customizing the Restart Classloader.md index 2e8bf124..d583214d 100644 --- a/III. Using Spring Boot/20.2.6. Customizing the restart classloader.md +++ b/III. Using Spring Boot/20.2.6. Customizing the Restart Classloader.md @@ -1,12 +1,12 @@ -###20.2.5 自定义restart类加载器 +### 20.2.5 自定义restart类加载器 -正如以上[Restart vs Reload](http://docs.spring.io/spring-boot/docs/current-SNAPSHOT/reference/htmlsingle/#using-spring-boot-restart-vs-reload)章节讨论的,重启功能是通过两个类加载器实现的。对于大部分应用来说是没问题的,但有时候它可能导致类加载问题。 +正如之前[Restart vs Reload](https://docs.spring.io/spring-boot/docs/2.0.0.RELEASE/reference/htmlsingle/#using-spring-boot-restart-vs-reload)章节讨论的,重启功能是通过两个类加载器实现的。对于大部分应用来说是没问题的,但有时候它可能导致类加载问题。 -默认情况,在IDE里打开的项目会通过'restart'类加载器加载,其他常规的`.jar`文件会使用'basic'类加载器加载。如果你工作在一个多模块的项目下,并且不是每个模块都导入IDE里,你可能需要自定义一些东西。你需要创建一个`META-INF/spring-devtools.properties`文件,`spring-devtools.properties`文件可以包含`restart.exclude.`,`restart.include.`前缀的属性。`include`元素定义了那些需要加载进'restart'类加载器中的实体,`exclude`元素定义了那些需要加载进'basic'类加载器中的实体,这些属性的值是一个将应用到classpath的正则表达式。 - -例如: +默认情况,在IDE里打开的项目会通过'restart'类加载器加载,其他常规的`.jar`文件会使用'basic'类加载器加载。如果你工作在一个多模块的项目下,并且不是每个模块都导入IDE里,你可能需要自定义一些东西。你需要创建一个`META-INF/spring-devtools.properties`文件,`spring-devtools.properties`文件可以包含`restart.exclude.`,`restart.include.`前缀的属性。`include`元素定义了那些需要加载进'restart'类加载器中的实体,`exclude`元素定义了那些需要加载进'basic'类加载器中的实体,这些属性的值是一个将应用到classpath的正则表达式。例如: ```properties restart.include.companycommonlibs=/mycorp-common-[\\w-]+\.jar restart.include.projectcommon=/mycorp-myproj-[\\w-]+\.jar ``` -**注** 所有属性的keys必须唯一,只要以`restart.include.`或`restart.exclude.`开头都会考虑进去。所有来自classpath的`META-INF/spring-devtools.properties`都会被加载,你可以将文件打包进工程或工程使用的库里。 +**注** 所有属性的keys必须唯一,只要以`restart.include.`或`restart.exclude.`开头都会考虑进去。 + +**注** 所有来自classpath的`META-INF/spring-devtools.properties`都会被加载,你可以将文件打包进工程或工程使用的库里。 From 63c3a885d7690a0d22a6d049e4b43d7f11c9dbbe Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E7=83=AD=E5=BF=83=E5=B8=82=E6=B0=91=E9=92=9F=E5=B0=8F?= =?UTF-8?q?=E5=BC=BA?= Date: Thu, 26 Apr 2018 18:08:04 +0800 Subject: [PATCH 077/865] Update 20.2.6. Customizing the Restart Classloader.md --- .../20.2.6. Customizing the Restart Classloader.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/III. Using Spring Boot/20.2.6. Customizing the Restart Classloader.md b/III. Using Spring Boot/20.2.6. Customizing the Restart Classloader.md index d583214d..32a16242 100644 --- a/III. Using Spring Boot/20.2.6. Customizing the Restart Classloader.md +++ b/III. Using Spring Boot/20.2.6. Customizing the Restart Classloader.md @@ -1,4 +1,4 @@ -### 20.2.5 自定义restart类加载器 +### 20.2.6 自定义restart类加载器 正如之前[Restart vs Reload](https://docs.spring.io/spring-boot/docs/2.0.0.RELEASE/reference/htmlsingle/#using-spring-boot-restart-vs-reload)章节讨论的,重启功能是通过两个类加载器实现的。对于大部分应用来说是没问题的,但有时候它可能导致类加载问题。 From 8cfd0610ff41e18b11b870f2d83c56f02f820d77 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E7=83=AD=E5=BF=83=E5=B8=82=E6=B0=91=E9=92=9F=E5=B0=8F?= =?UTF-8?q?=E5=BC=BA?= Date: Thu, 26 Apr 2018 18:09:47 +0800 Subject: [PATCH 078/865] Update and rename 20.2.7. Known limitations.md to 20.2.7. Known Limitations.md --- ...0.2.7. Known limitations.md => 20.2.7. Known Limitations.md} | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) rename III. Using Spring Boot/{20.2.7. Known limitations.md => 20.2.7. Known Limitations.md} (94%) diff --git a/III. Using Spring Boot/20.2.7. Known limitations.md b/III. Using Spring Boot/20.2.7. Known Limitations.md similarity index 94% rename from III. Using Spring Boot/20.2.7. Known limitations.md rename to III. Using Spring Boot/20.2.7. Known Limitations.md index b7a4e045..d27a5d0c 100644 --- a/III. Using Spring Boot/20.2.7. Known limitations.md +++ b/III. Using Spring Boot/20.2.7. Known Limitations.md @@ -1,4 +1,4 @@ -###20.2.6 已知限制 +### 20.2.7 已知限制 重启功能不能跟使用标准`ObjectInputStream`反序列化的对象工作,如果需要反序列化数据,你可能需要使用Spring的`ConfigurableObjectInputStream`,并结合`Thread.currentThread().getContextClassLoader()`。 From 8b11eec9336ac00441ca36d19bb45bbb7a9e04b4 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E7=83=AD=E5=BF=83=E5=B8=82=E6=B0=91=E9=92=9F=E5=B0=8F?= =?UTF-8?q?=E5=BC=BA?= Date: Thu, 26 Apr 2018 18:11:10 +0800 Subject: [PATCH 079/865] Update SUMMARY.md --- SUMMARY.md | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/SUMMARY.md b/SUMMARY.md index bcbd4801..4381d796 100644 --- a/SUMMARY.md +++ b/SUMMARY.md @@ -68,9 +68,9 @@ * [20.2.2. 排除资源](III. Using Spring Boot/20.2.2. Excluding Resources.md) * [20.2.3. 查看其他路径](III. Using Spring Boot/20.2.3. Watching Additional Paths.md) * [20.2.4. 禁用重启](III. Using Spring Boot/20.2.4. Disabling Restart.md) - * [20.2.5. 使用触发器文件](III. Using Spring Boot/20.2.5. Using a trigger file.md) - * [20.2.6. 自定义restart类加载器](III. Using Spring Boot/20.2.6. Customizing the restart classloader.md) - * [20.2.7. 已知限制](III. Using Spring Boot/20.2.7. Known limitations.md) + * [20.2.5. 使用触发器文件](III. Using Spring Boot/20.2.5. Using a Trigger File.md) + * [20.2.6. 自定义restart类加载器](III. Using Spring Boot/20.2.6. Customizing the Restart Classloader.md) + * [20.2.7. 已知限制](III. Using Spring Boot/20.2.7. Known Limitations.md) * [20.3. LiveReload](III. Using Spring Boot/20.3. LiveReload.md) * [20.4. 全局设置](III. Using Spring Boot/20.4. Global settings.md) * [20.5. 远程应用](III. Using Spring Boot/20.5. Remote applications.md) From 6928661d20ee444a0bf0d738eea877bcd414a3db Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E7=83=AD=E5=BF=83=E5=B8=82=E6=B0=91=E9=92=9F=E5=B0=8F?= =?UTF-8?q?=E5=BC=BA?= Date: Fri, 27 Apr 2018 14:16:35 +0800 Subject: [PATCH 080/865] Update 20.3. LiveReload.md --- III. Using Spring Boot/20.3. LiveReload.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/III. Using Spring Boot/20.3. LiveReload.md b/III. Using Spring Boot/20.3. LiveReload.md index e9be8d28..d83c6ddc 100644 --- a/III. Using Spring Boot/20.3. LiveReload.md +++ b/III. Using Spring Boot/20.3. LiveReload.md @@ -1,7 +1,7 @@ -###20.3 LiveReload +### 20.3 LiveReload `spring-boot-devtools`模块包含一个内嵌的LiveReload服务器,它可以在资源改变时触发浏览器刷新。LiveReload浏览器扩展可以免费从[livereload.com](http://livereload.com/extensions/)站点获取,支持Chrome,Firefox,Safari等浏览器。 如果不想在运行应用时启动LiveReload服务器,你可以将`spring.devtools.livereload.enabled`属性设置为false。 -**注** 每次只能运行一个LiveReload服务器。在启动应用之前,确保没有其它的LiveReload服务器正在运行。如果你在IDE中启动多个应用,只有第一个能够获得动态加载功能。 +**注** 每次只能运行一个LiveReload服务器。在启动应用之前,确保没有其它的LiveReload服务器正在运行。如果你在IDE中启动多个应用,只有第一个能够获得动态重载功能。 From 4a8b0122c74b330652b8a44c8fa8ee46a4ec7cc9 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E7=83=AD=E5=BF=83=E5=B8=82=E6=B0=91=E9=92=9F=E5=B0=8F?= =?UTF-8?q?=E5=BC=BA?= Date: Fri, 27 Apr 2018 14:22:03 +0800 Subject: [PATCH 081/865] Update and rename 20.4. Global settings.md to 20.4. Global Settings.md --- .../{20.4. Global settings.md => 20.4. Global Settings.md} | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) rename III. Using Spring Boot/{20.4. Global settings.md => 20.4. Global Settings.md} (84%) diff --git a/III. Using Spring Boot/20.4. Global settings.md b/III. Using Spring Boot/20.4. Global Settings.md similarity index 84% rename from III. Using Spring Boot/20.4. Global settings.md rename to III. Using Spring Boot/20.4. Global Settings.md index f1dfe24a..9f38d0f4 100644 --- a/III. Using Spring Boot/20.4. Global settings.md +++ b/III. Using Spring Boot/20.4. Global Settings.md @@ -1,8 +1,8 @@ -###20.4 全局设置 +### 20.4 全局设置 -在`$HOME`文件夹下添加一个`.spring-boot-devtools.properties`的文件可以用来配置全局的devtools设置(注意文件名以"."开头),添加进该文件的任何属性都会应用到你机器上使用该devtools的Spring Boot应用。例如,想使用触发器文件进行重启,可以添加如下配置: +在`$HOME`文件夹下添加一个`.spring-boot-devtools.properties`的文件可以用来配置全局的devtools设置(注意文件名以"."开头),添加进该文件的任何属性都会应用到你机器上使用该devtools的Spring Boot应用。例如,想使用触发器文件进行重启,可以添加如下属性: -~/.spring-boot-devtools.properties. +**~/.spring-boot-devtools.properties.** ```properties spring.devtools.reload.trigger-file=.reloadtrigger ``` From b628865777d8a983a697528f011a0208b8f5e5e3 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E7=83=AD=E5=BF=83=E5=B8=82=E6=B0=91=E9=92=9F=E5=B0=8F?= =?UTF-8?q?=E5=BC=BA?= Date: Fri, 27 Apr 2018 14:26:31 +0800 Subject: [PATCH 082/865] Update and rename 20.5. Remote applications.md to 20.5. Remote Applications.md --- ...5. Remote applications.md => 20.5. Remote Applications.md} | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) rename III. Using Spring Boot/{20.5. Remote applications.md => 20.5. Remote Applications.md} (88%) diff --git a/III. Using Spring Boot/20.5. Remote applications.md b/III. Using Spring Boot/20.5. Remote Applications.md similarity index 88% rename from III. Using Spring Boot/20.5. Remote applications.md rename to III. Using Spring Boot/20.5. Remote Applications.md index c6b686b9..6446aa43 100644 --- a/III. Using Spring Boot/20.5. Remote applications.md +++ b/III. Using Spring Boot/20.5. Remote Applications.md @@ -1,6 +1,6 @@ -###20.5 远程应用 +### 20.5 远程应用 -Spring Boot开发者工具并不仅限于本地开发,在运行远程应用时你也可以使用一些特性。远程支持是可选的,你需要确保开发者工具被包含在重新打包的归档文件中。 +Spring Boot开发者工具并不仅限于本地开发,在运行远程应用时你也可以使用一些特性。远程支持是可选的。启用远程支持,你需要确保开发者工具被包含在重新打包的归档文件中。 ```properties From 5afc8f18fdad2bf46ab48dfac2bcb989e90140c6 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E7=83=AD=E5=BF=83=E5=B8=82=E6=B0=91=E9=92=9F=E5=B0=8F?= =?UTF-8?q?=E5=BC=BA?= Date: Fri, 27 Apr 2018 14:53:38 +0800 Subject: [PATCH 083/865] Update and rename 20.5.1. Running the remote client application.md to 20.5.1. Running the Remote Client Application.md --- ...d => 20.5.1. Running the Remote Client Application.md} | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) rename III. Using Spring Boot/{20.5.1. Running the remote client application.md => 20.5.1. Running the Remote Client Application.md} (88%) diff --git a/III. Using Spring Boot/20.5.1. Running the remote client application.md b/III. Using Spring Boot/20.5.1. Running the Remote Client Application.md similarity index 88% rename from III. Using Spring Boot/20.5.1. Running the remote client application.md rename to III. Using Spring Boot/20.5.1. Running the Remote Client Application.md index d1f7f7c5..27d01a68 100644 --- a/III. Using Spring Boot/20.5.1. Running the remote client application.md +++ b/III. Using Spring Boot/20.5.1. Running the Remote Client Application.md @@ -1,5 +1,6 @@ -###20.5.1 运行远程客户端应用 -远程客户端应用程序(remote client application)需要在你的IDE中运行,你需要使用跟将要连接的远程应用相同的classpath运行`org.springframework.boot.devtools.RemoteSpringApplication`,传参为你要连接的远程应用URL。例如,你正在使用Eclipse或STS,并有一个部署到Cloud Foundry的`my-app`工程,远程连接该应用需要做以下操作: +### 20.5.1 运行远程客户端应用 + +远程客户端应用程序(remote client application)需要在你的IDE中运行。你需要使用跟将要连接的远程应用相同的classpath运行`org.springframework.boot.devtools.RemoteSpringApplication`。应用需要的唯一一个参数是你要连接的远程应用URL。例如,你正在使用Eclipse或STS,并有一个部署到Cloud Foundry的`my-app`工程,远程连接该应用需要做以下操作: * 从`Run`菜单选择`Run Configurations…`。 * 创建一个新的`Java Application`启动配置(launch configuration)。 * 浏览`my-app`工程。 @@ -7,7 +8,7 @@ * 将`https://myapp.cfapps.io`作为参数传递给`RemoteSpringApplication`(或其他任何远程URL)。 运行中的远程客户端看起来如下: -```shell +``` . ____ _ __ _ _ /\\ / ___'_ __ _ _(_)_ __ __ _ ___ _ \ \ \ \ ( ( )\___ | '_ | '_| | '_ \/ _` | | _ \___ _ __ ___| |_ ___ \ \ \ \ @@ -28,4 +29,3 @@ 强烈建议使用`https://`作为连接协议,这样传输通道是加密的,密码也不会被截获。 如果需要使用代理连接远程应用,你需要配置`spring.devtools.remote.proxy.host`和`spring.devtools.remote.proxy.port`属性。 - From ef7ba7f2a8ebef346be68294f43f269422073f25 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E7=83=AD=E5=BF=83=E5=B8=82=E6=B0=91=E9=92=9F=E5=B0=8F?= =?UTF-8?q?=E5=BC=BA?= Date: Fri, 27 Apr 2018 14:56:57 +0800 Subject: [PATCH 084/865] Update SUMMARY.md --- SUMMARY.md | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/SUMMARY.md b/SUMMARY.md index 4381d796..6c84cbf4 100644 --- a/SUMMARY.md +++ b/SUMMARY.md @@ -72,9 +72,9 @@ * [20.2.6. 自定义restart类加载器](III. Using Spring Boot/20.2.6. Customizing the Restart Classloader.md) * [20.2.7. 已知限制](III. Using Spring Boot/20.2.7. Known Limitations.md) * [20.3. LiveReload](III. Using Spring Boot/20.3. LiveReload.md) - * [20.4. 全局设置](III. Using Spring Boot/20.4. Global settings.md) - * [20.5. 远程应用](III. Using Spring Boot/20.5. Remote applications.md) - * [20.5.1. 运行远程客户端应用](III. Using Spring Boot/20.5.1. Running the remote client application.md) +      * [20.4. 全局设置](III. Using Spring Boot/20.4. Global Settings.md) + * [20.5. 远程应用](III. Using Spring Boot/20.5. Remote Applications.md) + * [20.5.1. 运行远程客户端应用](III. Using Spring Boot/20.5.1. Running the Remote Client Application.md) * [20.5.2. 远程更新](III. Using Spring Boot/20.5.2. Remote update.md) * [21. 打包用于生产的应用](III. Using Spring Boot/21. Packaging your application for production.md) * [22. 接下来阅读什么](III. Using Spring Boot/22. What to read next.md) From fde5a4a987b84c8c449e9dfa68318cb41608e50f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E7=83=AD=E5=BF=83=E5=B8=82=E6=B0=91=E9=92=9F=E5=B0=8F?= =?UTF-8?q?=E5=BC=BA?= Date: Fri, 27 Apr 2018 15:05:04 +0800 Subject: [PATCH 085/865] Update and rename 20.5.2. Remote update.md to 20.5.2. Remote Update.md --- .../{20.5.2. Remote update.md => 20.5.2. Remote Update.md} | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) rename III. Using Spring Boot/{20.5.2. Remote update.md => 20.5.2. Remote Update.md} (64%) diff --git a/III. Using Spring Boot/20.5.2. Remote update.md b/III. Using Spring Boot/20.5.2. Remote Update.md similarity index 64% rename from III. Using Spring Boot/20.5.2. Remote update.md rename to III. Using Spring Boot/20.5.2. Remote Update.md index 6c3b7f69..d9bf0017 100644 --- a/III. Using Spring Boot/20.5.2. Remote update.md +++ b/III. Using Spring Boot/20.5.2. Remote Update.md @@ -1,4 +1,5 @@ -###20.5.2 远程更新 -远程客户端将监听应用的classpath变化,任何更新的资源都会发布到远程应用,并触发重启,这在你使用云服务迭代某个特性时非常有用。通常远程更新和重启比完整rebuild和deploy快多了。 +### 20.5.2 远程更新 + +远程客户端将监听应用的classpath变化。任何更新的资源都会发布到远程应用,并触发重启。这在你使用云服务迭代某个特性时非常有用。通常远程更新和重启比完整rebuild和deploy快多了。 **注** 文件只有在远程客户端运行时才监控。如果你在启动远程客户端之前改变一个文件,它是不会被发布到远程server的。 From 041dc2fe5021281951b5ad11936f9d752972ab67 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E7=83=AD=E5=BF=83=E5=B8=82=E6=B0=91=E9=92=9F=E5=B0=8F?= =?UTF-8?q?=E5=BC=BA?= Date: Fri, 27 Apr 2018 15:08:33 +0800 Subject: [PATCH 086/865] Rename 21. Packaging your application for production.md to 21. Packaging Your Application for Production.md --- ...uction.md => 21. Packaging Your Application for Production.md} | 0 1 file changed, 0 insertions(+), 0 deletions(-) rename III. Using Spring Boot/{21. Packaging your application for production.md => 21. Packaging Your Application for Production.md} (100%) diff --git a/III. Using Spring Boot/21. Packaging your application for production.md b/III. Using Spring Boot/21. Packaging Your Application for Production.md similarity index 100% rename from III. Using Spring Boot/21. Packaging your application for production.md rename to III. Using Spring Boot/21. Packaging Your Application for Production.md From 4dcb643e4ea0c36dffe4a869b0b463e863458e0c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E7=83=AD=E5=BF=83=E5=B8=82=E6=B0=91=E9=92=9F=E5=B0=8F?= =?UTF-8?q?=E5=BC=BA?= Date: Fri, 27 Apr 2018 15:12:51 +0800 Subject: [PATCH 087/865] Update and rename 22. What to read next.md to 22. What to Read Next.md --- III. Using Spring Boot/22. What to Read Next.md | 3 +++ III. Using Spring Boot/22. What to read next.md | 2 -- 2 files changed, 3 insertions(+), 2 deletions(-) create mode 100644 III. Using Spring Boot/22. What to Read Next.md delete mode 100644 III. Using Spring Boot/22. What to read next.md diff --git a/III. Using Spring Boot/22. What to Read Next.md b/III. Using Spring Boot/22. What to Read Next.md new file mode 100644 index 00000000..79f7e020 --- /dev/null +++ b/III. Using Spring Boot/22. What to Read Next.md @@ -0,0 +1,3 @@ +### 22. 接下来阅读什么 + +现在你应该明白怎么结合最佳实践使用Spring Boot,接下来可以深入学习特殊的部分[Spring Boot特性](https://docs.spring.io/spring-boot/docs/2.0.0.RELEASE/reference/htmlsingle/#boot-features),或者你可以跳过开头,阅读Spring Boot的[production ready](https://docs.spring.io/spring-boot/docs/2.0.0.RELEASE/reference/htmlsingle/#production-ready)部分。 diff --git a/III. Using Spring Boot/22. What to read next.md b/III. Using Spring Boot/22. What to read next.md deleted file mode 100644 index 5ea0a862..00000000 --- a/III. Using Spring Boot/22. What to read next.md +++ /dev/null @@ -1,2 +0,0 @@ -### 22. 接下来阅读什么 -现在你应该明白怎么结合最佳实践使用Spring Boot,接下来可以深入学习特殊的部分[Spring Boot features](https://docs.spring.io/spring-boot/docs/2.0.0.RELEASE/reference/htmlsingle/#boot-features),或者你可以跳过开头,阅读Spring Boot的[production ready](https://docs.spring.io/spring-boot/docs/2.0.0.RELEASE/reference/htmlsingle/#production-ready)部分。 From 651975f104a8ac2286e21fab8c8df26f06b5ebe2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E7=83=AD=E5=BF=83=E5=B8=82=E6=B0=91=E9=92=9F=E5=B0=8F?= =?UTF-8?q?=E5=BC=BA?= Date: Fri, 27 Apr 2018 15:18:00 +0800 Subject: [PATCH 088/865] Update SUMMARY.md --- SUMMARY.md | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/SUMMARY.md b/SUMMARY.md index 6c84cbf4..7f2db89a 100644 --- a/SUMMARY.md +++ b/SUMMARY.md @@ -75,9 +75,9 @@      * [20.4. 全局设置](III. Using Spring Boot/20.4. Global Settings.md) * [20.5. 远程应用](III. Using Spring Boot/20.5. Remote Applications.md) * [20.5.1. 运行远程客户端应用](III. Using Spring Boot/20.5.1. Running the Remote Client Application.md) - * [20.5.2. 远程更新](III. Using Spring Boot/20.5.2. Remote update.md) - * [21. 打包用于生产的应用](III. Using Spring Boot/21. Packaging your application for production.md) - * [22. 接下来阅读什么](III. Using Spring Boot/22. What to read next.md) +         * [20.5.2. 远程更新](III. Using Spring Boot/20.5.2. Remote Update.md) + * [21. 打包用于生产的应用](III. Using Spring Boot/21. Packaging Your Application for Production.md) + * [22. 接下来阅读什么](III. Using Spring Boot/22. What to Read Next.md) * [IV. Spring Boot特性](IV. Spring Boot features/README.md) * [23. SpringApplication](IV. Spring Boot features/23. SpringApplication.md) * [23.1. 启动失败](IV. Spring Boot features/23.1. Startup failure.md) From bada38d17592ff865d3401e431d60058fabf4924 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E7=83=AD=E5=BF=83=E5=B8=82=E6=B0=91=E9=92=9F=E5=B0=8F?= =?UTF-8?q?=E5=BC=BA?= Date: Tue, 1 May 2018 14:58:18 +0800 Subject: [PATCH 089/865] Update 23. SpringApplication.md --- IV. Spring Boot features/23. SpringApplication.md | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/IV. Spring Boot features/23. SpringApplication.md b/IV. Spring Boot features/23. SpringApplication.md index 76950e12..da829b86 100644 --- a/IV. Spring Boot features/23. SpringApplication.md +++ b/IV. Spring Boot features/23. SpringApplication.md @@ -1,5 +1,6 @@ -###23. SpringApplication -SpringApplication类提供了一种快捷方式,用于从`main()`方法启动Spring应用。多数情况下,你只需要将该任务委托给`SpringApplication.run`静态方法: +### 23. SpringApplication + +SpringApplication类提供了一种快捷方式,用于从`main()`方法启动Spring应用。多数情况下,你可以将该任务委托给`SpringApplication.run`静态方法: ```java public static void main(String[] args){ SpringApplication.run(MySpringConfiguration.class, args); @@ -20,4 +21,4 @@ public static void main(String[] args){ 2014-03-04 13:09:54.912 INFO 41370 --- [ main] .t.TomcatServletWebServerFactory : Server initialized with port: 8080 2014-03-04 13:09:56.501 INFO 41370 --- [ main] o.s.b.s.app.SampleApplication : Started SampleApplication in 2.992 seconds (JVM running for 3.658) ``` -默认情况下会显示INFO级别的日志信息,包括一些相关的启动详情,比如启动应用的用户等。 +默认情况下会显示`INFO`级别的日志信息,包括一些相关的启动详情,比如启动应用的用户等。如果你需要`INFO`之外的日志级别,你可以参考[章节 26.4 日志级别](https://docs.spring.io/spring-boot/docs/2.0.0.RELEASE/reference/htmlsingle/#boot-features-custom-log-levels)进行设置。 From d81818157871adf31891c3241c1d9230ea1ba91a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E7=83=AD=E5=BF=83=E5=B8=82=E6=B0=91=E9=92=9F=E5=B0=8F?= =?UTF-8?q?=E5=BC=BA?= Date: Wed, 2 May 2018 19:37:57 +0800 Subject: [PATCH 090/865] Update and rename 23.1. Startup failure.md to 23.1. Startup Failure.md --- ...23.1. Startup failure.md => 23.1. Startup Failure.md} | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) rename IV. Spring Boot features/{23.1. Startup failure.md => 23.1. Startup Failure.md} (52%) diff --git a/IV. Spring Boot features/23.1. Startup failure.md b/IV. Spring Boot features/23.1. Startup Failure.md similarity index 52% rename from IV. Spring Boot features/23.1. Startup failure.md rename to IV. Spring Boot features/23.1. Startup Failure.md index 5ea20890..15cdde23 100644 --- a/IV. Spring Boot features/23.1. Startup failure.md +++ b/IV. Spring Boot features/23.1. Startup Failure.md @@ -1,5 +1,6 @@ -###23.1 启动失败 -如果应用启动失败,注册的`FailureAnalyzers`就有机会提供一个特定的错误信息,及具体的解决该问题的动作。例如,如果在`8080`端口启动一个web应用,而该端口已被占用,那你应该可以看到类似如下的内容: +### 23.1 启动失败 + +如果应用启动失败,注册的`FailureAnalyzers`就有机会提供一个特定的错误信息,及具体的解决该问题的动作。例如,如果在`8080`端口启动一个web应用,而该端口已被占用,那你应该可以看到类似如下的信息: ```properties *************************** APPLICATION FAILED TO START @@ -13,9 +14,9 @@ Action: Identify and stop the process that's listening on port 8080 or configure this application to listen on another port. ``` -**注** Spring Boot提供很多的`FailureAnalyzer`实现,你[自己实现](https://docs.spring.io/spring-boot/docs/2.0.0.RELEASE/reference/htmlsingle/#howto-failure-analyzer)也很容易。 +**注** Spring Boot提供很多的`FailureAnalyzer`实现。你也可以[自己实现](https://docs.spring.io/spring-boot/docs/2.0.0.RELEASE/reference/htmlsingle/#howto-failure-analyzer)。 -如果没有可用于处理该异常的失败分析器(failure analyzers),你需要展示完整的auto-configuration报告以便更好的查看出问题的地方,因此你需要启用`org.springframework.boot.autoconfigure.logging.AutoConfigurationReportLoggingInitializer`的[debug](https://docs.spring.io/spring-boot/docs/2.0.0.RELEASE/reference/htmlsingle/#boot-features-external-config)属性,或开启[DEBUG日志级别](https://docs.spring.io/spring-boot/docs/2.0.0.RELEASE/reference/htmlsingle/#boot-features-custom-log-levels)。 +如果没有可用于处理该异常的失败分析器(failure analyzers),你需要展示完整的情况报告以便更好的查看出问题的地方,因此你需要启用`org.springframework.boot.autoconfigure.logging.ConditionEvaluationReportLoggingListener`的[debug](https://docs.spring.io/spring-boot/docs/2.0.0.RELEASE/reference/htmlsingle/#boot-features-external-config)属性,或开启[DEBUG日志级别](https://docs.spring.io/spring-boot/docs/2.0.0.RELEASE/reference/htmlsingle/#boot-features-custom-log-levels)。 例如,使用`java -jar`运行应用时,你可以通过如下命令启用`debug`属性: ```shell From 787fddafdbdeadec5ce7f1113b5a891c915702b3 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E7=83=AD=E5=BF=83=E5=B8=82=E6=B0=91=E9=92=9F=E5=B0=8F?= =?UTF-8?q?=E5=BC=BA?= Date: Wed, 2 May 2018 19:38:35 +0800 Subject: [PATCH 091/865] Update SUMMARY.md --- SUMMARY.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/SUMMARY.md b/SUMMARY.md index 7f2db89a..b0051791 100644 --- a/SUMMARY.md +++ b/SUMMARY.md @@ -80,7 +80,7 @@ * [22. 接下来阅读什么](III. Using Spring Boot/22. What to Read Next.md) * [IV. Spring Boot特性](IV. Spring Boot features/README.md) * [23. SpringApplication](IV. Spring Boot features/23. SpringApplication.md) - * [23.1. 启动失败](IV. Spring Boot features/23.1. Startup failure.md) + * [23.1. 启动失败](IV. Spring Boot features/23.1. Startup Failure.md) * [23.2. 自定义Banner](IV. Spring Boot features/23.2. Customizing the Banner.md) * [23.3. 自定义SpringApplication](IV. Spring Boot features/23.3. Customizing SpringApplication.md) * [23.4. 流式构建API](IV. Spring Boot features/23.4. Fluent builder API.md) From b1b9eedcad294187b66ab6a50f53cd36431c4679 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E7=83=AD=E5=BF=83=E5=B8=82=E6=B0=91=E9=92=9F=E5=B0=8F?= =?UTF-8?q?=E5=BC=BA?= Date: Wed, 2 May 2018 23:14:16 +0800 Subject: [PATCH 092/865] Update 23.2. Customizing the Banner.md --- IV. Spring Boot features/23.2. Customizing the Banner.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/IV. Spring Boot features/23.2. Customizing the Banner.md b/IV. Spring Boot features/23.2. Customizing the Banner.md index ceca4ce5..ef6722a5 100644 --- a/IV. Spring Boot features/23.2. Customizing the Banner.md +++ b/IV. Spring Boot features/23.2. Customizing the Banner.md @@ -1,6 +1,6 @@ ### 23.2. 自定义Banner -通过在classpath下添加一个`banner.txt`或设置`banner.location`来指定相应的文件可以改变启动过程中打印的banner。如果这个文件有特殊的编码,你可以使用`banner.encoding`设置它(默认为UTF-8)。除了文本文件,你也可以添加一个`banner.gif`,`banner.jpg`或`banner.png`图片,或设置`banner.image.location`属性。图片会转换为字符画(ASCII art)形式,并在所有文本banner上方显示。 +通过在classpath下添加一个`banner.txt`或设置`spring.banner.location`属性来指定相应的文件,可以改变启动过程中打印的banner。如果这个文件不是以UTF-8编码,你可以设置`spring.banner.charset`。除了文本文件,你也可以添加一个`banner.gif`,`banner.jpg`或`banner.png`图片,或设置`spring.banner.image.location`属性。图片会转换为字符画(ASCII art)形式,并在所有文本banner上方显示。 在banner.txt中可以使用如下占位符: @@ -19,7 +19,7 @@ 打印的banner将注册成一个名为`springBootBanner`的单例bean。 -**注** YAML会将`off`映射为`false`,如果想在应用中禁用banner,你需要确保`off`添加了括号: +**注** YAML会将`off`映射为`false`,如果想在应用中禁用banner,你需要确保`off`添加了引号: ```json spring: main: From 9c76ad719e279441d4cb1e81278e2ddbe9ffaeed Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E7=83=AD=E5=BF=83=E5=B8=82=E6=B0=91=E9=92=9F=E5=B0=8F?= =?UTF-8?q?=E5=BC=BA?= Date: Wed, 2 May 2018 23:19:41 +0800 Subject: [PATCH 093/865] Update 23.3. Customizing SpringApplication.md --- IV. Spring Boot features/23.3. Customizing SpringApplication.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/IV. Spring Boot features/23.3. Customizing SpringApplication.md b/IV. Spring Boot features/23.3. Customizing SpringApplication.md index 9a79510f..9bd19920 100644 --- a/IV. Spring Boot features/23.3. Customizing SpringApplication.md +++ b/IV. Spring Boot features/23.3. Customizing SpringApplication.md @@ -8,6 +8,6 @@ public static void main(String[] args) { app.run(args); } ``` -**注**:传递给`SpringApplication`的构造器参数将作为spring beans的配置源,多数情况下,它们是一些`@Configuration`类的引用,但也可能是XML配置或要扫描包的引用。 +**注**:传递给`SpringApplication`的构造器参数将作为Spring bean的配置源,多数情况下,它们是一些`@Configuration`类的引用,但也可能是XML配置或要扫描包的引用。 你也可以使用`application.properties`文件来配置`SpringApplication`,具体参考[24. Externalized 配置](24. Externalized Configuration.md),访问[SpringApplication Javadoc](https://docs.spring.io/spring-boot/docs/2.0.0.RELEASE/api/org/springframework/boot/SpringApplication.html)可获取完整的配置选项列表. From b0812e0145f40bddfbe1dd8e8014cdeaefd946fa Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E7=83=AD=E5=BF=83=E5=B8=82=E6=B0=91=E9=92=9F=E5=B0=8F?= =?UTF-8?q?=E5=BC=BA?= Date: Mon, 7 May 2018 00:09:32 +0800 Subject: [PATCH 094/865] Update and rename 23.4. Fluent builder API.md to 23.4. Fluent Builder API.md --- ...4. Fluent builder API.md => 23.4. Fluent Builder API.md} | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) rename IV. Spring Boot features/{23.4. Fluent builder API.md => 23.4. Fluent Builder API.md} (52%) diff --git a/IV. Spring Boot features/23.4. Fluent builder API.md b/IV. Spring Boot features/23.4. Fluent Builder API.md similarity index 52% rename from IV. Spring Boot features/23.4. Fluent builder API.md rename to IV. Spring Boot features/23.4. Fluent Builder API.md index c07da6ec..0dc4f7ef 100644 --- a/IV. Spring Boot features/23.4. Fluent builder API.md +++ b/IV. Spring Boot features/23.4. Fluent Builder API.md @@ -1,7 +1,7 @@ ### 23.4. 流式构建API -如果需要创建一个分层的`ApplicationContext`(多个具有父子关系的上下文),或只是喜欢使用流式(fluent)构建API,那你可以使用SpringApplicationBuilder。 -SpringApplicationBuilder允许你以链式方式调用多个方法,包括parent和child方法,这样就可以创建多层次结构,例如: +如果需要创建一个分层的`ApplicationContext`(多个具有父子关系的上下文),或喜欢使用流式(fluent)构建API,那你可以使用SpringApplicationBuilder。 +SpringApplicationBuilder让你以链式方式调用多个方法,包括parent和child方法,这样就可以创建多层次结构,例如: ```java new SpringApplicationBuilder() .sources(Parent.class) @@ -9,4 +9,4 @@ new SpringApplicationBuilder() .bannerMode(Banner.Mode.OFF) .run(args); ``` -**注**:创建ApplicationContext层次时有些限制,比如,Web组件必须包含在子上下文中,并且父上下文和子上下文使用相同的Environment,具体参考[SpringApplicationBuilder javadoc](https://docs.spring.io/spring-boot/docs/2.0.0.RELEASE/api/org/springframework/boot/builder/SpringApplicationBuilder.html)。 +**注**:创建ApplicationContext层次时有些限制。比如,Web组件必须包含在子上下文中,并且父上下文和子上下文使用相同的Environment。具体参考[SpringApplicationBuilder javadoc](https://docs.spring.io/spring-boot/docs/2.0.0.RELEASE/api/org/springframework/boot/builder/SpringApplicationBuilder.html)。 From 4217580de9e4f515bb72c11447b14f6a5b69d51b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E7=83=AD=E5=BF=83=E5=B8=82=E6=B0=91=E9=92=9F=E5=B0=8F?= =?UTF-8?q?=E5=BC=BA?= Date: Mon, 7 May 2018 00:32:31 +0800 Subject: [PATCH 095/865] Update and rename 23.5. Application events and listeners.md to 23.5. Application Events and Listeners.md --- ...ners.md => 23.5. Application Events and Listeners.md} | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) rename IV. Spring Boot features/{23.5. Application events and listeners.md => 23.5. Application Events and Listeners.md} (57%) diff --git a/IV. Spring Boot features/23.5. Application events and listeners.md b/IV. Spring Boot features/23.5. Application Events and Listeners.md similarity index 57% rename from IV. Spring Boot features/23.5. Application events and listeners.md rename to IV. Spring Boot features/23.5. Application Events and Listeners.md index 49a10868..53dd5107 100644 --- a/IV. Spring Boot features/23.5. Application events and listeners.md +++ b/IV. Spring Boot features/23.5. Application Events and Listeners.md @@ -12,7 +12,12 @@ org.springframework.context.ApplicationListener=com.example.project.MyListener 1. 在运行开始,但除了监听器注册和初始化以外的任何处理之前,会发送一个`ApplicationStartingEvent`。 2. 在Environment将被用于已知的上下文,但在上下文被创建前,会发送一个`ApplicationEnvironmentPreparedEvent`。 3. 在refresh开始前,但在bean定义已被加载后,会发送一个`ApplicationPreparedEvent`。 -4. 在refresh之后,相关的回调处理完,会发送一个`ApplicationReadyEvent`,表示应用准备好接收请求了。 -4. 启动过程中如果出现异常,会发送一个`ApplicationFailedEvent`。 +4. 在上下文更新后,但在任何应用和命令行运行器被调用前,会发送一个`ApplicationStartedEvent`。 +5. 在任何应用和命令行运行器被调用后,会发送一个`ApplicationReadyEvent`,表示应用准备好接收请求了。 +6. 启动过程中如果出现异常,会发送一个`ApplicationFailedEvent`。 **注** 通常不需要使用application事件,但知道它们的存在是有用的(在某些场合可能会使用到),比如,在Spring Boot内部会使用事件处理各种任务。 + +Application events are sent by using Spring Framework’s event publishing mechanism. Part of this mechanism ensures that an event published to the listeners in a child context is also published to the listeners in any ancestor contexts. As a result of this, if your application uses a hierarchy of `SpringApplication` instances, a listener may receive multiple instances of the same type of application event. + +To allow your listener to distinguish between an event for its context and an event for a descendant context, it should request that its application context is injected and then compare the injected context with the context of the event. The context can be injected by implementing `ApplicationContextAware` or, if the listener is a bean, by using `@Autowired`. From 0b7ae5176fd6e25e49f19f4503ff73d02a7b3023 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E7=83=AD=E5=BF=83=E5=B8=82=E6=B0=91=E9=92=9F=E5=B0=8F?= =?UTF-8?q?=E5=BC=BA?= Date: Mon, 7 May 2018 01:00:41 +0800 Subject: [PATCH 096/865] Update 23.5. Application Events and Listeners.md --- .../23.5. Application Events and Listeners.md | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/IV. Spring Boot features/23.5. Application Events and Listeners.md b/IV. Spring Boot features/23.5. Application Events and Listeners.md index 53dd5107..093926b3 100644 --- a/IV. Spring Boot features/23.5. Application Events and Listeners.md +++ b/IV. Spring Boot features/23.5. Application Events and Listeners.md @@ -1,6 +1,6 @@ -### 23.5. Application事件和监听器 +### 23.5. 应用事件和监听器 -除了常见的Spring框架事件,比如[ContextRefreshedEvent](https://docs.spring.io/spring/docs/5.0.4.RELEASE/javadoc-api/org/springframework/context/event/ContextRefreshedEvent.html),`SpringApplication`也会发送其他的application事件。 +除了常见的Spring框架事件,比如[ContextRefreshedEvent](https://docs.spring.io/spring/docs/5.0.4.RELEASE/javadoc-api/org/springframework/context/event/ContextRefreshedEvent.html),`SpringApplication`也会发送其他的应用事件。 **注** 有些事件实际上是在`ApplicationContext`创建前触发的,所以你不能在那些事件(处理类)中通过`@Bean`注册监听器,只能通过`SpringApplication.addListeners(…)`或`SpringApplicationBuilder.listeners(…)`方法注册。如果想让监听器自动注册,而不关心应用的创建方式,你可以在工程中添加一个`META-INF/spring.factories`文件,并使用`org.springframework.context.ApplicationListener`作为key指向那些监听器,如下: ```properties @@ -16,8 +16,8 @@ org.springframework.context.ApplicationListener=com.example.project.MyListener 5. 在任何应用和命令行运行器被调用后,会发送一个`ApplicationReadyEvent`,表示应用准备好接收请求了。 6. 启动过程中如果出现异常,会发送一个`ApplicationFailedEvent`。 -**注** 通常不需要使用application事件,但知道它们的存在是有用的(在某些场合可能会使用到),比如,在Spring Boot内部会使用事件处理各种任务。 +**注** 通常不需要使用应用事件,但知道它们的存在是有用的(在某些场合可能会使用到),比如,在Spring Boot内部会使用事件处理各种任务。 -Application events are sent by using Spring Framework’s event publishing mechanism. Part of this mechanism ensures that an event published to the listeners in a child context is also published to the listeners in any ancestor contexts. As a result of this, if your application uses a hierarchy of `SpringApplication` instances, a listener may receive multiple instances of the same type of application event. +应用事件通过Spring框架的事件发布机制发送。此机制的一部分确保了一个发布到子上下文里的监听器的事件,也会发布到任何祖先上下文里的监听器。因此,如果你的应用使用`SpringApplication`实例的层级,监听器可能会接收到应用事件的多个相同类型的实例。 -To allow your listener to distinguish between an event for its context and an event for a descendant context, it should request that its application context is injected and then compare the injected context with the context of the event. The context can be injected by implementing `ApplicationContextAware` or, if the listener is a bean, by using `@Autowired`. +为了让你的监听器区分一个事件是对应它的上下文还是子孙上下文,它应当请求它的应用上下文被注入,然后比较注入的上下文与事件的上下文。上下文可以通过实现`ApplicationContextAware`注入。或者,如果监听器是一个bean,可以使用`@Autowired`。 From 072a6f0103c5674ab4f5e8000f0d9a249d27c49f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E7=83=AD=E5=BF=83=E5=B8=82=E6=B0=91=E9=92=9F=E5=B0=8F?= =?UTF-8?q?=E5=BC=BA?= Date: Mon, 7 May 2018 01:02:04 +0800 Subject: [PATCH 097/865] Update SUMMARY.md --- SUMMARY.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/SUMMARY.md b/SUMMARY.md index b0051791..9c9438bd 100644 --- a/SUMMARY.md +++ b/SUMMARY.md @@ -83,8 +83,8 @@ * [23.1. 启动失败](IV. Spring Boot features/23.1. Startup Failure.md) * [23.2. 自定义Banner](IV. Spring Boot features/23.2. Customizing the Banner.md) * [23.3. 自定义SpringApplication](IV. Spring Boot features/23.3. Customizing SpringApplication.md) - * [23.4. 流式构建API](IV. Spring Boot features/23.4. Fluent builder API.md) - * [23.5. Application事件和监听器](IV. Spring Boot features/23.5. Application events and listeners.md) + * [23.4. 流式构建API](IV. Spring Boot features/23.4. Fluent Builder API.md) + * [23.5. 应用事件和监听器](IV. Spring Boot features/23.5. Application Events and Listeners.md) * [23.6. Web环境](IV. Spring Boot features/23.6. Web environment.md) * [23.7. 访问应用参数](IV. Spring Boot features/23.7. Accessing application arguments.md) * [23.8. 使用ApplicationRunner或CommandLineRunner](IV. Spring Boot features/23.8. Using the ApplicationRunner or CommandLineRunner.md) From 7271f12e8cfdd61a321898ab34b0779d7c943967 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E7=83=AD=E5=BF=83=E5=B8=82=E6=B0=91=E9=92=9F=E5=B0=8F?= =?UTF-8?q?=E5=BC=BA?= Date: Mon, 7 May 2018 15:56:26 +0800 Subject: [PATCH 098/865] Rename 23.6. Web environment.md to 23.6. Web Environment.md --- .../{23.6. Web environment.md => 23.6. Web Environment.md} | 0 1 file changed, 0 insertions(+), 0 deletions(-) rename IV. Spring Boot features/{23.6. Web environment.md => 23.6. Web Environment.md} (100%) diff --git a/IV. Spring Boot features/23.6. Web environment.md b/IV. Spring Boot features/23.6. Web Environment.md similarity index 100% rename from IV. Spring Boot features/23.6. Web environment.md rename to IV. Spring Boot features/23.6. Web Environment.md From 5f69e72c3fb3a19b8575301be5249a2ca209517c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E7=83=AD=E5=BF=83=E5=B8=82=E6=B0=91=E9=92=9F=E5=B0=8F?= =?UTF-8?q?=E5=BC=BA?= Date: Mon, 7 May 2018 15:58:56 +0800 Subject: [PATCH 099/865] Rename 23.7. Accessing application arguments.md to 23.7. Accessing Application Arguments.md --- ...tion arguments.md => 23.7. Accessing Application Arguments.md} | 0 1 file changed, 0 insertions(+), 0 deletions(-) rename IV. Spring Boot features/{23.7. Accessing application arguments.md => 23.7. Accessing Application Arguments.md} (100%) diff --git a/IV. Spring Boot features/23.7. Accessing application arguments.md b/IV. Spring Boot features/23.7. Accessing Application Arguments.md similarity index 100% rename from IV. Spring Boot features/23.7. Accessing application arguments.md rename to IV. Spring Boot features/23.7. Accessing Application Arguments.md From 78255a24ff1e8dd34bed9bf7633901289aac3a71 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E7=83=AD=E5=BF=83=E5=B8=82=E6=B0=91=E9=92=9F=E5=B0=8F?= =?UTF-8?q?=E5=BC=BA?= Date: Mon, 7 May 2018 16:00:24 +0800 Subject: [PATCH 100/865] Update SUMMARY.md --- SUMMARY.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/SUMMARY.md b/SUMMARY.md index 9c9438bd..b9722a1b 100644 --- a/SUMMARY.md +++ b/SUMMARY.md @@ -85,8 +85,8 @@ * [23.3. 自定义SpringApplication](IV. Spring Boot features/23.3. Customizing SpringApplication.md) * [23.4. 流式构建API](IV. Spring Boot features/23.4. Fluent Builder API.md) * [23.5. 应用事件和监听器](IV. Spring Boot features/23.5. Application Events and Listeners.md) - * [23.6. Web环境](IV. Spring Boot features/23.6. Web environment.md) - * [23.7. 访问应用参数](IV. Spring Boot features/23.7. Accessing application arguments.md) +      * [23.6. Web环境](IV. Spring Boot features/23.6. Web Environment.md) + * [23.7. 访问应用参数](IV. Spring Boot features/23.7. Accessing Application Arguments.md) * [23.8. 使用ApplicationRunner或CommandLineRunner](IV. Spring Boot features/23.8. Using the ApplicationRunner or CommandLineRunner.md) * [23.9. Application退出](IV. Spring Boot features/23.9. Application exit.md) * [23.10. Admin特性](IV. Spring Boot features/23.10. Admin features.md) From f6c36b50da2c3ac3b8412a4ab102bd10ad76c1c7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E7=83=AD=E5=BF=83=E5=B8=82=E6=B0=91=E9=92=9F=E5=B0=8F?= =?UTF-8?q?=E5=BC=BA?= Date: Mon, 7 May 2018 16:18:56 +0800 Subject: [PATCH 101/865] Update 23.8. Using the ApplicationRunner or CommandLineRunner.md --- .../23.8. Using the ApplicationRunner or CommandLineRunner.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/IV. Spring Boot features/23.8. Using the ApplicationRunner or CommandLineRunner.md b/IV. Spring Boot features/23.8. Using the ApplicationRunner or CommandLineRunner.md index 29531eed..67d86c21 100644 --- a/IV. Spring Boot features/23.8. Using the ApplicationRunner or CommandLineRunner.md +++ b/IV. Spring Boot features/23.8. Using the ApplicationRunner or CommandLineRunner.md @@ -2,7 +2,7 @@ 如果需要在`SpringApplication`启动后执行一些特殊的代码,你可以实现`ApplicationRunner`或`CommandLineRunner`接口,这两个接口工作方式相同,都只提供单一的`run`方法,该方法仅在`SpringApplication.run(…)`完成之前调用。 -`CommandLineRunner`接口能够访问string数组类型的应用参数,而`ApplicationRunner`使用的是上面描述过的`ApplicationArguments`接口: +`CommandLineRunner`接口能够访问string数组类型的应用参数,而`ApplicationRunner`使用的是之前描述过的`ApplicationArguments`接口: ```java import org.springframework.boot.* import org.springframework.stereotype.* From 76345ccf2478a21ea70733751c38af36b03080d9 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E7=83=AD=E5=BF=83=E5=B8=82=E6=B0=91=E9=92=9F=E5=B0=8F?= =?UTF-8?q?=E5=BC=BA?= Date: Mon, 7 May 2018 16:25:41 +0800 Subject: [PATCH 102/865] Update and rename 23.9. Application exit.md to 23.9. Application Exit.md --- .../{23.9. Application exit.md => 23.9. Application Exit.md} | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) rename IV. Spring Boot features/{23.9. Application exit.md => 23.9. Application Exit.md} (91%) diff --git a/IV. Spring Boot features/23.9. Application exit.md b/IV. Spring Boot features/23.9. Application Exit.md similarity index 91% rename from IV. Spring Boot features/23.9. Application exit.md rename to IV. Spring Boot features/23.9. Application Exit.md index 55b14ea7..309c8417 100644 --- a/IV. Spring Boot features/23.9. Application exit.md +++ b/IV. Spring Boot features/23.9. Application Exit.md @@ -1,4 +1,4 @@ -### 23.9 Application退出 +### 23.9 应用退出 为确保`ApplicationContext`在退出时被平静的(gracefully)关闭,每个`SpringApplication`都会注册一个JVM的shutdown钩子,所有标准的Spring生命周期回调(比如`DisposableBean`接口或`@PreDestroy`注解)都能使用。 @@ -19,4 +19,4 @@ public class ExitCodeApplication { } ``` -`ExitCodeGenerator`接口也可以被异常实现。当遇到这样的一个异常,Spring Boot将返回由被实现了的`getExitCode()`方法提供的退出码。 \ No newline at end of file +`ExitCodeGenerator`接口也可以被异常实现。当遇到这样的一个异常,Spring Boot将返回由被实现了的`getExitCode()`方法提供的退出码。 From 5c96c8fd50ee4a11c808c6a9e862f711602c6d1a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E7=83=AD=E5=BF=83=E5=B8=82=E6=B0=91=E9=92=9F=E5=B0=8F?= =?UTF-8?q?=E5=BC=BA?= Date: Mon, 7 May 2018 16:27:28 +0800 Subject: [PATCH 103/865] Update SUMMARY.md --- SUMMARY.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/SUMMARY.md b/SUMMARY.md index b9722a1b..fae9c327 100644 --- a/SUMMARY.md +++ b/SUMMARY.md @@ -88,8 +88,8 @@      * [23.6. Web环境](IV. Spring Boot features/23.6. Web Environment.md) * [23.7. 访问应用参数](IV. Spring Boot features/23.7. Accessing Application Arguments.md) * [23.8. 使用ApplicationRunner或CommandLineRunner](IV. Spring Boot features/23.8. Using the ApplicationRunner or CommandLineRunner.md) - * [23.9. Application退出](IV. Spring Boot features/23.9. Application exit.md) - * [23.10. Admin特性](IV. Spring Boot features/23.10. Admin features.md) +      * [23.9. 应用退出](IV. Spring Boot features/23.9. Application Exit.md) + * [23.10. Admin特性](IV. Spring Boot features/23.10. Admin Features.md) * [24.外化配置](IV. Spring Boot features/24. Externalized Configuration.md) * [24.1. 配置随机值](IV. Spring Boot features/24.1. Configuring random values.md) * [24.2. 访问命令行属性](IV. Spring Boot features/24.2. Accessing command line properties.md) From cf784cb7aba1ecbb171a211c42df7a849d4c275d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E7=83=AD=E5=BF=83=E5=B8=82=E6=B0=91=E9=92=9F=E5=B0=8F?= =?UTF-8?q?=E5=BC=BA?= Date: Mon, 7 May 2018 16:31:36 +0800 Subject: [PATCH 104/865] Update and rename 23.10. Admin features.md to 23.10. Admin Features.md --- .../{23.10. Admin features.md => 23.10. Admin Features.md} | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) rename IV. Spring Boot features/{23.10. Admin features.md => 23.10. Admin Features.md} (72%) diff --git a/IV. Spring Boot features/23.10. Admin features.md b/IV. Spring Boot features/23.10. Admin Features.md similarity index 72% rename from IV. Spring Boot features/23.10. Admin features.md rename to IV. Spring Boot features/23.10. Admin Features.md index c3151a26..b12d8cb3 100644 --- a/IV. Spring Boot features/23.10. Admin features.md +++ b/IV. Spring Boot features/23.10. Admin Features.md @@ -1,6 +1,7 @@ ### 23.10 Admin特性 -通过设置`spring.application.admin.enabled`属性可以启用管理相关的(admin-related)特性,这将暴露[SpringApplicationAdminMXBean](https://github.com/spring-projects/spring-boot/tree/v2.0.0.RELEASE/spring-boot/src/main/java/org/springframework/boot/admin/SpringApplicationAdminMXBean.java)到平台的`MBeanServer`,你可以使用该特性远程管理Spring Boot应用,这对任何service包装器(wrapper)实现也有用。 +通过设置`spring.application.admin.enabled`属性可以启用管理相关的(admin-related)特性,这将暴露[SpringApplicationAdminMXBean](https://github.com/spring-projects/spring-boot/tree/v2.0.0.RELEASE/spring-boot/src/main/java/org/springframework/boot/admin/SpringApplicationAdminMXBean.java)到平台的`MBeanServer`,你可以使用该特性远程管理Spring Boot应用。这个特性对任何service包装器(wrapper)实现也有用。 -**注** 通过`local.server.port`可以获取该应用运行的HTTP端口。启用该特性时需要注意MBean会暴露一个方法去关闭应用。 - +**注** 通过`local.server.port`可以获取该应用运行的HTTP端口。 + +**警告** 启用该特性时需要注意MBean会暴露一个方法去关闭应用。 From da6b5d9a5ab8e40d8435a9e391fa5fde1b0d13d0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E7=83=AD=E5=BF=83=E5=B8=82=E6=B0=91=E9=92=9F=E5=B0=8F?= =?UTF-8?q?=E5=BC=BA?= Date: Wed, 9 May 2018 23:38:31 +0800 Subject: [PATCH 105/865] Update 24. Externalized Configuration.md --- .../24. Externalized Configuration.md | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/IV. Spring Boot features/24. Externalized Configuration.md b/IV. Spring Boot features/24. Externalized Configuration.md index 80c1e69a..cb715b70 100644 --- a/IV. Spring Boot features/24. Externalized Configuration.md +++ b/IV. Spring Boot features/24. Externalized Configuration.md @@ -20,7 +20,7 @@ Spring Boot设计了一个非常特别的`PropertySource`顺序,以允许对 14. 没有打进jar包的应用配置(`application.properties`和YAML变量)。 15. 打进jar包中的应用配置(`application.properties`和YAML变量)。 16. `@Configuration`类上的[`@PropertySource`注解](https://docs.spring.io/spring/docs/5.0.4.RELEASE/javadoc-api/org/springframework/context/annotation/PropertySource.html)。 -17. 默认属性(使用`SpringApplication.setDefaultProperties`指定)。 +17. 默认属性(通过设置`SpringApplication.setDefaultProperties`指定)。 下面是具体的示例,假设你开发一个使用name属性的`@Component`: ```java @@ -38,14 +38,14 @@ public class MyBean { **注** `SPRING_APPLICATION_JSON`属性可以通过命令行的环境变量设置,例如,在一个UNIX shell中可以这样: ```shell -$ SPRING_APPLICATION_JSON='{"foo":{"bar":"spam"}}' java -jar myapp.jar +$ SPRING_APPLICATION_JSON='{"acme":{"name":"test"}}' java -jar myapp.jar ``` 本示例中,如果是Spring `Environment`,你可以以`foo.bar=spam`结尾;如果在一个系统变量中,可以提供作为`spring.application.json`的JSON字符串: ```shell -$ java -Dspring.application.json='{"foo":"bar"}' -jar myapp.jar +$ java -Dspring.application.json='{"name":"test"}' -jar myapp.jar ``` 或命令行参数: ```shell -$ java -jar myapp.jar --spring.application.json='{"foo":"bar"}' +$ java -jar myapp.jar --spring.application.json='{"name":"test"}' ``` 或作为一个JNDI变量`java:comp/env/spring.application.json`。 From 5fd9df2e01ff05c0eea4e53dc71132ac368df36f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E7=83=AD=E5=BF=83=E5=B8=82=E6=B0=91=E9=92=9F=E5=B0=8F?= =?UTF-8?q?=E5=BC=BA?= Date: Wed, 9 May 2018 23:42:31 +0800 Subject: [PATCH 106/865] Update 24. Externalized Configuration.md --- IV. Spring Boot features/24. Externalized Configuration.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/IV. Spring Boot features/24. Externalized Configuration.md b/IV. Spring Boot features/24. Externalized Configuration.md index cb715b70..e612de08 100644 --- a/IV. Spring Boot features/24. Externalized Configuration.md +++ b/IV. Spring Boot features/24. Externalized Configuration.md @@ -40,7 +40,7 @@ public class MyBean { ```shell $ SPRING_APPLICATION_JSON='{"acme":{"name":"test"}}' java -jar myapp.jar ``` -本示例中,如果是Spring `Environment`,你可以以`foo.bar=spam`结尾;如果在一个系统变量中,可以提供作为`spring.application.json`的JSON字符串: +在之前的例子里,如果是Spring `Environment`,你可以以`acme.name=test`结尾;如果在一个系统属性中,可以提供作为`spring.application.json`的JSON字符串: ```shell $ java -Dspring.application.json='{"name":"test"}' -jar myapp.jar ``` From c21b0773cb1a634202d7b7f0639582a1a5ae1dc5 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E7=83=AD=E5=BF=83=E5=B8=82=E6=B0=91=E9=92=9F=E5=B0=8F?= =?UTF-8?q?=E5=BC=BA?= Date: Thu, 10 May 2018 01:07:00 +0800 Subject: [PATCH 107/865] Rename 24.1. Configuring random values.md to 24.1. Configuring Random Values.md --- ...guring random values.md => 24.1. Configuring Random Values.md} | 0 1 file changed, 0 insertions(+), 0 deletions(-) rename IV. Spring Boot features/{24.1. Configuring random values.md => 24.1. Configuring Random Values.md} (100%) diff --git a/IV. Spring Boot features/24.1. Configuring random values.md b/IV. Spring Boot features/24.1. Configuring Random Values.md similarity index 100% rename from IV. Spring Boot features/24.1. Configuring random values.md rename to IV. Spring Boot features/24.1. Configuring Random Values.md From 62d1f8849731500521d0d4e3c88ad5e85b0d6f5b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E7=83=AD=E5=BF=83=E5=B8=82=E6=B0=91=E9=92=9F=E5=B0=8F?= =?UTF-8?q?=E5=BC=BA?= Date: Thu, 10 May 2018 01:10:02 +0800 Subject: [PATCH 108/865] Update and rename 24.2. Accessing command line properties.md to 24.2. Accessing Command Line Properties.md --- ...properties.md => 24.2. Accessing Command Line Properties.md} | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) rename IV. Spring Boot features/{24.2. Accessing command line properties.md => 24.2. Accessing Command Line Properties.md} (53%) diff --git a/IV. Spring Boot features/24.2. Accessing command line properties.md b/IV. Spring Boot features/24.2. Accessing Command Line Properties.md similarity index 53% rename from IV. Spring Boot features/24.2. Accessing command line properties.md rename to IV. Spring Boot features/24.2. Accessing Command Line Properties.md index 3f2354bc..3412354a 100644 --- a/IV. Spring Boot features/24.2. Accessing command line properties.md +++ b/IV. Spring Boot features/24.2. Accessing Command Line Properties.md @@ -1,5 +1,5 @@ ### 24.2. 访问命令行属性 -默认情况下,`SpringApplication`会将所有命令行配置参数(以'--'开头,比如`--server.port=9000`)转化成一个`property`,并将其添加到Spring `Environment`中。正如以上章节提过的,命令行属性总是优先于其他属性源。 +默认情况下,`SpringApplication`会将所有命令行配置参数(以--开头,比如`--server.port=9000`)转化成一个`property`,并将其添加到Spring `Environment`中。正如以上章节提过的,命令行属性总是优先于其他属性源。 如果不想将命令行属性添加到`Environment`,你可以使用`SpringApplication.setAddCommandLineProperties(false)`来禁用它们。 From fdbf4fb02c252d8f95ab993a0dbaf2dc401c04ef Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E7=83=AD=E5=BF=83=E5=B8=82=E6=B0=91=E9=92=9F=E5=B0=8F?= =?UTF-8?q?=E5=BC=BA?= Date: Thu, 10 May 2018 01:12:26 +0800 Subject: [PATCH 109/865] Update SUMMARY.md --- SUMMARY.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/SUMMARY.md b/SUMMARY.md index fae9c327..d81696ce 100644 --- a/SUMMARY.md +++ b/SUMMARY.md @@ -91,8 +91,8 @@      * [23.9. 应用退出](IV. Spring Boot features/23.9. Application Exit.md) * [23.10. Admin特性](IV. Spring Boot features/23.10. Admin Features.md) * [24.外化配置](IV. Spring Boot features/24. Externalized Configuration.md) - * [24.1. 配置随机值](IV. Spring Boot features/24.1. Configuring random values.md) - * [24.2. 访问命令行属性](IV. Spring Boot features/24.2. Accessing command line properties.md) +      * [24.1. 配置随机值](IV. Spring Boot features/24.1. Configuring Random Values.md) + * [24.2. 访问命令行属性](IV. Spring Boot features/24.2. Accessing Command Line Properties.md) * [24.3. Application属性文件](IV. Spring Boot features/24.3. Application property files.md) * [24.4. Profile-specific属性](IV. Spring Boot features/24.4. Profile-specific properties.md) * [24.5. 属性占位符](IV. Spring Boot features/24.5. Placeholders in properties.md) From 2b375fec15cdc7bcbc6d96e3986916f724ed0de1 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E7=83=AD=E5=BF=83=E5=B8=82=E6=B0=91=E9=92=9F=E5=B0=8F?= =?UTF-8?q?=E5=BC=BA?= Date: Thu, 10 May 2018 23:20:53 +0800 Subject: [PATCH 110/865] Update and rename 24.3. Application property files.md to 24.3. Application Property Files.md --- .../24.3. Application Property Files.md | 51 +++++++++++++++++++ .../24.3. Application property files.md | 46 ----------------- 2 files changed, 51 insertions(+), 46 deletions(-) create mode 100644 IV. Spring Boot features/24.3. Application Property Files.md delete mode 100644 IV. Spring Boot features/24.3. Application property files.md diff --git a/IV. Spring Boot features/24.3. Application Property Files.md b/IV. Spring Boot features/24.3. Application Property Files.md new file mode 100644 index 00000000..05881865 --- /dev/null +++ b/IV. Spring Boot features/24.3. Application Property Files.md @@ -0,0 +1,51 @@ +### 24.3. 应用属性文件 + +`SpringApplication`从以下位置加载`application.properties`文件,并把它们添加到Spring `Environment`中: + +1. 当前目录下的`/config`子目录 +2. 当前目录 +3. classpath下的`/config`包 +4. classpath根路径(root) + +该列表是按优先级排序的(列表中位置高的路径下定义的属性将覆盖位置低的)。 + +**注** 你可以使用[YAML('.yml')文件](https://docs.spring.io/spring-boot/docs/2.0.0.RELEASE/reference/htmlsingle/#boot-features-external-config-yaml)替代'.properties'。 + +如果不喜欢将`application.properties`作为配置文件名,你可以通过指定`spring.config.name`环境属性来切换其它的文件名,也可以使用`spring.config.location`环境属性引用一个明确的路径(目录位置或文件路径列表以逗号分割)。下面的例子展示了怎么指定一个不同的文件名: +```shell +$ java -jar myproject.jar --spring.config.name=myproject +``` +下面的例子展示了怎么指定两个路径: +```shell +$ java -jar myproject.jar --spring.config.location=classpath:/default.properties,classpath:/override.properties +``` +**注** 在初期需要根据`spring.config.name`和`spring.config.location`决定加载哪个文件,所以它们必须定义为环境属性(通常为OS环境变量,系统属性或命令行参数)。 + +如果`spring.config.location`包含目录(相对于文件),那它们应该以`/`结尾(运行时,`spring.config.name`关联的名称会在被加载前被追加到后面,包括profile-specific的文件名)。`spring.config.location`下定义的文件使用方法跟往常一样,没有profile-specific变量支持的属性,会被profile-specific的属性覆盖。 + +配置位置按相反的顺序搜索。默认地,配置好的位置是`classpath:/,classpath:/config/,file:./,file:./config/`。产生的搜索顺序为: + +1.`file:./config/` +2.`file:./` +3.`classpath:/config/` +4.`classpath:/` + +当使用`spring.config.location`配置好自定义的配置位置时,它们会代替默认位置。比如,如果用值`classpath:/custom-config/,file:./custom-config/`配置了`spring.config.location`,搜索顺序会变成: + +1.`file:./custom-config/` +2.`classpath:custom-config/` + +或者,当使用`spring.config.additional-location`配置好自定义的配置位置时,,它们会在默认位置的基础上被使用。自定义的位置会在默认位置之前被搜索。例如,如果配置了自定义的位置`classpath:/custom-config/,file:./custom-config/`,搜索的顺序会变成: + +1.`file:./custom-config/` +2.`classpath:custom-config/` +3.`file:./config/` +4.`file:./` +5.`classpath:/config/` +6.`classpath:/` + +这种搜索排序允许你在一个配置文件里指定默认值,然后有选择地覆盖那些值。你可以选择默认位置中的一处,在这儿的`application.properties`(或者任何由`spring.config.name`指定的名字)里为应用设置默认值。然后,在运行时使用在自定义的位置上的不同的文件,覆盖这些默认值。 + +**注** 如果使用环境变量而不是系统属性,需要注意多数操作系统的key名称不允许以句号分割(period-separated),但你可以使用下划线(underscores)代替(比如,使用`SPRING_CONFIG_NAME`代替`spring.config.name`)。 + +**注** 如果你的应用运行在容器中,那么JNDI属性(java:comp/env)或servlet上下文初始化参数可以用来代替环境变量或系统属性,当然也可以使用环境变量或系统属性。 diff --git a/IV. Spring Boot features/24.3. Application property files.md b/IV. Spring Boot features/24.3. Application property files.md deleted file mode 100644 index bce4e542..00000000 --- a/IV. Spring Boot features/24.3. Application property files.md +++ /dev/null @@ -1,46 +0,0 @@ -### 24.3. Application属性文件 - -`SpringApplication`将从以下位置加载`application.properties`文件,并把它们添加到Spring `Environment`中: - -1. 当前目录下的`/config`子目录。 -2. 当前目录。 -3. classpath下的`/config`包。 -4. classpath根路径(root)。 - -该列表是按优先级排序的(列表中位置高的路径下定义的属性将覆盖位置低的)。 - -**注** 你可以使用[YAML('.yml')文件](https://docs.spring.io/spring-boot/docs/2.0.0.RELEASE/reference/htmlsingle/#boot-features-external-config-yaml)替代'.properties'。 - -如果不喜欢将`application.properties`作为配置文件名,你可以通过指定`spring.config.name`环境属性来切换其他的名称,也可以使用`spring.config.location`环境属性引用一个明确的路径(目录位置或文件路径列表以逗号分割)。 -```shell -$ java -jar myproject.jar --spring.config.name=myproject -``` -或 -```shell -$ java -jar myproject.jar --spring.config.location=classpath:/default.properties,classpath:/override.properties -``` -**注** 在初期需要根据`spring.config.name`和`spring.config.location`决定加载哪个文件,所以它们必须定义为environment属性(通常为OS env,系统属性或命令行参数)。 - -如果`spring.config.location`包含目录(相对于文件),那它们应该以`/`结尾(在被加载前,`spring.config.name`关联的名称将被追加到后面,包括profile-specific的文件名)。`spring.config.location`下定义的文件使用方法跟往常一样,没有profile-specific变量支持的属性,将被profile-specific的属性覆盖。 - -配置位置按相反的顺序搜索。默认地,配置好的位置是`classpath:/,classpath:/config/,file:./,file:./config/`。产生的搜索顺序为: - -1.`file:./config/` -2.`file:./` -3.`classpath:/config/` -4.`classpath:/` - -当自定义的配置位置配置好时,它们会在默认位置的基础上被使用。自定义的位置会在默认位置之前被搜索。例如,如果配置了自定义的位置`classpath:/custom-config/,file:./custom-config/`,搜索的顺序会变成: - -1.`file:./custom-config/` -2.`classpath:custom-config/` -3.`file:./config/` -4.`file:./` -5.`classpath:/config/` -6.`classpath:/` - -这种搜索排序允许你在一个配置文件里指定默认值,然后有选择地覆盖那些值。你可以选择默认位置中的一处,在这儿的`application.properties`(或者任何由`spring.config.name`指定的名字)里为应用设置默认值。然后,在运行时使用在自定义的位置上的不同的文件,覆盖这些默认值。 - -**注** 如果使用环境变量而不是系统属性,需要注意多数操作系统的key名称不允许以句号分割(period-separated),但你可以使用下划线(underscores)代替(比如,使用`SPRING_CONFIG_NAME`代替`spring.config.name`)。 - -**注** 如果应用运行在容器中,那么JNDI属性(java:comp/env)或servlet上下文初始化参数可以用来代替环境变量或系统属性,当然也可以使用环境变量或系统属性。 From 9e11997572105c1888bc7458a97005dd9faf935d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E7=83=AD=E5=BF=83=E5=B8=82=E6=B0=91=E9=92=9F=E5=B0=8F?= =?UTF-8?q?=E5=BC=BA?= Date: Thu, 10 May 2018 23:23:11 +0800 Subject: [PATCH 111/865] Update 24.3. Application Property Files.md --- .../24.3. Application Property Files.md | 24 +++++++++---------- 1 file changed, 12 insertions(+), 12 deletions(-) diff --git a/IV. Spring Boot features/24.3. Application Property Files.md b/IV. Spring Boot features/24.3. Application Property Files.md index 05881865..d182ab84 100644 --- a/IV. Spring Boot features/24.3. Application Property Files.md +++ b/IV. Spring Boot features/24.3. Application Property Files.md @@ -25,24 +25,24 @@ $ java -jar myproject.jar --spring.config.location=classpath:/default.properties 配置位置按相反的顺序搜索。默认地,配置好的位置是`classpath:/,classpath:/config/,file:./,file:./config/`。产生的搜索顺序为: -1.`file:./config/` -2.`file:./` -3.`classpath:/config/` -4.`classpath:/` +1. `file:./config/` +2. `file:./` +3. `classpath:/config/` +4. `classpath:/` 当使用`spring.config.location`配置好自定义的配置位置时,它们会代替默认位置。比如,如果用值`classpath:/custom-config/,file:./custom-config/`配置了`spring.config.location`,搜索顺序会变成: -1.`file:./custom-config/` -2.`classpath:custom-config/` +1. `file:./custom-config/` +2. `classpath:custom-config/` 或者,当使用`spring.config.additional-location`配置好自定义的配置位置时,,它们会在默认位置的基础上被使用。自定义的位置会在默认位置之前被搜索。例如,如果配置了自定义的位置`classpath:/custom-config/,file:./custom-config/`,搜索的顺序会变成: -1.`file:./custom-config/` -2.`classpath:custom-config/` -3.`file:./config/` -4.`file:./` -5.`classpath:/config/` -6.`classpath:/` +1. `file:./custom-config/` +2. `classpath:custom-config/` +3. `file:./config/` +4. `file:./` +5. `classpath:/config/` +6. `classpath:/` 这种搜索排序允许你在一个配置文件里指定默认值,然后有选择地覆盖那些值。你可以选择默认位置中的一处,在这儿的`application.properties`(或者任何由`spring.config.name`指定的名字)里为应用设置默认值。然后,在运行时使用在自定义的位置上的不同的文件,覆盖这些默认值。 From 3e6a3f61aab28d6e8088d8bfea066fd9925dd90a Mon Sep 17 00:00:00 2001 From: Jack Zhong Date: Thu, 10 May 2018 23:28:48 +0800 Subject: [PATCH 112/865] =?UTF-8?q?=E6=9B=B4=E6=96=B0=E7=9B=AE=E5=BD=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- SUMMARY.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/SUMMARY.md b/SUMMARY.md index d81696ce..ed5bbc2d 100644 --- a/SUMMARY.md +++ b/SUMMARY.md @@ -93,8 +93,8 @@ * [24.外化配置](IV. Spring Boot features/24. Externalized Configuration.md)      * [24.1. 配置随机值](IV. Spring Boot features/24.1. Configuring Random Values.md) * [24.2. 访问命令行属性](IV. Spring Boot features/24.2. Accessing Command Line Properties.md) - * [24.3. Application属性文件](IV. Spring Boot features/24.3. Application property files.md) - * [24.4. Profile-specific属性](IV. Spring Boot features/24.4. Profile-specific properties.md) + * [24.3. 应用属性文件](IV. Spring Boot features/24.3. Application Property Files.md) + * [24.4. Profile-specific属性](IV. Spring Boot features/24.4. Profile-specific Properties.md) * [24.5. 属性占位符](IV. Spring Boot features/24.5. Placeholders in properties.md) * [24.6. 使用YAML代替Properties](IV. Spring Boot features/24.6. Using YAML instead of Properties.md) * [24.6.1. 加载YAML](IV. Spring Boot features/24.6.1. Loading YAML.md) From 96302db916221f1a82b5ecb1ac7d0cf9b9a0e154 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E7=83=AD=E5=BF=83=E5=B8=82=E6=B0=91=E9=92=9F=E5=B0=8F?= =?UTF-8?q?=E5=BC=BA?= Date: Thu, 10 May 2018 23:34:16 +0800 Subject: [PATCH 113/865] Update and rename 24.4. Profile-specific properties.md to 24.4. Profile-specific Properties.md --- ...fic properties.md => 24.4. Profile-specific Properties.md} | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) rename IV. Spring Boot features/{24.4. Profile-specific properties.md => 24.4. Profile-specific Properties.md} (85%) diff --git a/IV. Spring Boot features/24.4. Profile-specific properties.md b/IV. Spring Boot features/24.4. Profile-specific Properties.md similarity index 85% rename from IV. Spring Boot features/24.4. Profile-specific properties.md rename to IV. Spring Boot features/24.4. Profile-specific Properties.md index 908fc5c6..1618d4bb 100644 --- a/IV. Spring Boot features/24.4. Profile-specific properties.md +++ b/IV. Spring Boot features/24.4. Profile-specific Properties.md @@ -1,11 +1,9 @@ ### 24.4. Profile-specific属性 -除了`application.properties`文件,profile-specific属性也能通过命名惯例`application-{profile}.properties`定义。`Environment`(Spring的环境抽象接口)有个默认profiles集合(默认情况为`[default]`),在没有设置激活的profiles时会被使用(例如,如果没有明确指定激活的profiles,`application-default.properties`中的属性会被加载)。 +除了`application.properties`文件,profile-specific属性也能通过命名惯例`application-{profile}.properties`定义。`Environment`(Spring的环境抽象接口)有个默认profiles集合(默认情况为`[default]`),在没有设置激活的profiles时会被使用。换句话说,如果没有明确指定激活的profiles,`application-default.properties`中的属性会被加载。 Profile-specific属性加载路径和标准的`application.properties`相同,并且profile-specific文件总是会覆盖non-specific文件,不管profile-specific文件是否被打包到jar中。 如果定义多个profiles,最后一个将获胜。例如,`spring.profiles.active`定义的profiles被添加到通过`SpringApplication`API定义的profiles后面,因此优先级更高。 **注** 如果你已经在`spring.config.location`下定义所有文件(非目录),那些profile-specific的文件将不被考虑。如果想使用profile-specific属性,那就在`spring.config.location`下使用目录。 - - From 3cb8a7eb3b1e89d5d2241978acf9bcba01a1ff3b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E7=83=AD=E5=BF=83=E5=B8=82=E6=B0=91=E9=92=9F=E5=B0=8F?= =?UTF-8?q?=E5=BC=BA?= Date: Sat, 12 May 2018 09:34:51 +0800 Subject: [PATCH 114/865] Update and rename 24.5. Placeholders in properties.md to 24.5. Placeholders in Properties.md --- ...ers in properties.md => 24.5. Placeholders in Properties.md} | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) rename IV. Spring Boot features/{24.5. Placeholders in properties.md => 24.5. Placeholders in Properties.md} (69%) diff --git a/IV. Spring Boot features/24.5. Placeholders in properties.md b/IV. Spring Boot features/24.5. Placeholders in Properties.md similarity index 69% rename from IV. Spring Boot features/24.5. Placeholders in properties.md rename to IV. Spring Boot features/24.5. Placeholders in Properties.md index 02aeb779..f15ead3d 100644 --- a/IV. Spring Boot features/24.5. Placeholders in properties.md +++ b/IV. Spring Boot features/24.5. Placeholders in Properties.md @@ -5,4 +5,4 @@ app.name=MyApp app.description=${app.name} is a Spring Boot application ``` -**注** 你也可以使用该技巧为存在的Spring Boot属性创建'短'变量,具体参考[章节 73.4,使用'short'命令行参数](../IX. ‘How-to’ guides/73.4 Use ‘short’ command line arguments.md)。 +**注** 你也可以使用该技巧为存在的Spring Boot属性创建'短'变量,具体参考[章节 74.4,使用'short'命令行参数](../IX. ‘How-to’ guides/74.4 Use ‘Short’ Command Line Arguments.md)。 From e80fd9aab8fee26e1932c41586fca01866adbb12 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E7=83=AD=E5=BF=83=E5=B8=82=E6=B0=91=E9=92=9F=E5=B0=8F?= =?UTF-8?q?=E5=BC=BA?= Date: Sat, 12 May 2018 09:47:33 +0800 Subject: [PATCH 115/865] Update and rename 24.6. Using YAML instead of Properties.md to 24.6. Using YAML Instead of Properties.md --- ... Properties.md => 24.6. Using YAML Instead of Properties.md} | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) rename IV. Spring Boot features/{24.6. Using YAML instead of Properties.md => 24.6. Using YAML Instead of Properties.md} (74%) diff --git a/IV. Spring Boot features/24.6. Using YAML instead of Properties.md b/IV. Spring Boot features/24.6. Using YAML Instead of Properties.md similarity index 74% rename from IV. Spring Boot features/24.6. Using YAML instead of Properties.md rename to IV. Spring Boot features/24.6. Using YAML Instead of Properties.md index 8e648269..582b53bd 100644 --- a/IV. Spring Boot features/24.6. Using YAML instead of Properties.md +++ b/IV. Spring Boot features/24.6. Using YAML Instead of Properties.md @@ -2,4 +2,4 @@ [YAML](http://yaml.org/)是JSON的一个超集,也是一种方便的定义层次配置数据的格式。只要你将[SnakeYAML ](http://code.google.com/p/snakeyaml/)库放到classpath下,`SpringApplication`就会自动支持YAML,以作为properties的替换。 -**注** 如果你使用'Starters',添加`spring-boot-starter`依赖会自动加载SnakeYAML。 +**注** 如果你使用“Starters”,添加`spring-boot-starter`依赖会自动加载SnakeYAML。 From 92759dd19c388f3d1562dce6311f9eff797fc549 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E7=83=AD=E5=BF=83=E5=B8=82=E6=B0=91=E9=92=9F=E5=B0=8F?= =?UTF-8?q?=E5=BC=BA?= Date: Sat, 12 May 2018 10:10:43 +0800 Subject: [PATCH 116/865] Update 24.6.1. Loading YAML.md --- .../24.6.1. Loading YAML.md | 26 ++++++++----------- 1 file changed, 11 insertions(+), 15 deletions(-) diff --git a/IV. Spring Boot features/24.6.1. Loading YAML.md b/IV. Spring Boot features/24.6.1. Loading YAML.md index 9fefdfbc..5d940924 100644 --- a/IV. Spring Boot features/24.6.1. Loading YAML.md +++ b/IV. Spring Boot features/24.6.1. Loading YAML.md @@ -6,32 +6,32 @@ Spring框架提供两个便利的类用于加载YAML文档,`YamlPropertiesFact ```json environments: dev: - url: http://dev.bar.com + url: http://dev.example.com name: Developer Setup prod: - url: http://foo.bar.com + url: http://another.example.com name: My Cool App ``` -会被转化到这些属性: +会被转化为如下属性: ```java -environments.dev.url=http://dev.bar.com +environments.dev.url=http://dev.example.com environments.dev.name=Developer Setup -environments.prod.url=http://foo.bar.com +environments.prod.url=http://another.example.com environments.prod.name=My Cool App ``` YAML列表被表示成使用`[index]`间接引用作为属性keys的形式,例如下面的YAML: ```json my: servers: - - dev.bar.com - - foo.bar.com + - dev.example.com + - another.example.com ``` 将会转化到这些属性: ```java -my.servers[0]=dev.bar.com -my.servers[1]=foo.bar.com +my.servers[0]=dev.example.com +my.servers[1]=another.example.com ``` -使用Spring `DataBinder`工具集绑定这些属性(这是`@ConfigurationProperties`做的事)时,你需要确保目标bean有个`java.util.List`或`Set`类型的属性,并且需要提供一个setter或使用可变的值初始化它,比如,下面的代码将绑定上面的属性: +使用Spring `DataBinder`工具集绑定这些属性(这是`@ConfigurationProperties`做的事)时,你需要确保目标bean有个`java.util.List`或`Set`类型的属性,并且需要提供一个setter或使用可变的值初始化它,比如,下面的代码将绑定之前的属性: ```java @ConfigurationProperties(prefix="my") public class Config { @@ -42,8 +42,4 @@ public class Config { } ``` -**注** 当配置列表时需要格外小心,因为重写并不会像你期望的那样发生。在上面的例子中,当my.servers在几个地方被重新定义时,个别的元素会被重写,而不是列表。 为了确保拥有更高优先权的属性源能够重写列表,你需要把它定义为单个的属性: -```java - my : - servers : dev.bar.com,foo.bar.com -``` +**注** When lists are configured in more than one place, overriding works by replacing the entire list. In the preceding example, when `my.servers` is defined in several places, the entire list from the `PropertySource` with higher precedence overrides any other configuration for that list. Both comma-separated lists and YAML lists can be used for completely overriding the contents of the list.当配置列表时需要格外小心,因为重写并不会像你期望的那样发生。在上面的例子中,当my.servers在几个地方被重新定义时,个别的元素会被重写,而不是列表。 为了确保拥有更高优先权的属性源能够重写列表,你需要把它定义为单个的属性: From c88ecbb2e95e96378920853af5ccccdd26ca7ae9 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E7=83=AD=E5=BF=83=E5=B8=82=E6=B0=91=E9=92=9F=E5=B0=8F?= =?UTF-8?q?=E5=BC=BA?= Date: Sat, 12 May 2018 10:24:02 +0800 Subject: [PATCH 117/865] Update 24.6.1. Loading YAML.md --- IV. Spring Boot features/24.6.1. Loading YAML.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/IV. Spring Boot features/24.6.1. Loading YAML.md b/IV. Spring Boot features/24.6.1. Loading YAML.md index 5d940924..9ea301c3 100644 --- a/IV. Spring Boot features/24.6.1. Loading YAML.md +++ b/IV. Spring Boot features/24.6.1. Loading YAML.md @@ -42,4 +42,4 @@ public class Config { } ``` -**注** When lists are configured in more than one place, overriding works by replacing the entire list. In the preceding example, when `my.servers` is defined in several places, the entire list from the `PropertySource` with higher precedence overrides any other configuration for that list. Both comma-separated lists and YAML lists can be used for completely overriding the contents of the list.当配置列表时需要格外小心,因为重写并不会像你期望的那样发生。在上面的例子中,当my.servers在几个地方被重新定义时,个别的元素会被重写,而不是列表。 为了确保拥有更高优先权的属性源能够重写列表,你需要把它定义为单个的属性: +**注** 当多个位置配置了列表,重写通过替换整个列表发生。在之前的例子里,当在几个地方定义了`my.servers`,来自`PropertySource`拥有更高优先级的整个列表会重写那个列表的任何其它的配置。可以使用逗号分隔的列表和YAML列表来完全重写列表的内容。 From eec3609261b8fcc33413e364903c6a8ebcd5d9d5 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E7=83=AD=E5=BF=83=E5=B8=82=E6=B0=91=E9=92=9F=E5=B0=8F?= =?UTF-8?q?=E5=BC=BA?= Date: Tue, 15 May 2018 21:20:39 +0800 Subject: [PATCH 118/865] Update and rename 24.6.2. Exposing YAML as properties in the Spring Environment.md to 24.6.2. Exposing YAML as Properties in the Spring Environment.md --- ...2. Exposing YAML as Properties in the Spring Environment.md} | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) rename IV. Spring Boot features/{24.6.2. Exposing YAML as properties in the Spring Environment.md => 24.6.2. Exposing YAML as Properties in the Spring Environment.md} (50%) diff --git a/IV. Spring Boot features/24.6.2. Exposing YAML as properties in the Spring Environment.md b/IV. Spring Boot features/24.6.2. Exposing YAML as Properties in the Spring Environment.md similarity index 50% rename from IV. Spring Boot features/24.6.2. Exposing YAML as properties in the Spring Environment.md rename to IV. Spring Boot features/24.6.2. Exposing YAML as Properties in the Spring Environment.md index 707a396d..19196af0 100644 --- a/IV. Spring Boot features/24.6.2. Exposing YAML as properties in the Spring Environment.md +++ b/IV. Spring Boot features/24.6.2. Exposing YAML as Properties in the Spring Environment.md @@ -1,3 +1,3 @@ ### 24.6.2. 在Spring环境中使用YAML暴露属性 -`YamlPropertySourceLoader`类能够将YAML作为`PropertySource`导出到Sprig `Environment`,这允许你使用常用的`@Value`注解配合占位符语法访问YAML属性。 +`YamlPropertySourceLoader`类能够将YAML作为`PropertySource`导出到Sprig `Environment`,这允许你使用`@Value`注解配合占位符语法访问YAML属性。 From ac94c1309d6b838ce38afcb42821fc2a733fc5e9 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E7=83=AD=E5=BF=83=E5=B8=82=E6=B0=91=E9=92=9F=E5=B0=8F?= =?UTF-8?q?=E5=BC=BA?= Date: Tue, 15 May 2018 21:31:38 +0800 Subject: [PATCH 119/865] Update and rename 24.6.3. Multi-profile YAML documents.md to 24.6.3. Multi-profile YAML Documents.md --- ...nts.md => 24.6.3. Multi-profile YAML Documents.md} | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) rename IV. Spring Boot features/{24.6.3. Multi-profile YAML documents.md => 24.6.3. Multi-profile YAML Documents.md} (68%) diff --git a/IV. Spring Boot features/24.6.3. Multi-profile YAML documents.md b/IV. Spring Boot features/24.6.3. Multi-profile YAML Documents.md similarity index 68% rename from IV. Spring Boot features/24.6.3. Multi-profile YAML documents.md rename to IV. Spring Boot features/24.6.3. Multi-profile YAML Documents.md index 570e7001..29bfda51 100644 --- a/IV. Spring Boot features/24.6.3. Multi-profile YAML documents.md +++ b/IV. Spring Boot features/24.6.3. Multi-profile YAML Documents.md @@ -15,9 +15,9 @@ spring: server: address: 192.168.1.120 ``` -在以上例子中,如果`development` profile被激活,`server.address`属性将是`127.0.0.1`;如果`development`和`production` profiles没有启用,则该属性的值将是`192.168.1.100`。 +在之前的例子中,如果`development` profile被激活,`server.address`属性将是`127.0.0.1`。相似的,如果`production` profile被激活,`server.address`属性将是`192.168.1.120`。如果`development`和`production` profiles没有启用,则该属性的值将是`192.168.1.100`。 -在应用上下文启动时,如果没有明确指定激活的profiles,则默认的profiles将生效。所以,在下面的文档中我们为`security.user.password`设置了一个值,该值只在"default" profile中有效: +在应用上下文启动时,如果没有明确指定激活的profiles,则默认的profiles将生效。所以,在下面的文档中我们为`spring.security.user.password`设置了一个值,该值只在"default" profile中有效: ```properties server: port: 8000 @@ -32,8 +32,9 @@ security: ```properties server: port: 8000 -security: - user: - password: weak +spring: + security: + user: + password: weak ``` 通过`!`可以对`spring.profiles`指定的profiles进行取反(negated,跟java中的`!`作用一样),如果negated和non-negated profiles都指定一个单一文件,至少需要匹配一个non-negated profile,可能不会匹配任何negated profiles。 From c6ebc402afbfd4229bc877feae289dfadd517f64 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E7=83=AD=E5=BF=83=E5=B8=82=E6=B0=91=E9=92=9F=E5=B0=8F?= =?UTF-8?q?=E5=BC=BA?= Date: Tue, 15 May 2018 21:44:34 +0800 Subject: [PATCH 120/865] Update SUMMARY.md --- SUMMARY.md | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/SUMMARY.md b/SUMMARY.md index ed5bbc2d..4610c6d0 100644 --- a/SUMMARY.md +++ b/SUMMARY.md @@ -95,11 +95,11 @@ * [24.2. 访问命令行属性](IV. Spring Boot features/24.2. Accessing Command Line Properties.md) * [24.3. 应用属性文件](IV. Spring Boot features/24.3. Application Property Files.md) * [24.4. Profile-specific属性](IV. Spring Boot features/24.4. Profile-specific Properties.md) - * [24.5. 属性占位符](IV. Spring Boot features/24.5. Placeholders in properties.md) - * [24.6. 使用YAML代替Properties](IV. Spring Boot features/24.6. Using YAML instead of Properties.md) + * [24.5. 属性占位符](IV. Spring Boot features/24.5. Placeholders in Properties.md) +      * [24.6. 使用YAML代替Properties](IV. Spring Boot features/24.6. Using YAML Instead of Properties.md) * [24.6.1. 加载YAML](IV. Spring Boot features/24.6.1. Loading YAML.md) - * [24.6.2. 在Spring环境中使用YAML暴露属性](IV. Spring Boot features/24.6.2. Exposing YAML as properties in the Spring Environment.md) - * [24.6.3. Multi-profile YAML文档](IV. Spring Boot features/24.6.3. Multi-profile YAML documents.md) + * [24.6.2. 在Spring环境中使用YAML暴露属性](IV. Spring Boot features/24.6.2. Exposing YAML as Properties in the Spring Environment.md) +         * [24.6.3. Multi-profile YAML文档](IV. Spring Boot features/24.6.3. Multi-profile YAML Documents.md) * [24.6.4. YAML缺点](IV. Spring Boot features/24.6.4. YAML shortcomings.md) * [24.6.5. 合并YAML列表](IV. Spring Boot features/24.6.5. Merging YAML lists.md) * [24.7. 类型安全的配置属性](IV. Spring Boot features/24.7. Type-safe Configuration Properties.md) From 8001734d3dcfece2b64a520830448c8e75757f0e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E7=83=AD=E5=BF=83=E5=B8=82=E6=B0=91=E9=92=9F=E5=B0=8F?= =?UTF-8?q?=E5=BC=BA?= Date: Thu, 17 May 2018 22:48:40 +0800 Subject: [PATCH 121/865] Rename 24.6.4. YAML shortcomings.md to 24.6.4. YAML Shortcomings.md --- ...{24.6.4. YAML shortcomings.md => 24.6.4. YAML Shortcomings.md} | 0 1 file changed, 0 insertions(+), 0 deletions(-) rename IV. Spring Boot features/{24.6.4. YAML shortcomings.md => 24.6.4. YAML Shortcomings.md} (100%) diff --git a/IV. Spring Boot features/24.6.4. YAML shortcomings.md b/IV. Spring Boot features/24.6.4. YAML Shortcomings.md similarity index 100% rename from IV. Spring Boot features/24.6.4. YAML shortcomings.md rename to IV. Spring Boot features/24.6.4. YAML Shortcomings.md From 5d20a33bae5c179b3d49d47ab0aef8758b3951ab Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E7=83=AD=E5=BF=83=E5=B8=82=E6=B0=91=E9=92=9F=E5=B0=8F?= =?UTF-8?q?=E5=BC=BA?= Date: Thu, 17 May 2018 23:00:41 +0800 Subject: [PATCH 122/865] Update and rename 24.6.5. Merging YAML lists.md to 24.6.5. Merging YAML Lists.md --- .../24.6.5. Merging YAML Lists.md | 46 +++++++++++++++++++ .../24.6.5. Merging YAML lists.md | 46 ------------------- 2 files changed, 46 insertions(+), 46 deletions(-) create mode 100644 IV. Spring Boot features/24.6.5. Merging YAML Lists.md delete mode 100644 IV. Spring Boot features/24.6.5. Merging YAML lists.md diff --git a/IV. Spring Boot features/24.6.5. Merging YAML Lists.md b/IV. Spring Boot features/24.6.5. Merging YAML Lists.md new file mode 100644 index 00000000..63dabeb6 --- /dev/null +++ b/IV. Spring Boot features/24.6.5. Merging YAML Lists.md @@ -0,0 +1,46 @@ +### 24.6.5 合并YAML列表 + +正如[之前](https://docs.spring.io/spring-boot/docs/2.0.0.RELEASE/reference/htmlsingle/#boot-features-external-config-loading-yaml)展示的,所有YAML最终都转换为properties,在通过一个profile覆盖"list"属性时这个过程可能不够直观(counter intuitive)。例如,假设有一个`MyPojo`对象,默认它的`name`和`description`属性都为`null`。下面的例子从`AcmeProperties`暴露一个`MyPojo`对象列表(list): +```java +@ConfigurationProperties("acme") +public class AcmeProperties { + + private final List list = new ArrayList<>(); + + public List getList() { + return this.list; + } + +} +``` +考虑如下配置: +```properties +acme: + list: + - name: my name + description: my description +--- +spring: + profiles: dev +acme: + list: + - name: my another name +``` +如果`dev` profile没有激活,`AcmeProperties.list`将包括一个如之前定义的`MyPojo`实体。即使`dev`生效,该`list`仍旧只包含一个实体(`name`值为`my another name`,`description`值为`null`)。此配置不会向该列表添加第二个`MyPojo`实例,也不会对该项进行合并。 + +当一个集合定义在多个profiles时,只使用优先级最高的。考虑下面的例子: +```properties +acme: + list: + - name: my name + description: my description + - name: another name + description: another description +--- +spring: + profiles: dev +acme: + list: + - name: my another name +``` +在之前的示例中,如果`dev` profile激活,`AcmeProperties.list`将包含一个`MyPojo`实体(`name`值为`my another name`,`description`值为`null`)。 diff --git a/IV. Spring Boot features/24.6.5. Merging YAML lists.md b/IV. Spring Boot features/24.6.5. Merging YAML lists.md deleted file mode 100644 index c584ecdc..00000000 --- a/IV. Spring Boot features/24.6.5. Merging YAML lists.md +++ /dev/null @@ -1,46 +0,0 @@ -###24.6.5 合并YAML列表 - -正如[上面](http://docs.spring.io/spring-boot/docs/2.0.0.RELEASE/reference/htmlsingle/#boot-features-external-config-loading-yaml)看到的,所有YAML最终都转换为properties,在通过一个profile覆盖"list"属性时这个过程可能不够直观(counter intuitive)。例如,假设有一个`MyPojo`对象,默认它的`name`和`description`属性都为`null`,下面我们将从`FooProperties`暴露一个`MyPojo`对象列表(list): -```java -@ConfigurationProperties("foo") -public class FooProperties { - - private final List list = new ArrayList<>(); - - public List getList() { - return this.list; - } - -} -``` -考虑如下配置: -```properties -foo: - list: - - name: my name - description: my description ---- -spring: - profiles: dev -foo: - list: - - name: my another name -``` -如果`dev` profile没有激活,`FooProperties.list`将包括一个如上述定义的`MyPojo`实体,即使`dev`生效,该`list`仍旧只包含一个实体(`name`值为`my another name`,`description`值为`null`)。此配置不会向该列表添加第二个`MyPojo`实例,也不会对该项进行合并。 - -当一个集合定义在多个profiles时,只使用优先级最高的: -```properties -foo: - list: - - name: my name - description: my description - - name: another name - description: another description ---- -spring: - profiles: dev -foo: - list: - - name: my another name -``` -在以上示例中,如果`dev` profile激活,`FooProperties.list`将包含一个`MyPojo`实体(`name`值为`my another name`,`description`值为`null`)。 From fa5eb27408fc0fbea8d5d66f6a143ed824796ea3 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E7=83=AD=E5=BF=83=E5=B8=82=E6=B0=91=E9=92=9F=E5=B0=8F?= =?UTF-8?q?=E5=BC=BA?= Date: Thu, 17 May 2018 23:01:37 +0800 Subject: [PATCH 123/865] Update SUMMARY.md --- SUMMARY.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/SUMMARY.md b/SUMMARY.md index 4610c6d0..d97a33d3 100644 --- a/SUMMARY.md +++ b/SUMMARY.md @@ -100,8 +100,8 @@ * [24.6.1. 加载YAML](IV. Spring Boot features/24.6.1. Loading YAML.md) * [24.6.2. 在Spring环境中使用YAML暴露属性](IV. Spring Boot features/24.6.2. Exposing YAML as Properties in the Spring Environment.md)         * [24.6.3. Multi-profile YAML文档](IV. Spring Boot features/24.6.3. Multi-profile YAML Documents.md) - * [24.6.4. YAML缺点](IV. Spring Boot features/24.6.4. YAML shortcomings.md) - * [24.6.5. 合并YAML列表](IV. Spring Boot features/24.6.5. Merging YAML lists.md) +         * [24.6.4. YAML缺点](IV. Spring Boot features/24.6.4. YAML Shortcomings.md) +         * [24.6.5. 合并YAML列表](IV. Spring Boot features/24.6.5. Merging YAML Lists.md) * [24.7. 类型安全的配置属性](IV. Spring Boot features/24.7. Type-safe Configuration Properties.md) * [24.7.1. 第三方配置](IV. Spring Boot features/24.7.1. Third-party configuration.md) * [24.7.2. Relaxed绑定](IV. Spring Boot features/24.7.2. Relaxed binding.md) From a2e8f9f2ec0aa877c897ecec0e11b662d2d6a650 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E7=83=AD=E5=BF=83=E5=B8=82=E6=B0=91=E9=92=9F=E5=B0=8F?= =?UTF-8?q?=E5=BC=BA?= Date: Thu, 17 May 2018 23:23:14 +0800 Subject: [PATCH 124/865] Update 24.7. Type-safe Configuration Properties.md --- ...4.7. Type-safe Configuration Properties.md | 46 +++++++++---------- 1 file changed, 22 insertions(+), 24 deletions(-) diff --git a/IV. Spring Boot features/24.7. Type-safe Configuration Properties.md b/IV. Spring Boot features/24.7. Type-safe Configuration Properties.md index fe947750..86feb628 100644 --- a/IV. Spring Boot features/24.7. Type-safe Configuration Properties.md +++ b/IV. Spring Boot features/24.7. Type-safe Configuration Properties.md @@ -1,6 +1,6 @@ ### 24.7. 类型安全的配置属性 -使用`@Value("${property}")`注解注入配置属性有时会比较麻烦(cumbersome),特别是需要使用多个properties,或数据本身有层次结构。Spring Boot提供一种使用配置的替代方法,这种方法允许强类型的beans以管理和校验应用的配置。 +使用`@Value("${property}")`注解注入配置属性有时会比较难处理,特别是但你需要使用多个properties,或者数据本身有层次结构的时候。Spring Boot提供一种可选的使用配置的方法,这种方法让强类型的beans来管理和校验应用的配置,如下所示: ```java package com.example; @@ -11,8 +11,8 @@ import java.util.List; import org.springframework.boot.context.properties.ConfigurationProperties; -@ConfigurationProperties("foo") -public class FooProperties { +@ConfigurationProperties("acme") +public class AcmeProperties { private boolean enabled; @@ -53,46 +53,46 @@ public class FooProperties { } } ``` -上面的POJO定义了如下的属性: +之前的POJO定义了如下的属性: -- foo.enabled,默认为false +- acme.enabled,默认值为false -- foo.remote-address,带有一个能从String转换的类型 +- acme.remote-address,带有一个能从String转换的类型 -- foo.security.username,有一个嵌套的“security”,它的名字由属性名定义。特别的,返回类型没有在那儿被使用,本来可以是SecurityProperties。 +- acme.security.username,有一个嵌套的“security”对象,它的名字由属性名定义。特别的,返回类型没有在那儿被使用,本来可以是SecurityProperties。 -- foo.security.password +- acme.security.password -- foo.security.roles,一个String的集合 +- acme.security.roles,一个String的集合 **注意** getters和setters时常是必须的。因为跟Spring MVC一样,绑定是通过标准的Java Beans属性描述符进行的。但是也有不需要setter的情况: - Maps,只要它们被初始化了,需要getter,但setter不是必须的。因为binder能够改变它们。 -- Collections和arrays能够通过索引(通常用YAML),或者使用单个的由逗号分隔的值(属性)存取。 在后面的情况下,setter是必须的。对于这些类型,我们建议总是加上setter。如果你初始化一个collection,确保它不是不可变的(如同上面的例子)。 +- Collections和arrays能够通过索引(通常用YAML),或者使用单个的由逗号分隔的值(属性)存取。 在后面的情况下,setter是必须的。对于这些类型,我们建议总是加上setter。如果你初始化一个collection,确保它不是不可变的(如同之前的例子)。 -- 如果嵌套的POJO属性被初始化(就像上面例子里的Security域),setter就不需要。如果你想要binder使用它默认的构造器,即时创建一个实例,你就需要一个setter。 +- 如果嵌套的POJO属性被初始化(就像之前例子里的Security域),setter就不需要。如果你想要binder使用它默认的构造器,即时创建一个实例,你就需要一个setter。 有些人使用Project Lombok自动添加getters和setters。确保Lombok不会为这些类型生成任何特别的构造器,因为它会自动地被容器使用,来实例化对象。 **提示** 查看[@Value和@ConfigurationProperties](https://docs.spring.io/spring-boot/docs/2.0.0.RELEASE/reference/htmlsingle/#boot-features-external-config-vs-value)之间的区别。 -你需要在`@EnableConfigurationProperties`注解中列出要注册的属性类: +你需要在`@EnableConfigurationProperties`注解中列出要注册的属性类,如下所示: ```java @Configuration -@EnableConfigurationProperties(FooProperties.class) +@EnableConfigurationProperties(AcmeProperties.class) public class MyConfiguration { } ``` -**注** 当`@ConfigurationProperties` bean以这种方式注册时,该bean将有个约定的名称:`-`,``是`@ConfigurationProperties`注解中定义的environment key前缀,``是bean的全限定名。如果注解中没有提供任何前缀,那就只使用bean的全限定名。上述示例中的bean名称将是`foo-com.example.FooProperties`。 +**注** 当`@ConfigurationProperties` bean以这种方式注册时,该bean将有个约定的名称:`-`,``是`@ConfigurationProperties`注解中定义的environment key前缀,``是bean的全限定名。如果注解中没有提供任何前缀,那就只使用bean的全限定名。上述示例中的bean名称将是`acme-com.example.AcmeProperties`。 -尽管上述配置为`FooProperties`创建了一个常规的bean,不过我们建议`@ConfigurationProperties`只用来处理environment(只用于注入配置,系统环境之类的),特别是不要注入上下文中的其他beans。话虽如此,`@EnableConfigurationProperties`注解会自动应用到你的项目,任何存在的,注解`@ConfigurationProperties`的bean将会从`Environment`中得到配置。只要确定`FooProperties`是一个已存在的bean,`MyConfiguration`就可以不用了。 +尽管上述配置为`FooProperties`创建了一个常规的bean,不过我们建议`@ConfigurationProperties`只用来处理environment(只用于注入配置,系统环境之类的),特别是不要注入上下文中的其他beans。话虽如此,`@EnableConfigurationProperties`注解会自动应用到你的项目,任何存在的,注解`@ConfigurationProperties`的bean将会从`Environment`中得到配置。只要确定`AcmeProperties`是一个已存在的bean,`MyConfiguration`就可以不用了。 ```java @Component -@ConfigurationProperties(prefix="foo") -public class FooProperties { +@ConfigurationProperties(prefix="acme") +public class AcmeProperties { - // ... see above + // ... see the preceding example } ``` @@ -100,10 +100,10 @@ public class FooProperties { ```json # application.yml -foo: +acme: remote-address: 192.168.1.1 security: - username: foo + username: admin roles: - USER - ADMIN @@ -115,10 +115,10 @@ foo: @Service public class MyService { - private final FooProperties properties; + private final AcmeProperties properties; @Autowired - public MyService(FooProperties properties) { + public MyService(AcmeProperties properties) { this.properties = properties; } @@ -133,5 +133,3 @@ public class MyService { } ``` **注** 使用`@ConfigurationProperties`能够产生可被IDEs使用的元数据文件,来为你自己的键值提供自动补全,具体参考[Appendix B, Configuration meta-data](../X. Appendices/B. Configuration meta-data.md)。 - -**此章节翻译的不好,后续整理*** From e2c9037012674539540c307ac640f6d79c856122 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E7=83=AD=E5=BF=83=E5=B8=82=E6=B0=91=E9=92=9F=E5=B0=8F?= =?UTF-8?q?=E5=BC=BA?= Date: Sun, 20 May 2018 00:15:15 +0800 Subject: [PATCH 125/865] Update and rename 24.7.1. Third-party configuration.md to 24.7.1. Third-party Configuration.md --- ...onfiguration.md => 24.7.1. Third-party Configuration.md} | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) rename IV. Spring Boot features/{24.7.1. Third-party configuration.md => 24.7.1. Third-party Configuration.md} (59%) diff --git a/IV. Spring Boot features/24.7.1. Third-party configuration.md b/IV. Spring Boot features/24.7.1. Third-party Configuration.md similarity index 59% rename from IV. Spring Boot features/24.7.1. Third-party configuration.md rename to IV. Spring Boot features/24.7.1. Third-party Configuration.md index 39ca58af..3a9dc764 100644 --- a/IV. Spring Boot features/24.7.1. Third-party configuration.md +++ b/IV. Spring Boot features/24.7.1. Third-party Configuration.md @@ -4,10 +4,10 @@ 为了从`Environment`属性中配置一个bean,你需要使用`@ConfigurationProperties`注解该bean: ```java -@ConfigurationProperties(prefix = "bar") +@ConfigurationProperties(prefix = "another") @Bean -public BarComponent barComponent() { +public AnotherComponent anotherComponent() { ... } ``` -和上面`FooProperties`的示例方式相同,所有以`bar`为前缀的属性定义都会被映射到`BarComponent`上。 +和之前的`AcmeProperties`的示例方式相同,所有以`another`为前缀的属性定义都会被映射到`AnotherComponent`上。 From cb97b0c0b5e211a118f053d9724306065fb0ee31 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E7=83=AD=E5=BF=83=E5=B8=82=E6=B0=91=E9=92=9F=E5=B0=8F?= =?UTF-8?q?=E5=BC=BA?= Date: Sun, 20 May 2018 00:17:29 +0800 Subject: [PATCH 126/865] Update SUMMARY.md --- SUMMARY.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/SUMMARY.md b/SUMMARY.md index d97a33d3..a3fcb452 100644 --- a/SUMMARY.md +++ b/SUMMARY.md @@ -103,7 +103,7 @@         * [24.6.4. YAML缺点](IV. Spring Boot features/24.6.4. YAML Shortcomings.md)         * [24.6.5. 合并YAML列表](IV. Spring Boot features/24.6.5. Merging YAML Lists.md) * [24.7. 类型安全的配置属性](IV. Spring Boot features/24.7. Type-safe Configuration Properties.md) - * [24.7.1. 第三方配置](IV. Spring Boot features/24.7.1. Third-party configuration.md) +         * [24.7.1. 第三方配置](IV. Spring Boot features/24.7.1. Third-party Configuration.md) * [24.7.2. Relaxed绑定](IV. Spring Boot features/24.7.2. Relaxed binding.md) * [24.7.3. 属性转换](IV. Spring Boot features/24.7.3. Properties conversion.md) * [24.7.4. @ConfigurationProperties校验](IV. Spring Boot features/24.7.4. @ConfigurationProperties Validation.md) From 9743c60fb114f93f3c0687c23322f25657b440a4 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E7=83=AD=E5=BF=83=E5=B8=82=E6=B0=91=E9=92=9F=E5=B0=8F?= =?UTF-8?q?=E5=BC=BA?= Date: Sun, 20 May 2018 13:39:00 +0800 Subject: [PATCH 127/865] Update and rename 24.7.2. Relaxed binding.md to 24.7.2. Relaxed Binding.md --- ... binding.md => 24.7.2. Relaxed Binding.md} | 20 +++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) rename IV. Spring Boot features/{24.7.2. Relaxed binding.md => 24.7.2. Relaxed Binding.md} (67%) diff --git a/IV. Spring Boot features/24.7.2. Relaxed binding.md b/IV. Spring Boot features/24.7.2. Relaxed Binding.md similarity index 67% rename from IV. Spring Boot features/24.7.2. Relaxed binding.md rename to IV. Spring Boot features/24.7.2. Relaxed Binding.md index 4544f2a6..17233bc0 100644 --- a/IV. Spring Boot features/24.7.2. Relaxed binding.md +++ b/IV. Spring Boot features/24.7.2. Relaxed Binding.md @@ -2,9 +2,9 @@ Spring Boot将`Environment`属性绑定到`@ConfigurationProperties` beans时会使用一些宽松的规则,所以`Environment`属性名和bean属性名不需要精确匹配。常见的示例中有用的包括虚线分割(比如,`context-path`绑定到`contextPath`),将environment属性转为大写字母(比如,`PORT`绑定`port`)。 -例如,给定以下`@ConfigurationProperties`类: +例如,考虑以下`@ConfigurationProperties`类: ```java -@ConfigurationProperties(prefix="person") +@ConfigurationProperties(prefix="acme.my-project.person") public class OwnerProperties { private String firstName; @@ -19,24 +19,24 @@ public class OwnerProperties { } ``` -下面的属性名都能使用: +在之前的例子里,下面的属性名都能使用: 表格 24.1. relaxed绑定 | 属性 | 说明 | | -------- | :----- | -|`person.firstName`|标准驼峰命名语法| -|`person.first-name`|短横线隔开表示,推荐用于`.properties`和`.yml`文件中| -|`person.first_name`|下划线表示,用于`.properties`和`.yml`文件的可选格式| -|`PERSON_FIRST_NAME`|大写形式,推荐用于系统环境变量| +|`acme.my-project.person.firstName`|标准驼峰命名语法| +|`acme.my-project.person.first-name`|短横线隔开表示,推荐用于`.properties`和`.yml`文件中| +|`acme.my-project.person.first_name`|下划线表示,用于`.properties`和`.yml`文件的可选格式| +|`ACME_MYPROJECT_PERSON_FIRSTNAME`|大写形式,推荐用于系统环境变量| -**注** 注解的`前缀`值必须用短横线隔开表示,即小写并用`-`隔开。 +**注** 注解的`前缀`值必须用短横线隔开表示,即小写并用`-`隔开,比如`acme.my-project.person`。 表格 24.2. 各个属性源的relaxed绑定规则 | 属性源 | Simple | List | | -------- | :----- | |Properties文件|驼峰命名法,短横线隔开表示,下划线表示|使用`[ ]`的标准list语法,或者由逗号分隔的值| |YAML文件|驼峰命名法,短横线隔开表示,下划线表示|标准的YAML list语法,或者由逗号分隔的值| -|环境变量|下划线作为分隔符的大写格式。`_`不应当用在属性名上|被下划线环绕的数值。比如:`MY_FOO_1_BAR = my.foo[1].bar`| +|环境变量|下划线作为分隔符的大写格式。`_`不应当用在属性名上|被下划线环绕的数值。比如:`MY_ACME_1_OTHER = my.acme[1].other`| |系统属性|驼峰命名法,短横线隔开表示,下划线表示|使用`[ ]`的标准list语法,或者由逗号分隔的值| -**提示** 我们推荐:当可能时,属性用小写短横线隔开的格式储存。比如,`my.property-name=foo` \ No newline at end of file +**提示** 我们推荐:当可能时,属性用小写短横线隔开的格式储存。比如,`my.property-name=acme` From fb2cd121f9f5b3cf32ccdaac502ed9ebe5c89c14 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E7=83=AD=E5=BF=83=E5=B8=82=E6=B0=91=E9=92=9F=E5=B0=8F?= =?UTF-8?q?=E5=BC=BA?= Date: Sun, 20 May 2018 13:46:14 +0800 Subject: [PATCH 128/865] Update 24.7.2. Relaxed Binding.md --- IV. Spring Boot features/24.7.2. Relaxed Binding.md | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/IV. Spring Boot features/24.7.2. Relaxed Binding.md b/IV. Spring Boot features/24.7.2. Relaxed Binding.md index 17233bc0..0d8e1dc3 100644 --- a/IV. Spring Boot features/24.7.2. Relaxed Binding.md +++ b/IV. Spring Boot features/24.7.2. Relaxed Binding.md @@ -22,6 +22,7 @@ public class OwnerProperties { 在之前的例子里,下面的属性名都能使用: 表格 24.1. relaxed绑定 + | 属性 | 说明 | | -------- | :----- | |`acme.my-project.person.firstName`|标准驼峰命名语法| @@ -32,8 +33,9 @@ public class OwnerProperties { **注** 注解的`前缀`值必须用短横线隔开表示,即小写并用`-`隔开,比如`acme.my-project.person`。 表格 24.2. 各个属性源的relaxed绑定规则 + | 属性源 | Simple | List | -| -------- | :----- | +| -------- | :----- | :----- | |Properties文件|驼峰命名法,短横线隔开表示,下划线表示|使用`[ ]`的标准list语法,或者由逗号分隔的值| |YAML文件|驼峰命名法,短横线隔开表示,下划线表示|标准的YAML list语法,或者由逗号分隔的值| |环境变量|下划线作为分隔符的大写格式。`_`不应当用在属性名上|被下划线环绕的数值。比如:`MY_ACME_1_OTHER = my.acme[1].other`| From eac3d9d74391e3815d2d57ed50269b51a7863acf Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E7=83=AD=E5=BF=83=E5=B8=82=E6=B0=91=E9=92=9F=E5=B0=8F?= =?UTF-8?q?=E5=BC=BA?= Date: Sun, 20 May 2018 14:13:14 +0800 Subject: [PATCH 129/865] Update and rename 24.7.3. Properties conversion.md to 24.7.3. Properties Conversion.md --- IV. Spring Boot features/24.7.3. Properties Conversion.md | 5 +++++ IV. Spring Boot features/24.7.3. Properties conversion.md | 5 ----- 2 files changed, 5 insertions(+), 5 deletions(-) create mode 100644 IV. Spring Boot features/24.7.3. Properties Conversion.md delete mode 100644 IV. Spring Boot features/24.7.3. Properties conversion.md diff --git a/IV. Spring Boot features/24.7.3. Properties Conversion.md b/IV. Spring Boot features/24.7.3. Properties Conversion.md new file mode 100644 index 00000000..8643ae9f --- /dev/null +++ b/IV. Spring Boot features/24.7.3. Properties Conversion.md @@ -0,0 +1,5 @@ +### 24.7.3 属性转换 + +将外部应用配置绑定到`@ConfigurationProperties` beans时,Spring Boot会尝试将属性强制转换为正确的类型。如果需要自定义类型转换器,你可以提供一个`ConversionService` bean(名为`conversionService`的bean),或自定义属性编辑器(通过`CustomEditorConfigurer` bean),或自定义`Converters`(bean定义时需要注解`@ConfigurationPropertiesBinding`)。 + +**注** 由于该bean在应用程序生命周期的早期就需要使用,所以确保限制你的`ConversionService`使用的依赖。通常,在创建时期任何你需要的依赖可能都没完全初始化。如果强制配置关键字不需要它,而且只依赖满足`@ConfigurationPropertiesBinding`的自定义的转换器,你可能想要重命名自定义的`ConversionService`。 diff --git a/IV. Spring Boot features/24.7.3. Properties conversion.md b/IV. Spring Boot features/24.7.3. Properties conversion.md deleted file mode 100644 index b6382c15..00000000 --- a/IV. Spring Boot features/24.7.3. Properties conversion.md +++ /dev/null @@ -1,5 +0,0 @@ -### 24.7.3 属性转换 - -将外部应用配置绑定到`@ConfigurationProperties` beans时,Spring会尝试将属性强制转换为正确的类型。如果需要自定义类型转换器,你可以提供一个`ConversionService` bean(bean id为`conversionService`),或自定义属性编辑器(通过`CustomEditorConfigurer` bean),或自定义`Converters`(bean定义时需要注解`@ConfigurationPropertiesBinding`)。 - -**注** 由于该bean在应用程序生命周期的早期就需要使用,所以确保限制你的`ConversionService`使用的依赖。通常,在创建时期任何你需要的依赖可能都没完全初始化。 From 589d3450b3a899490a184dd2867c505c44b1cf1c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E7=83=AD=E5=BF=83=E5=B8=82=E6=B0=91=E9=92=9F=E5=B0=8F?= =?UTF-8?q?=E5=BC=BA?= Date: Sun, 20 May 2018 14:30:12 +0800 Subject: [PATCH 130/865] Update SUMMARY.md --- SUMMARY.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/SUMMARY.md b/SUMMARY.md index a3fcb452..cab23b88 100644 --- a/SUMMARY.md +++ b/SUMMARY.md @@ -104,8 +104,8 @@         * [24.6.5. 合并YAML列表](IV. Spring Boot features/24.6.5. Merging YAML Lists.md) * [24.7. 类型安全的配置属性](IV. Spring Boot features/24.7. Type-safe Configuration Properties.md)         * [24.7.1. 第三方配置](IV. Spring Boot features/24.7.1. Third-party Configuration.md) - * [24.7.2. Relaxed绑定](IV. Spring Boot features/24.7.2. Relaxed binding.md) - * [24.7.3. 属性转换](IV. Spring Boot features/24.7.3. Properties conversion.md) +         * [24.7.2. Relaxed绑定](IV. Spring Boot features/24.7.2. Relaxed Binding.md) +         * [24.7.3. 属性转换](IV. Spring Boot features/24.7.3. Properties Conversion.md) * [24.7.4. @ConfigurationProperties校验](IV. Spring Boot features/24.7.4. @ConfigurationProperties Validation.md) * [24.7.5. @ConfigurationProperties vs @Value](IV. Spring Boot features/24.7.5. @ConfigurationProperties vs. @Value.md) * [25. Profiles](IV. Spring Boot features/25. Profiles.md) From d3de226a656caedbd3bb53427157974aaeb0d239 Mon Sep 17 00:00:00 2001 From: Jack Zhong Date: Sun, 27 May 2018 20:32:53 +0800 Subject: [PATCH 131/865] =?UTF-8?q?=E7=BF=BB=E8=AF=91=E6=96=B0=E5=A2=9E?= =?UTF-8?q?=E7=9A=84=E5=B0=8F=E8=8A=82=EF=BC=9A=E6=97=B6=E9=97=B4=E6=AE=B5?= =?UTF-8?q?=E8=BD=AC=E6=8D=A2?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../24.7.3. Properties Conversion.md | 51 +++++++++++++++++++ 1 file changed, 51 insertions(+) diff --git a/IV. Spring Boot features/24.7.3. Properties Conversion.md b/IV. Spring Boot features/24.7.3. Properties Conversion.md index 8643ae9f..7ff906c1 100644 --- a/IV. Spring Boot features/24.7.3. Properties Conversion.md +++ b/IV. Spring Boot features/24.7.3. Properties Conversion.md @@ -3,3 +3,54 @@ 将外部应用配置绑定到`@ConfigurationProperties` beans时,Spring Boot会尝试将属性强制转换为正确的类型。如果需要自定义类型转换器,你可以提供一个`ConversionService` bean(名为`conversionService`的bean),或自定义属性编辑器(通过`CustomEditorConfigurer` bean),或自定义`Converters`(bean定义时需要注解`@ConfigurationPropertiesBinding`)。 **注** 由于该bean在应用程序生命周期的早期就需要使用,所以确保限制你的`ConversionService`使用的依赖。通常,在创建时期任何你需要的依赖可能都没完全初始化。如果强制配置关键字不需要它,而且只依赖满足`@ConfigurationPropertiesBinding`的自定义的转换器,你可能想要重命名自定义的`ConversionService`。 + +**时间段转换** + +Spring Boot对表达时间段有专门的支持。 如果你暴露了`java.time.Duration`属性,可用下列格式的应用属性: + +- 常规的 `long`表示(默认单位为毫秒,除非指定了`@DefaultUnit`) +- [`java.util.Duration`使用的](https://docs.oracle.com/javase/8/docs/api//java/time/Duration.html#parse-java.lang.CharSequence-)标准的ISO-8601格式 +- 组合了值与单位的更加易读的格式(比如`10s`表示10秒) + +考虑下面的例子: +```java +@ConfigurationProperties("app.system") +public class AppSystemProperties { + + @DurationUnit(ChronoUnit.SECONDS) + private Duration sessionTimeout = Duration.ofSeconds(30); + + private Duration readTimeout = Duration.ofMillis(1000); + + public Duration getSessionTimeout() { + return this.sessionTimeout; + } + + public void setSessionTimeout(Duration sessionTimeout) { + this.sessionTimeout = sessionTimeout; + } + + public Duration getReadTimeout() { + return this.readTimeout; + } + + public void setReadTimeout(Duration readTimeout) { + this.readTimeout = readTimeout; + } + +} +``` +为了将会话超时指定为30秒,`30`, `PT30S`和 `30s`都是等价的。将读取超时指定为500毫秒,可以用下列格式里的任何一种:`500`, `PT0.5S`与`500ms`。 + +你也可以使用任何支持的单位: + +- ns用于纳秒 +- ms用于毫秒 +- s用于秒 +- m用于分 +- h用于小时 +- d应用日 + +默认单位是毫秒,可以使用`@DefaultUnit`重写。 + +**注** 如果你正在升级之前的版本,之前的版本简单地使用`Long`来表达时间段,如果切换到`Duration`时不是毫秒,要确保定义了单位(使用`@DefaultUnit`)。这样做的话,在支持更加丰富的格式的同时,升级也能更加透明。 \ No newline at end of file From b0429cf9351a77207237ffc17a03f1138cdd5780 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E7=83=AD=E5=BF=83=E5=B8=82=E6=B0=91=E9=92=9F=E5=B0=8F?= =?UTF-8?q?=E5=BC=BA?= Date: Sun, 27 May 2018 22:10:00 +0800 Subject: [PATCH 132/865] Update 24.7.4. @ConfigurationProperties Validation.md --- ...24.7.4. @ConfigurationProperties Validation.md | 15 +++++++++------ 1 file changed, 9 insertions(+), 6 deletions(-) diff --git a/IV. Spring Boot features/24.7.4. @ConfigurationProperties Validation.md b/IV. Spring Boot features/24.7.4. @ConfigurationProperties Validation.md index 3ed3788b..cbf6d5ed 100644 --- a/IV. Spring Boot features/24.7.4. @ConfigurationProperties Validation.md +++ b/IV. Spring Boot features/24.7.4. @ConfigurationProperties Validation.md @@ -1,10 +1,10 @@ ### 24.7.4. @ConfigurationProperties校验 -Spring Boot将尝试校验`@ConfigurationProperties`类,只要它们标注了Spring的`@Validated`。你可以在你的配置类中直接使用JSR-303 `javax.validation`约束标注。确保在你的类路径中存在适用的JSR-303实现,,再添加约束标注在你的域中: +Spring Boot会尝试校验`@ConfigurationProperties`类,只要它们标注了Spring的`@Validated`。你可以在你的配置类中直接使用JSR-303 `javax.validation`约束标注。确保在你的类路径中存在适用的JSR-303实现,再添加约束标注在你的域中: ```java -@ConfigurationProperties(prefix="foo") +@ConfigurationProperties(prefix="acme") @Validated -public class FooProperties { +public class AcmeProperties { @NotNull private InetAddress remoteAddress; @@ -13,11 +13,14 @@ public class FooProperties { } ``` +**注** 你也可以通过标注`@Bean`方法触发验证,用`@Validated`创建配置属性。 + +尽管在绑定后,内嵌属性也会被验证,但还是把相关的域标注上`@Valid`不失为一种良好的实践。这确保了即使没有找到内嵌属性,验证还是会被触发。下面的例子建立在之前的`AcmeProperties`示例之上: 为了校验内嵌属性的值,你需要使用`@Valid`注解关联的字段以触发它的校验,例如,建立在上面的FooProperties示例之上: ```java -@ConfigurationProperties(prefix="connection") +@ConfigurationProperties(prefix="acme") @Validated -public class FooProperties { +public class AcmeProperties { @NotNull private InetAddress remoteAddress; @@ -40,4 +43,4 @@ public class FooProperties { ``` 你也可以通过创建一个叫做`configurationPropertiesValidator`的bean来添加自定义的Spring `Validator`。`@Bean`方法需要声明为`static`,因为配置属性校验器在应用程序生命周期中创建的比较早,将`@Bean`方法声明为`static`允许该bean在创建时不需要实例化`@Configuration`类,从而避免了早期实例化(early instantiation)的所有问题。相关的示例可以看[这里](https://github.com/spring-projects/spring-boot/tree/v2.0.0.RELEASE/spring-boot-samples/spring-boot-sample-property-validation)。 -**注** `spring-boot-actuator`模块包含一个暴露所有`@ConfigurationProperties` beans的端点(endpoint),通过浏览器打开`/application/configprops`进行浏览,或使用等效的JMX端点,具体参考[Production ready features](../V. Spring Boot Actuator/49. Endpoints.md)。 +**注** `spring-boot-actuator`模块包含一个暴露所有`@ConfigurationProperties` beans的端点(endpoint),通过浏览器打开`/actuator/configprops`进行浏览,或使用等效的JMX端点,具体参考[Production ready features](../V. Spring Boot Actuator/50. Endpoints.md)。 From 0d231c8f89824082767b2da408aa63a9fc5869b6 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E7=83=AD=E5=BF=83=E5=B8=82=E6=B0=91=E9=92=9F=E5=B0=8F?= =?UTF-8?q?=E5=BC=BA?= Date: Tue, 29 May 2018 22:59:18 +0800 Subject: [PATCH 133/865] Update 24.7.5. @ConfigurationProperties vs. @Value.md --- .../24.7.5. @ConfigurationProperties vs. @Value.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/IV. Spring Boot features/24.7.5. @ConfigurationProperties vs. @Value.md b/IV. Spring Boot features/24.7.5. @ConfigurationProperties vs. @Value.md index e49bde6e..d3a81f27 100644 --- a/IV. Spring Boot features/24.7.5. @ConfigurationProperties vs. @Value.md +++ b/IV. Spring Boot features/24.7.5. @ConfigurationProperties vs. @Value.md @@ -1,6 +1,6 @@ ### 24.7.5 @ConfigurationProperties vs. @Value -`@Value`是Spring容器的一个核心特性,它没有提供跟type-safe Configuration Properties相同的特性。下面的表格总结了`@ConfigurationProperties`和`@Value`支持的特性: +`@Value`标注是Spring容器的一个核心特性,它没有提供跟类型安全的配置属性相同的特性。下面的表格总结了`@ConfigurationProperties`和`@Value`支持的特性: |特性|`@ConfigurationProperties`|`@Value`| |---|---|---| From 36479f30ef8b07c44415ad09efa2d51f4e850529 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E7=83=AD=E5=BF=83=E5=B8=82=E6=B0=91=E9=92=9F=E5=B0=8F?= =?UTF-8?q?=E5=BC=BA?= Date: Mon, 4 Jun 2018 23:14:30 +0800 Subject: [PATCH 134/865] Update 25. Profiles.md --- IV. Spring Boot features/25. Profiles.md | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/IV. Spring Boot features/25. Profiles.md b/IV. Spring Boot features/25. Profiles.md index c35f8272..4606d080 100644 --- a/IV. Spring Boot features/25. Profiles.md +++ b/IV. Spring Boot features/25. Profiles.md @@ -1,4 +1,5 @@ ### 25. Profiles + Spring Profiles提供了一种隔离应用程序配置的方式,并让这些配置只在特定的环境下生效。任何`@Component`或`@Configuration`都能注解`@Profile`,从而限制加载它的时机: ```java @Configuration @@ -9,7 +10,7 @@ public class ProductionConfiguration { } ``` -以正常的Spring方式,你可以使用`spring.profiles.active`的`Environment`属性来指定哪个配置生效。你可以使用通常的任何方式来指定该属性,例如,可以将它包含到`application.properties`中: +你可以使用`spring.profiles.active`的`Environment`属性来指定哪个配置生效。你可以使用在这一章的前面描述过的任何方式来指定该属性。例如,可以将它包含到`application.properties`中: ```java spring.profiles.active=dev,hsqldb ``` From 17beedcfd0dfb17f1807279ff078762e1c396d25 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E7=83=AD=E5=BF=83=E5=B8=82=E6=B0=91=E9=92=9F=E5=B0=8F?= =?UTF-8?q?=E5=BC=BA?= Date: Mon, 11 Jun 2018 23:58:56 +0800 Subject: [PATCH 135/865] Update and rename 25.1. Adding active profiles.md to 25.1. Adding Active Profiles.md --- ...ing active profiles.md => 25.1. Adding Active Profiles.md} | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) rename IV. Spring Boot features/{25.1. Adding active profiles.md => 25.1. Adding Active Profiles.md} (83%) diff --git a/IV. Spring Boot features/25.1. Adding active profiles.md b/IV. Spring Boot features/25.1. Adding Active Profiles.md similarity index 83% rename from IV. Spring Boot features/25.1. Adding active profiles.md rename to IV. Spring Boot features/25.1. Adding Active Profiles.md index 8eeed3ae..32fde7ba 100644 --- a/IV. Spring Boot features/25.1. Adding active profiles.md +++ b/IV. Spring Boot features/25.1. Adding Active Profiles.md @@ -1,6 +1,6 @@ ### 25.1. 添加激活的配置(profiles) -`spring.profiles.active`属性和其他属性一样都遵循相同的排列规则,优先级最高的`PropertySource`获胜,也就是说,你可以在`application.properties`中指定生效的配置,然后使用命令行开关替换它们。 +`spring.profiles.active`属性和其他属性一样都遵循相同的排列规则:优先级最高的`PropertySource`获胜,也就是说,你可以在`application.properties`中指定生效的配置,然后使用命令行开关替换它们。 有时,将profile-specific的属性添加到激活的配置中而不是直接替换它们是有好处的。`spring.profiles.include`属性可以用来无条件的添加激活的配置,而`SpringApplication`的入口点也提供了一个用于设置其他配置的Java API,通过它设置的active配置优先级高于`spring.profiles.active`,具体参考`setAdditionalProfiles()`方法。 @@ -14,4 +14,4 @@ spring.profiles.include: - proddb - prodmq ``` -**注** `spring.profiles`属性可以定义到YAML文档中,以决定何时将该文档包含进配置,具体参考[章节 73.7,根据环境改变配置](../IX. ‘How-to’ guides/73.7. Change configuration depending on the environment.md) +**注** `spring.profiles`属性可以定义到YAML文档中,以决定何时将该文档包含进配置,具体参考[章节 74.7 根据环境改变配置](../IX. ‘How-to’ guides/74.7 Change configuration depending on the environment.md) From f795a61078abc97078beba4053c2d7c2df8c5ea3 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E7=83=AD=E5=BF=83=E5=B8=82=E6=B0=91=E9=92=9F=E5=B0=8F?= =?UTF-8?q?=E5=BC=BA?= Date: Wed, 13 Jun 2018 00:03:35 +0800 Subject: [PATCH 136/865] Rename 25.2. Programmatically setting profiles.md to 25.2. Programmatically Setting Profiles.md --- ...ing profiles.md => 25.2. Programmatically Setting Profiles.md} | 0 1 file changed, 0 insertions(+), 0 deletions(-) rename IV. Spring Boot features/{25.2. Programmatically setting profiles.md => 25.2. Programmatically Setting Profiles.md} (100%) diff --git a/IV. Spring Boot features/25.2. Programmatically setting profiles.md b/IV. Spring Boot features/25.2. Programmatically Setting Profiles.md similarity index 100% rename from IV. Spring Boot features/25.2. Programmatically setting profiles.md rename to IV. Spring Boot features/25.2. Programmatically Setting Profiles.md From a3330627f32ea43c1e17ff6e043688db907f2fcd Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E7=83=AD=E5=BF=83=E5=B8=82=E6=B0=91=E9=92=9F=E5=B0=8F?= =?UTF-8?q?=E5=BC=BA?= Date: Wed, 13 Jun 2018 00:09:34 +0800 Subject: [PATCH 137/865] Update and rename 25.3. Profile specific configuration files.md to 25.3. Profile-specific Configuration Files.md --- ...n files.md => 25.3. Profile-specific Configuration Files.md} | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) rename IV. Spring Boot features/{25.3. Profile specific configuration files.md => 25.3. Profile-specific Configuration Files.md} (71%) diff --git a/IV. Spring Boot features/25.3. Profile specific configuration files.md b/IV. Spring Boot features/25.3. Profile-specific Configuration Files.md similarity index 71% rename from IV. Spring Boot features/25.3. Profile specific configuration files.md rename to IV. Spring Boot features/25.3. Profile-specific Configuration Files.md index 9f71dcd9..83acc750 100644 --- a/IV. Spring Boot features/25.3. Profile specific configuration files.md +++ b/IV. Spring Boot features/25.3. Profile-specific Configuration Files.md @@ -1,3 +1,3 @@ ### 25.3. Profile-specific配置文件 -Profile-specific的配置,不管是`application.properties`(或`application.yml`),还是通过`@ConfigurationProperties`引用的文件都是被当作文件来加载的,具体参考[Section 24.3, “Profile specific properties”](24.4. Profile-specific properties.md)。 +Profile-specific的配置,不管是`application.properties`(或`application.yml`),还是通过`@ConfigurationProperties`引用的文件都是被当作文件来加载的,具体参考[Section 24.4, “Profile-specific Properties”](24.4. Profile-specific Properties.md)。 From 5737349dcadfe662546f1ff5f39e0da09c9e73f2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E7=83=AD=E5=BF=83=E5=B8=82=E6=B0=91=E9=92=9F=E5=B0=8F?= =?UTF-8?q?=E5=BC=BA?= Date: Wed, 13 Jun 2018 00:20:55 +0800 Subject: [PATCH 138/865] Update SUMMARY.md --- SUMMARY.md | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/SUMMARY.md b/SUMMARY.md index cab23b88..97b55102 100644 --- a/SUMMARY.md +++ b/SUMMARY.md @@ -109,9 +109,9 @@ * [24.7.4. @ConfigurationProperties校验](IV. Spring Boot features/24.7.4. @ConfigurationProperties Validation.md) * [24.7.5. @ConfigurationProperties vs @Value](IV. Spring Boot features/24.7.5. @ConfigurationProperties vs. @Value.md) * [25. Profiles](IV. Spring Boot features/25. Profiles.md) - * [25.1. 添加激活的profiles](IV. Spring Boot features/25.1. Adding active profiles.md) - * [25.2.以编程方式设置profiles](IV. Spring Boot features/25.2. Programmatically setting profiles.md) - * [25.3. Profile-specific配置文件](IV. Spring Boot features/25.3. Profile specific configuration files.md) + * [25.1. 添加激活的profiles](IV. Spring Boot features/25.1. Adding Active Profiles.md) + * [25.2.以编程方式设置profiles](IV. Spring Boot features/25.2. Programmatically Setting Profiles.md) + * [25.3. Profile-specific配置文件](IV. Spring Boot features/25.3. Profile-specific Configuration Files.md) * [26. 日志](IV. Spring Boot features/26. Logging.md) * [26.1. 日志格式](IV. Spring Boot features/26.1. Log format.md) * [26.2. 控制台输出](IV. Spring Boot features/26.2. Console output.md) From fffcb0fc71b0d2ebad794d4191801bfdb8a4bfb4 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E7=83=AD=E5=BF=83=E5=B8=82=E6=B0=91=E9=92=9F=E5=B0=8F?= =?UTF-8?q?=E5=BC=BA?= Date: Thu, 14 Jun 2018 22:59:27 +0800 Subject: [PATCH 139/865] Update 26. Logging.md --- IV. Spring Boot features/26. Logging.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/IV. Spring Boot features/26. Logging.md b/IV. Spring Boot features/26. Logging.md index 285428fd..f0d8422b 100644 --- a/IV. Spring Boot features/26. Logging.md +++ b/IV. Spring Boot features/26. Logging.md @@ -1,6 +1,6 @@ ### 26. 日志 Spring Boot内部日志系统使用的是[Commons Logging](http://commons.apache.org/logging),但开放底层的日志实现,默认为会[Java Util Logging](http://docs.oracle.com/javase/7/docs/api/java/util/logging/package-summary.html), [Log4J](http://logging.apache.org/log4j/), [Log4J2](http://logging.apache.org/log4j/2.x/)和[Logback](http://logback.qos.ch/)提供配置。每种情况下都预先配置使用控制台输出,也可以使用可选的文件输出。 -默认情况下,如果你使用'Starters',那么就会使用Logback记录日志。为了确保使用Java Util Logging, Commons Logging, Log4J或SLF4J的依赖库能够正常工作,相应的Logback路由也会包含进来。 +默认情况下,如果你使用“Starters”,那么就会使用Logback记录日志。为了确保使用Java Util Logging, Commons Logging, Log4J或SLF4J的依赖库能够正常工作,相应的Logback路由也会包含进来。 **注** 如果上面的列表看起来令人困惑,不要担心,Java有很多可用的日志框架。通常,你不需要改变日志依赖,Spring Boot默认的就能很好的工作。 From 9f86770bfe8efef5daedf4ceaa5e75f1280ad7e8 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E7=83=AD=E5=BF=83=E5=B8=82=E6=B0=91=E9=92=9F=E5=B0=8F?= =?UTF-8?q?=E5=BC=BA?= Date: Thu, 14 Jun 2018 23:02:20 +0800 Subject: [PATCH 140/865] Update and rename 26.1. Log format.md to 26.1. Log Format.md --- .../{26.1. Log format.md => 26.1. Log Format.md} | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) rename IV. Spring Boot features/{26.1. Log format.md => 26.1. Log Format.md} (75%) diff --git a/IV. Spring Boot features/26.1. Log format.md b/IV. Spring Boot features/26.1. Log Format.md similarity index 75% rename from IV. Spring Boot features/26.1. Log format.md rename to IV. Spring Boot features/26.1. Log Format.md index f20d6bca..7bca9623 100644 --- a/IV. Spring Boot features/26.1. Log format.md +++ b/IV. Spring Boot features/26.1. Log Format.md @@ -10,12 +10,12 @@ Spring Boot默认的日志输出格式如下: ``` 输出的节点(items)如下: -1. 日期和时间 - 精确到毫秒,且易于排序。 -2. 日志级别 - `ERROR`, `WARN`, `INFO`, `DEBUG` 或 `TRACE`。 +1. 日期和时间:精确到毫秒,且易于排序。 +2. 日志级别:`ERROR`, `WARN`, `INFO`, `DEBUG` 或 `TRACE`。 3. Process ID。 4. `---`分隔符,用于区分实际日志信息开头。 -5. 线程名 - 包括在方括号中(控制台输出可能会被截断)。 -6. 日志名 - 通常是源class的类名(缩写)。 +5. 线程名:包括在方括号中(控制台输出可能会被截断)。 +6. 日志名:通常是源class的类名(缩写)。 7. 日志信息。 -**注** Logback没有`FATAL`级别,它会映射到`ERROR`。 +**注** Logback没有`FATAL`级别。它会映射到`ERROR`。 From 10c01ddbb67308eee5d9d62ec405cf588e3cac73 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E7=83=AD=E5=BF=83=E5=B8=82=E6=B0=91=E9=92=9F=E5=B0=8F?= =?UTF-8?q?=E5=BC=BA?= Date: Fri, 15 Jun 2018 00:37:58 +0800 Subject: [PATCH 141/865] Update SUMMARY.md --- SUMMARY.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/SUMMARY.md b/SUMMARY.md index 97b55102..f245689d 100644 --- a/SUMMARY.md +++ b/SUMMARY.md @@ -113,7 +113,7 @@ * [25.2.以编程方式设置profiles](IV. Spring Boot features/25.2. Programmatically Setting Profiles.md) * [25.3. Profile-specific配置文件](IV. Spring Boot features/25.3. Profile-specific Configuration Files.md) * [26. 日志](IV. Spring Boot features/26. Logging.md) - * [26.1. 日志格式](IV. Spring Boot features/26.1. Log format.md) + * [26.1. 日志格式](IV. Spring Boot features/26.1. Log Format.md) * [26.2. 控制台输出](IV. Spring Boot features/26.2. Console output.md) * [26.2.1. Color-coded输出](IV. Spring Boot features/26.2.1. Color-coded output.md) * [26.3. 文件输出](IV. Spring Boot features/26.3. File output.md) From 60ea9361779825fae3a659357bacd8f5a7815b67 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E7=83=AD=E5=BF=83=E5=B8=82=E6=B0=91=E9=92=9F=E5=B0=8F?= =?UTF-8?q?=E5=BC=BA?= Date: Sat, 16 Jun 2018 00:01:47 +0800 Subject: [PATCH 142/865] Rename 26.2. Console output.md to 26.2. Console Output.md --- .../{26.2. Console output.md => 26.2. Console Output.md} | 0 1 file changed, 0 insertions(+), 0 deletions(-) rename IV. Spring Boot features/{26.2. Console output.md => 26.2. Console Output.md} (100%) diff --git a/IV. Spring Boot features/26.2. Console output.md b/IV. Spring Boot features/26.2. Console Output.md similarity index 100% rename from IV. Spring Boot features/26.2. Console output.md rename to IV. Spring Boot features/26.2. Console Output.md From c0674bb2e41f09f07997b6b7f5e2cbd34d411c46 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E7=83=AD=E5=BF=83=E5=B8=82=E6=B0=91=E9=92=9F=E5=B0=8F?= =?UTF-8?q?=E5=BC=BA?= Date: Sat, 16 Jun 2018 00:04:05 +0800 Subject: [PATCH 143/865] Update SUMMARY.md --- SUMMARY.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/SUMMARY.md b/SUMMARY.md index f245689d..96fbcda6 100644 --- a/SUMMARY.md +++ b/SUMMARY.md @@ -114,7 +114,7 @@ * [25.3. Profile-specific配置文件](IV. Spring Boot features/25.3. Profile-specific Configuration Files.md) * [26. 日志](IV. Spring Boot features/26. Logging.md) * [26.1. 日志格式](IV. Spring Boot features/26.1. Log Format.md) - * [26.2. 控制台输出](IV. Spring Boot features/26.2. Console output.md) + * [26.2. 控制台输出](IV. Spring Boot features/26.2. Console Output.md) * [26.2.1. Color-coded输出](IV. Spring Boot features/26.2.1. Color-coded output.md) * [26.3. 文件输出](IV. Spring Boot features/26.3. File output.md) * [26.4. 日志级别](IV. Spring Boot features/26.4. Log Levels.md) From 430ce73159aedd47872b49bab1e23818dc2f91c0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E7=83=AD=E5=BF=83=E5=B8=82=E6=B0=91=E9=92=9F=E5=B0=8F?= =?UTF-8?q?=E5=BC=BA?= Date: Mon, 18 Jun 2018 15:37:43 +0800 Subject: [PATCH 144/865] Update and rename 26.2.1. Color-coded output.md to 26.2.1. Color-coded Output.md --- ... Color-coded output.md => 26.2.1. Color-coded Output.md} | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) rename IV. Spring Boot features/{26.2.1. Color-coded output.md => 26.2.1. Color-coded Output.md} (92%) diff --git a/IV. Spring Boot features/26.2.1. Color-coded output.md b/IV. Spring Boot features/26.2.1. Color-coded Output.md similarity index 92% rename from IV. Spring Boot features/26.2.1. Color-coded output.md rename to IV. Spring Boot features/26.2.1. Color-coded Output.md index c9ddbc5d..f3f5cd53 100644 --- a/IV. Spring Boot features/26.2.1. Color-coded output.md +++ b/IV. Spring Boot features/26.2.1. Color-coded Output.md @@ -5,9 +5,9 @@ ```properties %clr(%5p) ``` -日志级别到颜色的映射如下: +下面的表格描述了日志级别到颜色的映射: -|Level|Color| +|级别|颜色| |---|---| |`FATAL`|Red| |`ERROR`|Red| @@ -29,5 +29,3 @@ * `magenta` * `red` * `yellow` - - From 5f9803582c252e192c8c51725f57084c9e332b5f Mon Sep 17 00:00:00 2001 From: Jack Zhong Date: Mon, 18 Jun 2018 15:42:09 +0800 Subject: [PATCH 145/865] =?UTF-8?q?=E6=9B=B4=E6=96=B0=E6=96=87=E4=BB=B6?= =?UTF-8?q?=E5=90=8D?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- SUMMARY.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/SUMMARY.md b/SUMMARY.md index 96fbcda6..128eaedb 100644 --- a/SUMMARY.md +++ b/SUMMARY.md @@ -115,7 +115,7 @@ * [26. 日志](IV. Spring Boot features/26. Logging.md) * [26.1. 日志格式](IV. Spring Boot features/26.1. Log Format.md) * [26.2. 控制台输出](IV. Spring Boot features/26.2. Console Output.md) - * [26.2.1. Color-coded输出](IV. Spring Boot features/26.2.1. Color-coded output.md) + * [26.2.1. Color-coded输出](IV. Spring Boot features/26.2.1. Color-coded Output.md) * [26.3. 文件输出](IV. Spring Boot features/26.3. File output.md) * [26.4. 日志级别](IV. Spring Boot features/26.4. Log Levels.md) * [26.5. 自定义日志配置](IV. Spring Boot features/26.5. Custom log configuration.md) From 68950f2cd7172f8c6031db3db04c0f46d07edd97 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E7=83=AD=E5=BF=83=E5=B8=82=E6=B0=91=E9=92=9F=E5=B0=8F?= =?UTF-8?q?=E5=BC=BA?= Date: Thu, 21 Jun 2018 00:13:58 +0800 Subject: [PATCH 146/865] Update and rename 26.3. File output.md to 26.3. File Output.md --- .../{26.3. File output.md => 26.3. File Output.md} | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) rename IV. Spring Boot features/{26.3. File output.md => 26.3. File Output.md} (56%) diff --git a/IV. Spring Boot features/26.3. File output.md b/IV. Spring Boot features/26.3. File Output.md similarity index 56% rename from IV. Spring Boot features/26.3. File output.md rename to IV. Spring Boot features/26.3. File Output.md index b451b50c..fd26add6 100644 --- a/IV. Spring Boot features/26.3. File output.md +++ b/IV. Spring Boot features/26.3. File Output.md @@ -10,4 +10,8 @@ |Specific file|(none)|my.log|写到特定的日志文件,名称可以是精确的位置或相对于当前目录| |(none)|Specific directory|/var/log|写到特定目录下的`spring.log`里,名称可以是精确的位置或相对于当前目录| -日志文件每达到10MB就会被分割,跟控制台一样,默认记录`ERROR`, `WARN`和`INFO`级别的信息。 +日志文件每达到10MB就会被分割,跟控制台一样,默认记录`ERROR`, `WARN`和`INFO`级别的信息。可以使用`logging.file.max-size`属性改变大小限制。已经分割归档好的文件会无限期地保存下去,除非设置了`logging.file.max-history`属性。 + +**注** 日志系统在应用生命周期的早期初始化。因此,日志属性不能在通过`@PropertySource`标注加载的属性文件里找到。 + +**注** 日志属性独立于实际的日志基础设施。结果就是,特定的配置key(比如Logback的`logback.configurationFile`)不由Spring Boot管理。 From 0b9d9f893b3eca416c18efe869744836e50211e0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E7=83=AD=E5=BF=83=E5=B8=82=E6=B0=91=E9=92=9F=E5=B0=8F?= =?UTF-8?q?=E5=BC=BA?= Date: Thu, 21 Jun 2018 00:16:05 +0800 Subject: [PATCH 147/865] Update SUMMARY.md --- SUMMARY.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/SUMMARY.md b/SUMMARY.md index 128eaedb..5470e2b7 100644 --- a/SUMMARY.md +++ b/SUMMARY.md @@ -116,7 +116,7 @@ * [26.1. 日志格式](IV. Spring Boot features/26.1. Log Format.md) * [26.2. 控制台输出](IV. Spring Boot features/26.2. Console Output.md) * [26.2.1. Color-coded输出](IV. Spring Boot features/26.2.1. Color-coded Output.md) - * [26.3. 文件输出](IV. Spring Boot features/26.3. File output.md) + * [26.3. 文件输出](IV. Spring Boot features/26.3. File Output.md) * [26.4. 日志级别](IV. Spring Boot features/26.4. Log Levels.md) * [26.5. 自定义日志配置](IV. Spring Boot features/26.5. Custom log configuration.md) * [26.6. Logback扩展](IV. Spring Boot features/26.6. Logback extensions.md) From da1da7d423e62bf60f58deb1ecbb8cc1be02658c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E7=83=AD=E5=BF=83=E5=B8=82=E6=B0=91=E9=92=9F=E5=B0=8F?= =?UTF-8?q?=E5=BC=BA?= Date: Mon, 25 Jun 2018 00:40:24 +0800 Subject: [PATCH 148/865] Update 26.4. Log Levels.md --- IV. Spring Boot features/26.4. Log Levels.md | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/IV. Spring Boot features/26.4. Log Levels.md b/IV. Spring Boot features/26.4. Log Levels.md index 6c6cfdd4..43ee27e2 100644 --- a/IV. Spring Boot features/26.4. Log Levels.md +++ b/IV. Spring Boot features/26.4. Log Levels.md @@ -1,11 +1,10 @@ ### 26.4. 日志级别 -所有Spring Boot支持的日志系统都可以在Spring `Environment`中设置级别(`application.properties`里也一样),设置格式为'logging.level.*=LEVEL',其中`LEVEL`是`TRACE`, `DEBUG`, `INFO`, `WARN`, `ERROR`, `FATAL`, `OFF`之一: +所有Spring Boot支持的日志系统都可以在Spring `Environment`中设置级别(`application.properties`里也一样),设置格式为logging.level.=,其中`level`是`TRACE`, `DEBUG`, `INFO`, `WARN`, `ERROR`, `FATAL`, `OFF`之一。`root`记录器可以使用`logging.level.root`配置。 -以下是`application.properties`示例: +下面的例子展示了`application.properties`里可能的日志设置: ```properties logging.level.root=WARN logging.level.org.springframework.web=DEBUG logging.level.org.hibernate=ERROR ``` -**注** 默认情况,Spring Boot会重新映射Thymeleaf的`INFO`信息到`DEBUG`级别,这能减少标准日志输出的噪声。查看[LevelRemappingAppender](https://github.com/spring-projects/spring-boot/tree/v2.0.0.RELEASE/spring-boot/src/main/java/org/springframework/boot/logging/logback/LevelRemappingAppender.java)可以按自己的配置设置映射。 From 54c540b478a9e2c2042b616281b4493cc7c0923d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E7=83=AD=E5=BF=83=E5=B8=82=E6=B0=91=E9=92=9F=E5=B0=8F?= =?UTF-8?q?=E5=BC=BA?= Date: Sat, 30 Jun 2018 23:41:31 +0800 Subject: [PATCH 149/865] Update and rename 26.5. Custom log configuration.md to 26.5. Custom Log Configuration.md --- ...configuration.md => 26.5. Custom Log Configuration.md} | 8 ++++++++ 1 file changed, 8 insertions(+) rename IV. Spring Boot features/{26.5. Custom log configuration.md => 26.5. Custom Log Configuration.md} (76%) diff --git a/IV. Spring Boot features/26.5. Custom log configuration.md b/IV. Spring Boot features/26.5. Custom Log Configuration.md similarity index 76% rename from IV. Spring Boot features/26.5. Custom log configuration.md rename to IV. Spring Boot features/26.5. Custom Log Configuration.md index 4289ddd6..77a94a31 100644 --- a/IV. Spring Boot features/26.5. Custom log configuration.md +++ b/IV. Spring Boot features/26.5. Custom Log Configuration.md @@ -1,4 +1,5 @@ ### 26.5. 自定义日志配置 + 通过将相应的库添加到classpath可以激活各种日志系统,然后在classpath根目录下提供合适的配置文件可以进一步定制日志系统,配置文件也可以通过Spring `Environment`的`logging.config`属性指定。 使用`org.springframework.boot.logging.LoggingSystem`系统属性可以强制Spring Boot使用指定的日志系统,该属性值需要是`LoggingSystem`实现类的全限定名,如果值为`none`,则彻底禁用Spring Boot的日志配置。 @@ -24,14 +25,21 @@ | -------- | :-----: | :----: | |`logging.exception-conversion-word`|`LOG_EXCEPTION_CONVERSION_WORD`|记录异常使用的关键字| |`logging.file`|`LOG_FILE`|如果指定就会在默认的日志配置中使用| +|`logging.file.max-size`|`LOG_FILE_MAX_SIZE`|最大日志文件大小(如果LOG_FILE启用)。(只支持默认的Logback设置)| +|`logging.file.max-history`|`LOG_FILE_MAX_HISTORY`|保留的归档文件的最大数量(如果LOG_FILE启用)。(只支持默认的Logback设置)| |`logging.path`|`LOG_PATH`|如果指定就会在默认的日志配置中使用| |`logging.pattern.console`|`CONSOLE_LOG_PATTERN`|日志输出到控制台(stdout)时使用的模式(只支持默认的logback设置)| +|`logging.pattern.dateformat`|`LOG_DATEFORMAT_PATTERN`|日志日期格式的输出格式(只支持默认的logback设置)| |`logging.pattern.file`|`FILE_LOG_PATTERN`|日志输出到文件时使用的模式(如果LOG_FILE启用,只支持默认的logback设置)| |`logging.pattern.level`|`LOG_LEVEL_PATTERN`|用来渲染日志级别的格式(默认`%5p`,只支持默认的logback设置)| |`PID`|`PID`|当前的处理进程(process)ID(能够找到,且还没有用作OS环境变量)| 所有支持的日志系统在解析配置文件时都能获取系统属性的值,具体可以参考`spring-boot.jar`中的默认配置。 +- [Logback](https://github.com/spring-projects/spring-boot/tree/v2.0.0.RELEASE/spring-boot-project/spring-boot/src/main/resources/org/springframework/boot/logging/logback/defaults.xml) +- [Log4j 2](https://github.com/spring-projects/spring-boot/tree/v2.0.0.RELEASE/spring-boot-project/spring-boot/src/main/resources/org/springframework/boot/logging/log4j2/log4j2.xml) +- [Java Util logging](https://github.com/spring-projects/spring-boot/tree/v2.0.0.RELEASE/spring-boot-project/spring-boot/src/main/resources/org/springframework/boot/logging/java/logging-file.properties) + **注** 如果想在日志属性中使用占位符,你需要使用[Spring Boot的语法](http://docs.spring.io/spring-boot/docs/2.0.0.RELEASE/reference/htmlsingle/#boot-features-external-config-placeholders-in-properties),而不是底层框架的语法。尤其是使用Logback时,你需要使用`:`作为属性名和默认值的分隔符,而不是`:-`。 **注** 通过覆盖`LOG_LEVEL_PATTERN`(Logback对应`logging.pattern.level`),你可以向日志中添加MDC和其他ad-hoc的内容。例如,将该值设置为`logging.pattern.level=user:%X{user} %5p`,则默认日志格式将包含一个"user"的MDC实体,如果存在的话,比如: From b3b3db9404c0d02bbbe81276b187a4cba2f4d024 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E7=83=AD=E5=BF=83=E5=B8=82=E6=B0=91=E9=92=9F=E5=B0=8F?= =?UTF-8?q?=E5=BC=BA?= Date: Sat, 30 Jun 2018 23:42:07 +0800 Subject: [PATCH 150/865] Update SUMMARY.md --- SUMMARY.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/SUMMARY.md b/SUMMARY.md index 5470e2b7..199fcf7a 100644 --- a/SUMMARY.md +++ b/SUMMARY.md @@ -118,7 +118,7 @@ * [26.2.1. Color-coded输出](IV. Spring Boot features/26.2.1. Color-coded Output.md) * [26.3. 文件输出](IV. Spring Boot features/26.3. File Output.md) * [26.4. 日志级别](IV. Spring Boot features/26.4. Log Levels.md) - * [26.5. 自定义日志配置](IV. Spring Boot features/26.5. Custom log configuration.md) + * [26.5. 自定义日志配置](IV. Spring Boot features/26.5. Custom Log Configuration.md) * [26.6. Logback扩展](IV. Spring Boot features/26.6. Logback extensions.md) * [26.6.1. Profile-specific配置](IV. Spring Boot features/26.6.1. Profile-specific configuration.md) * [26.6.2. Environment属性](IV. Spring Boot features/26.6.2. Environment properties.md) From 4b6d5ecb8d6454753cf8ad1b8bef6ddb8003ef07 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E7=83=AD=E5=BF=83=E5=B8=82=E6=B0=91=E9=92=9F=E5=B0=8F?= =?UTF-8?q?=E5=BC=BA?= Date: Mon, 2 Jul 2018 23:02:39 +0800 Subject: [PATCH 151/865] Rename 26.6. Logback extensions.md to 26.6. Logback Extensions.md --- ...{26.6. Logback extensions.md => 26.6. Logback Extensions.md} | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) rename IV. Spring Boot features/{26.6. Logback extensions.md => 26.6. Logback Extensions.md} (99%) diff --git a/IV. Spring Boot features/26.6. Logback extensions.md b/IV. Spring Boot features/26.6. Logback Extensions.md similarity index 99% rename from IV. Spring Boot features/26.6. Logback extensions.md rename to IV. Spring Boot features/26.6. Logback Extensions.md index 63ea38ec..f5b1607b 100644 --- a/IV. Spring Boot features/26.6. Logback extensions.md +++ b/IV. Spring Boot features/26.6. Logback Extensions.md @@ -8,4 +8,4 @@ Spring Boot包含很多有用的Logback扩展,你可以在`logback-spring.xml` ```properties ERROR in ch.qos.logback.core.joran.spi.Interpreter@4:71 - no applicable action for [springProperty], current ElementPath is [[configuration][springProperty]] ERROR in ch.qos.logback.core.joran.spi.Interpreter@4:71 - no applicable action for [springProfile], current ElementPath is [[configuration][springProfile]] -``` \ No newline at end of file +``` From 6ffd3c9fcd9107f7e5b8a5ccb49faedd2f6e61be Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E7=83=AD=E5=BF=83=E5=B8=82=E6=B0=91=E9=92=9F=E5=B0=8F?= =?UTF-8?q?=E5=BC=BA?= Date: Mon, 2 Jul 2018 23:03:16 +0800 Subject: [PATCH 152/865] Update 26.6. Logback Extensions.md --- IV. Spring Boot features/26.6. Logback Extensions.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/IV. Spring Boot features/26.6. Logback Extensions.md b/IV. Spring Boot features/26.6. Logback Extensions.md index f5b1607b..1a4edc05 100644 --- a/IV. Spring Boot features/26.6. Logback Extensions.md +++ b/IV. Spring Boot features/26.6. Logback Extensions.md @@ -3,7 +3,7 @@ Spring Boot包含很多有用的Logback扩展,你可以在`logback-spring.xml` **注** 你不能在标准的`logback.xml`配置文件中使用扩展,因为它加载的太早了,不过可以使用`logback-spring.xml`,或指定`logging.config`属性。 -**警告⚠️** 这些扩展不能和`Logback`的配置扫描一起使用。如果你尝试这样做,改变配置文件会导致类似与下面的错误:👇 +**警告** 这些扩展不能和`Logback`的配置扫描一起使用。如果你尝试这样做,改变配置文件会导致类似与下面的错误: ```properties ERROR in ch.qos.logback.core.joran.spi.Interpreter@4:71 - no applicable action for [springProperty], current ElementPath is [[configuration][springProperty]] From 9f3f092e845e0c9482b3a34f096995c3f938d8d0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E7=83=AD=E5=BF=83=E5=B8=82=E6=B0=91=E9=92=9F=E5=B0=8F?= =?UTF-8?q?=E5=BC=BA?= Date: Mon, 2 Jul 2018 23:03:45 +0800 Subject: [PATCH 153/865] Update 26.6. Logback Extensions.md --- IV. Spring Boot features/26.6. Logback Extensions.md | 1 + 1 file changed, 1 insertion(+) diff --git a/IV. Spring Boot features/26.6. Logback Extensions.md b/IV. Spring Boot features/26.6. Logback Extensions.md index 1a4edc05..bb2b1739 100644 --- a/IV. Spring Boot features/26.6. Logback Extensions.md +++ b/IV. Spring Boot features/26.6. Logback Extensions.md @@ -1,4 +1,5 @@ ### 26.6 Logback扩展 + Spring Boot包含很多有用的Logback扩展,你可以在`logback-spring.xml`配置文件中使用它们。 **注** 你不能在标准的`logback.xml`配置文件中使用扩展,因为它加载的太早了,不过可以使用`logback-spring.xml`,或指定`logging.config`属性。 From 92c9712bf9eac69f53885a719071528862ff8556 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E7=83=AD=E5=BF=83=E5=B8=82=E6=B0=91=E9=92=9F=E5=B0=8F?= =?UTF-8?q?=E5=BC=BA?= Date: Mon, 2 Jul 2018 23:06:19 +0800 Subject: [PATCH 154/865] Update SUMMARY.md --- SUMMARY.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/SUMMARY.md b/SUMMARY.md index 199fcf7a..bdb8df44 100644 --- a/SUMMARY.md +++ b/SUMMARY.md @@ -119,8 +119,8 @@ * [26.3. 文件输出](IV. Spring Boot features/26.3. File Output.md) * [26.4. 日志级别](IV. Spring Boot features/26.4. Log Levels.md) * [26.5. 自定义日志配置](IV. Spring Boot features/26.5. Custom Log Configuration.md) - * [26.6. Logback扩展](IV. Spring Boot features/26.6. Logback extensions.md) - * [26.6.1. Profile-specific配置](IV. Spring Boot features/26.6.1. Profile-specific configuration.md) + * [26.6. Logback扩展](IV. Spring Boot features/26.6. Logback Extensions.md) + * [26.6.1. Profile-specific配置](IV. Spring Boot features/26.6.1. Profile-specific Configuration.md) * [26.6.2. Environment属性](IV. Spring Boot features/26.6.2. Environment properties.md) * [27. 开发Web应用](IV. Spring Boot features/27. Developing web applications.md) * [27.1. Spring Web MVC框架](IV. Spring Boot features/27.1. The ‘Spring Web MVC framework’.md) From 88cbe7b5e934c829a0fc8527a4f6d86177f11957 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E7=83=AD=E5=BF=83=E5=B8=82=E6=B0=91=E9=92=9F=E5=B0=8F?= =?UTF-8?q?=E5=BC=BA?= Date: Mon, 2 Jul 2018 23:08:28 +0800 Subject: [PATCH 155/865] Update and rename 26.6.1. Profile-specific configuration.md to 26.6.1. Profile-specific CConfiguration.md --- ...iguration.md => 26.6.1. Profile-specific CConfiguration.md} | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) rename IV. Spring Boot features/{26.6.1. Profile-specific configuration.md => 26.6.1. Profile-specific CConfiguration.md} (93%) diff --git a/IV. Spring Boot features/26.6.1. Profile-specific configuration.md b/IV. Spring Boot features/26.6.1. Profile-specific CConfiguration.md similarity index 93% rename from IV. Spring Boot features/26.6.1. Profile-specific configuration.md rename to IV. Spring Boot features/26.6.1. Profile-specific CConfiguration.md index 1476f9d0..34f0edcf 100644 --- a/IV. Spring Boot features/26.6.1. Profile-specific configuration.md +++ b/IV. Spring Boot features/26.6.1. Profile-specific CConfiguration.md @@ -1,5 +1,6 @@ ### 26.6.1 Profile-specific配置 -``标签可用于根据激活的Spring profiles,选择性的包含或排除配置片段。Profile片段可以放在``元素内的任何地方,使用`name`属性定义哪些profile接受该配置,多个profiles以逗号分隔。 + +``标签可用于根据激活的Spring profiles,选择性的包含或排除配置片段。Profile片段可以放在``元素内的任何地方,使用`name`属性定义哪些profile接受该配置,多个profiles以逗号分隔。下面展示了三个profile的示例: ```xml From c9c1b90bf81b304147abbcbaa66b9263d12d38cc Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E7=83=AD=E5=BF=83=E5=B8=82=E6=B0=91=E9=92=9F=E5=B0=8F?= =?UTF-8?q?=E5=BC=BA?= Date: Mon, 2 Jul 2018 23:13:25 +0800 Subject: [PATCH 156/865] Rename 26.6.1. Profile-specific CConfiguration.md to 26.6.1. Profile-specific Configuration.md --- ...Configuration.md => 26.6.1. Profile-specific Configuration.md} | 0 1 file changed, 0 insertions(+), 0 deletions(-) rename IV. Spring Boot features/{26.6.1. Profile-specific CConfiguration.md => 26.6.1. Profile-specific Configuration.md} (100%) diff --git a/IV. Spring Boot features/26.6.1. Profile-specific CConfiguration.md b/IV. Spring Boot features/26.6.1. Profile-specific Configuration.md similarity index 100% rename from IV. Spring Boot features/26.6.1. Profile-specific CConfiguration.md rename to IV. Spring Boot features/26.6.1. Profile-specific Configuration.md From 4ae93c1f75de64e94d6a6a8d3538a0ec7e9f2d65 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E7=83=AD=E5=BF=83=E5=B8=82=E6=B0=91=E9=92=9F=E5=B0=8F?= =?UTF-8?q?=E5=BC=BA?= Date: Tue, 3 Jul 2018 16:02:14 +0800 Subject: [PATCH 157/865] Update and rename 26.6.2. Environment properties.md to 26.6.2. Environment Properties.md --- ...onment properties.md => 26.6.2. Environment Properties.md} | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) rename IV. Spring Boot features/{26.6.2. Environment properties.md => 26.6.2. Environment Properties.md} (86%) diff --git a/IV. Spring Boot features/26.6.2. Environment properties.md b/IV. Spring Boot features/26.6.2. Environment Properties.md similarity index 86% rename from IV. Spring Boot features/26.6.2. Environment properties.md rename to IV. Spring Boot features/26.6.2. Environment Properties.md index b4a3d67f..44a0b958 100644 --- a/IV. Spring Boot features/26.6.2. Environment properties.md +++ b/IV. Spring Boot features/26.6.2. Environment Properties.md @@ -1,6 +1,6 @@ ### 26.6.2 Environment属性 -``标签允许你从Spring `Environment`读取属性,以便在Logback中使用。如果你想在logback配置获取`application.properties`中的属性值,该功能就很有用。该标签工作方式跟Logback标准``标签类似,但不是直接指定`value`值,你需要定义属性的`source`(来自`Environment`),也可以指定存储属性作用域的`scope`。如果`Environment`没有相应属性,你可以通过`defaultValue`设置默认值。 +``标签允许你从Spring `Environment`读取属性,以便在Logback中使用。如果你想在logback配置获取`application.properties`中的属性值,该功能就很有用。该标签工作方式跟Logback标准``标签类似,但不是直接指定`value`值,你需要定义属性的`source`(来自`Environment`),也可以指定存储属性作用域的`scope`。如果`Environment`没有相应属性,你可以通过`defaultValue`设置默认值。下面的例子展示了如何将属性暴露给Logback使用: ```xml @@ -9,4 +9,4 @@ ... ``` -**注** `source`必须使用短横线隔开(`my.property-name`)的格式指定。但是,属性可以通过relaxed规则添加到`Environment`里。 \ No newline at end of file +**注** `source`必须使用短横线隔开(`my.property-name`)的格式指定。但是,属性可以通过relaxed规则添加到`Environment`里。 From 5aadd0257b20d1cec7878cf57894b975152393f3 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E7=83=AD=E5=BF=83=E5=B8=82=E6=B0=91=E9=92=9F=E5=B0=8F?= =?UTF-8?q?=E5=BC=BA?= Date: Tue, 3 Jul 2018 16:05:44 +0800 Subject: [PATCH 158/865] Update SUMMARY.md --- SUMMARY.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/SUMMARY.md b/SUMMARY.md index bdb8df44..1f26e756 100644 --- a/SUMMARY.md +++ b/SUMMARY.md @@ -121,7 +121,7 @@ * [26.5. 自定义日志配置](IV. Spring Boot features/26.5. Custom Log Configuration.md) * [26.6. Logback扩展](IV. Spring Boot features/26.6. Logback Extensions.md) * [26.6.1. Profile-specific配置](IV. Spring Boot features/26.6.1. Profile-specific Configuration.md) - * [26.6.2. Environment属性](IV. Spring Boot features/26.6.2. Environment properties.md) + * [26.6.2. Environment属性](IV. Spring Boot features/26.6.2. Environment Properties.md) * [27. 开发Web应用](IV. Spring Boot features/27. Developing web applications.md) * [27.1. Spring Web MVC框架](IV. Spring Boot features/27.1. The ‘Spring Web MVC framework’.md) * [27.1.1. Spring MVC自动配置](IV. Spring Boot features/27.1.1. Spring MVC auto-configuration.md) From 44b5bcb17392bb4d9c0452ff40dbc983193ddd43 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E7=83=AD=E5=BF=83=E5=B8=82=E6=B0=91=E9=92=9F=E5=B0=8F?= =?UTF-8?q?=E5=BC=BA?= Date: Tue, 3 Jul 2018 23:50:07 +0800 Subject: [PATCH 159/865] Update and rename 27. Developing web applications.md to 27. Developing Web Applications.md --- ... web applications.md => 27. Developing Web Applications.md} | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) rename IV. Spring Boot features/{27. Developing web applications.md => 27. Developing Web Applications.md} (52%) diff --git a/IV. Spring Boot features/27. Developing web applications.md b/IV. Spring Boot features/27. Developing Web Applications.md similarity index 52% rename from IV. Spring Boot features/27. Developing web applications.md rename to IV. Spring Boot features/27. Developing Web Applications.md index bb2f8b34..9a576e04 100644 --- a/IV. Spring Boot features/27. Developing web applications.md +++ b/IV. Spring Boot features/27. Developing Web Applications.md @@ -1,4 +1,5 @@ ### 27. 开发Web应用 -Spring Boot非常适合开发web应用程序。你可以使用内嵌的Tomcat,Jetty,Undertow或Netty轻轻松松地创建一个HTTP服务器。大多数的web应用都可以使用`spring-boot-starter-web`模块进行快速搭建和运行。你也可以使用`spring-boot-starter-webflux`模块,来构建响应式的网络应用。 + +Spring Boot非常适合开发web应用程序。你可以使用内嵌的Tomcat,Jetty,Undertow或Netty创建一个HTTP服务器。大多数的web应用都可以使用`spring-boot-starter-web`模块进行快速搭建和运行。你也可以使用`spring-boot-starter-webflux`模块,来构建响应式的网络应用。 如果没有开发过Spring Boot web应用,可以参考[Getting started章节](https://docs.spring.io/spring-boot/docs/2.0.0.RELEASE/reference/htmlsingle/#getting-started-first-application)的"Hello World!"示例。 From 9f13fa38d2eefe5311379d39bee7e1aec337408d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E7=83=AD=E5=BF=83=E5=B8=82=E6=B0=91=E9=92=9F=E5=B0=8F?= =?UTF-8?q?=E5=BC=BA?= Date: Tue, 3 Jul 2018 23:52:59 +0800 Subject: [PATCH 160/865] Update SUMMARY.md --- SUMMARY.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/SUMMARY.md b/SUMMARY.md index 1f26e756..35ac5dbf 100644 --- a/SUMMARY.md +++ b/SUMMARY.md @@ -122,7 +122,7 @@ * [26.6. Logback扩展](IV. Spring Boot features/26.6. Logback Extensions.md) * [26.6.1. Profile-specific配置](IV. Spring Boot features/26.6.1. Profile-specific Configuration.md) * [26.6.2. Environment属性](IV. Spring Boot features/26.6.2. Environment Properties.md) - * [27. 开发Web应用](IV. Spring Boot features/27. Developing web applications.md) + * [27. 开发Web应用](IV. Spring Boot features/27. Developing Web Applications.md) * [27.1. Spring Web MVC框架](IV. Spring Boot features/27.1. The ‘Spring Web MVC framework’.md) * [27.1.1. Spring MVC自动配置](IV. Spring Boot features/27.1.1. Spring MVC auto-configuration.md) * [27.1.2. HttpMessageConverters](IV. Spring Boot features/27.1.2. HttpMessageConverters.md) From 04fe837c599a876a4fb0e877918edcd5ed9a6db3 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E7=83=AD=E5=BF=83=E5=B8=82=E6=B0=91=E9=92=9F=E5=B0=8F?= =?UTF-8?q?=E5=BC=BA?= Date: Wed, 4 Jul 2018 21:58:47 +0800 Subject: [PATCH 161/865] =?UTF-8?q?Rename=2027.1.=20The=20=E2=80=98Spring?= =?UTF-8?q?=20Web=20MVC=20framework=E2=80=99.md=20to=2027.1.=20The=20?= =?UTF-8?q?=E2=80=9CSpring=20Web=20MVC=20Framework=E2=80=9D.md?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- ...27.1. The \342\200\234Spring Web MVC Framework\342\200\235.md" | 0 1 file changed, 0 insertions(+), 0 deletions(-) rename "IV. Spring Boot features/27.1. The \342\200\230Spring Web MVC framework\342\200\231.md" => "IV. Spring Boot features/27.1. The \342\200\234Spring Web MVC Framework\342\200\235.md" (100%) diff --git "a/IV. Spring Boot features/27.1. The \342\200\230Spring Web MVC framework\342\200\231.md" "b/IV. Spring Boot features/27.1. The \342\200\234Spring Web MVC Framework\342\200\235.md" similarity index 100% rename from "IV. Spring Boot features/27.1. The \342\200\230Spring Web MVC framework\342\200\231.md" rename to "IV. Spring Boot features/27.1. The \342\200\234Spring Web MVC Framework\342\200\235.md" From 3ec3d753b40642003220f9e4d16253cb08bb8deb Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E7=83=AD=E5=BF=83=E5=B8=82=E6=B0=91=E9=92=9F=E5=B0=8F?= =?UTF-8?q?=E5=BC=BA?= Date: Wed, 4 Jul 2018 22:00:22 +0800 Subject: [PATCH 162/865] Update SUMMARY.md --- SUMMARY.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/SUMMARY.md b/SUMMARY.md index 35ac5dbf..124536d7 100644 --- a/SUMMARY.md +++ b/SUMMARY.md @@ -123,7 +123,7 @@ * [26.6.1. Profile-specific配置](IV. Spring Boot features/26.6.1. Profile-specific Configuration.md) * [26.6.2. Environment属性](IV. Spring Boot features/26.6.2. Environment Properties.md) * [27. 开发Web应用](IV. Spring Boot features/27. Developing Web Applications.md) - * [27.1. Spring Web MVC框架](IV. Spring Boot features/27.1. The ‘Spring Web MVC framework’.md) + * [27.1. Spring Web MVC框架](IV. Spring Boot features/27.1. The “Spring Web MVC Framework”.md) * [27.1.1. Spring MVC自动配置](IV. Spring Boot features/27.1.1. Spring MVC auto-configuration.md) * [27.1.2. HttpMessageConverters](IV. Spring Boot features/27.1.2. HttpMessageConverters.md) * [27.1.3. 自定义JSON序列化器和反序列化器](IV. Spring Boot features/27.1.3. Custom JSON Serializers and Deserializers.md) From d55f0ce5d41e8c3e72aae1dcb85a61b75c78cd7e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E7=83=AD=E5=BF=83=E5=B8=82=E6=B0=91=E9=92=9F=E5=B0=8F?= =?UTF-8?q?=E5=BC=BA?= Date: Wed, 4 Jul 2018 22:06:47 +0800 Subject: [PATCH 163/865] Update and rename 27.1.1. Spring MVC auto-configuration.md to 27.1.1. Spring MVC Auto-configuration.md --- ...configuration.md => 27.1.1. Spring MVC Auto-configuration.md} | 1 - 1 file changed, 1 deletion(-) rename IV. Spring Boot features/{27.1.1. Spring MVC auto-configuration.md => 27.1.1. Spring MVC Auto-configuration.md} (98%) diff --git a/IV. Spring Boot features/27.1.1. Spring MVC auto-configuration.md b/IV. Spring Boot features/27.1.1. Spring MVC Auto-configuration.md similarity index 98% rename from IV. Spring Boot features/27.1.1. Spring MVC auto-configuration.md rename to IV. Spring Boot features/27.1.1. Spring MVC Auto-configuration.md index 9ad9bc6f..ef7d1b8b 100644 --- a/IV. Spring Boot features/27.1.1. Spring MVC auto-configuration.md +++ b/IV. Spring Boot features/27.1.1. Spring MVC Auto-configuration.md @@ -13,5 +13,4 @@ Spring Boot为Spring MVC提供的auto-configuration适用于大多数应用, 如果保留Spring Boot MVC特性,你只需添加其他的[MVC配置](https://docs.spring.io/spring/docs/5.0.4.RELEASE/spring-framework-reference/web.html#mvc)(拦截器,格式化处理器,视图控制器等)。你可以添加自己的`WebMvcConfigurer`类型的`@Configuration`类,而不需要注解`@EnableWebMvc`。如果希望使用自定义的`RequestMappingHandlerMapping`,`RequestMappingHandlerAdapter`,或`ExceptionHandlerExceptionResolver`,你可以声明一个`WebMvcRegistrationsAdapter`实例提供这些组件。 - 如果想全面控制Spring MVC,你可以添加自己的`@Configuration`,并使用`@EnableWebMvc`注解。 From 01bec4e750ee05e4138c8fb193ba6dad3ddcc2b0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E7=83=AD=E5=BF=83=E5=B8=82=E6=B0=91=E9=92=9F=E5=B0=8F?= =?UTF-8?q?=E5=BC=BA?= Date: Wed, 4 Jul 2018 22:08:33 +0800 Subject: [PATCH 164/865] Update SUMMARY.md --- SUMMARY.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/SUMMARY.md b/SUMMARY.md index 124536d7..33cd85e7 100644 --- a/SUMMARY.md +++ b/SUMMARY.md @@ -124,7 +124,7 @@ * [26.6.2. Environment属性](IV. Spring Boot features/26.6.2. Environment Properties.md) * [27. 开发Web应用](IV. Spring Boot features/27. Developing Web Applications.md) * [27.1. Spring Web MVC框架](IV. Spring Boot features/27.1. The “Spring Web MVC Framework”.md) - * [27.1.1. Spring MVC自动配置](IV. Spring Boot features/27.1.1. Spring MVC auto-configuration.md) + * [27.1.1. Spring MVC自动配置](IV. Spring Boot features/27.1.1. Spring MVC Auto-configuration.md) * [27.1.2. HttpMessageConverters](IV. Spring Boot features/27.1.2. HttpMessageConverters.md) * [27.1.3. 自定义JSON序列化器和反序列化器](IV. Spring Boot features/27.1.3. Custom JSON Serializers and Deserializers.md) * [27.1.4. MessageCodesResolver](IV. Spring Boot features/27.1.4. MessageCodesResolver.md) From 6f511703d13a03fe2ecd6cf7b76fc4d659010587 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E7=83=AD=E5=BF=83=E5=B8=82=E6=B0=91=E9=92=9F=E5=B0=8F?= =?UTF-8?q?=E5=BC=BA?= Date: Thu, 5 Jul 2018 21:16:39 +0800 Subject: [PATCH 165/865] Update README.md --- README.md | 8 -------- 1 file changed, 8 deletions(-) diff --git a/README.md b/README.md index 9228cce0..fbe4d149 100644 --- a/README.md +++ b/README.md @@ -8,11 +8,3 @@ Spring Boot Reference Guide 2.0 中文翻译 -《Spring Boot参考指南》 GitBook : [Spring Boot参考指南](https://jack80342.gitbooks.io/spring-boot/content/) GitHub : [Spring Boot参考指南](https://github.com/jack80342/Spring-Boot-Reference-Guide) - -我和小白住在东京。 -我们花了好多个周末,将这本参考指南翻译到最新的版本。 -如果你想支持我们的工作🙃,你可以给小白🐈买几条小鱼干🐟。 - -|WeChatPay|ALipay|Paypal| -|:----|:----|:----| -|![ALiPay](https://github.com/jack80342/Materials/raw/master/Spring-Boot-Reference-Guide/alipay.jpg)|![WeChatPay](https://github.com/jack80342/Materials/raw/master/Spring-Boot-Reference-Guide/wechatpay.jpg)|![PayPal](https://github.com/jack80342/Materials/raw/master/Spring-Boot-Reference-Guide/paypal.jpg)| From 9fc4e1e726af5d286352b3f664e5f720eefa704b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E7=83=AD=E5=BF=83=E5=B8=82=E6=B0=91=E9=92=9F=E5=B0=8F?= =?UTF-8?q?=E5=BC=BA?= Date: Wed, 18 Jul 2018 20:33:35 +0800 Subject: [PATCH 166/865] Update 27.1.2. HttpMessageConverters.md --- IV. Spring Boot features/27.1.2. HttpMessageConverters.md | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/IV. Spring Boot features/27.1.2. HttpMessageConverters.md b/IV. Spring Boot features/27.1.2. HttpMessageConverters.md index 478ab543..947ac089 100644 --- a/IV. Spring Boot features/27.1.2. HttpMessageConverters.md +++ b/IV. Spring Boot features/27.1.2. HttpMessageConverters.md @@ -1,8 +1,8 @@ ### 27.1.2. HttpMessageConverters -Spring MVC使用`HttpMessageConverter`接口转换HTTP请求和响应,合适的默认配置可以开箱即用,例如对象自动转换为JSON(使用Jackson库)或XML(如果Jackson XML扩展可用,否则使用JAXB),字符串默认使用`UTF-8`编码。 +Spring MVC使用`HttpMessageConverter`接口转换HTTP请求和响应。合适的默认配置可以开箱即用,例如对象自动转换为JSON(使用Jackson库)或XML(如果Jackson XML扩展可用,否则使用JAXB),字符串默认使用`UTF-8`编码。 -可以使用Spring Boot的`HttpMessageConverters`类添加或自定义转换类: +可以使用Spring Boot的`HttpMessageConverters`类添加或自定义转换类,如下所示: ```java import org.springframework.boot.autoconfigure.web.HttpMessageConverters; import org.springframework.context.annotation.*; @@ -19,4 +19,4 @@ public class MyConfiguration { } } ``` -上下文中出现的所有`HttpMessageConverter` bean都将添加到converters列表,你可以通过这种方式覆盖默认的转换器列表(converters)。 +上下文中出现的所有`HttpMessageConverter` bean都将添加到converters列表。你可以通过这种方式覆盖默认的转换器列表(converters)。 From 97dad7723215c587202635c061025353c07755b7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E7=83=AD=E5=BF=83=E5=B8=82=E6=B0=91=E9=92=9F=E5=B0=8F?= =?UTF-8?q?=E5=BC=BA?= Date: Wed, 18 Jul 2018 20:53:01 +0800 Subject: [PATCH 167/865] Update 27.1.3. Custom JSON Serializers and Deserializers.md --- .../27.1.3. Custom JSON Serializers and Deserializers.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/IV. Spring Boot features/27.1.3. Custom JSON Serializers and Deserializers.md b/IV. Spring Boot features/27.1.3. Custom JSON Serializers and Deserializers.md index 3f2bab43..64092024 100644 --- a/IV. Spring Boot features/27.1.3. Custom JSON Serializers and Deserializers.md +++ b/IV. Spring Boot features/27.1.3. Custom JSON Serializers and Deserializers.md @@ -1,3 +1,3 @@ -###27.1.3 自定义JSON序列化器和反序列化器 +### 27.1.3 自定义JSON序列化器和反序列化器 如果使用Jackson序列化,反序列化JSON数据,你可能想编写自己的`JsonSerializer`和`JsonDeserializer`类。自定义序列化器(serializers)通常[通过Module注册到Jackson](http://wiki.fasterxml.com/JacksonHowToCustomDeserializers),但Spring Boot提供了`@JsonComponent`注解这一替代方式,它能轻松的将序列化器注册为Spring Beans。 From b50b1ab8c3d16893655308fa4b962c09dad0a9c7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E7=83=AD=E5=BF=83=E5=B8=82=E6=B0=91=E9=92=9F=E5=B0=8F?= =?UTF-8?q?=E5=BC=BA?= Date: Wed, 18 Jul 2018 21:02:52 +0800 Subject: [PATCH 168/865] Update 27.1.3. Custom JSON Serializers and Deserializers.md --- ...stom JSON Serializers and Deserializers.md | 26 +++++++++++++++++++ 1 file changed, 26 insertions(+) diff --git a/IV. Spring Boot features/27.1.3. Custom JSON Serializers and Deserializers.md b/IV. Spring Boot features/27.1.3. Custom JSON Serializers and Deserializers.md index 64092024..a1f211fe 100644 --- a/IV. Spring Boot features/27.1.3. Custom JSON Serializers and Deserializers.md +++ b/IV. Spring Boot features/27.1.3. Custom JSON Serializers and Deserializers.md @@ -1,3 +1,29 @@ ### 27.1.3 自定义JSON序列化器和反序列化器 如果使用Jackson序列化,反序列化JSON数据,你可能想编写自己的`JsonSerializer`和`JsonDeserializer`类。自定义序列化器(serializers)通常[通过Module注册到Jackson](http://wiki.fasterxml.com/JacksonHowToCustomDeserializers),但Spring Boot提供了`@JsonComponent`注解这一替代方式,它能轻松的将序列化器注册为Spring Beans。 + +You can use the `@JsonComponent` annotation directly on `JsonSerializer` or `JsonDeserializer` implementations. You can also use it on classes that contain serializers/deserializers as inner classes, as shown in the following example: + +``` +import java.io.*; +import com.fasterxml.jackson.core.*; +import com.fasterxml.jackson.databind.*; +import org.springframework.boot.jackson.*; + +@JsonComponent +public class Example { + + public static class Serializer extends JsonSerializer { + // ... + } + + public static class Deserializer extends JsonDeserializer { + // ... + } + +} +``` + +All `@JsonComponent` beans in the `ApplicationContext` are automatically registered with Jackson. Because `@JsonComponent` is meta-annotated with `@Component`, the usual component-scanning rules apply. + +Spring Boot also provides [`JsonObjectSerializer`](https://github.com/spring-projects/spring-boot/tree/v2.0.0.RELEASE/spring-boot-project/spring-boot/src/main/java/org/springframework/boot/jackson/JsonObjectSerializer.java) and [`JsonObjectDeserializer`](https://github.com/spring-projects/spring-boot/tree/v2.0.0.RELEASE/spring-boot-project/spring-boot/src/main/java/org/springframework/boot/jackson/JsonObjectDeserializer.java) base classes that provide useful alternatives to the standard Jackson versions when serializing objects. See [`JsonObjectSerializer`](https://docs.spring.io/spring-boot/docs/2.0.0.RELEASE/api/org/springframework/boot/jackson/JsonObjectSerializer.html) and [`JsonObjectDeserializer`](https://docs.spring.io/spring-boot/docs/2.0.0.RELEASE/api/org/springframework/boot/jackson/JsonObjectDeserializer.html) in the Javadoc for details. From ec81031a40a705022a1413b6ae25b6202823c107 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E7=83=AD=E5=BF=83=E5=B8=82=E6=B0=91=E9=92=9F=E5=B0=8F?= =?UTF-8?q?=E5=BC=BA?= Date: Wed, 18 Jul 2018 21:34:26 +0800 Subject: [PATCH 169/865] Update 27.1.3. Custom JSON Serializers and Deserializers.md --- .../27.1.3. Custom JSON Serializers and Deserializers.md | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/IV. Spring Boot features/27.1.3. Custom JSON Serializers and Deserializers.md b/IV. Spring Boot features/27.1.3. Custom JSON Serializers and Deserializers.md index a1f211fe..54a7fa7a 100644 --- a/IV. Spring Boot features/27.1.3. Custom JSON Serializers and Deserializers.md +++ b/IV. Spring Boot features/27.1.3. Custom JSON Serializers and Deserializers.md @@ -2,7 +2,7 @@ 如果使用Jackson序列化,反序列化JSON数据,你可能想编写自己的`JsonSerializer`和`JsonDeserializer`类。自定义序列化器(serializers)通常[通过Module注册到Jackson](http://wiki.fasterxml.com/JacksonHowToCustomDeserializers),但Spring Boot提供了`@JsonComponent`注解这一替代方式,它能轻松的将序列化器注册为Spring Beans。 -You can use the `@JsonComponent` annotation directly on `JsonSerializer` or `JsonDeserializer` implementations. You can also use it on classes that contain serializers/deserializers as inner classes, as shown in the following example: +你可以在`JsonSerializer`或者`JsonDeserializer`的实现上,直接使用`@JsonComponent`注解。你也可以在以内部类的形式包含序列化器/反序列化器的类上使用它,如下所示: ``` import java.io.*; @@ -24,6 +24,6 @@ public class Example { } ``` -All `@JsonComponent` beans in the `ApplicationContext` are automatically registered with Jackson. Because `@JsonComponent` is meta-annotated with `@Component`, the usual component-scanning rules apply. +`ApplicationContext`里所有的`@JsonComponent` bean会自动注册到Jackson。因为`@JsonComponent`用`@Component`进行元注解,会应用通常的组件扫描规则。 -Spring Boot also provides [`JsonObjectSerializer`](https://github.com/spring-projects/spring-boot/tree/v2.0.0.RELEASE/spring-boot-project/spring-boot/src/main/java/org/springframework/boot/jackson/JsonObjectSerializer.java) and [`JsonObjectDeserializer`](https://github.com/spring-projects/spring-boot/tree/v2.0.0.RELEASE/spring-boot-project/spring-boot/src/main/java/org/springframework/boot/jackson/JsonObjectDeserializer.java) base classes that provide useful alternatives to the standard Jackson versions when serializing objects. See [`JsonObjectSerializer`](https://docs.spring.io/spring-boot/docs/2.0.0.RELEASE/api/org/springframework/boot/jackson/JsonObjectSerializer.html) and [`JsonObjectDeserializer`](https://docs.spring.io/spring-boot/docs/2.0.0.RELEASE/api/org/springframework/boot/jackson/JsonObjectDeserializer.html) in the Javadoc for details. +Spring Boot也提供了[`JsonObjectSerializer`](https://github.com/spring-projects/spring-boot/tree/v2.0.0.RELEASE/spring-boot-project/spring-boot/src/main/java/org/springframework/boot/jackson/JsonObjectSerializer.java)和[`JsonObjectDeserializer`](https://github.com/spring-projects/spring-boot/tree/v2.0.0.RELEASE/spring-boot-project/spring-boot/src/main/java/org/springframework/boot/jackson/JsonObjectDeserializer.java)基础类。它们为标准的Jackson版本提供了替代选择。详情请查看[`JsonObjectSerializer`](https://docs.spring.io/spring-boot/docs/2.0.0.RELEASE/api/org/springframework/boot/jackson/JsonObjectSerializer.html)和[`JsonObjectDeserializer`](https://docs.spring.io/spring-boot/docs/2.0.0.RELEASE/api/org/springframework/boot/jackson/JsonObjectDeserializer.html)的Javadoc。 From 410c4c95073f079621e8c05cb6ebd82da4c1b6c2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E7=83=AD=E5=BF=83=E5=B8=82=E6=B0=91=E9=92=9F=E5=B0=8F?= =?UTF-8?q?=E5=BC=BA?= Date: Wed, 18 Jul 2018 21:39:35 +0800 Subject: [PATCH 170/865] Update 27.1.4. MessageCodesResolver.md --- IV. Spring Boot features/27.1.4. MessageCodesResolver.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/IV. Spring Boot features/27.1.4. MessageCodesResolver.md b/IV. Spring Boot features/27.1.4. MessageCodesResolver.md index c657cd2d..c5fce621 100644 --- a/IV. Spring Boot features/27.1.4. MessageCodesResolver.md +++ b/IV. Spring Boot features/27.1.4. MessageCodesResolver.md @@ -1,3 +1,3 @@ ### 27.1.4 MessageCodesResolver -Spring MVC有一个实现策略,用于从绑定的errors产生用来渲染错误信息的错误码:`MessageCodesResolver`。Spring Boot会自动为你创建该实现,只要设置`spring.mvc.message-codes-resolver.format`属性为`PREFIX_ERROR_CODE`或`POSTFIX_ERROR_CODE`(具体查看`DefaultMessageCodesResolver.Format`枚举值)。 +Spring MVC有一个实现策略,用于从绑定的errors产生用来渲染错误信息的错误码:`MessageCodesResolver`。只要设置`spring.mvc.message-codes-resolver.format`属性为`PREFIX_ERROR_CODE`或`POSTFIX_ERROR_CODE`,Spring Boot会自动为你创建该实现(具体查看`DefaultMessageCodesResolver.Format`枚举值)。 From bb79495a45ca5ff4f58b7e9a7baf09fc2fdcc6c1 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E7=83=AD=E5=BF=83=E5=B8=82=E6=B0=91=E9=92=9F=E5=B0=8F?= =?UTF-8?q?=E5=BC=BA?= Date: Fri, 27 Jul 2018 22:57:34 +0800 Subject: [PATCH 171/865] Update 27.1.5. Static Content.md --- IV. Spring Boot features/27.1.5. Static Content.md | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/IV. Spring Boot features/27.1.5. Static Content.md b/IV. Spring Boot features/27.1.5. Static Content.md index acc1eacb..5c166ba4 100644 --- a/IV. Spring Boot features/27.1.5. Static Content.md +++ b/IV. Spring Boot features/27.1.5. Static Content.md @@ -4,11 +4,11 @@ 在单机web应用中,容器会启动默认的servlet,并用它加载`ServletContext`根目录下的内容以响应那些Spring不处理的请求。大多数情况下这都不会发生(除非你修改默认的MVC配置),因为Spring总能够通过`DispatcherServlet`处理这些请求。 -默认地,资源放置在`/**`,但是你可以通过`spring.mvc.static-path-pattern`进行调整。例如,迁移所有的资源到`/resources/**`可以按照如下方式实现: +默认地,资源放置在`/**`,但是你可以通过`spring.mvc.static-path-pattern`属性进行调整。例如,迁移所有的资源到`/resources/**`可以按照如下方式实现: ```properties spring.mvc.static-path-pattern=/resources/** ``` -你可以设置`spring.resources.static-locations`属性自定义静态资源的位置(配置一系列目录位置代替默认的值)。根Servlet的上下文路径“/”也会被作为一个位置自动添加。如果你这样做,默认的欢迎页面将从自定义位置加载,所以只要这些路径中的任何地方有一个`index.html`,它都会成为应用的主页。 +你可以设置`spring.resources.static-locations`属性自定义静态资源的位置(配置一系列目录位置代替默认的值)。根Servlet的上下文路径“/”也会被作为一个位置自动添加。 此外,除了上述标准的静态资源位置,有个例外情况是[Webjars内容](http://www.webjars.org/)。任何在`/webjars/**`路径下的资源都将从jar文件中提供,只要它们以Webjars的格式打包。 @@ -18,7 +18,7 @@ Spring Boot也支持Spring MVC提供的高级资源处理特性,可用于清 如果想使用针对WebJars版本无感知的URLs(version agnostic),只需要添加`webjars-locator`依赖,然后声明你的Webjar。以jQuery为例,`"/webjars/jquery/dist/jquery.min.js"`实际为`"/webjars/jquery/x.y.z/dist/jquery.min.js"`,`x.y.z`为Webjar的版本。 -**注** 如果使用JBoss,你需要声明`webjars-locator-jboss-vfs`依赖而不是`webjars-locator`,否则所有的Webjars将解析为`404`。 +**注** 如果使用JBoss,你需要声明`webjars-locator-jboss-vfs`依赖而不是`webjars-locator-core`,否则所有的Webjars将解析为`404`。 以下的配置为所有的静态资源提供一种缓存清除(cache busting)方案,实际上是将内容hash添加到URLs中,比如``: ```properties @@ -35,6 +35,6 @@ spring.resources.chain.strategy.fixed.enabled=true spring.resources.chain.strategy.fixed.paths=/js/lib/ spring.resources.chain.strategy.fixed.version=v12 ``` -使用以上策略,JavaScript模块加载器加载`"/js/lib/"`下的文件时会使用一个固定的版本策略`"/v12/js/lib/mymodule.js"`,其他资源仍旧使用内容hash的方式``。查看[ResourceProperties](https://github.com/spring-projects/spring-boot/tree/v2.0.0.RELEASE/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/web/ResourceProperties.java)获取更多支持的选项。 +使用以上策略,JavaScript模块加载器加载`"/js/lib/"`下的文件时会使用一个固定的版本策略(`"/v12/js/lib/mymodule.js"`),其他资源仍旧使用内容hash的方式(``)。查看[ResourceProperties](https://github.com/spring-projects/spring-boot/tree/v2.0.0.RELEASE/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/web/ResourceProperties.java)获取更多支持的选项。 **注** 该特性在一个专门的[博文](https://spring.io/blog/2014/07/24/spring-framework-4-1-handling-static-web-resources)和Spring框架[参考文档](https://docs.spring.io/spring/docs/5.0.4.RELEASE/spring-framework-reference/htmlsingle/#mvc-config-static-resources)中有透彻描述。 From f92a91c5e8219efc028a9b641820eff1f3f5a856 Mon Sep 17 00:00:00 2001 From: Jack Zhong Date: Sat, 28 Jul 2018 09:20:22 +0800 Subject: [PATCH 172/865] =?UTF-8?q?=E7=BF=BB=E8=AF=9127.1.6=20=E6=AC=A2?= =?UTF-8?q?=E8=BF=8E=E9=A1=B5?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- IV. Spring Boot features/27.1.6. Welcome Page.md | 3 +++ SUMMARY.md | 1 + 2 files changed, 4 insertions(+) create mode 100644 IV. Spring Boot features/27.1.6. Welcome Page.md diff --git a/IV. Spring Boot features/27.1.6. Welcome Page.md b/IV. Spring Boot features/27.1.6. Welcome Page.md new file mode 100644 index 00000000..4bbb1774 --- /dev/null +++ b/IV. Spring Boot features/27.1.6. Welcome Page.md @@ -0,0 +1,3 @@ +### 27.1.6 欢迎页 + +Spring Boot支持静态的和模板化的欢迎页。它首先会去配置好的静态内容位置寻找`index.html`文件。如果没找到,则会去寻找 `index`模版。如果找到其中之一,Spring Boot会自动把它当做应用的欢迎页。 \ No newline at end of file diff --git a/SUMMARY.md b/SUMMARY.md index 33cd85e7..79cf6e4d 100644 --- a/SUMMARY.md +++ b/SUMMARY.md @@ -129,6 +129,7 @@ * [27.1.3. 自定义JSON序列化器和反序列化器](IV. Spring Boot features/27.1.3. Custom JSON Serializers and Deserializers.md) * [27.1.4. MessageCodesResolver](IV. Spring Boot features/27.1.4. MessageCodesResolver.md) * [27.1.5. 静态内容](IV. Spring Boot features/27.1.5. Static Content.md) + * [27.1.6. 欢迎页](IV. Spring Boot features/27.1.6. Welcome Page.md) * [27.1.6. 定制网站图标](IV. Spring Boot features/27.1.6. Custom Favicon.md) * [27.1.7. ConfigurableWebBindingInitializer](IV. Spring Boot features/27.1.7. ConfigurableWebBindingInitializer.md) * [27.1.8. 模板引擎](IV. Spring Boot features/27.1.8. Template engines.md) From ab43f38132ae604c66eacce1c2ef4530bd2643d7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E7=83=AD=E5=BF=83=E5=B8=82=E6=B0=91=E9=92=9F=E5=B0=8F?= =?UTF-8?q?=E5=BC=BA?= Date: Sat, 28 Jul 2018 09:26:48 +0800 Subject: [PATCH 173/865] Update and rename 27.1.6. Custom Favicon.md to 27.1.7. Custom Favicon.md --- .../{27.1.6. Custom Favicon.md => 27.1.7. Custom Favicon.md} | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) rename IV. Spring Boot features/{27.1.6. Custom Favicon.md => 27.1.7. Custom Favicon.md} (85%) diff --git a/IV. Spring Boot features/27.1.6. Custom Favicon.md b/IV. Spring Boot features/27.1.7. Custom Favicon.md similarity index 85% rename from IV. Spring Boot features/27.1.6. Custom Favicon.md rename to IV. Spring Boot features/27.1.7. Custom Favicon.md index a33dc90d..263939be 100644 --- a/IV. Spring Boot features/27.1.6. Custom Favicon.md +++ b/IV. Spring Boot features/27.1.7. Custom Favicon.md @@ -1,3 +1,3 @@ -### 27.1.6 定制网站图标 -Spring Boot会在已配置的静态内容位置和类路径的根目录下依次寻找`favicon.ico`文件。 如果文件存在,它会被自动用作应用的图标。 +### 27.1.7 定制网站图标 +Spring Boot会在已配置的静态内容位置和类路径的根目录下依次寻找`favicon.ico`文件。 如果文件存在,它会被自动用作应用的图标。 From 8201ad709b1e8b292690c8b27c1fd18d7d6176a0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E7=83=AD=E5=BF=83=E5=B8=82=E6=B0=91=E9=92=9F=E5=B0=8F?= =?UTF-8?q?=E5=BC=BA?= Date: Sat, 28 Jul 2018 09:28:48 +0800 Subject: [PATCH 174/865] Update SUMMARY.md --- SUMMARY.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/SUMMARY.md b/SUMMARY.md index 79cf6e4d..94d6276a 100644 --- a/SUMMARY.md +++ b/SUMMARY.md @@ -130,7 +130,7 @@ * [27.1.4. MessageCodesResolver](IV. Spring Boot features/27.1.4. MessageCodesResolver.md) * [27.1.5. 静态内容](IV. Spring Boot features/27.1.5. Static Content.md) * [27.1.6. 欢迎页](IV. Spring Boot features/27.1.6. Welcome Page.md) - * [27.1.6. 定制网站图标](IV. Spring Boot features/27.1.6. Custom Favicon.md) + * [27.1.7. 定制网站图标](IV. Spring Boot features/27.1.7. Custom Favicon.md) * [27.1.7. ConfigurableWebBindingInitializer](IV. Spring Boot features/27.1.7. ConfigurableWebBindingInitializer.md) * [27.1.8. 模板引擎](IV. Spring Boot features/27.1.8. Template engines.md) * [27.1.9. 错误处理](IV. Spring Boot features/27.1.9. Error Handling.md) From 6c8e309d88e278070093d08c87eca13e76712ae1 Mon Sep 17 00:00:00 2001 From: Jack Zhong Date: Sat, 28 Jul 2018 10:02:33 +0800 Subject: [PATCH 175/865] =?UTF-8?q?=E4=B8=8A=E4=BC=A027.1.8.=20=E8=B7=AF?= =?UTF-8?q?=E5=BE=84=E5=8C=B9=E9=85=8D=E4=B8=8E=E5=86=85=E5=AE=B9=E5=8D=8F?= =?UTF-8?q?=E5=95=86?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .... Path Matching and Content Negotiation.md | 29 +++++++++++++++++++ SUMMARY.md | 1 + 2 files changed, 30 insertions(+) create mode 100644 IV. Spring Boot features/27.1.8. Path Matching and Content Negotiation.md diff --git a/IV. Spring Boot features/27.1.8. Path Matching and Content Negotiation.md b/IV. Spring Boot features/27.1.8. Path Matching and Content Negotiation.md new file mode 100644 index 00000000..a54e834f --- /dev/null +++ b/IV. Spring Boot features/27.1.8. Path Matching and Content Negotiation.md @@ -0,0 +1,29 @@ +### 27.1.8 路径匹配与内容协商 + +Spring MVC can map incoming HTTP requests to handlers by looking at the request path and matching it to the mappings defined in your application (for example, `@GetMapping` annotations on Controller methods). + +Spring Boot chooses to disable suffix pattern matching by default, which means that requests like `"GET /projects/spring-boot.json"` won’t be matched to`@GetMapping("/projects/spring-boot")` mappings. This is considered as a [best practice for Spring MVC applications](https://docs.spring.io/spring/docs/5.0.4.RELEASE/spring-framework-reference/web.html#mvc-ann-requestmapping-suffix-pattern-match). This feature was mainly useful in the past for HTTP clients which did not send proper "Accept" request headers; we needed to make sure to send the correct Content Type to the client. Nowadays, Content Negotiation is much more reliable. + +There are other ways to deal with HTTP clients that don’t consistently send proper "Accept" request headers. Instead of using suffix matching, we can use a query parameter to ensure that requests like `"GET /projects/spring-boot?format=json"` will be mapped to `@GetMapping("/projects/spring-boot")`: + +```properties +spring.mvc.contentnegotiation.favor-parameter=true + +# We can change the parameter name, which is "format" by default: +# spring.mvc.contentnegotiation.parameter-name=myparam + +# We can also register additional file extensions/media types with: +spring.mvc.contentnegotiation.media-types.markdown=text/markdown +``` + +If you understand the caveats and would still like your application to use suffix pattern matching, the following configuration is required: + +```properties +spring.mvc.contentnegotiation.favor-path-extension=true + +# You can also restrict that feature to known extensions only +# spring.mvc.pathmatch.use-registered-suffix-pattern=true + +# We can also register additional file extensions/media types with: +# spring.mvc.contentnegotiation.media-types.adoc=text/asciidoc +``` \ No newline at end of file diff --git a/SUMMARY.md b/SUMMARY.md index 94d6276a..c64863ab 100644 --- a/SUMMARY.md +++ b/SUMMARY.md @@ -131,6 +131,7 @@ * [27.1.5. 静态内容](IV. Spring Boot features/27.1.5. Static Content.md) * [27.1.6. 欢迎页](IV. Spring Boot features/27.1.6. Welcome Page.md) * [27.1.7. 定制网站图标](IV. Spring Boot features/27.1.7. Custom Favicon.md) + * [27.1.8. 路径匹配与内容协商](IV. Spring Boot features/27.1.8. Path Matching and Content Negotiation.md) * [27.1.7. ConfigurableWebBindingInitializer](IV. Spring Boot features/27.1.7. ConfigurableWebBindingInitializer.md) * [27.1.8. 模板引擎](IV. Spring Boot features/27.1.8. Template engines.md) * [27.1.9. 错误处理](IV. Spring Boot features/27.1.9. Error Handling.md) From 779a279743730783668198fce355ba8e8f92b6f6 Mon Sep 17 00:00:00 2001 From: Jack Zhong Date: Sat, 28 Jul 2018 11:09:51 +0800 Subject: [PATCH 176/865] =?UTF-8?q?=E7=BF=BB=E8=AF=9127.1.8=20=E8=B7=AF?= =?UTF-8?q?=E5=BE=84=E5=8C=B9=E9=85=8D=E4=B8=8E=E5=86=85=E5=AE=B9=E5=8D=8F?= =?UTF-8?q?=E5=95=86?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../27.1.8. Path Matching and Content Negotiation.md | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/IV. Spring Boot features/27.1.8. Path Matching and Content Negotiation.md b/IV. Spring Boot features/27.1.8. Path Matching and Content Negotiation.md index a54e834f..fa24f0b1 100644 --- a/IV. Spring Boot features/27.1.8. Path Matching and Content Negotiation.md +++ b/IV. Spring Boot features/27.1.8. Path Matching and Content Negotiation.md @@ -1,10 +1,10 @@ ### 27.1.8 路径匹配与内容协商 -Spring MVC can map incoming HTTP requests to handlers by looking at the request path and matching it to the mappings defined in your application (for example, `@GetMapping` annotations on Controller methods). +Spring MVC能够查看请求路径,将HTTP请求映射到处理程序,并把它匹配到应用里定义的映射关系(比如,Controller方法的`@GetMapping`注解)。 -Spring Boot chooses to disable suffix pattern matching by default, which means that requests like `"GET /projects/spring-boot.json"` won’t be matched to`@GetMapping("/projects/spring-boot")` mappings. This is considered as a [best practice for Spring MVC applications](https://docs.spring.io/spring/docs/5.0.4.RELEASE/spring-framework-reference/web.html#mvc-ann-requestmapping-suffix-pattern-match). This feature was mainly useful in the past for HTTP clients which did not send proper "Accept" request headers; we needed to make sure to send the correct Content Type to the client. Nowadays, Content Negotiation is much more reliable. +Spring Boot默认禁用后缀模式匹配。这意味着类似`"GET /projects/spring-boot.json"`的请求,不会匹配到`@GetMapping("/projects/spring-boot")`。这是[Spring MVC应用的一种最佳实践](https://docs.spring.io/spring/docs/5.0.4.RELEASE/spring-framework-reference/web.html#mvc-ann-requestmapping-suffix-pattern-match)。过去,这个特性主要对HTTP客户端有用。HTTP客户端没有发送适当的"Accept"请求头。我们需要确保给客户端发送了正确的内容类型。现在,内容协商更为可靠。 -There are other ways to deal with HTTP clients that don’t consistently send proper "Accept" request headers. Instead of using suffix matching, we can use a query parameter to ensure that requests like `"GET /projects/spring-boot?format=json"` will be mapped to `@GetMapping("/projects/spring-boot")`: +还有其它方式处理HTTP客户端没有发送适当的"Accept"请求头的情况。不使用后缀匹配,但我们可以使用一个查询参数,来确保类似于`"GET /projects/spring-boot?format=json"`的请求会映射到`@GetMapping("/projects/spring-boot")`: ```properties spring.mvc.contentnegotiation.favor-parameter=true @@ -16,7 +16,7 @@ spring.mvc.contentnegotiation.favor-parameter=true spring.mvc.contentnegotiation.media-types.markdown=text/markdown ``` -If you understand the caveats and would still like your application to use suffix pattern matching, the following configuration is required: +如果你理解上面的警告,但还是想要在你的应用里使用后缀模式匹配,你需要下面的配置: ```properties spring.mvc.contentnegotiation.favor-path-extension=true From 1f3a3095428d4d444a97337b8a075d7617953cc4 Mon Sep 17 00:00:00 2001 From: Jack Zhong Date: Sat, 28 Jul 2018 19:14:01 +0800 Subject: [PATCH 177/865] =?UTF-8?q?=E9=87=8D=E5=91=BD=E5=90=8D27.1.9.=20Co?= =?UTF-8?q?nfigurableWebBindingInitializer?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- ...alizer.md => 27.1.9. ConfigurableWebBindingInitializer.md} | 4 ++-- SUMMARY.md | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) rename IV. Spring Boot features/{27.1.7. ConfigurableWebBindingInitializer.md => 27.1.9. ConfigurableWebBindingInitializer.md} (73%) diff --git a/IV. Spring Boot features/27.1.7. ConfigurableWebBindingInitializer.md b/IV. Spring Boot features/27.1.9. ConfigurableWebBindingInitializer.md similarity index 73% rename from IV. Spring Boot features/27.1.7. ConfigurableWebBindingInitializer.md rename to IV. Spring Boot features/27.1.9. ConfigurableWebBindingInitializer.md index 8ce28c19..2a78d01f 100644 --- a/IV. Spring Boot features/27.1.7. ConfigurableWebBindingInitializer.md +++ b/IV. Spring Boot features/27.1.9. ConfigurableWebBindingInitializer.md @@ -1,3 +1,3 @@ -### 27.1.7 ConfigurableWebBindingInitializer -Spring MVC使用`WebBindingInitializer`为每个特殊的请求初始化相应的`WebDataBinder`,如果你创建自己的`ConfigurableWebBindingInitializer @Bean`,Spring Boot会自动配置Spring MVC使用它。 +### 27.1.9 ConfigurableWebBindingInitializer +Spring MVC使用`WebBindingInitializer`为每个特殊的请求初始化相应的`WebDataBinder`,如果你创建自己的`ConfigurableWebBindingInitializer @Bean`,Spring Boot会自动配置Spring MVC使用它。 \ No newline at end of file diff --git a/SUMMARY.md b/SUMMARY.md index c64863ab..e29c9e34 100644 --- a/SUMMARY.md +++ b/SUMMARY.md @@ -132,8 +132,8 @@ * [27.1.6. 欢迎页](IV. Spring Boot features/27.1.6. Welcome Page.md) * [27.1.7. 定制网站图标](IV. Spring Boot features/27.1.7. Custom Favicon.md) * [27.1.8. 路径匹配与内容协商](IV. Spring Boot features/27.1.8. Path Matching and Content Negotiation.md) - * [27.1.7. ConfigurableWebBindingInitializer](IV. Spring Boot features/27.1.7. ConfigurableWebBindingInitializer.md) - * [27.1.8. 模板引擎](IV. Spring Boot features/27.1.8. Template engines.md) + * [27.1.9. ConfigurableWebBindingInitializer](IV. Spring Boot features/27.1.9. ConfigurableWebBindingInitializer.md) + * [27.1.10. 模板引擎](IV. Spring Boot features/27.1.10. Template Engines.md) * [27.1.9. 错误处理](IV. Spring Boot features/27.1.9. Error Handling.md) * [27.1.10. Spring HATEOAS](IV. Spring Boot features/27.1.10. Spring HATEOAS.md) * [27.1.11. CORS支持](IV. Spring Boot features/27.1.11. CORS support.md) From 74178aba95dc394e3cc6d6c450bc387830bce233 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E7=83=AD=E5=BF=83=E5=B8=82=E6=B0=91=E9=92=9F=E5=B0=8F?= =?UTF-8?q?=E5=BC=BA?= Date: Sat, 28 Jul 2018 19:19:27 +0800 Subject: [PATCH 178/865] Update and rename 27.1.8. Template engines.md to 27.1.10. Template Engines.md --- ....1.8. Template engines.md => 27.1.10. Template Engines.md} | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) rename IV. Spring Boot features/{27.1.8. Template engines.md => 27.1.10. Template Engines.md} (92%) diff --git a/IV. Spring Boot features/27.1.8. Template engines.md b/IV. Spring Boot features/27.1.10. Template Engines.md similarity index 92% rename from IV. Spring Boot features/27.1.8. Template engines.md rename to IV. Spring Boot features/27.1.10. Template Engines.md index 73685de8..c3c4c113 100644 --- a/IV. Spring Boot features/27.1.8. Template engines.md +++ b/IV. Spring Boot features/27.1.10. Template Engines.md @@ -1,4 +1,4 @@ -### 27.1.8 模板引擎 +### 27.1.10 模板引擎 正如REST web服务,你也可以使用Spring MVC提供动态HTML内容。Spring MVC支持各种各样的模板技术,包括Thymeleaf, FreeMarker和JSPs,很多其他的模板引擎也提供它们自己的Spring MVC集成。 @@ -9,7 +9,7 @@ Spring Boot为以下的模板引擎提供自动配置支持: * [Thymeleaf](http://www.thymeleaf.org/) * [Mustache](http://mustache.github.io/) -**注**:由于在内嵌servlet容器中使用JSPs存在一些[已知的限制](27.3.5. JSP limitations.md),所以建议尽量不使用它们。 +**注**:由于在内嵌servlet容器中使用JSPs存在一些[已知的限制](27.4.5. JSP limitations.md),所以建议尽量不使用它们。 使用以上引擎中的任何一种,并采用默认配置,则模块会从`src/main/resources/templates`自动加载。 From 0aeb5eebe0a14b074deb3c4c4ece3ececb71fdd2 Mon Sep 17 00:00:00 2001 From: Jack Zhong Date: Sat, 28 Jul 2018 20:53:07 +0800 Subject: [PATCH 179/865] =?UTF-8?q?=E7=BF=BB=E8=AF=9127.1.11.=20=E9=94=99?= =?UTF-8?q?=E8=AF=AF=E5=A4=84=E7=90=86=E3=80=8127.1.12.=20Spring=20HATEOAS?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- ... Handling.md => 27.1.11. Error Handling.md} | 18 ++++++++---------- ...g HATEOAS.md => 27.1.12. Spring HATEOAS.md} | 4 ++-- SUMMARY.md | 4 ++-- 3 files changed, 12 insertions(+), 14 deletions(-) rename IV. Spring Boot features/{27.1.9. Error Handling.md => 27.1.11. Error Handling.md} (75%) rename IV. Spring Boot features/{27.1.10. Spring HATEOAS.md => 27.1.12. Spring HATEOAS.md} (93%) diff --git a/IV. Spring Boot features/27.1.9. Error Handling.md b/IV. Spring Boot features/27.1.11. Error Handling.md similarity index 75% rename from IV. Spring Boot features/27.1.9. Error Handling.md rename to IV. Spring Boot features/27.1.11. Error Handling.md index e2704d30..6e510d6a 100644 --- a/IV. Spring Boot features/27.1.9. Error Handling.md +++ b/IV. Spring Boot features/27.1.11. Error Handling.md @@ -1,14 +1,14 @@ -### 27.1.9 错误处理 +### 27.1.11 错误处理 Spring Boot默认提供一个`/error`映射用来以合适的方式处理所有的错误,并将它注册为servlet容器中全局的 错误页面。对于机器客户端(相对于浏览器而言,浏览器偏重于人的行为),它会产生一个具有详细错误,HTTP状态,异常信息的JSON响应。对于浏览器客户端,它会产生一个白色标签样式(whitelabel)的错误视图,该视图将以HTML格式显示同样的数据(可以添加一个解析为'error'的View来自定义它)。为了完全替换默认的行为,你可以实现`ErrorController`,并注册一个该类型的bean定义,或简单地添加一个`ErrorAttributes`类型的bean以使用现存的机制,只是替换显示的内容。 **注** `BasicErrorController`可以作为自定义`ErrorController`的基类,如果你想添加对新context type的处理(默认处理`text/html`),这会很有帮助。你只需要继承`BasicErrorController`,添加一个public方法,并注解带有`produces`属性的`@RequestMapping`,然后创建该新类型的bean。 -你也可以定义一个`@ControllerAdvice`去自定义某个特殊controller或exception类型的JSON文档: +你也可以定义一个注解为`@ControllerAdvice`的类去自定义某个特殊controller或exception类型的JSON文档。如下所示: ```java -@ControllerAdvice(basePackageClasses = FooController.class) -public class FooControllerAdvice extends ResponseEntityExceptionHandler { +@ControllerAdvice(basePackageClasses = AcmeController.class) +public class AcmeControllerAdvice extends ResponseEntityExceptionHandler { @ExceptionHandler(YourException.class) @ResponseBody @@ -27,7 +27,7 @@ public class FooControllerAdvice extends ResponseEntityExceptionHandler { } ``` -在以上示例中,如果跟`FooController`相同package的某个controller抛出`YourException`,一个`CustomerErrorType`类型的POJO的json展示将代替`ErrorAttributes`展示。 +在以上示例中,如果跟`AcmeController`相同package的某个controller抛出`YourException`,一个`CustomErrorType`类型的POJO的JSON展示将代替`ErrorAttributes`展示。 **自定义错误页面** @@ -92,7 +92,7 @@ private static class MyErrorPageRegistrar implements ErrorPageRegistrar { } ``` -注.如果你注册一个`ErrorPage`,该页面需要被一个`Filter`处理(在一些非Spring web框架中很常见,比如Jersey,Wicket),那么该`Filter`需要明确注册为一个`ERROR`分发器(dispatcher),例如: +**注** 如果你注册一个`ErrorPage`,该页面需要被一个`Filter`处理(在一些非Spring web框架中很常见,比如Jersey,Wicket),那么该`Filter`需要明确注册为一个`ERROR`分发器(dispatcher),例如: ```java @Bean public FilterRegistrationBean myFilter() { @@ -103,8 +103,6 @@ public FilterRegistrationBean myFilter() { return registration; } ``` -(默认的`FilterRegistrationBean`不包含`ERROR` dispatcher类型)。 +默认的`FilterRegistrationBean`不包含`ERROR` dispatcher类型。 -**WebSphere应用服务器的错误处理** - -当部署到一个servlet容器时,Spring Boot通过它的错误页面过滤器将带有错误状态的请求转发到恰当的错误页面。request只有在response还没提交时才能转发(forwarded)到正确的错误页面,而WebSphere应用服务器8.0及后续版本默认情况会在servlet方法成功执行后提交response,你需要设置`com.ibm.ws.webcontainer.invokeFlushAfterService`属性为`false`来关闭该行为。 +注意:当部署到一个servlet容器时,Spring Boot通过它的错误页面过滤器将带有错误状态的请求转发到恰当的错误页面。request只有在response还没提交时才能转发(forwarded)到正确的错误页面,而WebSphere应用服务器8.0及后续版本默认情况会在servlet方法成功执行后提交response,你需要设置`com.ibm.ws.webcontainer.invokeFlushAfterService`属性为`false`来关闭该行为。 diff --git a/IV. Spring Boot features/27.1.10. Spring HATEOAS.md b/IV. Spring Boot features/27.1.12. Spring HATEOAS.md similarity index 93% rename from IV. Spring Boot features/27.1.10. Spring HATEOAS.md rename to IV. Spring Boot features/27.1.12. Spring HATEOAS.md index b190bef8..c4cd6613 100644 --- a/IV. Spring Boot features/27.1.10. Spring HATEOAS.md +++ b/IV. Spring Boot features/27.1.12. Spring HATEOAS.md @@ -1,6 +1,6 @@ -### 27.1.10 Spring HATEOAS +### 27.1.12 Spring HATEOAS 如果正在开发基于超媒体的RESTful API,你可能需要Spring HATEOAS,而Spring Boot会为其提供自动配置,这在大多数应用中都运作良好。 自动配置取代了`@EnableHypermediaSupport`,只需注册一定数量的beans就能轻松构建基于超媒体的应用,这些beans包括`LinkDiscoverers`(客户端支持),`ObjectMapper`(用于将响应编排为想要的形式)。`ObjectMapper`可以根据`spring.jackson.*`属性或`Jackson2ObjectMapperBuilder` bean进行自定义。 -通过注解`@EnableHypermediaSupport`,你可以控制Spring HATEOAS的配置,但这会禁用上述`ObjectMapper`的自定义功能。 +通过注解`@EnableHypermediaSupport`,你可以控制Spring HATEOAS的配置,但这会禁用上述`ObjectMapper`的自定义功能。 \ No newline at end of file diff --git a/SUMMARY.md b/SUMMARY.md index e29c9e34..b96e08fb 100644 --- a/SUMMARY.md +++ b/SUMMARY.md @@ -134,8 +134,8 @@ * [27.1.8. 路径匹配与内容协商](IV. Spring Boot features/27.1.8. Path Matching and Content Negotiation.md) * [27.1.9. ConfigurableWebBindingInitializer](IV. Spring Boot features/27.1.9. ConfigurableWebBindingInitializer.md) * [27.1.10. 模板引擎](IV. Spring Boot features/27.1.10. Template Engines.md) - * [27.1.9. 错误处理](IV. Spring Boot features/27.1.9. Error Handling.md) - * [27.1.10. Spring HATEOAS](IV. Spring Boot features/27.1.10. Spring HATEOAS.md) + * [27.1.11. 错误处理](IV. Spring Boot features/27.1.11. Error Handling.md) + * [27.1.12. Spring HATEOAS](IV. Spring Boot features/27.1.12. Spring HATEOAS.md) * [27.1.11. CORS支持](IV. Spring Boot features/27.1.11. CORS support.md) * [27.2 The ‘Spring WebFlux framework’](IV. Spring Boot features/27.2 The ‘Spring WebFlux framework’.md) * [27.2.1 Spring WebFlux auto-configuration](IV. Spring Boot features/27.2.1 Spring WebFlux auto-configuration.md) From 81777df5ee1f10cf2c4f830cdbaf20ac0952be26 Mon Sep 17 00:00:00 2001 From: Jack Zhong Date: Sat, 28 Jul 2018 22:31:19 +0800 Subject: [PATCH 180/865] =?UTF-8?q?=E7=BF=BB=E8=AF=9127.1.13.=20CORS?= =?UTF-8?q?=E6=94=AF=E6=8C=81?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../27.1.11. CORS support.md | 20 ------------------- .../27.1.13. CORS support.md | 20 +++++++++++++++++++ SUMMARY.md | 2 +- 3 files changed, 21 insertions(+), 21 deletions(-) delete mode 100644 IV. Spring Boot features/27.1.11. CORS support.md create mode 100644 IV. Spring Boot features/27.1.13. CORS support.md diff --git a/IV. Spring Boot features/27.1.11. CORS support.md b/IV. Spring Boot features/27.1.11. CORS support.md deleted file mode 100644 index 4887ec5c..00000000 --- a/IV. Spring Boot features/27.1.11. CORS support.md +++ /dev/null @@ -1,20 +0,0 @@ -### 27.1.11 CORS支持 - -[跨域资源共享](http://en.wikipedia.org/wiki/Cross-origin_resource_sharing)(CORS)是一个[大多数浏览器](http://caniuse.com/#feat=cors)都实现了的[W3C标准](http://www.w3.org/TR/cors/),它允许你以灵活的方式指定跨域请求如何被授权,而不是采用那些不安全,性能低的方式,比如IFRAME或JSONP。 - -从4.2版本开始,Spring MVC对[CORS](https://docs.spring.io/spring/docs/5.0.4.RELEASE/spring-framework-reference/htmlsingle/#cors)提供开箱即用的支持。不用添加任何特殊配置,只需要在Spring Boot应用的controller方法上注解[`@CrossOrigin`](https://docs.spring.io/spring/docs/5.0.4.RELEASE/javadoc-api/org/springframework/web/bind/annotation/CrossOrigin.html),并添加[CORS配置](https://docs.spring.io/spring/docs/5.0.4.RELEASE/spring-framework-reference/htmlsingle/#_controller_method_cors_configuration)。通过注册一个自定义`addCorsMappings(CorsRegistry)`方法的`WebMvcConfigurer` bean可以指定[全局CORS配置](https://docs.spring.io/spring/docs/5.0.4.RELEASE/spring-framework-reference/htmlsingle/#_global_cors_configuration): -```java -@Configuration -public class MyConfiguration { - - @Bean - public WebMvcConfigurer corsConfigurer() { - return new WebMvcConfigurer() { - @Override - public void addCorsMappings(CorsRegistry registry) { - registry.addMapping("/api/**"); - } - }; - } -} -``` diff --git a/IV. Spring Boot features/27.1.13. CORS support.md b/IV. Spring Boot features/27.1.13. CORS support.md new file mode 100644 index 00000000..f4f2e2f6 --- /dev/null +++ b/IV. Spring Boot features/27.1.13. CORS support.md @@ -0,0 +1,20 @@ +### 27.1.13 CORS支持 + +[跨域资源共享](https://en.wikipedia.org/wiki/Cross-origin_resource_sharing)(CORS)是一个[大多数浏览器](https://caniuse.com/#feat=cors)都实现了的[W3C标准](https://www.w3.org/TR/cors/),它允许你以灵活的方式指定跨域请求如何被授权,而不是采用那些不安全,性能低的方式,比如IFRAME或JSONP。 + +从4.2版本开始,Spring MVC对[CORS](https://docs.spring.io/spring/docs/5.0.4.RELEASE/spring-framework-reference/web.html#cors)提供开箱即用的支持。不用添加任何特殊配置,只需要在Spring Boot应用的controller方法上注解[`@CrossOrigin`](https://docs.spring.io/spring/docs/5.0.4.RELEASE/javadoc-api/org/springframework/web/bind/annotation/CrossOrigin.html),并添加[CORS配置](https://docs.spring.io/spring/docs/5.0.4.RELEASE/spring-framework-reference/web.html#controller-method-cors-configuration)。通过注册一个自定义`addCorsMappings(CorsRegistry)`方法的`WebMvcConfigurer` bean可以指定[全局CORS配置](https://docs.spring.io/spring/docs/5.0.4.RELEASE/spring-framework-reference/web.html#global-cors-configuration): +```java +@Configuration +public class MyConfiguration { + + @Bean + public WebMvcConfigurer corsConfigurer() { + return new WebMvcConfigurer() { + @Override + public void addCorsMappings(CorsRegistry registry) { + registry.addMapping("/api/**"); + } + }; + } +} +``` diff --git a/SUMMARY.md b/SUMMARY.md index b96e08fb..2e2465ac 100644 --- a/SUMMARY.md +++ b/SUMMARY.md @@ -136,7 +136,7 @@ * [27.1.10. 模板引擎](IV. Spring Boot features/27.1.10. Template Engines.md) * [27.1.11. 错误处理](IV. Spring Boot features/27.1.11. Error Handling.md) * [27.1.12. Spring HATEOAS](IV. Spring Boot features/27.1.12. Spring HATEOAS.md) - * [27.1.11. CORS支持](IV. Spring Boot features/27.1.11. CORS support.md) + * [27.1.13. CORS支持](IV. Spring Boot features/27.1.13. CORS support.md) * [27.2 The ‘Spring WebFlux framework’](IV. Spring Boot features/27.2 The ‘Spring WebFlux framework’.md) * [27.2.1 Spring WebFlux auto-configuration](IV. Spring Boot features/27.2.1 Spring WebFlux auto-configuration.md) * [27.2.2 HTTP codecs with HttpMessageReaders and HttpMessageWriters](IV. Spring Boot features/27.2.2 HTTP codecs with HttpMessageReaders and HttpMessageWriters.md) From cdaa478ae39fc93100044e154419c92930ce5116 Mon Sep 17 00:00:00 2001 From: Jack Zhong Date: Sat, 28 Jul 2018 23:24:00 +0800 Subject: [PATCH 181/865] =?UTF-8?q?=E4=B8=8A=E4=BC=A027.2=20Spring=20WebFl?= =?UTF-8?q?ux=E6=A1=86=E6=9E=B6?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- ...30Spring WebFlux framework\342\200\231.md" | 32 ++++++++++--------- SUMMARY.md | 2 +- 2 files changed, 18 insertions(+), 16 deletions(-) diff --git "a/IV. Spring Boot features/27.2 The \342\200\230Spring WebFlux framework\342\200\231.md" "b/IV. Spring Boot features/27.2 The \342\200\230Spring WebFlux framework\342\200\231.md" index f6a672ee..fc1ba8e7 100644 --- "a/IV. Spring Boot features/27.2 The \342\200\230Spring WebFlux framework\342\200\231.md" +++ "b/IV. Spring Boot features/27.2 The \342\200\230Spring WebFlux framework\342\200\231.md" @@ -1,9 +1,9 @@ -### 27.2 The ‘Spring WebFlux framework’ +### 27.2 Spring WebFlux框架 -Spring WebFlux is the new reactive web framework introduced in Spring Framework 5.0. Unlike Spring MVC, it does not require the Servlet API, is fully asynchronous and non-blocking, and implements the Reactive Streams specification through the Reactor project. - -Spring WebFlux comes in two flavors; the annotation-based one is quite close to the Spring MVC model we know: +Spring WebFlux is the new reactive web framework introduced in Spring Framework 5.0. Unlike Spring MVC, it does not require the Servlet API, is fully asynchronous and non-blocking, and implements the [Reactive Streams](http://www.reactive-streams.org/) specification through [the Reactor project](https://projectreactor.io/). +Spring WebFlux comes in two flavors: functional and annotation-based. The annotation-based one is quite close to the Spring MVC model, as shown in the following example: +```java @RestController @RequestMapping("/users") public class MyRestController { @@ -12,20 +12,21 @@ public class MyRestController { public Mono getUser(@PathVariable Long user) { // ... } - + @GetMapping("/{user}/customers") - Flux getUserCustomers(@PathVariable Long user) { + public Flux getUserCustomers(@PathVariable Long user) { // ... } - + @DeleteMapping("/{user}") public Mono deleteUser(@PathVariable Long user) { // ... } } -‘WebFlux.fn’, the functional variant, separates the routing configuration from the actual handling of the requests: - +``` +“WebFlux.fn”, the functional variant, separates the routing configuration from the actual handling of the requests, as shown in the following example: +```java @Configuration public class RoutingConfiguration { @@ -44,19 +45,20 @@ public class UserHandler { public Mono getUser(ServerRequest request) { // ... } - + public Mono getUserCustomers(ServerRequest request) { // ... } - + public Mono deleteUser(ServerRequest request) { // ... } } -WebFlux is part of the Spring Framework and detailed information is available in the reference documentation. +``` +WebFlux is part of the Spring Framework and detailed information is available in its [reference documentation](https://docs.spring.io/spring/docs/5.0.4.RELEASE/spring-framework-reference/web-reactive.html#webflux-fn). -To get started, add the spring-boot-starter-webflux module to your application. +**注** You can define as many `RouterFunction` beans as you like to modularize the definition of the router. Beans can be ordered if you need to apply a precedence. -[Note] -Adding both spring-boot-starter-web and spring-boot-starter-webflux modules in your application will result in Spring Boot auto-configuring Spring MVC, not WebFlux. This behavior has been chosen because many Spring developers will add spring-boot-starter-webflux to their Spring MVC application to use the reactive WebCLient. You can still enforce your choice by setting the chosen application type like SpringApplication.setWebApplicationType(WebApplicationType.REACTIVE). +To get started, add the `spring-boot-starter-webflux` module to your application. +**注** Adding both `spring-boot-starter-web` and `spring-boot-starter-webflux` modules in your application results in Spring Boot auto-configuring Spring MVC, not WebFlux. This behavior has been chosen because many Spring developers add `spring-boot-starter-webflux` to their Spring MVC application to use the reactive `WebClient`. You can still enforce your choice by setting the chosen application type to `SpringApplication.setWebApplicationType(WebApplicationType.REACTIVE)`. \ No newline at end of file diff --git a/SUMMARY.md b/SUMMARY.md index 2e2465ac..14e1e0aa 100644 --- a/SUMMARY.md +++ b/SUMMARY.md @@ -137,7 +137,7 @@ * [27.1.11. 错误处理](IV. Spring Boot features/27.1.11. Error Handling.md) * [27.1.12. Spring HATEOAS](IV. Spring Boot features/27.1.12. Spring HATEOAS.md) * [27.1.13. CORS支持](IV. Spring Boot features/27.1.13. CORS support.md) - * [27.2 The ‘Spring WebFlux framework’](IV. Spring Boot features/27.2 The ‘Spring WebFlux framework’.md) + * [27.2 Spring WebFlux框架](IV. Spring Boot features/27.2 The ‘Spring WebFlux framework’.md) * [27.2.1 Spring WebFlux auto-configuration](IV. Spring Boot features/27.2.1 Spring WebFlux auto-configuration.md) * [27.2.2 HTTP codecs with HttpMessageReaders and HttpMessageWriters](IV. Spring Boot features/27.2.2 HTTP codecs with HttpMessageReaders and HttpMessageWriters.md) * [27.2.3 Static Content](IV. Spring Boot features/27.2.3 Static Content.md) From fd9ebd0f039730eb6801bfaa1aea2dfa6d7e5bb8 Mon Sep 17 00:00:00 2001 From: Jack Zhong Date: Sun, 29 Jul 2018 14:02:30 +0800 Subject: [PATCH 182/865] =?UTF-8?q?=E7=BF=BB=E8=AF=9127.2=20Spring=20WebFl?= =?UTF-8?q?ux=E6=A1=86=E6=9E=B6?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- ...2 The \342\200\230Spring WebFlux framework\342\200\231.md" | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git "a/IV. Spring Boot features/27.2 The \342\200\230Spring WebFlux framework\342\200\231.md" "b/IV. Spring Boot features/27.2 The \342\200\230Spring WebFlux framework\342\200\231.md" index fc1ba8e7..8624d9f6 100644 --- "a/IV. Spring Boot features/27.2 The \342\200\230Spring WebFlux framework\342\200\231.md" +++ "b/IV. Spring Boot features/27.2 The \342\200\230Spring WebFlux framework\342\200\231.md" @@ -1,8 +1,8 @@ ### 27.2 Spring WebFlux框架 -Spring WebFlux is the new reactive web framework introduced in Spring Framework 5.0. Unlike Spring MVC, it does not require the Servlet API, is fully asynchronous and non-blocking, and implements the [Reactive Streams](http://www.reactive-streams.org/) specification through [the Reactor project](https://projectreactor.io/). +Spring WebFlux是Spring Framework 5.0中引入的新的响应式网络框架。不同与Spring MVC,它不需要Servlet API,是完全异步、非阻塞的,通过[Reactor项目](https://projectreactor.io/)实现了[Reactive Streams](http://www.reactive-streams.org/) 规范。 -Spring WebFlux comes in two flavors: functional and annotation-based. The annotation-based one is quite close to the Spring MVC model, as shown in the following example: +Spring WebFlux有两种风格:函数式和基于注解。基于注解的风格相当接近于Spring MVC模型,如下所示: ```java @RestController @RequestMapping("/users") From bf3ae4cec2fe60bbfab71454cac8450edd2fed69 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E7=83=AD=E5=BF=83=E5=B8=82=E6=B0=91=E9=92=9F=E5=B0=8F?= =?UTF-8?q?=E5=BC=BA?= Date: Sun, 29 Jul 2018 14:41:17 +0800 Subject: [PATCH 183/865] =?UTF-8?q?Update=2027.2=20The=20=E2=80=98Spring?= =?UTF-8?q?=20WebFlux=20framework=E2=80=99.md?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- ...2 The \342\200\230Spring WebFlux framework\342\200\231.md" | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git "a/IV. Spring Boot features/27.2 The \342\200\230Spring WebFlux framework\342\200\231.md" "b/IV. Spring Boot features/27.2 The \342\200\230Spring WebFlux framework\342\200\231.md" index 8624d9f6..6b0e0781 100644 --- "a/IV. Spring Boot features/27.2 The \342\200\230Spring WebFlux framework\342\200\231.md" +++ "b/IV. Spring Boot features/27.2 The \342\200\230Spring WebFlux framework\342\200\231.md" @@ -25,7 +25,7 @@ public class MyRestController { } ``` -“WebFlux.fn”, the functional variant, separates the routing configuration from the actual handling of the requests, as shown in the following example: +“WebFlux.fn”——函数式变体,从请求的实际处理中分离了路由配置,如下所示: ```java @Configuration public class RoutingConfiguration { @@ -55,7 +55,7 @@ public class UserHandler { } } ``` -WebFlux is part of the Spring Framework and detailed information is available in its [reference documentation](https://docs.spring.io/spring/docs/5.0.4.RELEASE/spring-framework-reference/web-reactive.html#webflux-fn). +WebFlux是Spring框架的一部分。详细信息请查看它的[参考文档](https://docs.spring.io/spring/docs/5.0.4.RELEASE/spring-framework-reference/web-reactive.html#webflux-fn)。 **注** You can define as many `RouterFunction` beans as you like to modularize the definition of the router. Beans can be ordered if you need to apply a precedence. From f262716ce062028fdf7a06d6aa666d4ce074de30 Mon Sep 17 00:00:00 2001 From: Jack Zhong Date: Sun, 29 Jul 2018 21:03:45 +0800 Subject: [PATCH 184/865] =?UTF-8?q?=E7=BF=BB=E8=AF=9127.2=20Spring=20WebFl?= =?UTF-8?q?ux=E6=A1=86=E6=9E=B6?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- ...The \342\200\230Spring WebFlux framework\342\200\231.md" | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git "a/IV. Spring Boot features/27.2 The \342\200\230Spring WebFlux framework\342\200\231.md" "b/IV. Spring Boot features/27.2 The \342\200\230Spring WebFlux framework\342\200\231.md" index 6b0e0781..faf29c8e 100644 --- "a/IV. Spring Boot features/27.2 The \342\200\230Spring WebFlux framework\342\200\231.md" +++ "b/IV. Spring Boot features/27.2 The \342\200\230Spring WebFlux framework\342\200\231.md" @@ -57,8 +57,8 @@ public class UserHandler { ``` WebFlux是Spring框架的一部分。详细信息请查看它的[参考文档](https://docs.spring.io/spring/docs/5.0.4.RELEASE/spring-framework-reference/web-reactive.html#webflux-fn)。 -**注** You can define as many `RouterFunction` beans as you like to modularize the definition of the router. Beans can be ordered if you need to apply a precedence. +**注** 你可以定义多个`RouterFunction` bean来模块化路由的定义。如果你需要应用优先级,可以给bean排序。 -To get started, add the `spring-boot-starter-webflux` module to your application. +给你的应用添加`spring-boot-starter-webflux`模块,开始使用。 -**注** Adding both `spring-boot-starter-web` and `spring-boot-starter-webflux` modules in your application results in Spring Boot auto-configuring Spring MVC, not WebFlux. This behavior has been chosen because many Spring developers add `spring-boot-starter-webflux` to their Spring MVC application to use the reactive `WebClient`. You can still enforce your choice by setting the chosen application type to `SpringApplication.setWebApplicationType(WebApplicationType.REACTIVE)`. \ No newline at end of file +**注** 在你的应用里同时添加`spring-boot-starter-web`和`spring-boot-starter-webflux`模块,会使Spring Boot自动配置Spring MVC,而不是WebFlux。这种行为是因为许多Spring开发者为了使用响应式的`WebClient`,往他们的Spring MVC应用里添加`spring-boot-starter-webflux`。你可以设置应用类型为`SpringApplication.setWebApplicationType(WebApplicationType.REACTIVE)`,强制Spring Boot自动配置WebFlux。 \ No newline at end of file From c72f340b66b40ebdd001ab020eeb6ec5e6d3e038 Mon Sep 17 00:00:00 2001 From: Jack Zhong Date: Tue, 14 Aug 2018 22:25:05 +0800 Subject: [PATCH 185/865] =?UTF-8?q?=E7=BF=BB=E8=AF=9127.2.1=20Spring=20Web?= =?UTF-8?q?Flux=E8=87=AA=E5=8A=A8=E9=85=8D=E7=BD=AE?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- SUMMARY.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/SUMMARY.md b/SUMMARY.md index 14e1e0aa..8b9fffcb 100644 --- a/SUMMARY.md +++ b/SUMMARY.md @@ -138,7 +138,7 @@ * [27.1.12. Spring HATEOAS](IV. Spring Boot features/27.1.12. Spring HATEOAS.md) * [27.1.13. CORS支持](IV. Spring Boot features/27.1.13. CORS support.md) * [27.2 Spring WebFlux框架](IV. Spring Boot features/27.2 The ‘Spring WebFlux framework’.md) - * [27.2.1 Spring WebFlux auto-configuration](IV. Spring Boot features/27.2.1 Spring WebFlux auto-configuration.md) + * [27.2.1 Spring WebFlux自动配置](IV. Spring Boot features/27.2.1 Spring WebFlux auto-configuration.md) * [27.2.2 HTTP codecs with HttpMessageReaders and HttpMessageWriters](IV. Spring Boot features/27.2.2 HTTP codecs with HttpMessageReaders and HttpMessageWriters.md) * [27.2.3 Static Content](IV. Spring Boot features/27.2.3 Static Content.md) * [27.2.4 Template engines](IV. Spring Boot features/27.2.4 Template engines.md) From 1914679a6cbfe36d3c1b75e91bfaa361c186c4a7 Mon Sep 17 00:00:00 2001 From: Jack Zhong Date: Tue, 14 Aug 2018 22:31:17 +0800 Subject: [PATCH 186/865] =?UTF-8?q?=E7=BF=BB=E8=AF=9127.2.1=20Spring=20Web?= =?UTF-8?q?Flux=E8=87=AA=E5=8A=A8=E9=85=8D=E7=BD=AE?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- ...2 The \342\200\234Spring WebFlux Framework\342\200\235.md" | 0 SUMMARY.md | 4 ++-- 2 files changed, 2 insertions(+), 2 deletions(-) rename "IV. Spring Boot features/27.2 The \342\200\230Spring WebFlux framework\342\200\231.md" => "IV. Spring Boot features/27.2 The \342\200\234Spring WebFlux Framework\342\200\235.md" (100%) diff --git "a/IV. Spring Boot features/27.2 The \342\200\230Spring WebFlux framework\342\200\231.md" "b/IV. Spring Boot features/27.2 The \342\200\234Spring WebFlux Framework\342\200\235.md" similarity index 100% rename from "IV. Spring Boot features/27.2 The \342\200\230Spring WebFlux framework\342\200\231.md" rename to "IV. Spring Boot features/27.2 The \342\200\234Spring WebFlux Framework\342\200\235.md" diff --git a/SUMMARY.md b/SUMMARY.md index 8b9fffcb..5f7d6b68 100644 --- a/SUMMARY.md +++ b/SUMMARY.md @@ -137,8 +137,8 @@ * [27.1.11. 错误处理](IV. Spring Boot features/27.1.11. Error Handling.md) * [27.1.12. Spring HATEOAS](IV. Spring Boot features/27.1.12. Spring HATEOAS.md) * [27.1.13. CORS支持](IV. Spring Boot features/27.1.13. CORS support.md) - * [27.2 Spring WebFlux框架](IV. Spring Boot features/27.2 The ‘Spring WebFlux framework’.md) - * [27.2.1 Spring WebFlux自动配置](IV. Spring Boot features/27.2.1 Spring WebFlux auto-configuration.md) + * [27.2 Spring WebFlux框架](IV. Spring Boot features/27.2 The “Spring WebFlux Framework”.md) + * [27.2.1 Spring WebFlux自动配置](IV. Spring Boot features/27.2.1 Spring WebFlux Auto-configuration.md) * [27.2.2 HTTP codecs with HttpMessageReaders and HttpMessageWriters](IV. Spring Boot features/27.2.2 HTTP codecs with HttpMessageReaders and HttpMessageWriters.md) * [27.2.3 Static Content](IV. Spring Boot features/27.2.3 Static Content.md) * [27.2.4 Template engines](IV. Spring Boot features/27.2.4 Template engines.md) From d73273b0e200e47408303f835e469bd671033520 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E7=83=AD=E5=BF=83=E5=B8=82=E6=B0=91=E9=92=9F=E5=B0=8F?= =?UTF-8?q?=E5=BC=BA?= Date: Tue, 14 Aug 2018 22:36:25 +0800 Subject: [PATCH 187/865] Update and rename 27.2.1 Spring WebFlux auto-configuration.md to 27.2.1 Spring WebFlux Auto-configuration.md --- .../27.2.1 Spring WebFlux Auto-configuration.md | 12 ++++++++++++ .../27.2.1 Spring WebFlux auto-configuration.md | 11 ----------- 2 files changed, 12 insertions(+), 11 deletions(-) create mode 100644 IV. Spring Boot features/27.2.1 Spring WebFlux Auto-configuration.md delete mode 100644 IV. Spring Boot features/27.2.1 Spring WebFlux auto-configuration.md diff --git a/IV. Spring Boot features/27.2.1 Spring WebFlux Auto-configuration.md b/IV. Spring Boot features/27.2.1 Spring WebFlux Auto-configuration.md new file mode 100644 index 00000000..479b0df9 --- /dev/null +++ b/IV. Spring Boot features/27.2.1 Spring WebFlux Auto-configuration.md @@ -0,0 +1,12 @@ +### 27.2.1 Spring WebFlux自动配置 + +Spring Boot provides auto-configuration for Spring WebFlux that works well with most applications. + +The auto-configuration adds the following features on top of Spring’s defaults: + +- Configuring codecs for `HttpMessageReader` and `HttpMessageWriter` instances (described [later in this document](https://docs.spring.io/spring-boot/docs/2.0.0.RELEASE/reference/htmlsingle/#boot-features-webflux-httpcodecs)). +- Support for serving static resources, including support for WebJars (described [later in this document](https://docs.spring.io/spring-boot/docs/2.0.0.RELEASE/reference/htmlsingle/#boot-features-spring-mvc-static-content)). + +If you want to keep Spring Boot WebFlux features and you want to add additional [WebFlux configuration](https://docs.spring.io/spring/docs/5.0.4.RELEASE/spring-framework-reference/web.html#web-reactive), you can add your own `@Configuration` class of type `WebFluxConfigurer` but without `@EnableWebFlux`. + +If you want to take complete control of Spring WebFlux, you can add your own `@Configuration` annotated with `@EnableWebFlux`. diff --git a/IV. Spring Boot features/27.2.1 Spring WebFlux auto-configuration.md b/IV. Spring Boot features/27.2.1 Spring WebFlux auto-configuration.md deleted file mode 100644 index 95c0ab89..00000000 --- a/IV. Spring Boot features/27.2.1 Spring WebFlux auto-configuration.md +++ /dev/null @@ -1,11 +0,0 @@ -### 27.2.1 Spring WebFlux auto-configuration - -Spring Boot provides auto-configuration for Spring WebFlux that works well with most applications. - -The auto-configuration adds the following features on top of Spring’s defaults: - -Configuring codecs for HttpMessageReader and HttpMessageWriter instances (see below). -Support for serving static resources, including support for WebJars (see below). -If you want to keep Spring Boot WebFlux features, and you just want to add additional WebFlux configuration you can add your own @Configuration class of type WebFluxConfigurer, but without @EnableWebFlux. - -If you want to take complete control of Spring WebFlux, you can add your own @Configuration annotated with @EnableWebFlux. \ No newline at end of file From efc495e2d6487ee28d1d72a23cb64cffb137782d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E7=83=AD=E5=BF=83=E5=B8=82=E6=B0=91=E9=92=9F=E5=B0=8F?= =?UTF-8?q?=E5=BC=BA?= Date: Thu, 16 Aug 2018 12:51:52 +0800 Subject: [PATCH 188/865] Update 27.2.1 Spring WebFlux Auto-configuration.md --- .../27.2.1 Spring WebFlux Auto-configuration.md | 13 ++++++------- 1 file changed, 6 insertions(+), 7 deletions(-) diff --git a/IV. Spring Boot features/27.2.1 Spring WebFlux Auto-configuration.md b/IV. Spring Boot features/27.2.1 Spring WebFlux Auto-configuration.md index 479b0df9..6522e9ab 100644 --- a/IV. Spring Boot features/27.2.1 Spring WebFlux Auto-configuration.md +++ b/IV. Spring Boot features/27.2.1 Spring WebFlux Auto-configuration.md @@ -1,12 +1,11 @@ ### 27.2.1 Spring WebFlux自动配置 -Spring Boot provides auto-configuration for Spring WebFlux that works well with most applications. +Spring Boot为Spring WebFlux提供了自动配置。这些配置在大多数应用里能够很好地工作。 -The auto-configuration adds the following features on top of Spring’s defaults: +自动配置会添加以下特性: +- 为`HttpMessageReader`和`HttpMessageWriter`实例配置编解码器([在此文档的后面章节](https://docs.spring.io/spring-boot/docs/2.0.0.RELEASE/reference/htmlsingle/#boot-features-webflux-httpcodecs)有描述)。 +- 支持服务静态内容,包括对WebJars的支持 ([在此文档的后面章节](https://docs.spring.io/spring-boot/docs/2.0.0.RELEASE/reference/htmlsingle/#boot-features-spring-mvc-static-content)有描述)。 -- Configuring codecs for `HttpMessageReader` and `HttpMessageWriter` instances (described [later in this document](https://docs.spring.io/spring-boot/docs/2.0.0.RELEASE/reference/htmlsingle/#boot-features-webflux-httpcodecs)). -- Support for serving static resources, including support for WebJars (described [later in this document](https://docs.spring.io/spring-boot/docs/2.0.0.RELEASE/reference/htmlsingle/#boot-features-spring-mvc-static-content)). +如果你想保持Spring Boot WebFlux特性,并添加额外的[WebFlux配置](https://docs.spring.io/spring/docs/5.0.4.RELEASE/spring-framework-reference/web.html#web-reactive),你可以添加你自己的`WebFluxConfigurer`类型的`@Configuration`类,但是不加`@EnableWebFlux`。 -If you want to keep Spring Boot WebFlux features and you want to add additional [WebFlux configuration](https://docs.spring.io/spring/docs/5.0.4.RELEASE/spring-framework-reference/web.html#web-reactive), you can add your own `@Configuration` class of type `WebFluxConfigurer` but without `@EnableWebFlux`. - -If you want to take complete control of Spring WebFlux, you can add your own `@Configuration` annotated with `@EnableWebFlux`. +如果你想完全控制Spring WebFlux,你可以添加你自己的`@Configuration`,并用`@EnableWebFlux`标注。 From 939cefb03a39aafef386033ae024d55695c8cdc7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E7=83=AD=E5=BF=83=E5=B8=82=E6=B0=91=E9=92=9F=E5=B0=8F?= =?UTF-8?q?=E5=BC=BA?= Date: Sat, 18 Aug 2018 15:40:34 +0800 Subject: [PATCH 189/865] Update SUMMARY.md --- SUMMARY.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/SUMMARY.md b/SUMMARY.md index 5f7d6b68..b5fffb0a 100644 --- a/SUMMARY.md +++ b/SUMMARY.md @@ -139,7 +139,7 @@ * [27.1.13. CORS支持](IV. Spring Boot features/27.1.13. CORS support.md) * [27.2 Spring WebFlux框架](IV. Spring Boot features/27.2 The “Spring WebFlux Framework”.md) * [27.2.1 Spring WebFlux自动配置](IV. Spring Boot features/27.2.1 Spring WebFlux Auto-configuration.md) - * [27.2.2 HTTP codecs with HttpMessageReaders and HttpMessageWriters](IV. Spring Boot features/27.2.2 HTTP codecs with HttpMessageReaders and HttpMessageWriters.md) + * [27.2.2 HTTP编解码器————HttpMessageReaders与HttpMessageWriters](IV. Spring Boot features/27.2.2 HTTP Codecs with HttpMessageReaders and HttpMessageWriters.md) * [27.2.3 Static Content](IV. Spring Boot features/27.2.3 Static Content.md) * [27.2.4 Template engines](IV. Spring Boot features/27.2.4 Template engines.md) * [27.3. JAX-RS和Jersey](IV. Spring Boot features/27.3. JAX-RS and Jersey.md) From 57ddd653cef28453b5db715da7fce3b8a5924f72 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E7=83=AD=E5=BF=83=E5=B8=82=E6=B0=91=E9=92=9F=E5=B0=8F?= =?UTF-8?q?=E5=BC=BA?= Date: Sat, 18 Aug 2018 15:44:50 +0800 Subject: [PATCH 190/865] Update and rename 27.2.2 HTTP codecs with HttpMessageReaders and HttpMessageWriters.md to 27.2.2 HTTP Codecs with HttpMessageReaders and HttpMessageWriters.md --- ...tpMessageReaders and HttpMessageWriters.md | 23 +++++++++++++++++++ ...tpMessageReaders and HttpMessageWriters.md | 22 ------------------ 2 files changed, 23 insertions(+), 22 deletions(-) create mode 100644 IV. Spring Boot features/27.2.2 HTTP Codecs with HttpMessageReaders and HttpMessageWriters.md delete mode 100644 IV. Spring Boot features/27.2.2 HTTP codecs with HttpMessageReaders and HttpMessageWriters.md diff --git a/IV. Spring Boot features/27.2.2 HTTP Codecs with HttpMessageReaders and HttpMessageWriters.md b/IV. Spring Boot features/27.2.2 HTTP Codecs with HttpMessageReaders and HttpMessageWriters.md new file mode 100644 index 00000000..d41e83be --- /dev/null +++ b/IV. Spring Boot features/27.2.2 HTTP Codecs with HttpMessageReaders and HttpMessageWriters.md @@ -0,0 +1,23 @@ +### 27.2.2 HTTP编解码器————HttpMessageReaders与HttpMessageWriters + +Spring WebFlux uses the `HttpMessageReader` and `HttpMessageWriter` interfaces to convert HTTP requests and responses. They are configured with `CodecConfigurer` to have sensible defaults by looking at the libraries available in your classpath. + +Spring Boot applies further customization by using `CodecCustomizer` instances. For example, `spring.jackson.*` configuration keys are applied to the Jackson codec. + +If you need to add or customize codecs, you can create a custom `CodecCustomizer` component, as shown in the following example: +```java +import org.springframework.boot.web.codec.CodecCustomizer; + +@Configuration +public class MyConfiguration { + + @Bean + public CodecCustomizer myCodecCustomizer() { + return codecConfigurer -> { + // ... + } + } + +} +``` +You can also leverage [Boot’s custom JSON serializers and deserializers](https://docs.spring.io/spring-boot/docs/2.0.0.RELEASE/reference/htmlsingle/#boot-features-json-components). diff --git a/IV. Spring Boot features/27.2.2 HTTP codecs with HttpMessageReaders and HttpMessageWriters.md b/IV. Spring Boot features/27.2.2 HTTP codecs with HttpMessageReaders and HttpMessageWriters.md deleted file mode 100644 index 56f5f96b..00000000 --- a/IV. Spring Boot features/27.2.2 HTTP codecs with HttpMessageReaders and HttpMessageWriters.md +++ /dev/null @@ -1,22 +0,0 @@ -### 27.2.2 HTTP codecs with HttpMessageReaders and HttpMessageWriters - -Spring WebFlux uses the HttpMessageReader and HttpMessageWriter interface to convert HTTP requests and responses. They are configured with CodecConfigurer with sensible defaults, by looking at the libraries available in your classpath. - -Spring Boot will apply further customization using CodecCustomizer instances. For example, spring.jackson.* configuration keys will be applied to the Jackson codec. - -If you need to add or customize codecs you can create a custom CodecCustomizer component: - -import org.springframework.boot.web.codec.CodecCustomizer; - -@Configuration -public class MyConfiguration { - - @Bean - public CodecCustomizer myCodecCustomizer() { - return codecConfigurer -> { - // ... - } - } - -} -You can also leverage Boot’s custom JSON serializers and deserializers. \ No newline at end of file From a7317668b47a39f487d06e665e4749f4cb19b4cf Mon Sep 17 00:00:00 2001 From: Jack Zhong Date: Sun, 19 Aug 2018 09:47:50 +0800 Subject: [PATCH 191/865] =?UTF-8?q?=E7=BF=BB=E8=AF=9127.2.2=20HTTP?= =?UTF-8?q?=E7=BC=96=E8=A7=A3=E7=A0=81=E5=99=A8=E2=80=94=E2=80=94=E2=80=94?= =?UTF-8?q?=E2=80=94HttpMessageReaders=E4=B8=8EHttpMessageWriters?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- ...decs with HttpMessageReaders and HttpMessageWriters.md | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/IV. Spring Boot features/27.2.2 HTTP Codecs with HttpMessageReaders and HttpMessageWriters.md b/IV. Spring Boot features/27.2.2 HTTP Codecs with HttpMessageReaders and HttpMessageWriters.md index d41e83be..b773bc36 100644 --- a/IV. Spring Boot features/27.2.2 HTTP Codecs with HttpMessageReaders and HttpMessageWriters.md +++ b/IV. Spring Boot features/27.2.2 HTTP Codecs with HttpMessageReaders and HttpMessageWriters.md @@ -1,10 +1,10 @@ ### 27.2.2 HTTP编解码器————HttpMessageReaders与HttpMessageWriters -Spring WebFlux uses the `HttpMessageReader` and `HttpMessageWriter` interfaces to convert HTTP requests and responses. They are configured with `CodecConfigurer` to have sensible defaults by looking at the libraries available in your classpath. +Spring WebFlux使用`HttpMessageReader`和`HttpMessageWriter`接口转换HTTP请求与回应。它们由`CodecConfigurer`配置——通过查看类路径里可用的库配置默认值。 -Spring Boot applies further customization by using `CodecCustomizer` instances. For example, `spring.jackson.*` configuration keys are applied to the Jackson codec. +Spring Boot通过使用`CodecCustomizer`实例,更进一步地实现自定义。比如,`spring.jackson.*`配置键被应用于Jackson编解码器。 -If you need to add or customize codecs, you can create a custom `CodecCustomizer` component, as shown in the following example: +如果你需要添加或自定义编解码器,你可以创建一个自定义的`CodecCustomizer`组件,如下所示: ```java import org.springframework.boot.web.codec.CodecCustomizer; @@ -20,4 +20,4 @@ public class MyConfiguration { } ``` -You can also leverage [Boot’s custom JSON serializers and deserializers](https://docs.spring.io/spring-boot/docs/2.0.0.RELEASE/reference/htmlsingle/#boot-features-json-components). +你也可以利用[Spring Boot的自定义JSON序列化器和反序列化器](https://docs.spring.io/spring-boot/docs/2.0.0.RELEASE/reference/htmlsingle/#boot-features-json-components)。 \ No newline at end of file From 317af92f4c4f1cb62be5826935e3427320decaae Mon Sep 17 00:00:00 2001 From: Jack Zhong Date: Sun, 19 Aug 2018 10:00:59 +0800 Subject: [PATCH 192/865] =?UTF-8?q?=E7=BF=BB=E8=AF=9127.2.3=20=E9=9D=99?= =?UTF-8?q?=E6=80=81=E5=86=85=E5=AE=B9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../27.2.3 Static Content.md | 16 +++++++++------- 1 file changed, 9 insertions(+), 7 deletions(-) diff --git a/IV. Spring Boot features/27.2.3 Static Content.md b/IV. Spring Boot features/27.2.3 Static Content.md index 8fcb2966..1aca8fad 100644 --- a/IV. Spring Boot features/27.2.3 Static Content.md +++ b/IV. Spring Boot features/27.2.3 Static Content.md @@ -1,13 +1,15 @@ ### 27.2.3 Static Content -By default Spring Boot will serve static content from a directory called /static (or /public or /resources or /META-INF/resources) in the classpath. It uses the ResourceWebHandler from Spring WebFlux so you can modify that behavior by adding your own WebFluxConfigurer and overriding the addResourceHandlers method. +By default, Spring Boot serves static content from a directory called `/static` (or `/public` or `/resources` or `/META-INF/resources`) in the classpath. It uses the `ResourceWebHandler` from Spring WebFlux so that you can modify that behavior by adding your own `WebFluxConfigurer` and overriding the `addResourceHandlers` method. -By default, resources are mapped on /** but you can tune that via spring.mvc.static-path-pattern. For instance, relocating all resources to /resources/** can be achieved as follows: +By default, resources are mapped on `/**`, but you can tune that by setting the `spring.webflux.static-path-pattern` property. For instance, relocating all resources to `/resources/**` can be achieved as follows: -spring.mvc.static-path-pattern=/resources/** -You can also customize the static resource locations using spring.resources.static-locations (replacing the default values with a list of directory locations). If you do this the default welcome page detection will switch to your custom locations, so if there is an index.html in any of your locations on startup, it will be the home page of the application. +```properties +spring.webflux.static-path-pattern=/resources/** +``` -In addition to the ‘standard’ static resource locations above, a special case is made for Webjars content. Any resources with a path in /webjars/** will be served from jar files if they are packaged in the Webjars format. +You can also customize the static resource locations by using `spring.resources.static-locations`. Doing so replaces the default values with a list of directory locations. If you do so, the default welcome page detection switches to your custom locations. So, if there is an `index.html` in any of your locations on startup, it is the home page of the application. -[Tip] -Spring WebFlux applications don’t strictly depend on the Servlet API, so they can’t be deployed as war and have no use of the src/main/webapp directory. +In addition to the “standard” static resource locations listed earlier, a special case is made for [Webjars content](http://www.webjars.org/). Any resources with a path in `/webjars/**` are served from jar files if they are packaged in the Webjars format. + +**注** Spring WebFlux applications do not strictly depend on the Servlet API, so they cannot be deployed as war files and do not use the `src/main/webapp` directory. From 4ef55125228b88abd01ab146cc4713a9d79e124d Mon Sep 17 00:00:00 2001 From: Jack Zhong Date: Sun, 19 Aug 2018 11:30:50 +0800 Subject: [PATCH 193/865] =?UTF-8?q?=E7=BF=BB=E8=AF=9127.2.3=20=E9=9D=99?= =?UTF-8?q?=E6=80=81=E5=86=85=E5=AE=B9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- IV. Spring Boot features/27.2.3 Static Content.md | 14 ++++++-------- 1 file changed, 6 insertions(+), 8 deletions(-) diff --git a/IV. Spring Boot features/27.2.3 Static Content.md b/IV. Spring Boot features/27.2.3 Static Content.md index 1aca8fad..bc8c64d0 100644 --- a/IV. Spring Boot features/27.2.3 Static Content.md +++ b/IV. Spring Boot features/27.2.3 Static Content.md @@ -1,15 +1,13 @@ -### 27.2.3 Static Content +### 27.2.3 静态内容 -By default, Spring Boot serves static content from a directory called `/static` (or `/public` or `/resources` or `/META-INF/resources`) in the classpath. It uses the `ResourceWebHandler` from Spring WebFlux so that you can modify that behavior by adding your own `WebFluxConfigurer` and overriding the `addResourceHandlers` method. - -By default, resources are mapped on `/**`, but you can tune that by setting the `spring.webflux.static-path-pattern` property. For instance, relocating all resources to `/resources/**` can be achieved as follows: +默认情况下,Spring Boot从类路径下的`/static`(或者是`/public`、`/resources`、`/META-INF/resources`)文件夹提供静态内容。这是通过Spring WebFlux的`ResourceWebHandler`实现的。你可以添加你自己的`WebFluxConfigurer`并覆写`addResourceHandlers`方法来改变该行为(加载静态文件)。 +默认地,资源放置在`/**`,但是你可以通过`spring.webflux.static-path-pattern`属性进行调整。例如,迁移所有的资源到`/resources/**`可以按照如下方式实现: ```properties spring.webflux.static-path-pattern=/resources/** ``` +你可以设置`spring.resources.static-locations`属性自定义静态资源的位置(配置一系列目录位置代替默认的值)。这样,Spring Boot会在你自定义的位置查找欢迎页。所以,要是在哪个位置有`index.html`,它就会是应用的主页。 -You can also customize the static resource locations by using `spring.resources.static-locations`. Doing so replaces the default values with a list of directory locations. If you do so, the default welcome page detection switches to your custom locations. So, if there is an `index.html` in any of your locations on startup, it is the home page of the application. - -In addition to the “standard” static resource locations listed earlier, a special case is made for [Webjars content](http://www.webjars.org/). Any resources with a path in `/webjars/**` are served from jar files if they are packaged in the Webjars format. +此外,除了上述标准的静态资源位置,有个例外情况是[Webjars内容](http://www.webjars.org/)。任何在`/webjars/**`路径下的资源都将从jar文件中提供,只要它们以Webjars的格式打包。 -**注** Spring WebFlux applications do not strictly depend on the Servlet API, so they cannot be deployed as war files and do not use the `src/main/webapp` directory. +**注** Spring WebFlux应用并不完全依赖Servlet API,所以它们不能用war文件部署,也不使用`src/main/webapp`目录。 From 4e8b12f4ee15d9a5ce52c0bab024b8fe77f420b3 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E7=83=AD=E5=BF=83=E5=B8=82=E6=B0=91=E9=92=9F=E5=B0=8F?= =?UTF-8?q?=E5=BC=BA?= Date: Sat, 25 Aug 2018 10:25:48 +0800 Subject: [PATCH 194/865] Update SUMMARY.md --- SUMMARY.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/SUMMARY.md b/SUMMARY.md index b5fffb0a..16e3bcfc 100644 --- a/SUMMARY.md +++ b/SUMMARY.md @@ -140,8 +140,8 @@ * [27.2 Spring WebFlux框架](IV. Spring Boot features/27.2 The “Spring WebFlux Framework”.md) * [27.2.1 Spring WebFlux自动配置](IV. Spring Boot features/27.2.1 Spring WebFlux Auto-configuration.md) * [27.2.2 HTTP编解码器————HttpMessageReaders与HttpMessageWriters](IV. Spring Boot features/27.2.2 HTTP Codecs with HttpMessageReaders and HttpMessageWriters.md) - * [27.2.3 Static Content](IV. Spring Boot features/27.2.3 Static Content.md) - * [27.2.4 Template engines](IV. Spring Boot features/27.2.4 Template engines.md) + * [27.2.3 静态内容](IV. Spring Boot features/27.2.3 Static Content.md) + * [27.2.4 模板引擎](IV. Spring Boot features/27.2.4 Template Engines.md) * [27.3. JAX-RS和Jersey](IV. Spring Boot features/27.3. JAX-RS and Jersey.md) * [27.4 内嵌servlet容器支持](IV. Spring Boot features/27.4 Embedded servlet container support.md) * [27.4.1 Servlets, Filters和listeners](IV. Spring Boot features/27.4.1 Servlets, Filters, and listeners.md) From b1c7ad4a1d9b9e7de6a0c9e2ab6b3647cb576fc1 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E7=83=AD=E5=BF=83=E5=B8=82=E6=B0=91=E9=92=9F=E5=B0=8F?= =?UTF-8?q?=E5=BC=BA?= Date: Sat, 25 Aug 2018 10:31:20 +0800 Subject: [PATCH 195/865] Update and rename 27.2.4 Template engines.md to 27.2.4 Template Engines.md --- IV. Spring Boot features/27.2.4 Template Engines.md | 11 +++++++++++ IV. Spring Boot features/27.2.4 Template engines.md | 10 ---------- 2 files changed, 11 insertions(+), 10 deletions(-) create mode 100644 IV. Spring Boot features/27.2.4 Template Engines.md delete mode 100644 IV. Spring Boot features/27.2.4 Template engines.md diff --git a/IV. Spring Boot features/27.2.4 Template Engines.md b/IV. Spring Boot features/27.2.4 Template Engines.md new file mode 100644 index 00000000..0ffebef6 --- /dev/null +++ b/IV. Spring Boot features/27.2.4 Template Engines.md @@ -0,0 +1,11 @@ +### 27.2.4 模板引擎 + +As well as REST web services, you can also use Spring WebFlux to serve dynamic HTML content. Spring WebFlux supports a variety of templating technologies, including Thymeleaf, FreeMarker, and Mustache. + +Spring Boot includes auto-configuration support for the following templating engines: + +- [FreeMarker](http://freemarker.org/docs/) +- [Thymeleaf](http://www.thymeleaf.org/) +- [Mustache](https://mustache.github.io/) + +When you use one of these templating engines with the default configuration, your templates are picked up automatically from `src/main/resources/templates`. diff --git a/IV. Spring Boot features/27.2.4 Template engines.md b/IV. Spring Boot features/27.2.4 Template engines.md deleted file mode 100644 index 16db8acc..00000000 --- a/IV. Spring Boot features/27.2.4 Template engines.md +++ /dev/null @@ -1,10 +0,0 @@ -### 27.2.4 Template engines - -As well as REST web services, you can also use Spring WebFlux to serve dynamic HTML content. Spring WebFlux supports a variety of templating technologies including Thymeleaf, FreeMarker and Mustache. - -Spring Boot includes auto-configuration support for the following templating engines: - -FreeMarker -Thymeleaf -Mustache -When you’re using one of these templating engines with the default configuration, your templates will be picked up automatically from src/main/resources/templates. From 950e80263beec8a3d85dd5679d921d95ecd1556c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E7=83=AD=E5=BF=83=E5=B8=82=E6=B0=91=E9=92=9F=E5=B0=8F?= =?UTF-8?q?=E5=BC=BA?= Date: Sat, 25 Aug 2018 10:41:16 +0800 Subject: [PATCH 196/865] Update 27.2.4 Template Engines.md --- IV. Spring Boot features/27.2.4 Template Engines.md | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/IV. Spring Boot features/27.2.4 Template Engines.md b/IV. Spring Boot features/27.2.4 Template Engines.md index 0ffebef6..a3381a0c 100644 --- a/IV. Spring Boot features/27.2.4 Template Engines.md +++ b/IV. Spring Boot features/27.2.4 Template Engines.md @@ -1,11 +1,11 @@ ### 27.2.4 模板引擎 -As well as REST web services, you can also use Spring WebFlux to serve dynamic HTML content. Spring WebFlux supports a variety of templating technologies, including Thymeleaf, FreeMarker, and Mustache. +除了REST网络服务,你也可以将Spring WebFlux用于动态HTML内容。Spring WebFlux支持许多的模板技术,包括Thymeleaf、FreeMarker、与Mustache。 -Spring Boot includes auto-configuration support for the following templating engines: +Spring Boot支持以下模板引擎的自动配置: - [FreeMarker](http://freemarker.org/docs/) - [Thymeleaf](http://www.thymeleaf.org/) - [Mustache](https://mustache.github.io/) -When you use one of these templating engines with the default configuration, your templates are picked up automatically from `src/main/resources/templates`. +当你用默认配置使用这些模板引擎时,你的模板会自动从`src/main/resources/templates`获取。 From 9d34609397372ec9373b2d882b71e2f895f591d2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E7=83=AD=E5=BF=83=E5=B8=82=E6=B0=91=E9=92=9F=E5=B0=8F?= =?UTF-8?q?=E5=BC=BA?= Date: Sat, 25 Aug 2018 10:54:21 +0800 Subject: [PATCH 197/865] Update 27.2.2 HTTP Codecs with HttpMessageReaders and HttpMessageWriters.md --- ...P Codecs with HttpMessageReaders and HttpMessageWriters.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/IV. Spring Boot features/27.2.2 HTTP Codecs with HttpMessageReaders and HttpMessageWriters.md b/IV. Spring Boot features/27.2.2 HTTP Codecs with HttpMessageReaders and HttpMessageWriters.md index b773bc36..eda3b239 100644 --- a/IV. Spring Boot features/27.2.2 HTTP Codecs with HttpMessageReaders and HttpMessageWriters.md +++ b/IV. Spring Boot features/27.2.2 HTTP Codecs with HttpMessageReaders and HttpMessageWriters.md @@ -1,4 +1,4 @@ -### 27.2.2 HTTP编解码器————HttpMessageReaders与HttpMessageWriters +### 27.2.2 HTTP编解码器——HttpMessageReaders与HttpMessageWriters Spring WebFlux使用`HttpMessageReader`和`HttpMessageWriter`接口转换HTTP请求与回应。它们由`CodecConfigurer`配置——通过查看类路径里可用的库配置默认值。 @@ -20,4 +20,4 @@ public class MyConfiguration { } ``` -你也可以利用[Spring Boot的自定义JSON序列化器和反序列化器](https://docs.spring.io/spring-boot/docs/2.0.0.RELEASE/reference/htmlsingle/#boot-features-json-components)。 \ No newline at end of file +你也可以利用[Spring Boot的自定义JSON序列化器和反序列化器](https://docs.spring.io/spring-boot/docs/2.0.0.RELEASE/reference/htmlsingle/#boot-features-json-components)。 From adcf8908abec1d479df581b243949c61862163e2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E7=83=AD=E5=BF=83=E5=B8=82=E6=B0=91=E9=92=9F=E5=B0=8F?= =?UTF-8?q?=E5=BC=BA?= Date: Sat, 25 Aug 2018 10:55:25 +0800 Subject: [PATCH 198/865] Update SUMMARY.md --- SUMMARY.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/SUMMARY.md b/SUMMARY.md index 16e3bcfc..b334a332 100644 --- a/SUMMARY.md +++ b/SUMMARY.md @@ -139,7 +139,7 @@ * [27.1.13. CORS支持](IV. Spring Boot features/27.1.13. CORS support.md) * [27.2 Spring WebFlux框架](IV. Spring Boot features/27.2 The “Spring WebFlux Framework”.md) * [27.2.1 Spring WebFlux自动配置](IV. Spring Boot features/27.2.1 Spring WebFlux Auto-configuration.md) - * [27.2.2 HTTP编解码器————HttpMessageReaders与HttpMessageWriters](IV. Spring Boot features/27.2.2 HTTP Codecs with HttpMessageReaders and HttpMessageWriters.md) + * [27.2.2 HTTP编解码器——HttpMessageReaders与HttpMessageWriters](IV. Spring Boot features/27.2.2 HTTP Codecs with HttpMessageReaders and HttpMessageWriters.md) * [27.2.3 静态内容](IV. Spring Boot features/27.2.3 Static Content.md) * [27.2.4 模板引擎](IV. Spring Boot features/27.2.4 Template Engines.md) * [27.3. JAX-RS和Jersey](IV. Spring Boot features/27.3. JAX-RS and Jersey.md) From 07cf79d872733ba379fb3e74a4a8c78d0e8470f3 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E7=83=AD=E5=BF=83=E5=B8=82=E6=B0=91=E9=92=9F=E5=B0=8F?= =?UTF-8?q?=E5=BC=BA?= Date: Thu, 6 Sep 2018 20:24:56 +0800 Subject: [PATCH 199/865] Update 27.2.4 Template Engines.md --- IV. Spring Boot features/27.2.4 Template Engines.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/IV. Spring Boot features/27.2.4 Template Engines.md b/IV. Spring Boot features/27.2.4 Template Engines.md index a3381a0c..bb7d4dd0 100644 --- a/IV. Spring Boot features/27.2.4 Template Engines.md +++ b/IV. Spring Boot features/27.2.4 Template Engines.md @@ -1,6 +1,6 @@ ### 27.2.4 模板引擎 -除了REST网络服务,你也可以将Spring WebFlux用于动态HTML内容。Spring WebFlux支持许多的模板技术,包括Thymeleaf、FreeMarker、与Mustache。 +除了REST网络服务,你也可以将Spring WebFlux用于动态HTML内容。Spring WebFlux支持许多的模板技术,包括Thymeleaf、FreeMarker与Mustache。 Spring Boot支持以下模板引擎的自动配置: From 924e7759d3133892269e6b259705c11c24fbb57f Mon Sep 17 00:00:00 2001 From: Jack Zhong Date: Thu, 6 Sep 2018 20:33:53 +0800 Subject: [PATCH 200/865] =?UTF-8?q?=E6=B7=BB=E5=8A=A027.2.5=20=E9=94=99?= =?UTF-8?q?=E8=AF=AF=E5=A4=84=E7=90=86?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- SUMMARY.md | 1 + 1 file changed, 1 insertion(+) diff --git a/SUMMARY.md b/SUMMARY.md index b334a332..83ccdc1e 100644 --- a/SUMMARY.md +++ b/SUMMARY.md @@ -142,6 +142,7 @@ * [27.2.2 HTTP编解码器——HttpMessageReaders与HttpMessageWriters](IV. Spring Boot features/27.2.2 HTTP Codecs with HttpMessageReaders and HttpMessageWriters.md) * [27.2.3 静态内容](IV. Spring Boot features/27.2.3 Static Content.md) * [27.2.4 模板引擎](IV. Spring Boot features/27.2.4 Template Engines.md) + * [27.2.5 错误处理](IV. Spring Boot features/27.2.5 Error Handling.md) * [27.3. JAX-RS和Jersey](IV. Spring Boot features/27.3. JAX-RS and Jersey.md) * [27.4 内嵌servlet容器支持](IV. Spring Boot features/27.4 Embedded servlet container support.md) * [27.4.1 Servlets, Filters和listeners](IV. Spring Boot features/27.4.1 Servlets, Filters, and listeners.md) From c9209382125a5ecb0a7448123dcb0ae0eeb341b7 Mon Sep 17 00:00:00 2001 From: Jack Zhong Date: Thu, 6 Sep 2018 20:43:11 +0800 Subject: [PATCH 201/865] =?UTF-8?q?=E4=B8=8A=E4=BC=A027.2.5=20=E9=94=99?= =?UTF-8?q?=E8=AF=AF=E5=A4=84=E7=90=86?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../27.2.5 Error Handling.md | 55 +++++++++++++++++++ 1 file changed, 55 insertions(+) create mode 100644 IV. Spring Boot features/27.2.5 Error Handling.md diff --git a/IV. Spring Boot features/27.2.5 Error Handling.md b/IV. Spring Boot features/27.2.5 Error Handling.md new file mode 100644 index 00000000..67d3a4a3 --- /dev/null +++ b/IV. Spring Boot features/27.2.5 Error Handling.md @@ -0,0 +1,55 @@ +### 27.2.5 错误处理 + +Spring Boot provides a `WebExceptionHandler` that handles all errors in a sensible way. Its position in the processing order is immediately before the handlers provided by WebFlux, which are considered last. For machine clients, it produces a JSON response with details of the error, the HTTP status, and the exception message. For browser clients, there is a “whitelabel” error handler that renders the same data in HTML format. You can also provide your own HTML templates to display errors (see the [next section](https://docs.spring.io/spring-boot/docs/2.0.0.RELEASE/reference/htmlsingle/#boot-features-webflux-error-handling-custom-error-pages)). + +The first step to customizing this feature often involves using the existing mechanism but replacing or augmenting the error contents. For that, you can add a bean of type `ErrorAttributes`. + +To change the error handling behavior, you can implement `ErrorWebExceptionHandler` and register a bean definition of that type. Because a `WebExceptionHandler` is quite low-level, Spring Boot also provides a convenient `AbstractErrorWebExceptionHandler` to let you handle errors in a WebFlux functional way, as shown in the following example: +```java +public class CustomErrorWebExceptionHandler extends AbstractErrorWebExceptionHandler { + + // Define constructor here + + @Override + protected RouterFunction getRoutingFunction(ErrorAttributes errorAttributes) { + + return RouterFunctions + .route(aPredicate, aHandler) + .andRoute(anotherPredicate, anotherHandler); + } + +} +``` +For a more complete picture, you can also subclass `DefaultErrorWebExceptionHandler` directly and override specific methods. + +**Custom Error Pages** + +If you want to display a custom HTML error page for a given status code, you can add a file to an `/error` folder. Error pages can either be static HTML (that is, added under any of the static resource folders) or built with templates. The name of the file should be the exact status code or a series mask. + +For example, to map `404` to a static HTML file, your folder structure would be as follows: + +``` +src/ + +- main/ + +- java/ + | + + +- resources/ + +- public/ + +- error/ + | +- 404.html + +- +``` + +To map all `5xx` errors by using a Mustache template, your folder structure would be as follows: + +``` +src/ + +- main/ + +- java/ + | + + +- resources/ + +- templates/ + +- error/ + | +- 5xx.mustache + +- +``` \ No newline at end of file From 34f63286cdca7f36259ed6925b44eeba59bb7401 Mon Sep 17 00:00:00 2001 From: Jack Zhong Date: Sat, 8 Sep 2018 23:08:09 +0800 Subject: [PATCH 202/865] =?UTF-8?q?=E7=BF=BB=E8=AF=9127.2.5=20=E9=94=99?= =?UTF-8?q?=E8=AF=AF=E5=A4=84=E7=90=86?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- IV. Spring Boot features/27.2.5 Error Handling.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/IV. Spring Boot features/27.2.5 Error Handling.md b/IV. Spring Boot features/27.2.5 Error Handling.md index 67d3a4a3..50cefcda 100644 --- a/IV. Spring Boot features/27.2.5 Error Handling.md +++ b/IV. Spring Boot features/27.2.5 Error Handling.md @@ -1,6 +1,6 @@ ### 27.2.5 错误处理 -Spring Boot provides a `WebExceptionHandler` that handles all errors in a sensible way. Its position in the processing order is immediately before the handlers provided by WebFlux, which are considered last. For machine clients, it produces a JSON response with details of the error, the HTTP status, and the exception message. For browser clients, there is a “whitelabel” error handler that renders the same data in HTML format. You can also provide your own HTML templates to display errors (see the [next section](https://docs.spring.io/spring-boot/docs/2.0.0.RELEASE/reference/htmlsingle/#boot-features-webflux-error-handling-custom-error-pages)). +Spring Boot提供了`WebExceptionHandler`,用一种明智的方式处理所有的错误。在处理顺序上,它的位置在WebFlux提供处理器之前。对于机器客户端,它会产生带有错误的详细描述(HTTP状态与异常信息)的JSON响应。对于浏览器客户端,“whitelabel”错误处理器会以HTML格式渲染相同的数据。你也可以提供你自己的HTML模版来显示错误(查看[下一章节](https://docs.spring.io/spring-boot/docs/2.0.0.RELEASE/reference/htmlsingle/#boot-features-webflux-error-handling-custom-error-pages))。 The first step to customizing this feature often involves using the existing mechanism but replacing or augmenting the error contents. For that, you can add a bean of type `ErrorAttributes`. From dd527a583a40baf664eb8aa5e2c3801376172a35 Mon Sep 17 00:00:00 2001 From: Jack Zhong Date: Sun, 9 Sep 2018 01:13:55 +0800 Subject: [PATCH 203/865] =?UTF-8?q?=E7=BF=BB=E8=AF=91=E5=AE=8C27.2.5=20?= =?UTF-8?q?=E9=94=99=E8=AF=AF=E5=A4=84=E7=90=86?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- IV. Spring Boot features/27.2.5 Error Handling.md | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/IV. Spring Boot features/27.2.5 Error Handling.md b/IV. Spring Boot features/27.2.5 Error Handling.md index 50cefcda..7196c286 100644 --- a/IV. Spring Boot features/27.2.5 Error Handling.md +++ b/IV. Spring Boot features/27.2.5 Error Handling.md @@ -2,9 +2,9 @@ Spring Boot提供了`WebExceptionHandler`,用一种明智的方式处理所有的错误。在处理顺序上,它的位置在WebFlux提供处理器之前。对于机器客户端,它会产生带有错误的详细描述(HTTP状态与异常信息)的JSON响应。对于浏览器客户端,“whitelabel”错误处理器会以HTML格式渲染相同的数据。你也可以提供你自己的HTML模版来显示错误(查看[下一章节](https://docs.spring.io/spring-boot/docs/2.0.0.RELEASE/reference/htmlsingle/#boot-features-webflux-error-handling-custom-error-pages))。 -The first step to customizing this feature often involves using the existing mechanism but replacing or augmenting the error contents. For that, you can add a bean of type `ErrorAttributes`. +自定义这个特性的第一步时常需要使用现存的机制,但是替换或者添加错误的内容。为此,你可以添加`ErrorAttributes`类型的bean。 -To change the error handling behavior, you can implement `ErrorWebExceptionHandler` and register a bean definition of that type. Because a `WebExceptionHandler` is quite low-level, Spring Boot also provides a convenient `AbstractErrorWebExceptionHandler` to let you handle errors in a WebFlux functional way, as shown in the following example: +为了改变错误处理的行为,你可以实现`ErrorWebExceptionHandler`,并注册一个那种类型的bean定义。因为 `WebExceptionHandler`的级别相当低,Spring Boot提供了方便的`AbstractErrorWebExceptionHandler`,让你以WebFlux函数式方法处理错误,如下所示: ```java public class CustomErrorWebExceptionHandler extends AbstractErrorWebExceptionHandler { @@ -20,13 +20,13 @@ public class CustomErrorWebExceptionHandler extends AbstractErrorWebExceptionHan } ``` -For a more complete picture, you can also subclass `DefaultErrorWebExceptionHandler` directly and override specific methods. +你也可以直接继承`DefauLambdatErrorWebExceptionHandler`,并重写特定的方法。 -**Custom Error Pages** +**自定义错误页** -If you want to display a custom HTML error page for a given status code, you can add a file to an `/error` folder. Error pages can either be static HTML (that is, added under any of the static resource folders) or built with templates. The name of the file should be the exact status code or a series mask. +如果你想要给某个给定的状态码显示自定义的HTML错误页,你可以在`/error`文件夹下添加一个文件。错误页可以是静态的HTML(也就是,添加在任何的静态资源文件夹下面),或者使用模版构建。文件名应当是状态码,或者是一系列掩码。 -For example, to map `404` to a static HTML file, your folder structure would be as follows: +比如,为了将`404`映射到一个静态HTML文件,你的文件夹结构将会如下: ``` src/ @@ -40,7 +40,7 @@ src/ +- ``` -To map all `5xx` errors by using a Mustache template, your folder structure would be as follows: +使用Mustache模版映射所有的`5xx`错误,你的文件夹结构将会如下: ``` src/ From 7467b7853ebf180121abed5fc3938f3e2090b28d Mon Sep 17 00:00:00 2001 From: Jack Zhong Date: Sun, 9 Sep 2018 01:32:31 +0800 Subject: [PATCH 204/865] =?UTF-8?q?=E4=B8=8A=E4=BC=A027.2.6=20=E7=BD=91?= =?UTF-8?q?=E7=BB=9C=E8=BF=87=E6=BB=A4=E5=99=A8?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- IV. Spring Boot features/27.2.6 Web Filters.md | 11 +++++++++++ SUMMARY.md | 1 + 2 files changed, 12 insertions(+) create mode 100644 IV. Spring Boot features/27.2.6 Web Filters.md diff --git a/IV. Spring Boot features/27.2.6 Web Filters.md b/IV. Spring Boot features/27.2.6 Web Filters.md new file mode 100644 index 00000000..55e1352d --- /dev/null +++ b/IV. Spring Boot features/27.2.6 Web Filters.md @@ -0,0 +1,11 @@ +### 27.2.6 网络过滤器 + +Spring WebFlux provides a `WebFilter` interface that can be implemented to filter HTTP request-response exchanges. `WebFilter` beans found in the application context will be automatically used to filter each exchange. + +Where the order of the filters is important they can implement `Ordered` or be annotated with `@Order`. Spring Boot auto-configuration may configure web filters for you. When it does so, the orders shown in the following table will be used: + +|Web Filter|Order| +|--|--| +|`MetricsWebFilter`|`Ordered.HIGHEST_PRECEDENCE + 1`| +|`WebFilterChainProxy `(Spring Security)|`-100`| +|`HttpTraceWebFilter`|`Ordered.LOWEST_PRECEDENCE - 10`| \ No newline at end of file diff --git a/SUMMARY.md b/SUMMARY.md index 83ccdc1e..bbda72d4 100644 --- a/SUMMARY.md +++ b/SUMMARY.md @@ -143,6 +143,7 @@ * [27.2.3 静态内容](IV. Spring Boot features/27.2.3 Static Content.md) * [27.2.4 模板引擎](IV. Spring Boot features/27.2.4 Template Engines.md) * [27.2.5 错误处理](IV. Spring Boot features/27.2.5 Error Handling.md) + * [27.2.6 网络过滤器](IV. Spring Boot features/27.2.6 Web Filters.md) * [27.3. JAX-RS和Jersey](IV. Spring Boot features/27.3. JAX-RS and Jersey.md) * [27.4 内嵌servlet容器支持](IV. Spring Boot features/27.4 Embedded servlet container support.md) * [27.4.1 Servlets, Filters和listeners](IV. Spring Boot features/27.4.1 Servlets, Filters, and listeners.md) From 52e1933a81ed5fc790c0ccdca88f8d8a40e8b6c6 Mon Sep 17 00:00:00 2001 From: Jack Zhong Date: Sun, 9 Sep 2018 15:46:19 +0800 Subject: [PATCH 205/865] =?UTF-8?q?=E7=BF=BB=E8=AF=9127.2.6=20=E7=BD=91?= =?UTF-8?q?=E7=BB=9C=E8=BF=87=E6=BB=A4=E5=99=A8?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- IV. Spring Boot features/27.2.6 Web Filters.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/IV. Spring Boot features/27.2.6 Web Filters.md b/IV. Spring Boot features/27.2.6 Web Filters.md index 55e1352d..5daad3e5 100644 --- a/IV. Spring Boot features/27.2.6 Web Filters.md +++ b/IV. Spring Boot features/27.2.6 Web Filters.md @@ -1,8 +1,8 @@ ### 27.2.6 网络过滤器 -Spring WebFlux provides a `WebFilter` interface that can be implemented to filter HTTP request-response exchanges. `WebFilter` beans found in the application context will be automatically used to filter each exchange. +Spring WebFlux提供了`WebFilter`接口。它可以用来过滤HTTP请求-响应交换。在应用上下文里的`WebFilter`将会自动用于过滤每一个交换。 -Where the order of the filters is important they can implement `Ordered` or be annotated with `@Order`. Spring Boot auto-configuration may configure web filters for you. When it does so, the orders shown in the following table will be used: +过滤器的顺序很重要。它们可以实现`Ordered`,或者标注`@Order`。Spring Boot会为你自动配置网络过滤器,顺序如下: |Web Filter|Order| |--|--| From 97c818c5816fa18c36838bce525bbdd7f08407e7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E7=83=AD=E5=BF=83=E5=B8=82=E6=B0=91=E9=92=9F=E5=B0=8F?= =?UTF-8?q?=E5=BC=BA?= Date: Wed, 19 Sep 2018 21:20:15 +0800 Subject: [PATCH 206/865] Update 27.3. JAX-RS and Jersey.md --- IV. Spring Boot features/27.3. JAX-RS and Jersey.md | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/IV. Spring Boot features/27.3. JAX-RS and Jersey.md b/IV. Spring Boot features/27.3. JAX-RS and Jersey.md index d9f8c451..ad89a371 100644 --- a/IV. Spring Boot features/27.3. JAX-RS and Jersey.md +++ b/IV. Spring Boot features/27.3. JAX-RS and Jersey.md @@ -2,7 +2,7 @@ 如果你更喜欢JAX-RS为REST端点提供的编程模型,可以使用相应的实现代替Spring MVC。如果将Jersey 1.x和Apache CXF的`Servlet`或`Filter`注册到应用上下文中,那它们可以很好的工作。Spring对Jersey 2.x有一些原生支持,所以在Spring Boot中也为它提供了自动配置及一个starter。 -想要使用Jersey 2.x,只需添加`spring-boot-starter-jersey`依赖,然后创建一个`ResourceConfig`类型的`@Bean`,用于注册所有的端点(endpoints): +想要使用Jersey 2.x,需要添加`spring-boot-starter-jersey`依赖,然后创建一个`ResourceConfig`类型的`@Bean`,用于注册所有的端点(endpoints),如下所示: ```java @Component public class JerseyConfig extends ResourceConfig { @@ -15,7 +15,7 @@ public class JerseyConfig extends ResourceConfig { 你也可以注册任意数量的,实现`ResourceConfigCustomizer`的beans来进一步自定义。 -所有注册的端点都需注解`@Components`和HTTP资源annotations(比如`@GET`): +所有注册的端点都需注解`@Components`和HTTP资源annotations(比如`@GET`),如下所示: ```java @Component @Path("/hello") @@ -26,8 +26,8 @@ public class Endpoint { } } ``` -由于`Endpoint`是一个Spring组件(`@Component`),所以它的生命周期受Spring管理,你可以使用`@Autowired`添加依赖,也可以使用`@Value`注入外部配置。Jersey的servlet会被注册,并默认映射到`/*`,你可以将`@ApplicationPath`添加到`ResourceConfig`来改变该映射。 +由于`Endpoint`是一个Spring组件(`@Component`),所以它的生命周期受Spring管理,你可以使用`@Autowired`注解注入依赖,也可以使用`@Value`注解注入外部配置。Jersey的servlet会被注册,并默认映射到`/*`,你可以将`@ApplicationPath`添加到`ResourceConfig`来改变该映射。 -默认情况下,Jersey将以Servlet的形式注册为一个`ServletRegistrationBean`类型的`@Bean`,name为`jerseyServletRegistration`,该servlet默认会延迟初始化,不过可以通过`spring.jersey.servlet.load-on-startup`自定义。通过创建相同name的bean,你可以禁用或覆盖框架默认产生的bean。设置`spring.jersey.type=filter`可以使用Filter的形式代替Servlet,相应的`@Bean`类型变为`jerseyFilterRegistration`,该filter有一个`@Order`属性,你可以通过`spring.jersey.filter.order`设置。Servlet和Filter注册时都可以使用`spring.jersey.init.*`定义一个属性集合传递给init参数。 +默认情况下,Jersey将以Servlet的形式注册为一个`ServletRegistrationBean`类型的`@Bean`,name为`jerseyServletRegistration`,该servlet默认会延迟初始化,不过可以通过`spring.jersey.servlet.load-on-startup`自定义。通过创建相同name的bean,你可以禁用或覆盖框架默认产生的bean。设置`spring.jersey.type=filter`可以使用filter的形式代替servlet,相应的`@Bean`类型变为`jerseyFilterRegistration`,该filter有一个`@Order`属性,你可以通过`spring.jersey.filter.order`设置。servlet和filter注册时都可以使用`spring.jersey.init.*`定义一个属性集合传递给init参数。 -这里有一个[Jersey示例](https://github.com/spring-projects/spring-boot/tree/v2.0.0.RELEASE/spring-boot-samples/spring-boot-sample-jersey),你可以查看如何设置相关事项。 +这里有一个[Jersey示例](https://github.com/spring-projects/spring-boot/tree/v2.0.0.RELEASE/spring-boot-samples/spring-boot-sample-jersey),你可以查看如何设置相关事项。There is also a [Jersey 1.x sample](https://github.com/spring-projects/spring-boot/tree/v2.0.0.RELEASE/spring-boot-samples/spring-boot-sample-jersey1). Note that, in the Jersey 1.x sample, the spring-boot maven plugin has been configured to unpack some Jersey jars so that they can be scanned by the JAX-RS implementation (because the sample asks for them to be scanned in its `Filter` registration). If any of your JAX-RS resources are packaged as nested jars, you may need to do the same. From d74433f7ed869c9de791cf930b01543d11a5daa2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E7=83=AD=E5=BF=83=E5=B8=82=E6=B0=91=E9=92=9F=E5=B0=8F?= =?UTF-8?q?=E5=BC=BA?= Date: Wed, 19 Sep 2018 22:29:06 +0800 Subject: [PATCH 207/865] Update 27.3. JAX-RS and Jersey.md --- IV. Spring Boot features/27.3. JAX-RS and Jersey.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/IV. Spring Boot features/27.3. JAX-RS and Jersey.md b/IV. Spring Boot features/27.3. JAX-RS and Jersey.md index ad89a371..c9c39df5 100644 --- a/IV. Spring Boot features/27.3. JAX-RS and Jersey.md +++ b/IV. Spring Boot features/27.3. JAX-RS and Jersey.md @@ -30,4 +30,4 @@ public class Endpoint { 默认情况下,Jersey将以Servlet的形式注册为一个`ServletRegistrationBean`类型的`@Bean`,name为`jerseyServletRegistration`,该servlet默认会延迟初始化,不过可以通过`spring.jersey.servlet.load-on-startup`自定义。通过创建相同name的bean,你可以禁用或覆盖框架默认产生的bean。设置`spring.jersey.type=filter`可以使用filter的形式代替servlet,相应的`@Bean`类型变为`jerseyFilterRegistration`,该filter有一个`@Order`属性,你可以通过`spring.jersey.filter.order`设置。servlet和filter注册时都可以使用`spring.jersey.init.*`定义一个属性集合传递给init参数。 -这里有一个[Jersey示例](https://github.com/spring-projects/spring-boot/tree/v2.0.0.RELEASE/spring-boot-samples/spring-boot-sample-jersey),你可以查看如何设置相关事项。There is also a [Jersey 1.x sample](https://github.com/spring-projects/spring-boot/tree/v2.0.0.RELEASE/spring-boot-samples/spring-boot-sample-jersey1). Note that, in the Jersey 1.x sample, the spring-boot maven plugin has been configured to unpack some Jersey jars so that they can be scanned by the JAX-RS implementation (because the sample asks for them to be scanned in its `Filter` registration). If any of your JAX-RS resources are packaged as nested jars, you may need to do the same. +这里有一个[Jersey示例](https://github.com/spring-projects/spring-boot/tree/v2.0.0.RELEASE/spring-boot-samples/spring-boot-sample-jersey),你可以查看如何设置相关事项。还有一个[Jersey 1.x示例](https://github.com/spring-projects/spring-boot/tree/v2.0.0.RELEASE/spring-boot-samples/spring-boot-sample-jersey1)。注意,在Jersey 1.x示例里,spring-boot maven plugin被配置为拆开某些Jersey jars。这样,它们就会被JAX-RS实现扫描(因为示例要求它们在`Filter`注册里接受扫描)。如果你的JAX-RS资源以内部jars的方法打包,你可能需要做同样的事情。 From 956623dbe473f06e059e641c465c1b6a2c358968 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E7=83=AD=E5=BF=83=E5=B8=82=E6=B0=91=E9=92=9F=E5=B0=8F?= =?UTF-8?q?=E5=BC=BA?= Date: Wed, 19 Sep 2018 23:16:08 +0800 Subject: [PATCH 208/865] Update and rename 27.4 Embedded servlet container support.md to 27.4 Embedded Servlet Container Support.md --- ...er support.md => 27.4 Embedded Servlet Container Support.md} | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) rename IV. Spring Boot features/{27.4 Embedded servlet container support.md => 27.4 Embedded Servlet Container Support.md} (68%) diff --git a/IV. Spring Boot features/27.4 Embedded servlet container support.md b/IV. Spring Boot features/27.4 Embedded Servlet Container Support.md similarity index 68% rename from IV. Spring Boot features/27.4 Embedded servlet container support.md rename to IV. Spring Boot features/27.4 Embedded Servlet Container Support.md index 856d740a..065c71cd 100644 --- a/IV. Spring Boot features/27.4 Embedded servlet container support.md +++ b/IV. Spring Boot features/27.4 Embedded Servlet Container Support.md @@ -1,5 +1,5 @@ ### 27.4 内嵌servlet容器支持 -Spring Boot支持内嵌的Tomcat, Jetty和Undertow服务器,多数开发者只需要使用合适的'Starter'来获取一个完全配置好的实例即可,内嵌服务器默认监听8080端口的HTTP请求。 +Spring Boot支持内嵌的Tomcat、Jetty和Undertow服务器。多数开发者使用合适的"Starter"来获取一个完全配置好的实例即可。内嵌服务器默认监听8080端口的HTTP请求。 **警告⚠️** 如果你在CentOS上使用Tomcat,需要注意:默认情况下,一个临时的目录会被用于存储编译完成的JSPs和上传的文件等。当你的应用运行时出错,这个目录可能会被`tmpwatch`删除。为了避免这种情况,你需要自定义`tmpwatch`。这样`tomcat.*`目录才不会被删除。或者,配置`server.tomcat.basedir`。这样内嵌的Tomcat会使用一个不同的位置。 From eb3f5bc95e621b5635e1eddeb2dab780260df79b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E7=83=AD=E5=BF=83=E5=B8=82=E6=B0=91=E9=92=9F=E5=B0=8F?= =?UTF-8?q?=E5=BC=BA?= Date: Wed, 19 Sep 2018 23:18:30 +0800 Subject: [PATCH 209/865] Update SUMMARY.md --- SUMMARY.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/SUMMARY.md b/SUMMARY.md index bbda72d4..fd1ba33c 100644 --- a/SUMMARY.md +++ b/SUMMARY.md @@ -145,8 +145,8 @@ * [27.2.5 错误处理](IV. Spring Boot features/27.2.5 Error Handling.md) * [27.2.6 网络过滤器](IV. Spring Boot features/27.2.6 Web Filters.md) * [27.3. JAX-RS和Jersey](IV. Spring Boot features/27.3. JAX-RS and Jersey.md) - * [27.4 内嵌servlet容器支持](IV. Spring Boot features/27.4 Embedded servlet container support.md) - * [27.4.1 Servlets, Filters和listeners](IV. Spring Boot features/27.4.1 Servlets, Filters, and listeners.md) + * [27.4 内嵌servlet容器支持](IV. Spring Boot features/27.4 Embedded Servlet Container Support.md) + * [27.4.1 Servlets、Filters和listeners](IV. Spring Boot features/27.4.1 Servlets, Filters, and listeners.md) * [27.4.2 Servlet上下文初始化](IV. Spring Boot features/27.4.2 Servlet Context Initialization.md) * [27.4.3 ServletWebServerApplicationContext](IV. Spring Boot features/27.4.3 The ServletWebServerApplicationContext.md) * [27.4.4 自定义内嵌servlet容器](IV. Spring Boot features/27.4.4 Customizing embedded servlet containers.md) From f7389fa45e07e7e7ddf4263bbe115b21c46ca0d4 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E7=83=AD=E5=BF=83=E5=B8=82=E6=B0=91=E9=92=9F=E5=B0=8F?= =?UTF-8?q?=E5=BC=BA?= Date: Wed, 19 Sep 2018 23:26:52 +0800 Subject: [PATCH 210/865] Update 27.4.1 Servlets, Filters, and listeners.md --- .../27.4.1 Servlets, Filters, and listeners.md | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/IV. Spring Boot features/27.4.1 Servlets, Filters, and listeners.md b/IV. Spring Boot features/27.4.1 Servlets, Filters, and listeners.md index 9fa91a51..d0a63844 100644 --- a/IV. Spring Boot features/27.4.1 Servlets, Filters, and listeners.md +++ b/IV. Spring Boot features/27.4.1 Servlets, Filters, and listeners.md @@ -1,9 +1,9 @@ -### 27.4.1 Servlets, Filters和listeners +### 27.4.1 Servlets、Filters和listeners -使用内嵌servlet容器时,你可以通过使用Spring beans或扫描Servlet组件的方式注册Servlets,Filters及特定Servlet相关的所有listeners(比如`HttpSessionListener`)。 +使用内嵌servlet容器时,你可以通过使用Spring beans或扫描Servlet组件的方式注册servlets,filters及特定Servlet相关的所有listeners(比如`HttpSessionListener`)。 **将Servlets,Filters和listeners注册为Spring beans** -所有`Servlet`,`Filter`或Servlet `*Listener`实例,只要是Spring bean,都会注册到内嵌容器中。如果想在配置期间引用`application.properties`的属性,这是非常方便的。默认情况下,如果上下文只包含单个Servlet,那它将被映射到`/`。如果存在多个Servlet beans,那么bean的名称将被用作路径的前缀,过滤器将映射到`/*`。 +所有`Servlet`,`Filter`或servlet `*Listener`实例,只要是Spring bean,都会注册到内嵌容器中。如果想在配置期间引用`application.properties`的属性,这是非常方便的。默认情况下,如果上下文只包含单个Servlet,那它将被映射到`/`。如果存在多个servlet beans,那么bean的名称将被用作路径的前缀,过滤器将映射到`/*`。 如果基于约定(convention-based)的映射不够灵活,你可以使用`ServletRegistrationBean`,`FilterRegistrationBean`,`ServletListenerRegistrationBean`实现完全的控制。 From c8e25f2ba6f0a16b691ecac79a551776fd166631 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E7=83=AD=E5=BF=83=E5=B8=82=E6=B0=91=E9=92=9F=E5=B0=8F?= =?UTF-8?q?=E5=BC=BA?= Date: Wed, 19 Sep 2018 23:34:03 +0800 Subject: [PATCH 211/865] Update 27.4.1 Servlets, Filters, and listeners.md --- .../27.4.1 Servlets, Filters, and listeners.md | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/IV. Spring Boot features/27.4.1 Servlets, Filters, and listeners.md b/IV. Spring Boot features/27.4.1 Servlets, Filters, and listeners.md index d0a63844..1dfabe64 100644 --- a/IV. Spring Boot features/27.4.1 Servlets, Filters, and listeners.md +++ b/IV. Spring Boot features/27.4.1 Servlets, Filters, and listeners.md @@ -7,3 +7,16 @@ 所有`Servlet`,`Filter`或servlet `*Listener`实例,只要是Spring bean,都会注册到内嵌容器中。如果想在配置期间引用`application.properties`的属性,这是非常方便的。默认情况下,如果上下文只包含单个Servlet,那它将被映射到`/`。如果存在多个servlet beans,那么bean的名称将被用作路径的前缀,过滤器将映射到`/*`。 如果基于约定(convention-based)的映射不够灵活,你可以使用`ServletRegistrationBean`,`FilterRegistrationBean`,`ServletListenerRegistrationBean`实现完全的控制。 + +Spring Boot ships with many auto-configurations that may define Filter beans. Here are a few examples of Filters and their respective order (lower order value means higher precedence): + +| Servlet Filter | Order | +|----------|-------------| +| `OrderedCharacterEncodingFilter` | `Ordered.HIGHEST_PRECEDENCE` | +| `WebMvcMetricsFilter` | `Ordered.HIGHEST_PRECEDENCE + 1` | +| `ErrorPageFilter` | `Ordered.HIGHEST_PRECEDENCE + 1` | +| `HttpTraceFilter` | `Ordered.LOWEST_PRECEDENCE - 10` | + +It is usually safe to leave Filter beans unordered. + +If a specific order is required, you should avoid configuring a Filter that reads the request body at `Ordered.HIGHEST_PRECEDENCE`, since it might go against the character encoding configuration of your application. If a Servlet filter wraps the request, it should be configured with an order that is less than or equal to `FilterRegistrationBean.REQUEST_WRAPPER_FILTER_MAX_ORDER`. From 55ec1ac27996e694e38b506d42f0b143822a6d62 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E7=83=AD=E5=BF=83=E5=B8=82=E6=B0=91=E9=92=9F=E5=B0=8F?= =?UTF-8?q?=E5=BC=BA?= Date: Wed, 19 Sep 2018 23:54:59 +0800 Subject: [PATCH 212/865] Update 27.4.1 Servlets, Filters, and listeners.md --- .../27.4.1 Servlets, Filters, and listeners.md | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/IV. Spring Boot features/27.4.1 Servlets, Filters, and listeners.md b/IV. Spring Boot features/27.4.1 Servlets, Filters, and listeners.md index 1dfabe64..0b565f56 100644 --- a/IV. Spring Boot features/27.4.1 Servlets, Filters, and listeners.md +++ b/IV. Spring Boot features/27.4.1 Servlets, Filters, and listeners.md @@ -8,8 +8,7 @@ 如果基于约定(convention-based)的映射不够灵活,你可以使用`ServletRegistrationBean`,`FilterRegistrationBean`,`ServletListenerRegistrationBean`实现完全的控制。 -Spring Boot ships with many auto-configurations that may define Filter beans. Here are a few examples of Filters and their respective order (lower order value means higher precedence): - +Spring Boot带有许多的自动配置。它们可能定义Filter bean。这里有一些Filter以及它们的顺序的例子(低位意味着更高的优先级)。 | Servlet Filter | Order | |----------|-------------| | `OrderedCharacterEncodingFilter` | `Ordered.HIGHEST_PRECEDENCE` | @@ -17,6 +16,6 @@ Spring Boot ships with many auto-configurations that may define Filter beans. He | `ErrorPageFilter` | `Ordered.HIGHEST_PRECEDENCE + 1` | | `HttpTraceFilter` | `Ordered.LOWEST_PRECEDENCE - 10` | -It is usually safe to leave Filter beans unordered. +无序的Filter bean通常是安全的。 -If a specific order is required, you should avoid configuring a Filter that reads the request body at `Ordered.HIGHEST_PRECEDENCE`, since it might go against the character encoding configuration of your application. If a Servlet filter wraps the request, it should be configured with an order that is less than or equal to `FilterRegistrationBean.REQUEST_WRAPPER_FILTER_MAX_ORDER`. +如果需要一个特定的顺序,你应当避免配置一个在`Ordered.HIGHEST_PRECEDENCE`上读取请求体的Filter。因为它可能违反你的应用的字符编码配置。如果一个Servlet filter包裹请求,它应当被配置一个顺序。此顺序不高于`FilterRegistrationBean.REQUEST_WRAPPER_FILTER_MAX_ORDER`。 From 50e64e388cac13ab697c0cdccefa39e40e83696b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E7=83=AD=E5=BF=83=E5=B8=82=E6=B0=91=E9=92=9F=E5=B0=8F?= =?UTF-8?q?=E5=BC=BA?= Date: Wed, 19 Sep 2018 23:56:01 +0800 Subject: [PATCH 213/865] Update 27.4.1 Servlets, Filters, and listeners.md --- .../27.4.1 Servlets, Filters, and listeners.md | 1 + 1 file changed, 1 insertion(+) diff --git a/IV. Spring Boot features/27.4.1 Servlets, Filters, and listeners.md b/IV. Spring Boot features/27.4.1 Servlets, Filters, and listeners.md index 0b565f56..cabb7a0d 100644 --- a/IV. Spring Boot features/27.4.1 Servlets, Filters, and listeners.md +++ b/IV. Spring Boot features/27.4.1 Servlets, Filters, and listeners.md @@ -9,6 +9,7 @@ 如果基于约定(convention-based)的映射不够灵活,你可以使用`ServletRegistrationBean`,`FilterRegistrationBean`,`ServletListenerRegistrationBean`实现完全的控制。 Spring Boot带有许多的自动配置。它们可能定义Filter bean。这里有一些Filter以及它们的顺序的例子(低位意味着更高的优先级)。 + | Servlet Filter | Order | |----------|-------------| | `OrderedCharacterEncodingFilter` | `Ordered.HIGHEST_PRECEDENCE` | From 4d494835423d3de5dcc8c12be79639b36c78b672 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E7=83=AD=E5=BF=83=E5=B8=82=E6=B0=91=E9=92=9F=E5=B0=8F?= =?UTF-8?q?=E5=BC=BA?= Date: Thu, 20 Sep 2018 22:53:02 +0800 Subject: [PATCH 214/865] Update 27.4.2 Servlet Context Initialization.md --- .../27.4.2 Servlet Context Initialization.md | 1 + 1 file changed, 1 insertion(+) diff --git a/IV. Spring Boot features/27.4.2 Servlet Context Initialization.md b/IV. Spring Boot features/27.4.2 Servlet Context Initialization.md index 77536d3a..9ad6372c 100644 --- a/IV. Spring Boot features/27.4.2 Servlet Context Initialization.md +++ b/IV. Spring Boot features/27.4.2 Servlet Context Initialization.md @@ -1,4 +1,5 @@ ### 27.4.2 Servlet上下文初始化 + 内嵌servlet容器不会直接执行Servlet 3.0+的`javax.servlet.ServletContainerInitializer`接口,或Spring的`org.springframework.web.WebApplicationInitializer`接口,这样设计的目的是降低war包内运行的第三方库破坏Spring Boot应用的风险。 如果需要在Spring Boot应用中执行servlet上下文初始化,你需要注册一个实现`org.springframework.boot.web.servlet.ServletContextInitializer`接口的bean。`onStartup`方法可以获取`ServletContext`,如果需要的话可以轻松用来适配一个已存在的`WebApplicationInitializer`。 From ff7985c8edf26da05a7c236a10e4f937b9e182ea Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E7=83=AD=E5=BF=83=E5=B8=82=E6=B0=91=E9=92=9F=E5=B0=8F?= =?UTF-8?q?=E5=BC=BA?= Date: Thu, 27 Sep 2018 23:00:59 +0800 Subject: [PATCH 215/865] Update 27.4.3 The ServletWebServerApplicationContext.md --- .../27.4.3 The ServletWebServerApplicationContext.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/IV. Spring Boot features/27.4.3 The ServletWebServerApplicationContext.md b/IV. Spring Boot features/27.4.3 The ServletWebServerApplicationContext.md index 3a499574..fe9a1afc 100644 --- a/IV. Spring Boot features/27.4.3 The ServletWebServerApplicationContext.md +++ b/IV. Spring Boot features/27.4.3 The ServletWebServerApplicationContext.md @@ -1,5 +1,5 @@ ### 27.4.3 The ServletWebServerApplicationContext -Spring Boot底层使用一种新的`ApplicationContext`类型,用于对内嵌servlet容器的支持。`ServletWebServerApplicationContext`是一种特殊类型的`WebApplicationContext`,它通过搜索到的单个`ServletWebServerFactory` bean来启动自己,通常`TomcatServletWebServerFactory`,`JettyServletWebServerFactory`或`UndertowServletWebServerFactory`将被自动配置。 +Spring Boot底层使用一种不同的`ApplicationContext`类型,用于对内嵌servlet容器的支持。`ServletWebServerApplicationContext`是一种特殊类型的`WebApplicationContext`,它通过搜索到的单个`ServletWebServerFactory` bean来启动自己,通常`TomcatServletWebServerFactory`,`JettyServletWebServerFactory`或`UndertowServletWebServerFactory`将被自动配置。 -**注** 你不需要关心这些实现类,大部分应用都能被自动配置,并根据你的行为创建合适的`ApplicationContext`和`ServletWebServerFactory`。 +**注** 你通常不需要关心这些实现类,大部分应用都能被自动配置,并根据你的行为创建合适的`ApplicationContext`和`ServletWebServerFactory`。 From c24f4ab734de457d9b5cc859da73dc8e9759ed8f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E7=83=AD=E5=BF=83=E5=B8=82=E6=B0=91=E9=92=9F=E5=B0=8F?= =?UTF-8?q?=E5=BC=BA?= Date: Wed, 17 Oct 2018 21:32:57 +0800 Subject: [PATCH 216/865] Update and rename 27.4.4 Customizing embedded servlet containers.md to 27.4.4 Customizing Embedded Servlet Containers.md --- ...s.md => 27.4.4 Customizing Embedded Servlet Containers.md} | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) rename IV. Spring Boot features/{27.4.4 Customizing embedded servlet containers.md => 27.4.4 Customizing Embedded Servlet Containers.md} (85%) diff --git a/IV. Spring Boot features/27.4.4 Customizing embedded servlet containers.md b/IV. Spring Boot features/27.4.4 Customizing Embedded Servlet Containers.md similarity index 85% rename from IV. Spring Boot features/27.4.4 Customizing embedded servlet containers.md rename to IV. Spring Boot features/27.4.4 Customizing Embedded Servlet Containers.md index 4805bb7c..a94b2c43 100644 --- a/IV. Spring Boot features/27.4.4 Customizing embedded servlet containers.md +++ b/IV. Spring Boot features/27.4.4 Customizing Embedded Servlet Containers.md @@ -5,7 +5,7 @@ 常见的服务器配置包括: 1. 网络设置:监听进入Http请求的端口(`server.port`),接口绑定地址`server.address`等。 -2. Session设置:session是否持久化(`server.session.persistence`),session超时时间(`server.session.timeout`),session数据存放位置(`server.session.store-dir`),session-cookie配置(`server.session.cookie.*`)。 +2. Session设置:session是否持久化(`server.servlet.session.persistence`),session超时时间(`server.servlet.session.timeout`),数据存放位置(`server.servlet.session.store-dir`),session-cookie配置(`server.servlet.session.cookie.*`)。 3. Error管理:错误页面的位置(`server.error.path`)等。 4. [SSL](https://docs.spring.io/spring-boot/docs/2.0.0.RELEASE/reference/htmlsingle/#howto-configure-ssl)。 5. [HTTP压缩](https://docs.spring.io/spring-boot/docs/2.0.0.RELEASE/reference/htmlsingle/#how-to-enable-http-response-compression) @@ -16,7 +16,7 @@ Spring Boot会尽量暴露常用设置,但这并不总是可能的。对于不 **编程方式的自定义** -如果需要以编程方式配置内嵌servlet容器,你可以注册一个实现`WebServerFactoryCustomizer`接口的Spring bean。`WebServerFactoryCustomizer`能够获取到包含很多自定义setter方法的`ConfigurableServletWebServerFactory`,你可以通过这些setter方法对内嵌容器自定义。 +如果需要以编程方式配置内嵌servlet容器,你可以注册一个实现`WebServerFactoryCustomizer`接口的Spring bean。`WebServerFactoryCustomizer`能够获取到包含很多自定义setter方法的`ConfigurableServletWebServerFactory`,你可以通过这些setter方法对内嵌容器自定义。Tomcat,Jetty和Undertow有独立的变体。下面的例子展示了以编程的方式设置端口: ```java import org.springframework.boot.web.server.WebServerFactoryCustomizer; import org.springframework.boot.web.servlet.server.ConfigurableServletWebServerFactory; From 74e74f0a539890568b489efa3bf32c9fbdf24d17 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E7=83=AD=E5=BF=83=E5=B8=82=E6=B0=91=E9=92=9F=E5=B0=8F?= =?UTF-8?q?=E5=BC=BA?= Date: Wed, 17 Oct 2018 21:34:03 +0800 Subject: [PATCH 217/865] Update SUMMARY.md --- SUMMARY.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/SUMMARY.md b/SUMMARY.md index fd1ba33c..6227deab 100644 --- a/SUMMARY.md +++ b/SUMMARY.md @@ -149,7 +149,7 @@ * [27.4.1 Servlets、Filters和listeners](IV. Spring Boot features/27.4.1 Servlets, Filters, and listeners.md) * [27.4.2 Servlet上下文初始化](IV. Spring Boot features/27.4.2 Servlet Context Initialization.md) * [27.4.3 ServletWebServerApplicationContext](IV. Spring Boot features/27.4.3 The ServletWebServerApplicationContext.md) - * [27.4.4 自定义内嵌servlet容器](IV. Spring Boot features/27.4.4 Customizing embedded servlet containers.md) + * [27.4.4 自定义内嵌servlet容器](IV. Spring Boot features/27.4.4 Customizing Embedded Servlet Containers.md) * [27.4.5 JSP的限制](IV. Spring Boot features/27.4.5 JSP limitations.md) * [28. 安全](IV. Spring Boot features/28. Security.md) * [28.1 OAuth2](IV. Spring Boot features/28.1 OAuth2.md) From a540e969222d73483029141e52793e8111d542aa Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E7=83=AD=E5=BF=83=E5=B8=82=E6=B0=91=E9=92=9F=E5=B0=8F?= =?UTF-8?q?=E5=BC=BA?= Date: Wed, 24 Oct 2018 22:21:56 +0800 Subject: [PATCH 218/865] Update and rename 27.4.5 JSP limitations.md to 27.4.5 JSP Limitations.md --- .../{27.4.5 JSP limitations.md => 27.4.5 JSP Limitations.md} | 0 1 file changed, 0 insertions(+), 0 deletions(-) rename IV. Spring Boot features/{27.4.5 JSP limitations.md => 27.4.5 JSP Limitations.md} (100%) diff --git a/IV. Spring Boot features/27.4.5 JSP limitations.md b/IV. Spring Boot features/27.4.5 JSP Limitations.md similarity index 100% rename from IV. Spring Boot features/27.4.5 JSP limitations.md rename to IV. Spring Boot features/27.4.5 JSP Limitations.md From 7efedcedd8843030363ea4ac24c67c87d99f828a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E7=83=AD=E5=BF=83=E5=B8=82=E6=B0=91=E9=92=9F=E5=B0=8F?= =?UTF-8?q?=E5=BC=BA?= Date: Wed, 24 Oct 2018 22:23:14 +0800 Subject: [PATCH 219/865] Update SUMMARY.md --- SUMMARY.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/SUMMARY.md b/SUMMARY.md index 6227deab..695fea74 100644 --- a/SUMMARY.md +++ b/SUMMARY.md @@ -150,7 +150,7 @@ * [27.4.2 Servlet上下文初始化](IV. Spring Boot features/27.4.2 Servlet Context Initialization.md) * [27.4.3 ServletWebServerApplicationContext](IV. Spring Boot features/27.4.3 The ServletWebServerApplicationContext.md) * [27.4.4 自定义内嵌servlet容器](IV. Spring Boot features/27.4.4 Customizing Embedded Servlet Containers.md) - * [27.4.5 JSP的限制](IV. Spring Boot features/27.4.5 JSP limitations.md) + * [27.4.5 JSP的限制](IV. Spring Boot features/27.4.5 JSP Limitations.md) * [28. 安全](IV. Spring Boot features/28. Security.md) * [28.1 OAuth2](IV. Spring Boot features/28.1 OAuth2.md) * [28.1.1 授权服务器](IV. Spring Boot features/28.1.1 Authorization Server.md) From f85aadbd0a828e4fbfbb57fa0b062fe04e61a3f8 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E7=83=AD=E5=BF=83=E5=B8=82=E6=B0=91=E9=92=9F=E5=B0=8F?= =?UTF-8?q?=E5=BC=BA?= Date: Sun, 4 Nov 2018 15:59:21 +0800 Subject: [PATCH 220/865] Update 28. Security.md --- IV. Spring Boot features/28. Security.md | 28 ++++++++---------------- 1 file changed, 9 insertions(+), 19 deletions(-) diff --git a/IV. Spring Boot features/28. Security.md b/IV. Spring Boot features/28. Security.md index 9dbf2ab2..53c11097 100644 --- a/IV. Spring Boot features/28. Security.md +++ b/IV. Spring Boot features/28. Security.md @@ -1,29 +1,19 @@ ### 28. 安全 -如果添加了Spring Security的依赖,那么web应用默认对所有的HTTP路径(也称为终点,端点,表示API的具体网址)使用'basic'认证。为了给web应用添加方法级别(method-level)的保护,你可以添加`@EnableGlobalMethodSecurity`并使用想要的设置,其他信息参考[Spring Security Reference](http://docs.spring.io/spring-security/site/docs/4.1.3.RELEASE/reference/htmlsingle#jc-method)。 +如果Spring Security在类路径上,那么web应用默认是安全的。 is on the classpath, then web applications are secure by default. Spring Boot依靠Spring Security的内容协商策略,决定是使用httpBasic,还是formLogin。为了给web应用添加方法级别(method-level)的保护,你可以添加`@EnableGlobalMethodSecurity`并使用想要的设置。其它信息参考[Spring Security参考指南](https://docs.spring.io/spring-security/site/docs/5.0.3.RELEASE/reference/htmlsingle#jc-method)。 -默认的`AuthenticationManager`只有一个用户('user'的用户名和随机密码会在应用启动时以INFO日志级别打印出来),如下: +默认的`AuthenticationManager`只有一个用户。用户名是user,密码随机,会在应用启动时以INFO日志级别打印出来。如下: ```java -Using default security password: 78fa095d-3f4c-48b1-ad50-e24c31d5cf35 +Using generated security password: 78fa095d-3f4c-48b1-ad50-e24c31d5cf35 ``` **注** 如果你对日志配置进行微调,确保`org.springframework.boot.autoconfigure.security`类别记录日志级别为`INFO`,否则默认的密码不会打印出来。 -你可以通过设置`security.user.password`改变默认密码,这些和其他有用的属性通过[SecurityProperties](https://github.com/spring-projects/spring-boot/tree/v2.0.0.RELEASE/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/security/SecurityProperties.java)(以"security"为前缀的属性)被外部化了。 +你可以通过提供`spring.security.user.name`和`spring.security.user.password`,改变用户名和密码。 -默认的安全配置是通过`SecurityAutoConfiguration`,`SpringBootWebSecurityConfiguration`(用于web安全),`AuthenticationManagerConfiguration`(可用于非web应用的认证配置)进行管理的。你可以添加一个`@EnableWebSecurity` bean来彻底关掉Spring Boot的默认配置。为了对它进行自定义,你需要使用外部的属性配置和`WebSecurityConfigurerAdapter`类型的beans(比如,添加基于表单的登陆)。 +在web应用中,你默认能得到如下的基本特性: -**注** 如果你添加`@EnableWebSecurity`,同时也禁用了执行器安全,你将在整个应用里得到默认的基于表单的登录,除非你添加了一个自定义的`WebSecurityConfigurerAdapter`。 +- 一个`UserDetailsService`(如果是WebFlux应用的话,则是`ReactiveUserDetailsService`)bean,存储在内存中。还有一个用户,用户的密码是生成的(关于这个用户的属性,请查看[`SecurityProperties.User`](https://docs.spring.io/spring-boot/docs/2.0.0.RELEASE/api/org/springframework/boot/autoconfigure/security/SecurityProperties.User.html))。 +- 应用在整个应用上的基于表单的登录或是HTTP Basic security(取决于Content-Type)。如果执行器在类路径上,则包含执行器端点。 +- 一个`DefaultAuthenticationEventPublisher`,用来发布认证事件。 -想要关闭认证管理的配置,你可以添加一个`AuthenticationManager`类型的bean,或在`@Configuration`类的某个方法里注入`AuthenticationManagerBuilder`来配置全局的`AuthenticationManager`。这里有一些安全相关的[Spring Boot应用示例](https://github.com/spring-projects/spring-boot/tree/v2.0.0.RELEASE/spring-boot-samples/)可以拿来参考。 - -在web应用中你能得到的开箱即用的基本特性如下: - -1. 一个使用内存存储的`AuthenticationManager` bean和一个用户(查看`SecurityProperties.User`获取user的属性)。 -2. 忽略(不保护)常见的静态资源路径(`/css/**, /js/**, /images/**`,`/webjars/**`和 `**/favicon.ico`)。 -3. 对其他所有路径实施HTTP Basic安全保护。 -4. 安全相关的事件会发布到Spring的`ApplicationEventPublisher`(成功和失败的认证,拒绝访问)。 -5. Spring Security提供的常见底层特性(HSTS, XSS, CSRF, 缓存)默认都被开启。 - -上述所有特性都能通过外部配置(`security.*`)打开,关闭,或修改。想要覆盖访问规则而不改变其他自动配置的特性,你可以添加一个注解`@Order(SecurityProperties.ACCESS_OVERRIDE_ORDER)`的`WebSecurityConfigurerAdapter`类型的`@Bean`。 - -**注** `WebSecurityConfigurerAdapter`默认会匹配所有路径,如果不想完全覆盖Spring Boot自动配置的访问规则,你可以精确的配置想要覆盖的路径。 +你可以通过添加一个bean,为它提供一个不同的`AuthenticationEventPublisher`。 From 23c47d53a37087747079287acd8a3266b192b607 Mon Sep 17 00:00:00 2001 From: Jack Zhong Date: Sun, 4 Nov 2018 16:38:49 +0800 Subject: [PATCH 221/865] =?UTF-8?q?=E4=B8=8A=E4=BC=A028.1=20MVC=20Security?= =?UTF-8?q?=EF=BC=8C=E6=9C=AA=E7=BF=BB=E8=AF=91?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- IV. Spring Boot features/28.1 MVC Security.md | 7 +++++++ SUMMARY.md | 1 + 2 files changed, 8 insertions(+) create mode 100644 IV. Spring Boot features/28.1 MVC Security.md diff --git a/IV. Spring Boot features/28.1 MVC Security.md b/IV. Spring Boot features/28.1 MVC Security.md new file mode 100644 index 00000000..01e40e5c --- /dev/null +++ b/IV. Spring Boot features/28.1 MVC Security.md @@ -0,0 +1,7 @@ +### 28.1 MVC Security + +The default security configuration is implemented in `SecurityAutoConfiguration` and in the classes imported from there (`SpringBootWebSecurityConfiguration` for web security and `AuthenticationManagerConfiguration` for authentication configuration, which is also relevant in non-web applications). To switch off the default web application security configuration completely, you can add a bean of type `WebSecurityConfigurerAdapter` (doing so does not disable the authentication manager configuration or Actuator’s security). + +To also switch off the authentication manager configuration, you can add a bean of type `UserDetailsService`, `AuthenticationProvider`, or `AuthenticationManager`. There are several secure applications in the [Spring Boot samples](https://github.com/spring-projects/spring-boot/tree/v2.0.0.RELEASE/spring-boot-samples/) to get you started with common use cases. + +Access rules can be overridden by adding a custom `WebSecurityConfigurerAdapter`. Spring Boot provides convenience methods that can be used to override access rules for actuator endpoints and static resources. `EndpointRequest` can be used to create a `RequestMatcher` that is based on the `management.endpoints.web.base-path` property. `PathRequest` can be used to create a `RequestMatcher` for resources in commonly used locations. \ No newline at end of file diff --git a/SUMMARY.md b/SUMMARY.md index 695fea74..7de416a3 100644 --- a/SUMMARY.md +++ b/SUMMARY.md @@ -152,6 +152,7 @@ * [27.4.4 自定义内嵌servlet容器](IV. Spring Boot features/27.4.4 Customizing Embedded Servlet Containers.md) * [27.4.5 JSP的限制](IV. Spring Boot features/27.4.5 JSP Limitations.md) * [28. 安全](IV. Spring Boot features/28. Security.md) + * [28.1 MVC Security](IV. Spring Boot features/28.1 MVC Security.md) * [28.1 OAuth2](IV. Spring Boot features/28.1 OAuth2.md) * [28.1.1 授权服务器](IV. Spring Boot features/28.1.1 Authorization Server.md) * [28.1.2 资源服务器](IV. Spring Boot features/28.1.2 Resource Server.md) From 908501d7a812f50167a25f13b259c4add85410c6 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E7=83=AD=E5=BF=83=E5=B8=82=E6=B0=91=E9=92=9F=E5=B0=8F?= =?UTF-8?q?=E5=BC=BA?= Date: Sun, 4 Nov 2018 16:42:20 +0800 Subject: [PATCH 222/865] Update 28. Security.md --- IV. Spring Boot features/28. Security.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/IV. Spring Boot features/28. Security.md b/IV. Spring Boot features/28. Security.md index 53c11097..ec2acace 100644 --- a/IV. Spring Boot features/28. Security.md +++ b/IV. Spring Boot features/28. Security.md @@ -1,6 +1,6 @@ ### 28. 安全 -如果Spring Security在类路径上,那么web应用默认是安全的。 is on the classpath, then web applications are secure by default. Spring Boot依靠Spring Security的内容协商策略,决定是使用httpBasic,还是formLogin。为了给web应用添加方法级别(method-level)的保护,你可以添加`@EnableGlobalMethodSecurity`并使用想要的设置。其它信息参考[Spring Security参考指南](https://docs.spring.io/spring-security/site/docs/5.0.3.RELEASE/reference/htmlsingle#jc-method)。 +如果Spring Security在类路径上,那么web应用默认是安全的。Spring Boot依靠Spring Security的内容协商策略,决定是使用httpBasic,还是formLogin。为了给web应用添加方法级别(method-level)的保护,你可以添加`@EnableGlobalMethodSecurity`并使用想要的设置。其它信息参考[Spring Security参考指南](https://docs.spring.io/spring-security/site/docs/5.0.3.RELEASE/reference/htmlsingle#jc-method)。 默认的`AuthenticationManager`只有一个用户。用户名是user,密码随机,会在应用启动时以INFO日志级别打印出来。如下: ```java From b773da9b30e403f1779ba1c1cc7d95dc686edd6e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E7=83=AD=E5=BF=83=E5=B8=82=E6=B0=91=E9=92=9F=E5=B0=8F?= =?UTF-8?q?=E5=BC=BA?= Date: Sun, 4 Nov 2018 17:45:15 +0800 Subject: [PATCH 223/865] Update 28.1 MVC Security.md --- IV. Spring Boot features/28.1 MVC Security.md | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/IV. Spring Boot features/28.1 MVC Security.md b/IV. Spring Boot features/28.1 MVC Security.md index 01e40e5c..1dab67e6 100644 --- a/IV. Spring Boot features/28.1 MVC Security.md +++ b/IV. Spring Boot features/28.1 MVC Security.md @@ -1,7 +1,7 @@ ### 28.1 MVC Security -The default security configuration is implemented in `SecurityAutoConfiguration` and in the classes imported from there (`SpringBootWebSecurityConfiguration` for web security and `AuthenticationManagerConfiguration` for authentication configuration, which is also relevant in non-web applications). To switch off the default web application security configuration completely, you can add a bean of type `WebSecurityConfigurerAdapter` (doing so does not disable the authentication manager configuration or Actuator’s security). +默认的安全配置是通过`SecurityAutoConfiguration`,`SpringBootWebSecurityConfiguration`(用于web安全),`AuthenticationManagerConfiguration`(用于认证配置,也与非web应用相关)进行管理的。你可以添加一个`WebSecurityConfigurerAdapter`类型的bean,来彻底关掉默认的web应用安全配置(这样做不会禁用认证管理者配置或者Actuator的安全)。 -To also switch off the authentication manager configuration, you can add a bean of type `UserDetailsService`, `AuthenticationProvider`, or `AuthenticationManager`. There are several secure applications in the [Spring Boot samples](https://github.com/spring-projects/spring-boot/tree/v2.0.0.RELEASE/spring-boot-samples/) to get you started with common use cases. +为了关闭认证管理者配置,你可以添加`UserDetailsService`、`AuthenticationProvider`、或是`AuthenticationManager`类型的bean。在[Spring Boot示例](https://github.com/spring-projects/spring-boot/tree/v2.0.0.RELEASE/spring-boot-samples/)里有几个安全的应用,里面包含了一些常见用例。 -Access rules can be overridden by adding a custom `WebSecurityConfigurerAdapter`. Spring Boot provides convenience methods that can be used to override access rules for actuator endpoints and static resources. `EndpointRequest` can be used to create a `RequestMatcher` that is based on the `management.endpoints.web.base-path` property. `PathRequest` can be used to create a `RequestMatcher` for resources in commonly used locations. \ No newline at end of file +访问规则可以通过添加自定义的`WebSecurityConfigurerAdapter`覆盖。Spring Boot提供了便捷的方法。它们可以用来覆盖执行器端点和静态资源的访问规则。`EndpointRequest`可以用来创建基于`management.endpoints.web.base-path`属性的`RequestMatcher`。`PathRequest`可以用来创建常用位置上的资源的`RequestMatcher`。 From 82d9a6fda6339d36fb44ae10ad5a77c4c4414d4c Mon Sep 17 00:00:00 2001 From: Jack Zhong Date: Sun, 11 Nov 2018 14:11:21 +0800 Subject: [PATCH 224/865] =?UTF-8?q?=E4=B8=8A=E4=BC=A028.2=20WebFlux=20Secu?= =?UTF-8?q?rity=EF=BC=8C=E6=9C=AA=E7=BF=BB=E8=AF=91?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- IV. Spring Boot features/28.1 MVC Security.md | 2 +- .../28.2 WebFlux Security.md | 24 +++++++++++++++++++ SUMMARY.md | 3 ++- 3 files changed, 27 insertions(+), 2 deletions(-) create mode 100644 IV. Spring Boot features/28.2 WebFlux Security.md diff --git a/IV. Spring Boot features/28.1 MVC Security.md b/IV. Spring Boot features/28.1 MVC Security.md index 1dab67e6..22494ac9 100644 --- a/IV. Spring Boot features/28.1 MVC Security.md +++ b/IV. Spring Boot features/28.1 MVC Security.md @@ -1,4 +1,4 @@ -### 28.1 MVC Security +### 28.1 MVC安全 默认的安全配置是通过`SecurityAutoConfiguration`,`SpringBootWebSecurityConfiguration`(用于web安全),`AuthenticationManagerConfiguration`(用于认证配置,也与非web应用相关)进行管理的。你可以添加一个`WebSecurityConfigurerAdapter`类型的bean,来彻底关掉默认的web应用安全配置(这样做不会禁用认证管理者配置或者Actuator的安全)。 diff --git a/IV. Spring Boot features/28.2 WebFlux Security.md b/IV. Spring Boot features/28.2 WebFlux Security.md new file mode 100644 index 00000000..dfe1d980 --- /dev/null +++ b/IV. Spring Boot features/28.2 WebFlux Security.md @@ -0,0 +1,24 @@ +### 28.2 WebFlux安全 + +Similar to Spring MVC applications, you can secure your WebFlux applications by adding the `spring-boot-starter-security` dependency. The default security configuration is implemented in `ReactiveSecurityAutoConfiguration` and in the classes imported from there (`WebFluxSecurityConfiguration` for web security and `ReactiveAuthenticationManagerConfiguration` for authentication configuration, which is also relevant in non-web applications). To switch off the default web application security configuration completely, you can add a bean of type `WebFilterChainProxy` (doing so does not disable the authentication manager configuration or Actuator’s security). + +To also switch off the authentication manager configuration, you can add a bean of type `ReactiveUserDetailsService` or `ReactiveAuthenticationManager`. + +Access rules can be configured by adding a custom `SecurityWebFilterChain`. Spring Boot provides convenience methods that can be used to override access rules for actuator endpoints and static resources. `EndpointRequest` can be used to create a `ServerWebExchangeMatcher` that is based on the `management.endpoints.web.base-path` property. + +`PathRequest` can be used to create a `ServerWebExchangeMatcher` for resources in commonly used locations. + +For example, you can customize your security configuration by adding something like: + +```java +@Bean +public SecurityWebFilterChain springSecurityFilterChain(ServerHttpSecurity http) { + http + .authorizeExchange() + .matchers(PathRequest.toStaticResources().atCommonLocations()).permitAll() + .pathMatchers("/foo", "/bar") + .authenticated().and() + .formLogin(); + return http.build(); +} +``` \ No newline at end of file diff --git a/SUMMARY.md b/SUMMARY.md index 7de416a3..2e77df11 100644 --- a/SUMMARY.md +++ b/SUMMARY.md @@ -152,7 +152,8 @@ * [27.4.4 自定义内嵌servlet容器](IV. Spring Boot features/27.4.4 Customizing Embedded Servlet Containers.md) * [27.4.5 JSP的限制](IV. Spring Boot features/27.4.5 JSP Limitations.md) * [28. 安全](IV. Spring Boot features/28. Security.md) - * [28.1 MVC Security](IV. Spring Boot features/28.1 MVC Security.md) + * [28.1 MVC安全](IV. Spring Boot features/28.1 MVC Security.md) + * [28.2 WebFlux安全](IV. Spring Boot features/28.2 WebFlux Security.md) * [28.1 OAuth2](IV. Spring Boot features/28.1 OAuth2.md) * [28.1.1 授权服务器](IV. Spring Boot features/28.1.1 Authorization Server.md) * [28.1.2 资源服务器](IV. Spring Boot features/28.1.2 Resource Server.md) From 34d8275eae5531bf8deed57c82c419b8575d7967 Mon Sep 17 00:00:00 2001 From: Jack Zhong Date: Sun, 11 Nov 2018 15:10:48 +0800 Subject: [PATCH 225/865] =?UTF-8?q?=E7=BF=BB=E8=AF=9128.2=20WebFlux?= =?UTF-8?q?=E5=AE=89=E5=85=A8?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- IV. Spring Boot features/28.1 MVC Security.md | 2 +- IV. Spring Boot features/28.2 WebFlux Security.md | 11 +++++------ 2 files changed, 6 insertions(+), 7 deletions(-) diff --git a/IV. Spring Boot features/28.1 MVC Security.md b/IV. Spring Boot features/28.1 MVC Security.md index 22494ac9..a75f03e1 100644 --- a/IV. Spring Boot features/28.1 MVC Security.md +++ b/IV. Spring Boot features/28.1 MVC Security.md @@ -1,6 +1,6 @@ ### 28.1 MVC安全 -默认的安全配置是通过`SecurityAutoConfiguration`,`SpringBootWebSecurityConfiguration`(用于web安全),`AuthenticationManagerConfiguration`(用于认证配置,也与非web应用相关)进行管理的。你可以添加一个`WebSecurityConfigurerAdapter`类型的bean,来彻底关掉默认的web应用安全配置(这样做不会禁用认证管理者配置或者Actuator的安全)。 +默认的安全配置由`SecurityAutoConfiguration`以及从其它地方导入的类(`SpringBootWebSecurityConfiguration`用于web安全,`AuthenticationManagerConfiguration`用于认证配置,也与非web应用相关)实现的。你可以添加一个`WebSecurityConfigurerAdapter`类型的bean,来彻底关掉默认的web应用安全配置(这样做不会禁用认证管理者配置或者Actuator的安全)。 为了关闭认证管理者配置,你可以添加`UserDetailsService`、`AuthenticationProvider`、或是`AuthenticationManager`类型的bean。在[Spring Boot示例](https://github.com/spring-projects/spring-boot/tree/v2.0.0.RELEASE/spring-boot-samples/)里有几个安全的应用,里面包含了一些常见用例。 diff --git a/IV. Spring Boot features/28.2 WebFlux Security.md b/IV. Spring Boot features/28.2 WebFlux Security.md index dfe1d980..1422d3dc 100644 --- a/IV. Spring Boot features/28.2 WebFlux Security.md +++ b/IV. Spring Boot features/28.2 WebFlux Security.md @@ -1,15 +1,14 @@ ### 28.2 WebFlux安全 -Similar to Spring MVC applications, you can secure your WebFlux applications by adding the `spring-boot-starter-security` dependency. The default security configuration is implemented in `ReactiveSecurityAutoConfiguration` and in the classes imported from there (`WebFluxSecurityConfiguration` for web security and `ReactiveAuthenticationManagerConfiguration` for authentication configuration, which is also relevant in non-web applications). To switch off the default web application security configuration completely, you can add a bean of type `WebFilterChainProxy` (doing so does not disable the authentication manager configuration or Actuator’s security). +类似于Spring MVC应用,你可以通过添加`spring-boot-starter-security`依赖,保护你的WebFlux应用。默认的安全配置由`ReactiveSecurityAutoConfiguration`以及从其它地方导入的类(`WebFluxSecurityConfiguration`用于web安全,`ReactiveAuthenticationManagerConfiguration`用于认证配置,也与非web应用相关)实现的。你可以添加一个`WebFilterChainProxy`类型的bean,来彻底关掉默认的web应用安全配置(这样做不会禁用认证管理者配置或者Actuator的安全)。 -To also switch off the authentication manager configuration, you can add a bean of type `ReactiveUserDetailsService` or `ReactiveAuthenticationManager`. +为了关闭认证管理者配置,你可以添加`ReactiveUserDetailsService`或是`ReactiveAuthenticationManager`类型的bean。 -Access rules can be configured by adding a custom `SecurityWebFilterChain`. Spring Boot provides convenience methods that can be used to override access rules for actuator endpoints and static resources. `EndpointRequest` can be used to create a `ServerWebExchangeMatcher` that is based on the `management.endpoints.web.base-path` property. +访问规则可以通过添加自定义的`SecurityWebFilterChain`配置。Spring Boot提供了便捷的方法。它们可以用来覆盖执行器端点和静态资源的访问规则。`EndpointRequest`可以用来创建基于`management.endpoints.web.base-path`属性的`ServerWebExchangeMatcher`。 -`PathRequest` can be used to create a `ServerWebExchangeMatcher` for resources in commonly used locations. - -For example, you can customize your security configuration by adding something like: +`PathRequest`可以用来创建常用位置上的资源的`ServerWebExchangeMatcher`。 +例如,你可以添加如下代码,自定义你的安全配置: ```java @Bean public SecurityWebFilterChain springSecurityFilterChain(ServerHttpSecurity http) { From ba0d4df9409186c5b0955e61ac6cd07d1e2a9be7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E7=83=AD=E5=BF=83=E5=B8=82=E6=B0=91=E9=92=9F=E5=B0=8F?= =?UTF-8?q?=E5=BC=BA?= Date: Thu, 15 Nov 2018 21:05:26 +0800 Subject: [PATCH 226/865] Update and rename 28.1 OAuth2.md to 28.3 OAuth2.md --- IV. Spring Boot features/28.1 OAuth2.md | 3 --- IV. Spring Boot features/28.3 OAuth2.md | 3 +++ 2 files changed, 3 insertions(+), 3 deletions(-) delete mode 100644 IV. Spring Boot features/28.1 OAuth2.md create mode 100644 IV. Spring Boot features/28.3 OAuth2.md diff --git a/IV. Spring Boot features/28.1 OAuth2.md b/IV. Spring Boot features/28.1 OAuth2.md deleted file mode 100644 index 80792651..00000000 --- a/IV. Spring Boot features/28.1 OAuth2.md +++ /dev/null @@ -1,3 +0,0 @@ -###28.1 OAuth2 -如果添加了`spring-security-oauth2`依赖,你可以利用自动配置简化认证(Authorization)或资源服务器(Resource Server)的设置,详情参考[Spring Security OAuth 2 Developers Guide](http://projects.spring.io/spring-security-oauth/docs/oauth2.html)。 - diff --git a/IV. Spring Boot features/28.3 OAuth2.md b/IV. Spring Boot features/28.3 OAuth2.md new file mode 100644 index 00000000..bde053d0 --- /dev/null +++ b/IV. Spring Boot features/28.3 OAuth2.md @@ -0,0 +1,3 @@ +### 28.3 OAuth2 + +[OAuth2](https://oauth.net/2/)是一个Spring支持的被广泛使用的认证框架。 From dfbf2ec973b975a4d40e68d95ecda8ddbe4768cc Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E7=83=AD=E5=BF=83=E5=B8=82=E6=B0=91=E9=92=9F=E5=B0=8F?= =?UTF-8?q?=E5=BC=BA?= Date: Thu, 15 Nov 2018 21:06:33 +0800 Subject: [PATCH 227/865] Update SUMMARY.md --- SUMMARY.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/SUMMARY.md b/SUMMARY.md index 2e77df11..cb47804d 100644 --- a/SUMMARY.md +++ b/SUMMARY.md @@ -154,7 +154,7 @@ * [28. 安全](IV. Spring Boot features/28. Security.md) * [28.1 MVC安全](IV. Spring Boot features/28.1 MVC Security.md) * [28.2 WebFlux安全](IV. Spring Boot features/28.2 WebFlux Security.md) - * [28.1 OAuth2](IV. Spring Boot features/28.1 OAuth2.md) + * [28.3 OAuth2](IV. Spring Boot features/28.3 OAuth2.md) * [28.1.1 授权服务器](IV. Spring Boot features/28.1.1 Authorization Server.md) * [28.1.2 资源服务器](IV. Spring Boot features/28.1.2 Resource Server.md) * [28.2 User Info中的Token类型](IV. Spring Boot features/28.2 Token Type in User Info.md) From ea230892eb4a2bae3e8233d6055ff0b080bea32c Mon Sep 17 00:00:00 2001 From: Jack Zhong Date: Thu, 15 Nov 2018 21:53:45 +0800 Subject: [PATCH 228/865] =?UTF-8?q?=E7=BF=BB=E8=AF=9128.3.1=20=E5=AE=A2?= =?UTF-8?q?=E6=88=B7=E7=AB=AF?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- IV. Spring Boot features/28.3.1 Client.md | 74 ++++++++++++++++------- 1 file changed, 52 insertions(+), 22 deletions(-) diff --git a/IV. Spring Boot features/28.3.1 Client.md b/IV. Spring Boot features/28.3.1 Client.md index 2a5a6380..bf701991 100644 --- a/IV. Spring Boot features/28.3.1 Client.md +++ b/IV. Spring Boot features/28.3.1 Client.md @@ -1,30 +1,60 @@ ### 28.3.1 客户端 -为了将web-app放入一个OAuth2客户端,你只需注解`@EnableOAuth2Client`,Spring Boot会创建`OAuth2ClientContext`和`OAuth2ProtectedResourceDetails`,这些是创建`OAuth2RestOperations`必需的。Spring Boot不会自动创建该bean,但你自己创建也不费力: +如果你的类路径上有`spring-security-oauth2-client`,你可以利用某些自动配置更容易地设置OAuth2客户端。 这个配置使用`OAuth2ClientProperties`里的属性。 + +你可以在`spring.security.oauth2.client`前缀下,注册多个OAuth2客户端和提供商,如下所示: + +```properties +spring.security.oauth2.client.registration.my-client-1.client-id=abcd +spring.security.oauth2.client.registration.my-client-1.client-secret=password +spring.security.oauth2.client.registration.my-client-1.client-name=Client for user scope +spring.security.oauth2.client.registration.my-client-1.provider=my-oauth-provider +spring.security.oauth2.client.registration.my-client-1.scope=user +spring.security.oauth2.client.registration.my-client-1.redirect-uri-template=http://my-redirect-uri.com +spring.security.oauth2.client.registration.my-client-1.client-authentication-method=basic +spring.security.oauth2.client.registration.my-client-1.authorization-grant-type=authorization_code + +spring.security.oauth2.client.registration.my-client-2.client-id=abcd +spring.security.oauth2.client.registration.my-client-2.client-secret=password +spring.security.oauth2.client.registration.my-client-2.client-name=Client for email scope +spring.security.oauth2.client.registration.my-client-2.provider=my-oauth-provider +spring.security.oauth2.client.registration.my-client-2.scope=email +spring.security.oauth2.client.registration.my-client-2.redirect-uri-template=http://my-redirect-uri.com +spring.security.oauth2.client.registration.my-client-2.client-authentication-method=basic +spring.security.oauth2.client.registration.my-client-2.authorization-grant-type=authorization_code + +spring.security.oauth2.client.provider.my-oauth-provider.authorization-uri=http://my-auth-server/oauth/authorize +spring.security.oauth2.client.provider.my-oauth-provider.token-uri=http://my-auth-server/oauth/token +spring.security.oauth2.client.provider.my-oauth-provider.user-info-uri=http://my-auth-server/userinfo +spring.security.oauth2.client.provider.my-oauth-provider.jwk-set-uri=http://my-auth-server/token_keys +spring.security.oauth2.client.provider.my-oauth-provider.user-name-attribute=name +``` +默认的,Spring Security的`OAuth2LoginAuthenticationFilter`只处理匹配`/login/oauth2/code/*`的URL。如果你想要自定义`redirect-uri-template`来使用不同的模式,你需要提供处理那个自定义模式的配置。比如,你可以添加类似于下面示例的你自己的`WebSecurityConfigurerAdapter`: ```java -@Bean -public OAuth2RestTemplate oauth2RestTemplate(OAuth2ClientContext oauth2ClientContext, - OAuth2ProtectedResourceDetails details) { - return new OAuth2RestTemplate(details, oauth2ClientContext); +public class OAuth2LoginSecurityConfig extends WebSecurityConfigurerAdapter { + + @Override + protected void configure(HttpSecurity http) throws Exception { + http + .authorizeRequests() + .anyRequest().authenticated() + .and() + .oauth2Login() + .redirectionEndpoint() + .baseUri("/custom-callback"); + } } ``` -**注** 你可能想添加一个限定名(qualifier),因为应用中可能定义多个`RestTemplate`。 - -该配置使用`security.oauth2.client.*`作为证书(跟授权服务器使用的相同),此外,它也需要知道授权服务器中认证和token的URIs,例如: -```yml -security: - oauth2: - client: - clientId: bd1c0a783ccdd1c9b9e4 - clientSecret: 1a9030fbca47a5b2c28e92f19050bb77824b5ad1 - accessTokenUri: https://github.com/login/oauth/access_token - userAuthorizationUri: https://github.com/login/oauth/authorize - clientAuthenticationScheme: form -``` -具有该配置的应用在使用`OAuth2RestTemplate`时会重定向到GitHub以完成授权,如果已经登陆GitHub,你甚至不会注意到它已经授权过了。那些特殊的凭证(credentials)只在应用运行于8080端口时有效(为了更灵活,在GitHub或其他提供商上注册自己的客户端app)。 +对于通常的OAuth2和OpenID提供商,包括Google、Github、Facebook、和Okta,我们提供了一系列默认的提供商(`google`、`github`、`facebook`、`okta`)。 -在客户端获取access token时,你可以设置`security.oauth2.client.scope`(逗号分隔或一个YAML数组)来限制它请求的作用域(scope)。作用域默认是空的,默认值取决于授权服务器,通常依赖于它拥有的客户端在注册时的设置。 +如果你不需要自定义这些提供商,你可以把`provider`属性设置为其中的一个。同样的,如果你客户端的ID匹配默认支持的提供商,Spring Boot也会推断你要使用它。 -**注** 对`security.oauth2.client.client-authentication-scheme`也有设置,默认为"header"(如果你的OAuth2提供商不喜欢header认证,例如Github,你可能需要将它设置为“form”)。实际上,`security.oauth2.client.*`属性绑定到一个`AuthorizationCodeResourceDetails`实例,所以它的所有属性都可以指定。 +也就是说,下面例子中的两个配置使用提供商: +```properties +spring.security.oauth2.client.registration.my-client.client-id=abcd +spring.security.oauth2.client.registration.my-client.client-secret=password +spring.security.oauth2.client.registration.my-client.provider=google -**注** 在一个非web应用中,你仍旧可以创建一个`OAuth2RestOperations`,并且跟`security.oauth2.client.*`配置关联。在这种情况下,它是一个“client credentials token grant”,如果你使用它的话就需要获取(此处不需要注解`@EnableOAuth2Client`或`@EnableOAuth2Sso`)。为了防止基础设施定义,只需要将`security.oauth2.client.client-id`从配置中移除(或将它设为空字符串)。 +spring.security.oauth2.client.registration.google.client-id=abcd +spring.security.oauth2.client.registration.google.client-secret=password +``` \ No newline at end of file From e056bb39ed695aba3e081faf85bc33b94ed15361 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E7=83=AD=E5=BF=83=E5=B8=82=E6=B0=91=E9=92=9F=E5=B0=8F?= =?UTF-8?q?=E5=BC=BA?= Date: Thu, 15 Nov 2018 21:56:45 +0800 Subject: [PATCH 229/865] Update 28.3.1 Client.md --- IV. Spring Boot features/28.3.1 Client.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/IV. Spring Boot features/28.3.1 Client.md b/IV. Spring Boot features/28.3.1 Client.md index bf701991..dd61ce2d 100644 --- a/IV. Spring Boot features/28.3.1 Client.md +++ b/IV. Spring Boot features/28.3.1 Client.md @@ -49,7 +49,7 @@ public class OAuth2LoginSecurityConfig extends WebSecurityConfigurerAdapter { 如果你不需要自定义这些提供商,你可以把`provider`属性设置为其中的一个。同样的,如果你客户端的ID匹配默认支持的提供商,Spring Boot也会推断你要使用它。 -也就是说,下面例子中的两个配置使用提供商: +也就是说,下面例子中的两个配置使用Google提供商: ```properties spring.security.oauth2.client.registration.my-client.client-id=abcd spring.security.oauth2.client.registration.my-client.client-secret=password @@ -57,4 +57,4 @@ spring.security.oauth2.client.registration.my-client.provider=google spring.security.oauth2.client.registration.google.client-id=abcd spring.security.oauth2.client.registration.google.client-secret=password -``` \ No newline at end of file +``` From 93e7641441833f869d87a8695599f948ced80215 Mon Sep 17 00:00:00 2001 From: Jack Zhong Date: Thu, 15 Nov 2018 22:02:55 +0800 Subject: [PATCH 230/865] =?UTF-8?q?=E6=9B=B4=E6=96=B0=E7=9B=AE=E5=BD=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../28.1.1 Authorization Server.md | 11 ------- .../28.1.2 Resource Server.md | 16 ---------- .../28.2 Token Type in User Info.md | 3 -- ... Customizing the User Info RestTemplate.md | 14 --------- .../28.3.2 Single Sign On.md | 29 ------------------- SUMMARY.md | 5 ---- 6 files changed, 78 deletions(-) delete mode 100644 IV. Spring Boot features/28.1.1 Authorization Server.md delete mode 100644 IV. Spring Boot features/28.1.2 Resource Server.md delete mode 100644 IV. Spring Boot features/28.2 Token Type in User Info.md delete mode 100644 IV. Spring Boot features/28.3 Customizing the User Info RestTemplate.md delete mode 100644 IV. Spring Boot features/28.3.2 Single Sign On.md diff --git a/IV. Spring Boot features/28.1.1 Authorization Server.md b/IV. Spring Boot features/28.1.1 Authorization Server.md deleted file mode 100644 index d864b965..00000000 --- a/IV. Spring Boot features/28.1.1 Authorization Server.md +++ /dev/null @@ -1,11 +0,0 @@ -### 28.1.1 授权服务器 - -想要创建一个授权服务器,并授予access tokens,你需要使用`@EnableAuthorizationServer`,并提供`security.oauth2.client.client-id`和`security.oauth2.client.client-secret`配置。 - -按以上操作后,你就能使用客户端证书创建一个access token,例如: -```shell -$ curl client:secret@localhost:8080/oauth/token -d grant_type=password -d username=user -d password=pwd -``` -`/token`端点basic形式的认证证书是`client-id`和`client-secret`,用户证书通常是Spring Security的user详情(Spring Boot中默认是"user"和一个随机的密码)。 - -想要关闭自动配置,自己配置授权服务器特性,你只需添加一个`AuthorizationServerConfigurer`类型的`@Bean`。 diff --git a/IV. Spring Boot features/28.1.2 Resource Server.md b/IV. Spring Boot features/28.1.2 Resource Server.md deleted file mode 100644 index b0ca0ec3..00000000 --- a/IV. Spring Boot features/28.1.2 Resource Server.md +++ /dev/null @@ -1,16 +0,0 @@ -### 28.1.2 资源服务器 -为了使用access token,你需要一个资源服务器(可以跟授权服务器是同一个)。创建资源服务器很简单,只需要添加`@EnableResourceServer`,提供一些配置以允许服务器解码access token。如果应用也是授权服务器,由于它知道如何去解码tokens,所以也就不需要做其他事情。如果你的app是独立的服务,那你就需要给它添加以下可选配置中的某一项: - -* `security.oauth2.resource.user-info-uri`用于`/me`资源(例如,PWS的`https://uaa.run.pivotal.io/userinfo`)。 -* `security.oauth2.resource.token-info-uri`用于token解码端点(例如,PWS的`https://uaa.run.pivotal.io/check_token`)。 - -如果`user-info-uri`和`token-info-uri`都指定了,你可以设置flag筛选出最想要的那个(默认`prefer-token-info=true`)。 - -另外,如果token是JWTs,你可以配置`security.oauth2.resource.jwt.key-value`解码它们(key是验签的key)。验签的键值可以是一个对称密钥,也可以是PEM编码的RSA公钥。如果你没有key,并且它是公开的,你可以通过`security.oauth2.resource.jwt.key-uri`提供一个下载URI(有一个"value"字段的JSON对象),例如,在PWS平台上: -``` -$ curl https://uaa.run.pivotal.io/token_key -{"alg":"SHA256withRSA","value":"-----BEGIN PUBLIC KEY-----\nMIIBI...\n-----END PUBLIC KEY-----\n"} -``` -**注** 如果你使用`security.oauth2.resource.jwt.key-uri`,授权服务器需要在应用启动时也运行起来,如果找不到key,它将输出warning,并告诉你如何解决。 - -OAuth2资源被过滤器链按`security.oauth2.resource.filter-order`指明的顺序保护着。默认地,在过滤器的保护结束之后才会到执行器端点(这样,执行器端点将会继续停留在HTTP Basic,除非你改变了顺序)。 diff --git a/IV. Spring Boot features/28.2 Token Type in User Info.md b/IV. Spring Boot features/28.2 Token Type in User Info.md deleted file mode 100644 index df8aded9..00000000 --- a/IV. Spring Boot features/28.2 Token Type in User Info.md +++ /dev/null @@ -1,3 +0,0 @@ -###28.2 User Info中的Token类型 - -Google和其他一些第三方身份(identity)提供商对发送给user info端点的请求头中设置的token类型名有严格要求。默认的`Bearer`满足大多数提供商要求,如果需要你可以设置`security.oauth2.resource.token-type`来改变它。 diff --git a/IV. Spring Boot features/28.3 Customizing the User Info RestTemplate.md b/IV. Spring Boot features/28.3 Customizing the User Info RestTemplate.md deleted file mode 100644 index 59d49b13..00000000 --- a/IV. Spring Boot features/28.3 Customizing the User Info RestTemplate.md +++ /dev/null @@ -1,14 +0,0 @@ -### 28.3 自定义User Info RestTemplate -如果设置了`user-info-uri`,资源服务器在内部将使用一个`OAuth2RestTemplate`抓取用于认证的用户信息,这是一个类型为`UserInfoRestTemplateFactory`的`@Bean`提供的。默认适用于大多数提供商,但偶尔你可能需要添加其他interceptors,或改变request的验证器(authenticator)。想要添加自定义,只需创建一个`UserInfoRestTemplateCustomizer`类型的bean —— 它只有单个方法,在bean创建后,初始化前会调用该方法。此处自定义的rest template仅用于内部执行认证。或者,你可以定义你自己的`UserInfoRestTemplateFactory``@Bean`来掌握完全的控制。 - -**注** 在YAML中设置RSA key时,需要使用管道符分割多行(“|”),记得缩进key value,例如: -```yaml -security: - oauth2: - resource: - jwt: - keyValue: | - -----BEGIN PUBLIC KEY----- - MIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8AMIIBCgKC... - -----END PUBLIC KEY----- -``` diff --git a/IV. Spring Boot features/28.3.2 Single Sign On.md b/IV. Spring Boot features/28.3.2 Single Sign On.md deleted file mode 100644 index d327309c..00000000 --- a/IV. Spring Boot features/28.3.2 Single Sign On.md +++ /dev/null @@ -1,29 +0,0 @@ -### 28.3.2 单点登陆 -OAuth2客户端可用于从提供商抓取用户详情,然后转换为Spring Security需要的`Authentication` token。上述提到的资源服务器通过`user-info-uri`属性来支持该功能,这是基于OAuth2的单点登陆(SSO)协议最基本的,Spring Boot提供的`@EnableOAuth2Sso`注解让它更容易实践。通过添加该注解及端点配置(`security.oauth2.client.*`),Github客户端就可以使用`/user/`端点保护它的所有资源了: -```yaml -security: - oauth2: -... - resource: - userInfoUri: https://api.github.com/user - preferTokenInfo: false -``` -由于所有路径默认都处于保护下,也就没有主页展示那些未授权的用户,进而邀请他们去登陆(通过访问`/login`路径,或`security.oauth2.sso.login-path`指定的路径)。 - -为了自定义访问规则或保护的路径(这样你就可以添加主页),你可以将`@EnableOAuth2Sso`添加到一个`WebSecurityConfigurerAdapter`,该注解会包装它,增强需要的地方以使`/login`路径工作。例如,这里我们允许未授权的用户访问主页`/`,其他的依旧保持默认: -```java -@Configuration -static class WebSecurityConfiguration extends WebSecurityConfigurerAdapter { - - @Override - public void init(WebSecurity web) { - web.ignore.antMatchers("/"); - } - - @Override - protected void configure(HttpSecurity http) throws Exception { - http.antMatcher("/**").authorizeRequests().anyRequest().authenticated(); - } - -} -``` diff --git a/SUMMARY.md b/SUMMARY.md index cb47804d..59d5278a 100644 --- a/SUMMARY.md +++ b/SUMMARY.md @@ -155,12 +155,7 @@ * [28.1 MVC安全](IV. Spring Boot features/28.1 MVC Security.md) * [28.2 WebFlux安全](IV. Spring Boot features/28.2 WebFlux Security.md) * [28.3 OAuth2](IV. Spring Boot features/28.3 OAuth2.md) - * [28.1.1 授权服务器](IV. Spring Boot features/28.1.1 Authorization Server.md) - * [28.1.2 资源服务器](IV. Spring Boot features/28.1.2 Resource Server.md) - * [28.2 User Info中的Token类型](IV. Spring Boot features/28.2 Token Type in User Info.md) - * [28.3 自定义User Info RestTemplate](IV. Spring Boot features/28.3 Customizing the User Info RestTemplate.md) * [28.3.1 客户端](IV. Spring Boot features/28.3.1 Client.md) - * [28.3.2 单点登陆](IV. Spring Boot features/28.3.2 Single Sign On.md) * [28.4 Actuator安全](IV. Spring Boot features/28.4 Actuator Security.md) * [29. 使用SQL数据库](IV. Spring Boot features/29. Working with SQL databases.md) * [29.1. 配置DataSource](IV. Spring Boot features/29.1. Configure a DataSource.md) From 254b4b1bb710a0182ed97ee9ea49719ac150f317 Mon Sep 17 00:00:00 2001 From: Jack Zhong Date: Thu, 22 Nov 2018 22:48:22 +0800 Subject: [PATCH 231/865] =?UTF-8?q?=E7=BF=BB=E8=AF=9128.4=20=E6=89=A7?= =?UTF-8?q?=E8=A1=8C=E5=99=A8=E5=AE=89=E5=85=A8?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- IV. Spring Boot features/28.4 Actuator Security.md | 11 ++++------- SUMMARY.md | 2 +- 2 files changed, 5 insertions(+), 8 deletions(-) diff --git a/IV. Spring Boot features/28.4 Actuator Security.md b/IV. Spring Boot features/28.4 Actuator Security.md index 790592be..343caa12 100644 --- a/IV. Spring Boot features/28.4 Actuator Security.md +++ b/IV. Spring Boot features/28.4 Actuator Security.md @@ -1,10 +1,7 @@ -### 28.4 Actuator安全 -如果Actuator处于使用中,你会发现: +### 28.4 执行器安全 -* 管理的端点是安全的,即使应用端点不安全。 -* Security事件转换为`AuditEvent`实例,并发布到`AuditEventRepository`。 -* 默认用户拥有`ACTUATOR`和`USER`角色。 - -Actuator的安全特性可以通过外部配置属性(`management.security.*`)进行修改。为了覆盖应用访问规则但不覆盖actuator的访问规则,你可以添加一个`WebSecurityConfigurerAdapter`类型的`@Bean`,并注解`@Order(SecurityProperties.ACCESS_OVERRIDE_ORDER)`,如果想覆盖actuator访问规则,则注解`@Order(ManagementServerProperties.ACCESS_OVERRIDE_ORDER)`。 +为了安全,`/health`与`/info`之外的所有执行器都默认禁用。可以使用`management.endpoints.web.exposure.include`属性启用执行器。 +如果Spring Security在类路径上,并且没有其它的`WebSecurityConfigurerAdapter`,执行器会受到Spring Boot自动配置的保护。如果你自定义了一个`WebSecurityConfigurerAdapter`,Spring Boot将不会自动配置,你将完全掌控执行器的访问规则。 +**注** 在设置`management.endpoints.web.exposure.include`之前,确保暴露的执行器不包含敏感信息,并且/或者将它们放在防火墙后面,或是通过Spring Security等进行保护。 \ No newline at end of file diff --git a/SUMMARY.md b/SUMMARY.md index 59d5278a..2e61ce9c 100644 --- a/SUMMARY.md +++ b/SUMMARY.md @@ -156,7 +156,7 @@ * [28.2 WebFlux安全](IV. Spring Boot features/28.2 WebFlux Security.md) * [28.3 OAuth2](IV. Spring Boot features/28.3 OAuth2.md) * [28.3.1 客户端](IV. Spring Boot features/28.3.1 Client.md) - * [28.4 Actuator安全](IV. Spring Boot features/28.4 Actuator Security.md) + * [28.4 执行器安全](IV. Spring Boot features/28.4 Actuator Security.md) * [29. 使用SQL数据库](IV. Spring Boot features/29. Working with SQL databases.md) * [29.1. 配置DataSource](IV. Spring Boot features/29.1. Configure a DataSource.md) * [29.1.1. 对内嵌数据库的支持](IV. Spring Boot features/29.1.1. Embedded Database Support.md) From cf743da80384abe5a74665a28f1de2f8b29b58d8 Mon Sep 17 00:00:00 2001 From: Jack Zhong Date: Sun, 25 Nov 2018 22:17:06 +0800 Subject: [PATCH 232/865] =?UTF-8?q?=E7=BF=BB=E8=AF=9128.4.1=20=E8=B7=A8?= =?UTF-8?q?=E7=AB=99=E8=AF=B7=E6=B1=82=E4=BC=AA=E9=80=A0=E4=BF=9D=E6=8A=A4?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../28.4.1 Cross Site Request Forgery Protection.md | 7 +++++++ SUMMARY.md | 1 + 2 files changed, 8 insertions(+) create mode 100644 IV. Spring Boot features/28.4.1 Cross Site Request Forgery Protection.md diff --git a/IV. Spring Boot features/28.4.1 Cross Site Request Forgery Protection.md b/IV. Spring Boot features/28.4.1 Cross Site Request Forgery Protection.md new file mode 100644 index 00000000..f2dd46b9 --- /dev/null +++ b/IV. Spring Boot features/28.4.1 Cross Site Request Forgery Protection.md @@ -0,0 +1,7 @@ +### 28.4.1 跨站请求伪造保护 + +由于Spring Boot依赖Spring Security的默认配置,CSRF保护默认启用。这意味着:当默认安全配置在使用中时,需要`POST`(关机和记录器端点)、`PUT`或者`DELETE`的执行器端点会得到一个403的禁止错误。 + +**注** 我们推荐只在创建由非浏览器客户端使用的服务时,完全禁用CSRF保护。 + +可以在[Spring Security参考指南](https://docs.spring.io/spring-security/site/docs/5.0.3.RELEASE/reference/htmlsingle#csrf)查看与CSRF保护相关的额外信息。 \ No newline at end of file diff --git a/SUMMARY.md b/SUMMARY.md index 2e61ce9c..69bdebbd 100644 --- a/SUMMARY.md +++ b/SUMMARY.md @@ -157,6 +157,7 @@ * [28.3 OAuth2](IV. Spring Boot features/28.3 OAuth2.md) * [28.3.1 客户端](IV. Spring Boot features/28.3.1 Client.md) * [28.4 执行器安全](IV. Spring Boot features/28.4 Actuator Security.md) + * [28.4.1 跨站请求伪造保护](IV. Spring Boot features/28.4.1 Cross Site Request Forgery Protection.md) * [29. 使用SQL数据库](IV. Spring Boot features/29. Working with SQL databases.md) * [29.1. 配置DataSource](IV. Spring Boot features/29.1. Configure a DataSource.md) * [29.1.1. 对内嵌数据库的支持](IV. Spring Boot features/29.1.1. Embedded Database Support.md) From 77e6deb075adc885c46352c329b284c94d130be8 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E7=83=AD=E5=BF=83=E5=B8=82=E6=B0=91=E9=92=9F=E5=B0=8F?= =?UTF-8?q?=E5=BC=BA?= Date: Sun, 2 Dec 2018 22:44:42 +0800 Subject: [PATCH 233/865] Update and rename 29. Working with SQL databases.md to 29. Working with SQL Databases.md --- IV. Spring Boot features/29. Working with SQL Databases.md | 3 +++ IV. Spring Boot features/29. Working with SQL databases.md | 3 --- 2 files changed, 3 insertions(+), 3 deletions(-) create mode 100644 IV. Spring Boot features/29. Working with SQL Databases.md delete mode 100644 IV. Spring Boot features/29. Working with SQL databases.md diff --git a/IV. Spring Boot features/29. Working with SQL Databases.md b/IV. Spring Boot features/29. Working with SQL Databases.md new file mode 100644 index 00000000..e963d3d1 --- /dev/null +++ b/IV. Spring Boot features/29. Working with SQL Databases.md @@ -0,0 +1,3 @@ +### 29. 使用SQL数据库 + +Spring框架为使用SQL数据库提供了广泛支持,从使用`JdbcTemplate`直接访问JDBC到完全的“对象关系映射”技术,比如Hibernate。Spring Data提供了更高级的功能:直接从接口创建`Repository`实现,并根据约定从方法名生成查询。 diff --git a/IV. Spring Boot features/29. Working with SQL databases.md b/IV. Spring Boot features/29. Working with SQL databases.md deleted file mode 100644 index eeaed696..00000000 --- a/IV. Spring Boot features/29. Working with SQL databases.md +++ /dev/null @@ -1,3 +0,0 @@ -### 29. 使用SQL数据库 - -Spring框架为使用SQL数据库提供了广泛支持,从使用`JdbcTemplate`直接访问JDBC到完全的‘对象关系映射’技术,比如Hibernate。Spring Data提供了更高级的功能,直接从接口创建`Repository`实现,并根据约定从方法名生成查询。 From be7cb87a99cf2d7d8e34edbdb038ebeb0fa5b033 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E7=83=AD=E5=BF=83=E5=B8=82=E6=B0=91=E9=92=9F=E5=B0=8F?= =?UTF-8?q?=E5=BC=BA?= Date: Sun, 2 Dec 2018 22:47:34 +0800 Subject: [PATCH 234/865] Update SUMMARY.md --- SUMMARY.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/SUMMARY.md b/SUMMARY.md index 69bdebbd..26803510 100644 --- a/SUMMARY.md +++ b/SUMMARY.md @@ -158,7 +158,7 @@ * [28.3.1 客户端](IV. Spring Boot features/28.3.1 Client.md) * [28.4 执行器安全](IV. Spring Boot features/28.4 Actuator Security.md) * [28.4.1 跨站请求伪造保护](IV. Spring Boot features/28.4.1 Cross Site Request Forgery Protection.md) - * [29. 使用SQL数据库](IV. Spring Boot features/29. Working with SQL databases.md) + * [29. 使用SQL数据库](IV. Spring Boot features/29. Working with SQL Databases.md) * [29.1. 配置DataSource](IV. Spring Boot features/29.1. Configure a DataSource.md) * [29.1.1. 对内嵌数据库的支持](IV. Spring Boot features/29.1.1. Embedded Database Support.md) * [29.1.2. 连接生产环境数据库](IV. Spring Boot features/29.1.2. Connection to a production database.md) From 01b882007a678c108d8fee7df60f7cbe9bb8f798 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E7=83=AD=E5=BF=83=E5=B8=82=E6=B0=91=E9=92=9F=E5=B0=8F?= =?UTF-8?q?=E5=BC=BA?= Date: Tue, 4 Dec 2018 23:08:49 +0800 Subject: [PATCH 235/865] Update 29.1. Configure a DataSource.md --- IV. Spring Boot features/29.1. Configure a DataSource.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/IV. Spring Boot features/29.1. Configure a DataSource.md b/IV. Spring Boot features/29.1. Configure a DataSource.md index fd3be78d..86ac32d8 100644 --- a/IV. Spring Boot features/29.1. Configure a DataSource.md +++ b/IV. Spring Boot features/29.1. Configure a DataSource.md @@ -2,4 +2,4 @@ Java的`javax.sql.DataSource`接口提供了一个标准的使用数据库连接的方法。通常,DataSource使用`URL`和相应的凭证去初始化数据库连接。 -**提示** 查看How-to章节,获取更多的高级示例,典型地完全控制DataSource的配置。 +**提示** 查看[How-to章节](https://docs.spring.io/spring-boot/docs/2.0.0.RELEASE/reference/htmlsingle/#howto-configure-a-datasource),获取更多的高级示例,典型地完全控制DataSource的配置。 From 121c92080e6159c61a7f1514fbd7ef23bc16504f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E7=83=AD=E5=BF=83=E5=B8=82=E6=B0=91=E9=92=9F=E5=B0=8F?= =?UTF-8?q?=E5=BC=BA?= Date: Sat, 5 Jan 2019 21:38:08 +0800 Subject: [PATCH 236/865] Update 29.1.1. Embedded Database Support.md --- IV. Spring Boot features/29.1.1. Embedded Database Support.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/IV. Spring Boot features/29.1.1. Embedded Database Support.md b/IV. Spring Boot features/29.1.1. Embedded Database Support.md index 82fff2f8..98fc546d 100644 --- a/IV. Spring Boot features/29.1.1. Embedded Database Support.md +++ b/IV. Spring Boot features/29.1.1. Embedded Database Support.md @@ -4,12 +4,12 @@ **提示** How-to章节包含有一章讲解如何初始化数据库。 -Spring Boot可以自动配置的内嵌数据库包括[H2](http://www.h2database.com/), [HSQL](http://hsqldb.org/)和[Derby](http://db.apache.org/derby/)。你不需要提供任何连接URLs,只需要添加你想使用的内嵌数据库依赖。 +Spring Boot可以自动配置的内嵌数据库包括[H2](http://www.h2database.com/), [HSQL](http://hsqldb.org/)和[Derby](http://db.apache.org/derby/)。你不需要提供任何连接URL,只需要添加你想使用的内嵌数据库依赖。 **注** 如果你正在你的测试中使用这个特性,你可能注意到了:不管你使用了多少应用上下文,你的整个测试套件重复使用了同一个数据库。如果你想要确保每个上下文各自有一个内嵌数据库,你应当把 `spring.datasource.generate-unique-name`设置为`true`。 -示例:典型的POM依赖如下: +例如,典型的POM依赖如下所示: ```xml org.springframework.boot From 37643d1d0ee81093f5d6d26a459399a1a80d00d4 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E7=83=AD=E5=BF=83=E5=B8=82=E6=B0=91=E9=92=9F=E5=B0=8F?= =?UTF-8?q?=E5=BC=BA?= Date: Sat, 5 Jan 2019 22:43:25 +0800 Subject: [PATCH 237/865] Update and rename 29.1.2. Connection to a production database.md to 29.1.2 Connection to a Production Database.md --- ...9.1.2 Connection to a Production Database.md} | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) rename IV. Spring Boot features/{29.1.2. Connection to a production database.md => 29.1.2 Connection to a Production Database.md} (76%) diff --git a/IV. Spring Boot features/29.1.2. Connection to a production database.md b/IV. Spring Boot features/29.1.2 Connection to a Production Database.md similarity index 76% rename from IV. Spring Boot features/29.1.2. Connection to a production database.md rename to IV. Spring Boot features/29.1.2 Connection to a Production Database.md index 23c685a7..d44e44ce 100644 --- a/IV. Spring Boot features/29.1.2. Connection to a production database.md +++ b/IV. Spring Boot features/29.1.2 Connection to a Production Database.md @@ -1,12 +1,12 @@ -### 29.1.2. 连接生产环境数据库 +### 29.1.2 连接生产环境数据库 -生产环境的数据库连接可以通过池化的`DataSource`进行自动配置,下面是选取特定实现的算法: +生产环境的数据库连接可以通过池化的`DataSource`进行自动配置。Spring Boot使用如下的算法,选取特定实现: -- 出于HikariCP的优秀性能和并发,如果可用总会优先使用它。 -- 如果tomcat数据源连接池可用,我们将使用它。 -- 如果HikariCP和tomcat数据源连接池都不能用。如果Commons DBCP2可用,我们将使用它。 +1. 出于HikariCP的优秀性能和并发,如果可用总会优先使用它。 +2. 如果tomcat数据源连接池可用,我们将使用它。 +3. 如果HikariCP和tomcat数据源连接池都不能用。如果Commons DBCP2可用,我们将使用它。 -如果使用`spring-boot-starter-jdbc`或`spring-boot-starter-data-jpa` 'starters',你会自动添加`HikariCP`依赖。 +如果使用`spring-boot-starter-jdbc`或`spring-boot-starter-data-jpa`”starters“,你会自动添加`HikariCP`依赖。 **注** 通过指定`spring.datasource.type`属性,你可以完全抛弃该算法,然后指定数据库连接池。如果你在tomcat容器中运行应用,由于默认提供`tomcat-jdbc`,这就很重要了。 @@ -23,11 +23,11 @@ spring.datasource.driver-class-name=com.mysql.jdbc.Driver **注** 你经常不需要指定`driver-class-name`,因为Spring boot可以从`url`推断大部分数据库。 -**注** 对于将要创建的池化`DataSource`,我们需要验证是否有一个可用的`Driver`,所以在做其他事前会校验它。比如,如果你设置`spring.datasource.driver-class-name=com.mysql.jdbc.Driver`,然后该class加载出来,否则就会出错。 +**注** 对于将要创建的池化`DataSource`,我们需要验证是否有一个可用的`Driver`,所以在做其他事前会校验它。也就是说,如果你设置`spring.datasource.driver-class-name=com.mysql.jdbc.Driver`,然后该class加载出来,否则就会出错。 其他可选配置可以查看[DataSourceProperties](https://github.com/spring-projects/spring-boot/tree/v2.0.0.RELEASE/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/jdbc/DataSourceProperties.java),有些标准配置是跟实现无关的,对于实现相关的配置可以通过相应前缀进行设置(`spring.datasource.hikari.*`,`spring.datasource.tomcat.*`和`spring.datasource.dbcp2.*`),具体参考你使用的连接池文档。 -例如,如果正在使用[Tomcat连接池](http://tomcat.apache.org/tomcat-8.0-doc/jdbc-pool.html#Common_Attributes),你可以自定义很多其他设置: +例如,如果正在使用[Tomcat连接池](http://tomcat.apache.org/tomcat-8.0-doc/jdbc-pool.html#Common_Attributes),你可以自定义很多其他设置,如下所示: ```properties # Number of ms to wait before throwing an exception if no connection is available. spring.datasource.tomcat.max-wait=10000 From dd95987eb706d68617588723021bf0b05382a0ab Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E7=83=AD=E5=BF=83=E5=B8=82=E6=B0=91=E9=92=9F=E5=B0=8F?= =?UTF-8?q?=E5=BC=BA?= Date: Sat, 5 Jan 2019 22:48:27 +0800 Subject: [PATCH 238/865] Update 29.1.2 Connection to a Production Database.md --- .../29.1.2 Connection to a Production Database.md | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/IV. Spring Boot features/29.1.2 Connection to a Production Database.md b/IV. Spring Boot features/29.1.2 Connection to a Production Database.md index d44e44ce..037f9678 100644 --- a/IV. Spring Boot features/29.1.2 Connection to a Production Database.md +++ b/IV. Spring Boot features/29.1.2 Connection to a Production Database.md @@ -2,9 +2,9 @@ 生产环境的数据库连接可以通过池化的`DataSource`进行自动配置。Spring Boot使用如下的算法,选取特定实现: -1. 出于HikariCP的优秀性能和并发,如果可用总会优先使用它。 +1. 出于[HikariCP](https://github.com/brettwooldridge/HikariCP)的优秀性能和并发,如果可用总会优先使用它。 2. 如果tomcat数据源连接池可用,我们将使用它。 -3. 如果HikariCP和tomcat数据源连接池都不能用。如果Commons DBCP2可用,我们将使用它。 +3. 如果HikariCP和tomcat数据源连接池都不能用。如果[Commons DBCP2](https://commons.apache.org/proper/commons-dbcp/)可用,我们将使用它。 如果使用`spring-boot-starter-jdbc`或`spring-boot-starter-data-jpa`”starters“,你会自动添加`HikariCP`依赖。 @@ -25,9 +25,9 @@ spring.datasource.driver-class-name=com.mysql.jdbc.Driver **注** 对于将要创建的池化`DataSource`,我们需要验证是否有一个可用的`Driver`,所以在做其他事前会校验它。也就是说,如果你设置`spring.datasource.driver-class-name=com.mysql.jdbc.Driver`,然后该class加载出来,否则就会出错。 -其他可选配置可以查看[DataSourceProperties](https://github.com/spring-projects/spring-boot/tree/v2.0.0.RELEASE/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/jdbc/DataSourceProperties.java),有些标准配置是跟实现无关的,对于实现相关的配置可以通过相应前缀进行设置(`spring.datasource.hikari.*`,`spring.datasource.tomcat.*`和`spring.datasource.dbcp2.*`),具体参考你使用的连接池文档。 +其他可选配置可以查看[DataSourceProperties](https://github.com/spring-projects/spring-boot/tree/v2.0.0.RELEASE/spring-boot-project/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/jdbc/DataSourceProperties.java),有些标准配置是跟实现无关的,对于实现相关的配置可以通过相应前缀进行设置(`spring.datasource.hikari.*`,`spring.datasource.tomcat.*`和`spring.datasource.dbcp2.*`),具体参考你使用的连接池文档。 -例如,如果正在使用[Tomcat连接池](http://tomcat.apache.org/tomcat-8.0-doc/jdbc-pool.html#Common_Attributes),你可以自定义很多其他设置,如下所示: +例如,如果正在使用[Tomcat连接池](https://tomcat.apache.org/tomcat-8.0-doc/jdbc-pool.html#Common_Attributes),你可以自定义很多其他设置,如下所示: ```properties # Number of ms to wait before throwing an exception if no connection is available. spring.datasource.tomcat.max-wait=10000 From c1f5d65d590c68f1cdaa0558c8a57da0284bf087 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E7=83=AD=E5=BF=83=E5=B8=82=E6=B0=91=E9=92=9F=E5=B0=8F?= =?UTF-8?q?=E5=BC=BA?= Date: Sat, 5 Jan 2019 22:51:02 +0800 Subject: [PATCH 239/865] Update 29.1.1. Embedded Database Support.md --- IV. Spring Boot features/29.1.1. Embedded Database Support.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/IV. Spring Boot features/29.1.1. Embedded Database Support.md b/IV. Spring Boot features/29.1.1. Embedded Database Support.md index 98fc546d..7938a5ee 100644 --- a/IV. Spring Boot features/29.1.1. Embedded Database Support.md +++ b/IV. Spring Boot features/29.1.1. Embedded Database Support.md @@ -2,9 +2,9 @@ 开发应用时使用内存数据库是很方便的。显然,内存数据库不提供持久化存储;你只需要在应用启动时填充数据库,在应用结束前预先清除数据。 -**提示** How-to章节包含有一章讲解如何初始化数据库。 +**提示** How-to章节包含有[一章讲解如何初始化数据库](https://docs.spring.io/spring-boot/docs/2.0.0.RELEASE/reference/htmlsingle/#howto-database-initialization)。 -Spring Boot可以自动配置的内嵌数据库包括[H2](http://www.h2database.com/), [HSQL](http://hsqldb.org/)和[Derby](http://db.apache.org/derby/)。你不需要提供任何连接URL,只需要添加你想使用的内嵌数据库依赖。 +Spring Boot可以自动配置的内嵌数据库包括[H2](http://www.h2database.com/), [HSQL](http://hsqldb.org/)和[Derby](https://db.apache.org/derby/)。你不需要提供任何连接URL,只需要添加你想使用的内嵌数据库依赖。 **注** 如果你正在你的测试中使用这个特性,你可能注意到了:不管你使用了多少应用上下文,你的整个测试套件重复使用了同一个数据库。如果你想要确保每个上下文各自有一个内嵌数据库,你应当把 `spring.datasource.generate-unique-name`设置为`true`。 From 1c2211bc5127c092f361ec9969d85fc6b99422ee Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E7=83=AD=E5=BF=83=E5=B8=82=E6=B0=91=E9=92=9F=E5=B0=8F?= =?UTF-8?q?=E5=BC=BA?= Date: Sat, 5 Jan 2019 23:01:42 +0800 Subject: [PATCH 240/865] Update 29.1.3. Connection to a JNDI DataSource.md --- .../29.1.3. Connection to a JNDI DataSource.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/IV. Spring Boot features/29.1.3. Connection to a JNDI DataSource.md b/IV. Spring Boot features/29.1.3. Connection to a JNDI DataSource.md index 044fc32a..e1d6a4b2 100644 --- a/IV. Spring Boot features/29.1.3. Connection to a JNDI DataSource.md +++ b/IV. Spring Boot features/29.1.3. Connection to a JNDI DataSource.md @@ -2,7 +2,7 @@ 如果正在将Spring Boot应用部署到一个应用服务器,你可能想要用应用服务器内建的特性来配置和管理你的DataSource,并使用JNDI访问它。 -`spring.datasource.jndi-name`属性可用来替代`spring.datasource.url`,`spring.datasource.username`和`spring.datasource.password`去从一个特定的JNDI路径获取`DataSource`,比如,以下`application.properties`中的片段展示了如何获取JBoss AS定义的`DataSource`: +`spring.datasource.jndi-name`属性可用来替代`spring.datasource.url`、`spring.datasource.username`和`spring.datasource.password`,去从一个特定的JNDI路径获取`DataSource`。比如,以下`application.properties`中的片段展示了如何获取JBoss AS定义的`DataSource`: ```java spring.datasource.jndi-name=java:jboss/datasources/customers ``` From 3f7b8aee901934d8950a6bf438a74529f92eb893 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E7=83=AD=E5=BF=83=E5=B8=82=E6=B0=91=E9=92=9F=E5=B0=8F?= =?UTF-8?q?=E5=BC=BA?= Date: Sat, 5 Jan 2019 23:11:19 +0800 Subject: [PATCH 241/865] Update and rename 29.1.2 Connection to a Production Database.md to 29.1.2. Connection to a Production Database.md --- ...tabase.md => 29.1.2. Connection to a Production Database.md} | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) rename IV. Spring Boot features/{29.1.2 Connection to a Production Database.md => 29.1.2. Connection to a Production Database.md} (96%) diff --git a/IV. Spring Boot features/29.1.2 Connection to a Production Database.md b/IV. Spring Boot features/29.1.2. Connection to a Production Database.md similarity index 96% rename from IV. Spring Boot features/29.1.2 Connection to a Production Database.md rename to IV. Spring Boot features/29.1.2. Connection to a Production Database.md index 037f9678..2d3038ff 100644 --- a/IV. Spring Boot features/29.1.2 Connection to a Production Database.md +++ b/IV. Spring Boot features/29.1.2. Connection to a Production Database.md @@ -6,7 +6,7 @@ 2. 如果tomcat数据源连接池可用,我们将使用它。 3. 如果HikariCP和tomcat数据源连接池都不能用。如果[Commons DBCP2](https://commons.apache.org/proper/commons-dbcp/)可用,我们将使用它。 -如果使用`spring-boot-starter-jdbc`或`spring-boot-starter-data-jpa`”starters“,你会自动添加`HikariCP`依赖。 +如果使用`spring-boot-starter-jdbc`或`spring-boot-starter-data-jpa`“starters”,你会自动添加`HikariCP`依赖。 **注** 通过指定`spring.datasource.type`属性,你可以完全抛弃该算法,然后指定数据库连接池。如果你在tomcat容器中运行应用,由于默认提供`tomcat-jdbc`,这就很重要了。 From 90cdbdf3cac02b3e58b41bd460026b5f913cb1f2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E7=83=AD=E5=BF=83=E5=B8=82=E6=B0=91=E9=92=9F=E5=B0=8F?= =?UTF-8?q?=E5=BC=BA?= Date: Sun, 6 Jan 2019 14:30:14 +0800 Subject: [PATCH 242/865] Rename 29.1.2. Connection to a Production Database.md to 29.1.2. Connection to a production database.md --- ...Database.md => 29.1.2. Connection to a production database.md} | 0 1 file changed, 0 insertions(+), 0 deletions(-) rename IV. Spring Boot features/{29.1.2. Connection to a Production Database.md => 29.1.2. Connection to a production database.md} (100%) diff --git a/IV. Spring Boot features/29.1.2. Connection to a Production Database.md b/IV. Spring Boot features/29.1.2. Connection to a production database.md similarity index 100% rename from IV. Spring Boot features/29.1.2. Connection to a Production Database.md rename to IV. Spring Boot features/29.1.2. Connection to a production database.md From 0fdca786935f0fa93d361e9a45026fb002b95687 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E7=83=AD=E5=BF=83=E5=B8=82=E6=B0=91=E9=92=9F=E5=B0=8F?= =?UTF-8?q?=E5=BC=BA?= Date: Sun, 6 Jan 2019 14:36:12 +0800 Subject: [PATCH 243/865] Update SUMMARY.md --- SUMMARY.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/SUMMARY.md b/SUMMARY.md index 26803510..26f5ae93 100644 --- a/SUMMARY.md +++ b/SUMMARY.md @@ -161,7 +161,7 @@ * [29. 使用SQL数据库](IV. Spring Boot features/29. Working with SQL Databases.md) * [29.1. 配置DataSource](IV. Spring Boot features/29.1. Configure a DataSource.md) * [29.1.1. 对内嵌数据库的支持](IV. Spring Boot features/29.1.1. Embedded Database Support.md) - * [29.1.2. 连接生产环境数据库](IV. Spring Boot features/29.1.2. Connection to a production database.md) + * [29.1.2. 连接生产环境数据库](IV. Spring Boot features/29.1.2. Connection to a Production Database.md) * [29.1.3. 连接JNDI数据库](IV. Spring Boot features/29.1.3. Connection to a JNDI DataSource.md) * [29.2. 使用JdbcTemplate](IV. Spring Boot features/29.2. Using JdbcTemplate.md) * [29.3. JPA和Spring Data](IV. Spring Boot features/29.3. JPA and ‘Spring Data’.md) From 59426264e1c00261fea5021679f1491c959391c8 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E7=83=AD=E5=BF=83=E5=B8=82=E6=B0=91=E9=92=9F=E5=B0=8F?= =?UTF-8?q?=E5=BC=BA?= Date: Sun, 6 Jan 2019 14:37:03 +0800 Subject: [PATCH 244/865] Rename 29.1.2. Connection to a production database.md to 29.1.2. Connection to a Production Database.md --- ...database.md => 29.1.2. Connection to a Production Database.md} | 0 1 file changed, 0 insertions(+), 0 deletions(-) rename IV. Spring Boot features/{29.1.2. Connection to a production database.md => 29.1.2. Connection to a Production Database.md} (100%) diff --git a/IV. Spring Boot features/29.1.2. Connection to a production database.md b/IV. Spring Boot features/29.1.2. Connection to a Production Database.md similarity index 100% rename from IV. Spring Boot features/29.1.2. Connection to a production database.md rename to IV. Spring Boot features/29.1.2. Connection to a Production Database.md From 7a622ed629c98d1161cf368b4fcdee2d5d86735c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E7=83=AD=E5=BF=83=E5=B8=82=E6=B0=91=E9=92=9F=E5=B0=8F?= =?UTF-8?q?=E5=BC=BA?= Date: Mon, 7 Jan 2019 20:43:03 +0800 Subject: [PATCH 245/865] Update 29.2. Using JdbcTemplate.md --- IV. Spring Boot features/29.2. Using JdbcTemplate.md | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/IV. Spring Boot features/29.2. Using JdbcTemplate.md b/IV. Spring Boot features/29.2. Using JdbcTemplate.md index 1f3b7b78..3241fecd 100644 --- a/IV. Spring Boot features/29.2. Using JdbcTemplate.md +++ b/IV. Spring Boot features/29.2. Using JdbcTemplate.md @@ -1,6 +1,6 @@ ### 29.2. 使用JdbcTemplate -Spring的`JdbcTemplate`和`NamedParameterJdbcTemplate`类会被自动配置,你可以将它们直接`@Autowire`到自己的beans: +Spring的`JdbcTemplate`和`NamedParameterJdbcTemplate`类会被自动配置,你可以将它们直接`@Autowire`到自己的bean,如下所示: ```java import org.springframework.beans.factory.annotation.Autowired; import org.springframework.jdbc.core.JdbcTemplate; @@ -19,9 +19,9 @@ public class MyBean { } ``` -你可以使用`spring.jdbc.template.*`属性自定义模版的一些属性: +你可以使用`spring.jdbc.template.*`属性自定义模版的一些属性,如下所示: ```properties spring.jdbc.template.max-rows=500 ``` -**提示** `NamedParameterJdbcTemplate`在幕后重复使用了同一个`JdbcTemplate`实例。如果定义了不止一个`JdbcTemplate`,而且不存在候选,`NamedParameterJdbcTemplate`就没有被自动配置。 \ No newline at end of file +**提示** `NamedParameterJdbcTemplate`在幕后重复使用了同一个`JdbcTemplate`实例。如果定义了不止一个`JdbcTemplate`,而且不存在候选,`NamedParameterJdbcTemplate`就没有被自动配置。 From 5da9ea2aafeb8a9ea0bbeca85f410820c5daf213 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E7=83=AD=E5=BF=83=E5=B8=82=E6=B0=91=E9=92=9F=E5=B0=8F?= =?UTF-8?q?=E5=BC=BA?= Date: Fri, 1 Feb 2019 11:52:03 +0800 Subject: [PATCH 246/865] =?UTF-8?q?Update=20and=20rename=2029.3.=20JPA=20a?= =?UTF-8?q?nd=20=E2=80=98Spring=20Data=E2=80=99.md=20to=2029.3.=20JPA=20an?= =?UTF-8?q?d=20"Spring=20Data".md?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../29.3. JPA and \"Spring Data\".md" | 9 +++++++++ ...29.3. JPA and \342\200\230Spring Data\342\200\231.md" | 9 --------- 2 files changed, 9 insertions(+), 9 deletions(-) create mode 100644 "IV. Spring Boot features/29.3. JPA and \"Spring Data\".md" delete mode 100644 "IV. Spring Boot features/29.3. JPA and \342\200\230Spring Data\342\200\231.md" diff --git "a/IV. Spring Boot features/29.3. JPA and \"Spring Data\".md" "b/IV. Spring Boot features/29.3. JPA and \"Spring Data\".md" new file mode 100644 index 00000000..33132666 --- /dev/null +++ "b/IV. Spring Boot features/29.3. JPA and \"Spring Data\".md" @@ -0,0 +1,9 @@ +### 29.3. JPA和Spring Data + +Java持久化API是一个让你将对象映射为关系数据库的标准技术。`spring-boot-starter-data-jpa` POM提供了一种快速上手的方式,它提供以下关键依赖: + +- Hibernate:一个非常流行的JPA实现。 +- Spring Data JPA:让实现基于JPA的repositories更容易。 +- Spring ORMs:Spring框架支持的核心ORM。 + +**注** 我们不想在这涉及太多关于JPA或[Spring Data](https://projects.spring.io/spring-data/)的细节。你可以参考来自[spring.io](https://spring.io/)的指南[使用JPA获取数据](https://spring.io/guides/gs/accessing-data-jpa/),并阅读[Spring Data JPA](https://projects.spring.io/spring-data-jpa/)和[Hibernate](https://hibernate.org/orm/documentation/)的参考文档。 diff --git "a/IV. Spring Boot features/29.3. JPA and \342\200\230Spring Data\342\200\231.md" "b/IV. Spring Boot features/29.3. JPA and \342\200\230Spring Data\342\200\231.md" deleted file mode 100644 index 9068e841..00000000 --- "a/IV. Spring Boot features/29.3. JPA and \342\200\230Spring Data\342\200\231.md" +++ /dev/null @@ -1,9 +0,0 @@ -### 29.3. JPA和Spring Data - -Java持久化API是一个允许你将对象映射为关系数据库的标准技术,`spring-boot-starter-data-jpa` POM提供了一种快速上手的方式,它提供以下关键依赖: - -- Hibernate - 一个非常流行的JPA实现。 -- Spring Data JPA - 让实现基于JPA的repositories更容易。 -- Spring ORMs - Spring框架支持的核心ORM。 - -**注** 我们不想在这涉及太多关于JPA或Spring Data的细节。你可以参考来自[spring.io](http://spring.io/)的指南[使用JPA获取数据](http://spring.io/guides/gs/accessing-data-jpa/),并阅读[Spring Data JPA](http://projects.spring.io/spring-data-jpa/)和[Hibernate](http://hibernate.org/orm/documentation/)的参考文档。 From 353d44e1a397ecb4734ccce2c3289fb821493cb3 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E7=83=AD=E5=BF=83=E5=B8=82=E6=B0=91=E9=92=9F=E5=B0=8F?= =?UTF-8?q?=E5=BC=BA?= Date: Fri, 1 Feb 2019 11:53:07 +0800 Subject: [PATCH 247/865] Update SUMMARY.md --- SUMMARY.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/SUMMARY.md b/SUMMARY.md index 26f5ae93..f82b1723 100644 --- a/SUMMARY.md +++ b/SUMMARY.md @@ -164,7 +164,7 @@ * [29.1.2. 连接生产环境数据库](IV. Spring Boot features/29.1.2. Connection to a Production Database.md) * [29.1.3. 连接JNDI数据库](IV. Spring Boot features/29.1.3. Connection to a JNDI DataSource.md) * [29.2. 使用JdbcTemplate](IV. Spring Boot features/29.2. Using JdbcTemplate.md) - * [29.3. JPA和Spring Data](IV. Spring Boot features/29.3. JPA and ‘Spring Data’.md) + * [29.3. JPA和Spring Data](IV. Spring Boot features/29.3. JPA and "Spring Data".md) * [29.3.1. 实体类](IV. Spring Boot features/29.3.1. Entity Classes.md) * [29.3.2. Spring Data JPA仓库](IV. Spring Boot features/29.3.2. Spring Data JPA Repositories.md) * [29.3.3. 创建和删除JPA数据库](IV. Spring Boot features/29.3.3. Creating and dropping JPA databases.md) From d637184a3346c484b7f88f1a2c83ff6c383ec111 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E7=83=AD=E5=BF=83=E5=B8=82=E6=B0=91=E9=92=9F=E5=B0=8F?= =?UTF-8?q?=E5=BC=BA?= Date: Fri, 1 Feb 2019 15:21:09 +0800 Subject: [PATCH 248/865] Rename 29.3. JPA and "Spring Data".md to 29.3. JPA and Spring Data.md --- .../29.3. JPA and Spring Data.md | 0 1 file changed, 0 insertions(+), 0 deletions(-) rename "IV. Spring Boot features/29.3. JPA and \"Spring Data\".md" => IV. Spring Boot features/29.3. JPA and Spring Data.md (100%) diff --git "a/IV. Spring Boot features/29.3. JPA and \"Spring Data\".md" b/IV. Spring Boot features/29.3. JPA and Spring Data.md similarity index 100% rename from "IV. Spring Boot features/29.3. JPA and \"Spring Data\".md" rename to IV. Spring Boot features/29.3. JPA and Spring Data.md From b54d27b0b0ecd99a81209d9c23e11840133bdcaf Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E7=83=AD=E5=BF=83=E5=B8=82=E6=B0=91=E9=92=9F=E5=B0=8F?= =?UTF-8?q?=E5=BC=BA?= Date: Fri, 1 Feb 2019 15:23:02 +0800 Subject: [PATCH 249/865] Update SUMMARY.md --- SUMMARY.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/SUMMARY.md b/SUMMARY.md index f82b1723..7cb9b067 100644 --- a/SUMMARY.md +++ b/SUMMARY.md @@ -164,7 +164,7 @@ * [29.1.2. 连接生产环境数据库](IV. Spring Boot features/29.1.2. Connection to a Production Database.md) * [29.1.3. 连接JNDI数据库](IV. Spring Boot features/29.1.3. Connection to a JNDI DataSource.md) * [29.2. 使用JdbcTemplate](IV. Spring Boot features/29.2. Using JdbcTemplate.md) - * [29.3. JPA和Spring Data](IV. Spring Boot features/29.3. JPA and "Spring Data".md) + * [29.3. JPA和Spring Data](IV. Spring Boot features/29.3. JPA and Spring Data.md) * [29.3.1. 实体类](IV. Spring Boot features/29.3.1. Entity Classes.md) * [29.3.2. Spring Data JPA仓库](IV. Spring Boot features/29.3.2. Spring Data JPA Repositories.md) * [29.3.3. 创建和删除JPA数据库](IV. Spring Boot features/29.3.3. Creating and dropping JPA databases.md) From 7c829112dd90035334fe24db62d52ca69b89731f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E7=83=AD=E5=BF=83=E5=B8=82=E6=B0=91=E9=92=9F=E5=B0=8F?= =?UTF-8?q?=E5=BC=BA?= Date: Thu, 28 Feb 2019 21:02:28 +0800 Subject: [PATCH 250/865] Update 29.3.1. Entity Classes.md --- IV. Spring Boot features/29.3.1. Entity Classes.md | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/IV. Spring Boot features/29.3.1. Entity Classes.md b/IV. Spring Boot features/29.3.1. Entity Classes.md index 6b8e6e15..14de5f88 100644 --- a/IV. Spring Boot features/29.3.1. Entity Classes.md +++ b/IV. Spring Boot features/29.3.1. Entity Classes.md @@ -1,8 +1,8 @@ ### 29.3.1. 实体类 -通常,JPA实体类被定义到一个`persistence.xml`文件,在Spring Boot中,这个文件被'实体扫描'取代。默认情况,Spring Boot会查找主配置类(被`@EnableAutoConfiguration`或`@SpringBootApplication`注解的类)下的所有包。 +通常,JPA实体类被定义到一个`persistence.xml`文件。在Spring Boot中,这个文件被“实体扫描”取代。默认的,Spring Boot会查找主配置类(被`@EnableAutoConfiguration`或`@SpringBootApplication`注解的类)下的所有包。 -任何被`@Entity`,`@Embeddable`或`@MappedSuperclass`注解的类都将被考虑,一个普通的实体类看起来像这样: +任何被`@Entity`,`@Embeddable`或`@MappedSuperclass`注解的类都将被考虑。一个普通的实体类看起来像这样: ```java package com.example.myapp.domain; @@ -44,4 +44,4 @@ public class City implements Serializable { // ... etc } ``` -**注** 你可以使用`@EntityScan`注解自定义实体扫描路径,具体参考[章节 78.4,从Spring配置分离`@Entity`定义](../IX. ‘How-to’ guides/78.4. Separate @Entity definitions from Spring configuration.md)。 +**注** 你可以使用`@EntityScan`注解自定义实体扫描路径,具体参考[章节 79.4,从Spring配置分离`@Entity`定义](../IX. ‘How-to’ guides/79.4. Separate @Entity Definitions from Spring Configuration.md)。 From 4a1890a9dbfdd2453d9f47e48d3c924ba9d95b22 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E7=83=AD=E5=BF=83=E5=B8=82=E6=B0=91=E9=92=9F=E5=B0=8F?= =?UTF-8?q?=E5=BC=BA?= Date: Sun, 3 Mar 2019 16:14:57 +0800 Subject: [PATCH 251/865] Update 29.3.2. Spring Data JPA Repositories.md --- .../29.3.2. Spring Data JPA Repositories.md | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/IV. Spring Boot features/29.3.2. Spring Data JPA Repositories.md b/IV. Spring Boot features/29.3.2. Spring Data JPA Repositories.md index ca0267d2..f9dbb971 100644 --- a/IV. Spring Boot features/29.3.2. Spring Data JPA Repositories.md +++ b/IV. Spring Boot features/29.3.2. Spring Data JPA Repositories.md @@ -1,12 +1,12 @@ ### 29.3.2. Spring Data JPA仓库 -Spring Data JPA仓库(repositories)是用来定义访问数据的接口。根据你的方法名,JPA查询会被自动创建,比如,一个`CityRepository`接口可能声明一个`findAllByState(String state)`方法,用来查找给定状态的所有城市。 +[Spring Data JPA](http://projects.spring.io/spring-data-jpa/)仓库是用来定义访问数据的接口。根据你的方法名,JPA查询会被自动创建,比如,一个`CityRepository`接口可能声明一个`findAllByState(String state)`方法,用来查找给定状态的所有城市。 -对于比较复杂的查询,你可以使用Spring Data的[`Query`](http://docs.spring.io/spring-data/jpa/docs/current/api/org/springframework/data/jpa/repository/Query.html)注解你的方法。 +对于比较复杂的查询,你可以使用Spring Data的[`Query`](https://docs.spring.io/spring-data/jpa/docs/current/api/org/springframework/data/jpa/repository/Query.html)注解你的方法。 -Spring Data仓库通常继承自[`Repository`](http://docs.spring.io/spring-data/commons/docs/current/api/org/springframework/data/repository/Repository.html)或[`CrudRepository`](http://docs.spring.io/spring-data/commons/docs/current/api/org/springframework/data/repository/CrudRepository.html)接口。如果你使用自动配置,Spring Boot会搜索主配置类(注解`@EnableAutoConfiguration`或`@SpringBootApplication`的类)所在包下的仓库。 +Spring Data仓库通常继承自[`Repository`](https://docs.spring.io/spring-data/commons/docs/current/api/org/springframework/data/repository/Repository.html)或[`CrudRepository`](https://docs.spring.io/spring-data/commons/docs/current/api/org/springframework/data/repository/CrudRepository.html)接口。如果你使用自动配置,Spring Boot会搜索主配置类(注解`@EnableAutoConfiguration`或`@SpringBootApplication`的类)所在包下的仓库。 -下面是典型的Spring Data仓库: +下面是典型的Spring Data仓库接口定义: ```java package com.example.myapp.domain; @@ -20,4 +20,4 @@ public interface CityRepository extends Repository { City findByNameAndCountryAllIgnoringCase(String name, String country); } ``` -**注**:我们仅仅触及了Spring Data JPA的表面,具体查看它的[参考指南](http://projects.spring.io/spring-data-jpa/)。 +**注**:我们仅仅触及了Spring Data JPA的表面,具体查看它的[参考指南](https://docs.spring.io/spring-data/jpa/docs/current/reference/html/)。 From 70bac56c37edbdd17d8f75d90a14bee41b3fc6d8 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E7=83=AD=E5=BF=83=E5=B8=82=E6=B0=91=E9=92=9F=E5=B0=8F?= =?UTF-8?q?=E5=BC=BA?= Date: Wed, 20 Mar 2019 23:27:49 +0800 Subject: [PATCH 252/865] Update and rename 29.3.3. Creating and dropping JPA databases.md to 29.3.3. Creating and Dropping JPA Databases.md --- ...ases.md => 29.3.3. Creating and Dropping JPA Databases.md} | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) rename IV. Spring Boot features/{29.3.3. Creating and dropping JPA databases.md => 29.3.3. Creating and Dropping JPA Databases.md} (66%) diff --git a/IV. Spring Boot features/29.3.3. Creating and dropping JPA databases.md b/IV. Spring Boot features/29.3.3. Creating and Dropping JPA Databases.md similarity index 66% rename from IV. Spring Boot features/29.3.3. Creating and dropping JPA databases.md rename to IV. Spring Boot features/29.3.3. Creating and Dropping JPA Databases.md index b84c847f..7a592ed2 100644 --- a/IV. Spring Boot features/29.3.3. Creating and dropping JPA databases.md +++ b/IV. Spring Boot features/29.3.3. Creating and Dropping JPA Databases.md @@ -4,6 +4,8 @@ ```properties spring.jpa.hibernate.ddl-auto=create-drop ``` -**注** Hibernate自己内部对创建,删除表支持的属性是`hibernate.hbm2ddl.auto`(如果你记得更好)。你可以使用`spring.jpa.properties.*`(前缀在被添加到实体管理器之前会被去掉)设置Hibernate其他的native属性,比如:`spring.jpa.properties.hibernate.globally_quoted_identifiers=true`将传递`hibernate.globally_quoted_identifiers`到Hibernate实体管理器。 +**注** Hibernate自己内部对创建,删除表支持的属性是`hibernate.hbm2ddl.auto`(如果你记得更好)。你可以使用`spring.jpa.properties.*`设置Hibernate其他的native属性(前缀在被添加到实体管理器之前会被去掉)。下面是给Hibernate设置JPA属性的例子: +`spring.jpa.properties.hibernate.globally_quoted_identifiers=true` +上面的例子将true传递到Hibernate实体管理器里的`hibernate.globally_quoted_identifiers`属性。 通常,DDL执行(或验证)被延迟到`ApplicationContext`启动后,这可以通过`spring.jpa.generate-ddl`标签控制,如果Hibernate自动配置被激活,那该标识就不会被使用,因为`ddl-auto`设置粒度更细。 From c603bd8559538e61e02b8108fb131e79db6303ed Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E7=83=AD=E5=BF=83=E5=B8=82=E6=B0=91=E9=92=9F=E5=B0=8F?= =?UTF-8?q?=E5=BC=BA?= Date: Wed, 20 Mar 2019 23:29:48 +0800 Subject: [PATCH 253/865] Update 29.3.3. Creating and Dropping JPA Databases.md --- .../29.3.3. Creating and Dropping JPA Databases.md | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/IV. Spring Boot features/29.3.3. Creating and Dropping JPA Databases.md b/IV. Spring Boot features/29.3.3. Creating and Dropping JPA Databases.md index 7a592ed2..518fa928 100644 --- a/IV. Spring Boot features/29.3.3. Creating and Dropping JPA Databases.md +++ b/IV. Spring Boot features/29.3.3. Creating and Dropping JPA Databases.md @@ -5,7 +5,9 @@ spring.jpa.hibernate.ddl-auto=create-drop ``` **注** Hibernate自己内部对创建,删除表支持的属性是`hibernate.hbm2ddl.auto`(如果你记得更好)。你可以使用`spring.jpa.properties.*`设置Hibernate其他的native属性(前缀在被添加到实体管理器之前会被去掉)。下面是给Hibernate设置JPA属性的例子: +```properties `spring.jpa.properties.hibernate.globally_quoted_identifiers=true` -上面的例子将true传递到Hibernate实体管理器里的`hibernate.globally_quoted_identifiers`属性。 +``` +上面的例子将`true`传递到Hibernate实体管理器里的`hibernate.globally_quoted_identifiers`属性。 通常,DDL执行(或验证)被延迟到`ApplicationContext`启动后,这可以通过`spring.jpa.generate-ddl`标签控制,如果Hibernate自动配置被激活,那该标识就不会被使用,因为`ddl-auto`设置粒度更细。 From 77d8d836345c7444eb7f0806cf9024baa05bec66 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E7=83=AD=E5=BF=83=E5=B8=82=E6=B0=91=E9=92=9F=E5=B0=8F?= =?UTF-8?q?=E5=BC=BA?= Date: Thu, 21 Mar 2019 00:01:05 +0800 Subject: [PATCH 254/865] Update SUMMARY.md --- SUMMARY.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/SUMMARY.md b/SUMMARY.md index 7cb9b067..6e80c8c6 100644 --- a/SUMMARY.md +++ b/SUMMARY.md @@ -167,7 +167,7 @@ * [29.3. JPA和Spring Data](IV. Spring Boot features/29.3. JPA and Spring Data.md) * [29.3.1. 实体类](IV. Spring Boot features/29.3.1. Entity Classes.md) * [29.3.2. Spring Data JPA仓库](IV. Spring Boot features/29.3.2. Spring Data JPA Repositories.md) - * [29.3.3. 创建和删除JPA数据库](IV. Spring Boot features/29.3.3. Creating and dropping JPA databases.md) + * [29.3.3. 创建和删除JPA数据库](IV. Spring Boot features/29.3.3. Creating and Dropping JPA Databases.md) * [29.3.4. 在视图中打开实体管理器](IV. Spring Boot features/29.3.4. Open EntityManager in View.md) * [29.4 使用H2的web控制台](IV. Spring Boot features/29.4 Using H2’s web console.md) * [29.4.1 改变H2控制台路径](IV. Spring Boot features/29.4.1 Changing the H2 console’s path.md) From 193793f2a8cc18d61c8af184e19ab97465a1c7a0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E7=83=AD=E5=BF=83=E5=B8=82=E6=B0=91=E9=92=9F=E5=B0=8F?= =?UTF-8?q?=E5=BC=BA?= Date: Sun, 24 Mar 2019 10:58:35 +0800 Subject: [PATCH 255/865] =?UTF-8?q?Update=20and=20rename=2029.4=20Using=20?= =?UTF-8?q?H2=E2=80=99s=20web=20console.md=20to=2029.4=20Using=20H2?= =?UTF-8?q?=E2=80=99s=20Web=20Console.md?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../29.4 Using H2\342\200\231s Web Console.md" | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) rename "IV. Spring Boot features/29.4 Using H2\342\200\231s web console.md" => "IV. Spring Boot features/29.4 Using H2\342\200\231s Web Console.md" (80%) diff --git "a/IV. Spring Boot features/29.4 Using H2\342\200\231s web console.md" "b/IV. Spring Boot features/29.4 Using H2\342\200\231s Web Console.md" similarity index 80% rename from "IV. Spring Boot features/29.4 Using H2\342\200\231s web console.md" rename to "IV. Spring Boot features/29.4 Using H2\342\200\231s Web Console.md" index 79a31dbb..fa69d98c 100644 --- "a/IV. Spring Boot features/29.4 Using H2\342\200\231s web console.md" +++ "b/IV. Spring Boot features/29.4 Using H2\342\200\231s Web Console.md" @@ -1,8 +1,9 @@ ### 29.4 使用H2的web控制台 + [H2数据库](http://www.h2database.com/)提供一个[基于浏览器的控制台](http://www.h2database.com/html/quickstart.html#h2_console),Spring Boot可以为你自动配置。如果以下条件满足,则控制台会被自动配置: * 你正在开发一个web应用。 * 添加`com.h2database:h2`依赖。 -* 你正在使用[Spring Boot开发者工具](http://docs.spring.io/spring-boot/docs/2.0.0.RELEASE/reference/htmlsingle/#using-boot-devtools)。 +* 你正在使用[Spring Boot开发者工具](https://docs.spring.io/spring-boot/docs/2.0.0.RELEASE/reference/htmlsingle/#using-boot-devtools)。 **注** 如果你没有使用Spring Boot的开发者工具,仍想利用H2的控制台,可以设置`spring.h2.console.enabled`属性值为`true`。H2控制台应该只用于开发期间,所以确保生产环境没有设置`spring.h2.console.enabled`。 From 591e525d2904a9c1ea518df2e533f31d18ad736c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E7=83=AD=E5=BF=83=E5=B8=82=E6=B0=91=E9=92=9F=E5=B0=8F?= =?UTF-8?q?=E5=BC=BA?= Date: Sun, 24 Mar 2019 10:59:43 +0800 Subject: [PATCH 256/865] Update SUMMARY.md --- SUMMARY.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/SUMMARY.md b/SUMMARY.md index 6e80c8c6..23bc35bf 100644 --- a/SUMMARY.md +++ b/SUMMARY.md @@ -169,7 +169,7 @@ * [29.3.2. Spring Data JPA仓库](IV. Spring Boot features/29.3.2. Spring Data JPA Repositories.md) * [29.3.3. 创建和删除JPA数据库](IV. Spring Boot features/29.3.3. Creating and Dropping JPA Databases.md) * [29.3.4. 在视图中打开实体管理器](IV. Spring Boot features/29.3.4. Open EntityManager in View.md) - * [29.4 使用H2的web控制台](IV. Spring Boot features/29.4 Using H2’s web console.md) + * [29.4 使用H2的web控制台](IV. Spring Boot features/29.4 Using H2’s Web Console.md) * [29.4.1 改变H2控制台路径](IV. Spring Boot features/29.4.1 Changing the H2 console’s path.md) * [29.4.2 保护H2控制台](IV. Spring Boot features/29.4.2 Securing the H2 console.md) * [29.5 使用jOOQ](IV. Spring Boot features/29.5 Using jOOQ.md) From 7cd7b9fa57240e1897faa5ce7ea637460c13eb77 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E7=83=AD=E5=BF=83=E5=B8=82=E6=B0=91=E9=92=9F=E5=B0=8F?= =?UTF-8?q?=E5=BC=BA?= Date: Mon, 1 Apr 2019 23:32:06 +0800 Subject: [PATCH 257/865] =?UTF-8?q?Update=20and=20rename=2029.4.1=20Changi?= =?UTF-8?q?ng=20the=20H2=20console=E2=80=99s=20path.md=20to=2029.4.1=20Cha?= =?UTF-8?q?nging=20the=20H2=20Console=E2=80=99s=20Path.md?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../29.4.1 Changing the H2 Console\342\200\231s Path.md" | 1 + 1 file changed, 1 insertion(+) rename "IV. Spring Boot features/29.4.1 Changing the H2 console\342\200\231s path.md" => "IV. Spring Boot features/29.4.1 Changing the H2 Console\342\200\231s Path.md" (99%) diff --git "a/IV. Spring Boot features/29.4.1 Changing the H2 console\342\200\231s path.md" "b/IV. Spring Boot features/29.4.1 Changing the H2 Console\342\200\231s Path.md" similarity index 99% rename from "IV. Spring Boot features/29.4.1 Changing the H2 console\342\200\231s path.md" rename to "IV. Spring Boot features/29.4.1 Changing the H2 Console\342\200\231s Path.md" index 80a31dc7..94b2a350 100644 --- "a/IV. Spring Boot features/29.4.1 Changing the H2 console\342\200\231s path.md" +++ "b/IV. Spring Boot features/29.4.1 Changing the H2 Console\342\200\231s Path.md" @@ -1,2 +1,3 @@ ### 29.4.1 改变H2控制台路径 + H2控制台路径默认为`/h2-console`,你可以通过设置`spring.h2.console.path`属性自定义该路径。 From a23ad3a44438f46334ce71ca4ed904efb1081b43 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E7=83=AD=E5=BF=83=E5=B8=82=E6=B0=91=E9=92=9F=E5=B0=8F?= =?UTF-8?q?=E5=BC=BA?= Date: Mon, 1 Apr 2019 23:32:52 +0800 Subject: [PATCH 258/865] Update SUMMARY.md --- SUMMARY.md | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/SUMMARY.md b/SUMMARY.md index 23bc35bf..34d4d208 100644 --- a/SUMMARY.md +++ b/SUMMARY.md @@ -170,8 +170,7 @@ * [29.3.3. 创建和删除JPA数据库](IV. Spring Boot features/29.3.3. Creating and Dropping JPA Databases.md) * [29.3.4. 在视图中打开实体管理器](IV. Spring Boot features/29.3.4. Open EntityManager in View.md) * [29.4 使用H2的web控制台](IV. Spring Boot features/29.4 Using H2’s Web Console.md) - * [29.4.1 改变H2控制台路径](IV. Spring Boot features/29.4.1 Changing the H2 console’s path.md) - * [29.4.2 保护H2控制台](IV. Spring Boot features/29.4.2 Securing the H2 console.md) + * [29.4.1 改变H2控制台路径](IV. Spring Boot features/29.4.1 Changing the H2 Console’s Path.md) * [29.5 使用jOOQ](IV. Spring Boot features/29.5 Using jOOQ.md) * [29.5.1 代码生成](IV. Spring Boot features/29.5.1 Code Generation.md) * [29.5.2 使用DSLContext](IV. Spring Boot features/29.5.2 Using DSLContext.md) From aac31f7a53dbe027fac49c30529957ccd537a140 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E7=83=AD=E5=BF=83=E5=B8=82=E6=B0=91=E9=92=9F=E5=B0=8F?= =?UTF-8?q?=E5=BC=BA?= Date: Mon, 1 Apr 2019 23:33:57 +0800 Subject: [PATCH 259/865] Delete 29.4.2 Securing the H2 console.md --- IV. Spring Boot features/29.4.2 Securing the H2 console.md | 6 ------ 1 file changed, 6 deletions(-) delete mode 100644 IV. Spring Boot features/29.4.2 Securing the H2 console.md diff --git a/IV. Spring Boot features/29.4.2 Securing the H2 console.md b/IV. Spring Boot features/29.4.2 Securing the H2 console.md deleted file mode 100644 index 3a044d41..00000000 --- a/IV. Spring Boot features/29.4.2 Securing the H2 console.md +++ /dev/null @@ -1,6 +0,0 @@ -### 29.4.2 保护H2控制台 -当添加Spring Security依赖,并且启用基本认证时,Spring Boot自动使用基本认证保护H2控制台。以下属性可用于自定义安全配置: - -* `security.user.role` -* `security.basic.authorize-mode` -* `security.basic.enabled` From dc56e43fa1fd37aaec4d8a2d4d7b254cbf7f67c4 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E7=83=AD=E5=BF=83=E5=B8=82=E6=B0=91=E9=92=9F=E5=B0=8F?= =?UTF-8?q?=E5=BC=BA?= Date: Fri, 5 Apr 2019 00:32:08 +0800 Subject: [PATCH 260/865] Update 29.5.2 Using DSLContext.md --- IV. Spring Boot features/29.5.2 Using DSLContext.md | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/IV. Spring Boot features/29.5.2 Using DSLContext.md b/IV. Spring Boot features/29.5.2 Using DSLContext.md index 48b56696..1fcdb242 100644 --- a/IV. Spring Boot features/29.5.2 Using DSLContext.md +++ b/IV. Spring Boot features/29.5.2 Using DSLContext.md @@ -1,4 +1,5 @@ ### 29.5.2 使用DSLContext + jOOQ提供的流式(fluent)API是通过`org.jooq.DSLContext`接口初始化的,Spring Boot将自动配置一个`DSLContext`为Spring Bean,并将它跟应用的`DataSource`连接起来。想要使用`DSLContext`,只需`@Autowire`注入它: ```java @Component @@ -13,9 +14,9 @@ public class JooqExample implements CommandLineRunner { } ``` -**注** jOOQ手册倾向于使用一个名为`create`的变量持有`DSLContext`,示例中也是这样做的。 +**注** jOOQ手册倾向于使用一个名为`create`的变量持有`DSLContext`。 -然后你就可以使用`DSLContext`构造查询: +然后你就可以使用`DSLContext`构造查询,如下所示: ```java public List authorsBornAfter1980() { return this.create.selectFrom(AUTHOR) From f31eb7645a18ea9c385e1dd1d66d1eae0f82aeb1 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E7=83=AD=E5=BF=83=E5=B8=82=E6=B0=91=E9=92=9F=E5=B0=8F?= =?UTF-8?q?=E5=BC=BA?= Date: Fri, 5 Apr 2019 00:34:46 +0800 Subject: [PATCH 261/865] Update and rename 29.5.3 jOOQ SQL dialect.md to 29.5.3 jOOQ SQL Dialect.md --- .../{29.5.3 jOOQ SQL dialect.md => 29.5.3 jOOQ SQL Dialect.md} | 1 + 1 file changed, 1 insertion(+) rename IV. Spring Boot features/{29.5.3 jOOQ SQL dialect.md => 29.5.3 jOOQ SQL Dialect.md} (99%) diff --git a/IV. Spring Boot features/29.5.3 jOOQ SQL dialect.md b/IV. Spring Boot features/29.5.3 jOOQ SQL Dialect.md similarity index 99% rename from IV. Spring Boot features/29.5.3 jOOQ SQL dialect.md rename to IV. Spring Boot features/29.5.3 jOOQ SQL Dialect.md index 132a02d9..f6bb2626 100644 --- a/IV. Spring Boot features/29.5.3 jOOQ SQL dialect.md +++ b/IV. Spring Boot features/29.5.3 jOOQ SQL Dialect.md @@ -1,4 +1,5 @@ ### 29.5.3 jOOQ SQL方言 + Spring Boot决定了对你的数据库使用何种SQL方言,除非你配置了`spring.jooq.sql-dialect`属性。如果探测不到方言,将使用`默认值`。 **注** Spring Boot只能自动配置jOOQ的开源版本支持的方言。 From 0100aa3ec20df4ccf5a2180cb1d3c42192d57292 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E7=83=AD=E5=BF=83=E5=B8=82=E6=B0=91=E9=92=9F=E5=B0=8F?= =?UTF-8?q?=E5=BC=BA?= Date: Fri, 5 Apr 2019 00:36:43 +0800 Subject: [PATCH 262/865] Update SUMMARY.md --- SUMMARY.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/SUMMARY.md b/SUMMARY.md index 34d4d208..a5c0c12a 100644 --- a/SUMMARY.md +++ b/SUMMARY.md @@ -174,7 +174,7 @@ * [29.5 使用jOOQ](IV. Spring Boot features/29.5 Using jOOQ.md) * [29.5.1 代码生成](IV. Spring Boot features/29.5.1 Code Generation.md) * [29.5.2 使用DSLContext](IV. Spring Boot features/29.5.2 Using DSLContext.md) - * [29.5.3 jOOQ SQL方言](IV. Spring Boot features/29.5.3 jOOQ SQL dialect.md) + * [29.5.3 jOOQ SQL方言](IV. Spring Boot features/29.5.3 jOOQ SQL Dialect.md) * [29.5.4 自定义jOOQ](IV. Spring Boot features/29.5.4 Customizing jOOQ.md) * [30. 使用NoSQL技术](IV. Spring Boot features/30. Working with NoSQL technologies.md) * [30.1. Redis](IV. Spring Boot features/30.1. Redis.md) From a00d1759dc0f7529c16c679d09ad577add6c05a2 Mon Sep 17 00:00:00 2001 From: Zhong Zengqiang Date: Sat, 6 Apr 2019 23:08:45 +0800 Subject: [PATCH 263/865] =?UTF-8?q?=E6=B7=BB=E5=8A=A0996=E8=AE=B8=E5=8F=AF?= =?UTF-8?q?=E8=AF=81?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- 996License | 46 ++++++++++++++++++++++++++++++++++++++++++++++ README.md | 4 ++++ 2 files changed, 50 insertions(+) create mode 100644 996License diff --git a/996License b/996License new file mode 100644 index 00000000..278e5594 --- /dev/null +++ b/996License @@ -0,0 +1,46 @@ +Copyright (c) <2017> + +996 License Version 1.0 (Draft) + +Permission is hereby granted to any individual or legal entity +obtaining a copy of this licensed work (including the source code, +documentation and/or related items, hereinafter collectively referred +to as the "licensed work"), free of charge, to deal with the licensed +work for any purpose, including without limitation, the rights to use, +reproduce, modify, prepare derivative works of, distribute, publish +and sublicense the licensed work, subject to the following conditions: + +1. The individual or the legal entity must conspicuously display, +without modification, this License and the notice on each redistributed +or derivative copy of the Licensed Work. + +2. The individual or the legal entity must strictly comply with all +applicable laws, regulations, rules and standards of the jurisdiction +relating to labor and employment where the individual is physically +located or where the individual was born or naturalized; or where the +legal entity is registered or is operating (whichever is stricter). In +case that the jurisdiction has no such laws, regulations, rules and +standards or its laws, regulations, rules and standards are +unenforceable, the individual or the legal entity are required to +comply with Core International Labor Standards. + +3. The individual or the legal entity shall not induce or force its +employee(s), whether full-time or part-time, or its independent +contractor(s), in any methods, to agree in oral or written form, to +directly or indirectly restrict, weaken or relinquish his or her +rights or remedies under such laws, regulations, rules and standards +relating to labor and employment as mentioned above, no matter whether +such written or oral agreement are enforceable under the laws of the +said jurisdiction, nor shall such individual or the legal entity +limit, in any methods, the rights of its employee(s) or independent +contractor(s) from reporting or complaining to the copyright holder or +relevant authorities monitoring the compliance of the license about +its violation(s) of the said license. + +THE LICENSED WORK IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, +EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF +MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. +IN NO EVENT SHALL THE COPYRIGHT HOLDER BE LIABLE FOR ANY CLAIM, +DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR +OTHERWISE, ARISING FROM, OUT OF OR IN ANY WAY CONNECTION WITH THE +LICENSED WORK OR THE USE OR OTHER DEALINGS IN THE LICENSED WORK. diff --git a/README.md b/README.md index fbe4d149..48aaf10c 100644 --- a/README.md +++ b/README.md @@ -1,4 +1,7 @@ # Spring-Boot-Reference-Guide + +![LICENSE](https://img.shields.io/badge/license-MIT-blue.svg)[![LICENSE](https://img.shields.io/badge/license-Anti%20996-blue.svg)](https://github.com/996icu/996.ICU/blob/master/LICENSE) + Spring Boot Reference Guide 2.0 中文翻译 -《Spring Boot参考指南》 说明: @@ -8,3 +11,4 @@ Spring Boot Reference Guide 2.0 中文翻译 -《Spring Boot参考指南》 GitBook : [Spring Boot参考指南](https://jack80342.gitbooks.io/spring-boot/content/) GitHub : [Spring Boot参考指南](https://github.com/jack80342/Spring-Boot-Reference-Guide) + From c070485ab639d89e38e114168d059f3d03e2ba31 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E7=83=AD=E5=BF=83=E5=B8=82=E6=B0=91=E9=92=9F=E5=B0=8F?= =?UTF-8?q?=E5=BC=BA?= Date: Sat, 6 Apr 2019 23:33:27 +0800 Subject: [PATCH 264/865] Update README.md --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 48aaf10c..e4aa1b60 100644 --- a/README.md +++ b/README.md @@ -1,6 +1,6 @@ # Spring-Boot-Reference-Guide -![LICENSE](https://img.shields.io/badge/license-MIT-blue.svg)[![LICENSE](https://img.shields.io/badge/license-Anti%20996-blue.svg)](https://github.com/996icu/996.ICU/blob/master/LICENSE) +![LICENSE](https://img.shields.io/badge/license-MIT-blue.svg) [![LICENSE](https://img.shields.io/badge/license-Anti%20996-blue.svg)](https://github.com/996icu/996.ICU/blob/master/LICENSE) Spring Boot Reference Guide 2.0 中文翻译 -《Spring Boot参考指南》 From 5ac24c09927221f0be5dd79aba65472bd7e0eedb Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E7=83=AD=E5=BF=83=E5=B8=82=E6=B0=91=E9=92=9F=E5=B0=8F?= =?UTF-8?q?=E5=BC=BA?= Date: Sun, 7 Apr 2019 20:56:16 +0800 Subject: [PATCH 265/865] Update and rename 30. Working with NoSQL technologies.md to 30. Working with NoSQL Technologies.md --- .../30. Working with NoSQL Technologies.md | 3 +++ .../30. Working with NoSQL technologies.md | 3 --- 2 files changed, 3 insertions(+), 3 deletions(-) create mode 100644 IV. Spring Boot features/30. Working with NoSQL Technologies.md delete mode 100644 IV. Spring Boot features/30. Working with NoSQL technologies.md diff --git a/IV. Spring Boot features/30. Working with NoSQL Technologies.md b/IV. Spring Boot features/30. Working with NoSQL Technologies.md new file mode 100644 index 00000000..59ccbbd3 --- /dev/null +++ b/IV. Spring Boot features/30. Working with NoSQL Technologies.md @@ -0,0 +1,3 @@ +### 30. 使用NoSQL技术 + +Spring Data提供其他项目,用来帮你使用各种各样的NoSQL技术,包括:[MongoDB](https://projects.spring.io/spring-data-mongodb/)、[Neo4J](https://projects.spring.io/spring-data-neo4j/)、[Elasticsearch](https://github.com/spring-projects/spring-data-elasticsearch/)、 [Solr](https://projects.spring.io/spring-data-solr/)、[Redis](https://projects.spring.io/spring-data-redis/)、 [Gemfire](https://projects.spring.io/spring-data-gemfire/)、[Cassandra](https://projects.spring.io/spring-data-cassandra/)、[Couchbase](https://projects.spring.io/spring-data-couchbase/)和[LDAP](https://projects.spring.io/spring-data-ldap/)。Spring Boot为Redis、MongoDB、Elasticsearch、Solr Cassandra、Couchbase和LDAP提供自动配置。你也可以充分利用其他项目,但需要自己配置它们,具体查看[projects.spring.io/spring-data](https://projects.spring.io/spring-data)中相应的参考文档。 diff --git a/IV. Spring Boot features/30. Working with NoSQL technologies.md b/IV. Spring Boot features/30. Working with NoSQL technologies.md deleted file mode 100644 index 66ea61f6..00000000 --- a/IV. Spring Boot features/30. Working with NoSQL technologies.md +++ /dev/null @@ -1,3 +0,0 @@ -### 30. 使用NoSQL技术 - -Spring Data提供其他项目,用来帮你使用各种各样的NoSQL技术,包括[MongoDB](http://projects.spring.io/spring-data-mongodb/), [Neo4J](http://projects.spring.io/spring-data-neo4j/), [Elasticsearch](https://github.com/spring-projects/spring-data-elasticsearch/), [Solr](http://projects.spring.io/spring-data-solr/), [Redis](http://projects.spring.io/spring-data-redis/), [Gemfire](http://projects.spring.io/spring-data-gemfire/), [Cassandra](http://projects.spring.io/spring-data-cassandra/),[Couchbase](http://projects.spring.io/spring-data-couchbase/)和[LDAP](http://projects.spring.io/spring-data-ldap/)。Spring Boot为Redis, MongoDB, Elasticsearch, Solr Cassandra,Couchbase和LDAP提供自动配置。你也可以充分利用其他项目,但需要自己配置它们,具体查看[projects.spring.io/spring-data](http://projects.spring.io/spring-data/)中相应的参考文档。 From 45f335da2b5c466ef5420a9a0c365749b79f63b5 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E7=83=AD=E5=BF=83=E5=B8=82=E6=B0=91=E9=92=9F=E5=B0=8F?= =?UTF-8?q?=E5=BC=BA?= Date: Sun, 7 Apr 2019 20:57:12 +0800 Subject: [PATCH 266/865] Update SUMMARY.md --- SUMMARY.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/SUMMARY.md b/SUMMARY.md index a5c0c12a..81365eaa 100644 --- a/SUMMARY.md +++ b/SUMMARY.md @@ -176,7 +176,7 @@ * [29.5.2 使用DSLContext](IV. Spring Boot features/29.5.2 Using DSLContext.md) * [29.5.3 jOOQ SQL方言](IV. Spring Boot features/29.5.3 jOOQ SQL Dialect.md) * [29.5.4 自定义jOOQ](IV. Spring Boot features/29.5.4 Customizing jOOQ.md) - * [30. 使用NoSQL技术](IV. Spring Boot features/30. Working with NoSQL technologies.md) + * [30. 使用NoSQL技术](IV. Spring Boot features/30. Working with NoSQL Technologies.md) * [30.1. Redis](IV. Spring Boot features/30.1. Redis.md) * [30.1.1. 连接Redis](IV. Spring Boot features/30.1.1. Connecting to Redis.md) * [30.2. MongoDB](IV. Spring Boot features/30.2. MongoDB.md) From 3b3d25cf0a906ef0a400c334bf82e4bfa207647a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E7=83=AD=E5=BF=83=E5=B8=82=E6=B0=91=E9=92=9F=E5=B0=8F?= =?UTF-8?q?=E5=BC=BA?= Date: Sun, 7 Apr 2019 21:15:32 +0800 Subject: [PATCH 267/865] Update 30.1. Redis.md --- IV. Spring Boot features/30.1. Redis.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/IV. Spring Boot features/30.1. Redis.md b/IV. Spring Boot features/30.1. Redis.md index a3bee1fb..48d52cd2 100644 --- a/IV. Spring Boot features/30.1. Redis.md +++ b/IV. Spring Boot features/30.1. Redis.md @@ -1,4 +1,4 @@ ### 30.1. Redis -[Redis](http://redis.io/)是一个缓存,消息中间件及具有丰富特性的键值存储系统。Spring Boot为[Jedis](https://github.com/xetorthio/jedis/)和[Lettuce](https://github.com/mp911de/lettuce/)客户端library提供基本的自动配置,[Spring Data Redis](https://github.com/spring-projects/spring-data-redis)提供了在它之上的抽象。 -`spring-boot-starter-redis`'Starter'默认使用[Jedis](https://github.com/xetorthio/jedis/)方便地集合了需要的依赖。如果你正在搭建一个响应式的应用,`spring-boot-starter-data-redis-reactive`'Starter'对你来说非常有用。 +[Redis](http://redis.io/)是一个缓存、消息中间件及具有丰富特性的键值存储系统。Spring Boot为[Lettuce](https://github.com/lettuce-io/lettuce-core/)和[Jedis](https://github.com/xetorthio/jedis/)客户端库提供基本的自动配置。[Spring Data Redis](https://github.com/spring-projects/spring-data-redis)提供了在它们之上的抽象。 +`spring-boot-starter-redis`“Starter”方便地集合了需要的依赖。它默认使用[Lettuce](https://github.com/lettuce-io/lettuce-core/),既处理传统应用,也处理响应式应用。 From 2a31bc98f971c4cbffe80dcbb6ea5d045a060182 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E7=83=AD=E5=BF=83=E5=B8=82=E6=B0=91=E9=92=9F=E5=B0=8F?= =?UTF-8?q?=E5=BC=BA?= Date: Sun, 7 Apr 2019 21:28:49 +0800 Subject: [PATCH 268/865] Update 30.1. Redis.md --- IV. Spring Boot features/30.1. Redis.md | 2 ++ 1 file changed, 2 insertions(+) diff --git a/IV. Spring Boot features/30.1. Redis.md b/IV. Spring Boot features/30.1. Redis.md index 48d52cd2..8e7634c6 100644 --- a/IV. Spring Boot features/30.1. Redis.md +++ b/IV. Spring Boot features/30.1. Redis.md @@ -2,3 +2,5 @@ [Redis](http://redis.io/)是一个缓存、消息中间件及具有丰富特性的键值存储系统。Spring Boot为[Lettuce](https://github.com/lettuce-io/lettuce-core/)和[Jedis](https://github.com/xetorthio/jedis/)客户端库提供基本的自动配置。[Spring Data Redis](https://github.com/spring-projects/spring-data-redis)提供了在它们之上的抽象。 `spring-boot-starter-redis`“Starter”方便地集合了需要的依赖。它默认使用[Lettuce](https://github.com/lettuce-io/lettuce-core/),既处理传统应用,也处理响应式应用。 + +**注** 为了与其它存储系统保持一致,我们也提供了带有响应式支持的`spring-boot-starter-data-redis-reactive`“Starter”。 From faec14a52c7e7cba1cfcf008186c6a448b17abd9 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E7=83=AD=E5=BF=83=E5=B8=82=E6=B0=91=E9=92=9F=E5=B0=8F?= =?UTF-8?q?=E5=BC=BA?= Date: Sun, 7 Apr 2019 21:37:40 +0800 Subject: [PATCH 269/865] Update 30.1.1. Connecting to Redis.md --- IV. Spring Boot features/30.1.1. Connecting to Redis.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/IV. Spring Boot features/30.1.1. Connecting to Redis.md b/IV. Spring Boot features/30.1.1. Connecting to Redis.md index 1203abaf..67811d84 100644 --- a/IV. Spring Boot features/30.1.1. Connecting to Redis.md +++ b/IV. Spring Boot features/30.1.1. Connecting to Redis.md @@ -1,6 +1,6 @@ ### 30.1.1. 连接Redis -你可以注入一个自动配置的`RedisConnectionFactory`,`StringRedisTemplate`或普通的`RedisTemplate`实例,或任何其他Spring Bean只要你愿意。默认情况下,这个实例将尝试使用`localhost:6379`连接Redis服务器: +你可以注入一个自动配置的`RedisConnectionFactory`,`StringRedisTemplate`或普通的`RedisTemplate`实例,或任何其他Spring Bean只要你愿意。默认情况下,这个实例将尝试使用`localhost:6379`连接Redis服务器。下面的列表展示了这样的bean的一个示例: ```java @Component public class MyBean { @@ -15,6 +15,6 @@ public class MyBean { } ``` -**提示** 为了实现更高级的定制,你也可以注册任意数量的实现了`JedisClientConfigurationBuilderCustomizer`的bean。如果你正在使用Lettuce,那就实现`JedisClientConfigurationBuilderCustomizer`。 +**提示** 为了实现更高级的定制,你也可以注册任意数量的实现了`LettuceClientConfigurationBuilderCustomizer`的bean。如果你使用Jedis,那就实现`JedisClientConfigurationBuilderCustomizer`。 如果你添加一个自己的,或任何自动配置类型的`@Bean`,它将替换默认实例(除了`RedisTemplate`的情况,它是根据`bean`的name 'redisTemplate'而不是类型进行排除的)。如果在classpath路径下存在`commons-pool2`,默认你会获得一个连接池工厂。 From d37853fcec4c66f44d91ceaf6acbf33a321257f1 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E7=83=AD=E5=BF=83=E5=B8=82=E6=B0=91=E9=92=9F=E5=B0=8F?= =?UTF-8?q?=E5=BC=BA?= Date: Sun, 7 Apr 2019 21:41:32 +0800 Subject: [PATCH 270/865] Update 30.2. MongoDB.md --- IV. Spring Boot features/30.2. MongoDB.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/IV. Spring Boot features/30.2. MongoDB.md b/IV. Spring Boot features/30.2. MongoDB.md index 9b950aa0..3d0ba2b3 100644 --- a/IV. Spring Boot features/30.2. MongoDB.md +++ b/IV. Spring Boot features/30.2. MongoDB.md @@ -1,3 +1,3 @@ ### 30.2. MongoDB -[MongoDB](http://www.mongodb.com/)是一个开源的NoSQL文档数据库,它使用类JSON格式的模式(schema)替换了传统的基于表的关系数据。Spring Boot为使用MongoDB提供了很多便利,包括`spring-boot-starter-data-mongodb`和`spring-boot-starter-data-mongodb-reactive`'Starter'。 +[MongoDB](https://www.mongodb.com/)是一个开源的NoSQL文档数据库,它使用类JSON格式的模式(schema)替换了传统的基于表的关系数据。Spring Boot为使用MongoDB提供了很多便利,包括`spring-boot-starter-data-mongodb`和`spring-boot-starter-data-mongodb-reactive`“Starter”。 From 08f3493c40d839380527acd820c5cb5a28590d3d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E7=83=AD=E5=BF=83=E5=B8=82=E6=B0=91=E9=92=9F=E5=B0=8F?= =?UTF-8?q?=E5=BC=BA?= Date: Sun, 7 Apr 2019 22:02:35 +0800 Subject: [PATCH 271/865] Update and rename 30.2.1. Connecting to a MongoDB database.md to 30.2.1. Connecting to a MongoDB Database.md --- ...md => 30.2.1. Connecting to a MongoDB Database.md} | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-) rename IV. Spring Boot features/{30.2.1. Connecting to a MongoDB database.md => 30.2.1. Connecting to a MongoDB Database.md} (65%) diff --git a/IV. Spring Boot features/30.2.1. Connecting to a MongoDB database.md b/IV. Spring Boot features/30.2.1. Connecting to a MongoDB Database.md similarity index 65% rename from IV. Spring Boot features/30.2.1. Connecting to a MongoDB database.md rename to IV. Spring Boot features/30.2.1. Connecting to a MongoDB Database.md index 7f0cd1b1..a7ed4207 100644 --- a/IV. Spring Boot features/30.2.1. Connecting to a MongoDB database.md +++ b/IV. Spring Boot features/30.2.1. Connecting to a MongoDB Database.md @@ -1,6 +1,6 @@ ### 30.2.1. 连接MongoDB数据库 -你可以注入一个自动配置的`org.springframework.data.mongodb.MongoDbFactory`来访问Mongo数据库。默认情况下,该实例将尝试使用URL `mongodb://localhost/test`连接到MongoDB服务器: +你可以注入一个自动配置的`org.springframework.data.mongodb.MongoDbFactory`来访问Mongo数据库。默认情况下,该实例将尝试使用URL `mongodb://localhost/test`连接到MongoDB服务器。下面的例子展示了怎么连接到一个MongoDB数据库: ```java import org.springframework.data.mongodb.MongoDbFactory; import com.mongodb.DB; @@ -22,7 +22,7 @@ public class MyBean { } } ``` -你可以设置`spring.data.mongodb.uri`来改变该url,并配置其他的设置,比如副本集: +你可以设置`spring.data.mongodb.uri`来改变该URL,并配置其它的设置,比如副本集,如下所示: ```properties spring.data.mongodb.uri=mongodb://user:secret@mongo1.example.com:12345,mongo2.example.com:23456/test ``` @@ -31,11 +31,10 @@ spring.data.mongodb.uri=mongodb://user:secret@mongo1.example.com:12345,mongo2.ex spring.data.mongodb.host=mongoserver spring.data.mongodb.port=27017 ``` -**注** Mongo 3.0 Java驱动不支持`spring.data.mongodb.host`和`spring.data.mongodb.port`,对于这种情况,`spring.data.mongodb.uri`需要提供全部的配置信息。 +**注** Mongo 3.0 Java驱动不支持`spring.data.mongodb.host`和`spring.data.mongodb.port`。对于这种情况,`spring.data.mongodb.uri`需要提供全部的配置信息。 **注** 如果没有指定`spring.data.mongodb.port`,默认使用`27017`,上述示例中可以删除这行配置。 -**注** 如果不使用Spring Data Mongo,你可以注入`com.mongodb.Mongo beans`以代替`MongoDbFactory`。 +**注** 如果不使用Spring Data Mongo,你可以注入`com.mongodb.MongoClient`bean,以代替`MongoDbFactory`。如果想完全控制MongoDB连接的建立过程,你可以声明自己的`MongoDbFactory`或`MongoClient`bean。 -如果想完全控制MongoDB连接的建立过程,你可以声明自己的`MongoDbFactory`或`Mongo` bean。 -如果想全面控制MongoDB连接的建立,你也可以声明自己的MongoDbFactory或Mongo,@Beans。 +**注** 如果你正在使用响应式的驱动,使用SSL需要Netty。如果Netty可用,并且将使用的工厂没有被配置,那么工厂会被自动配置好。 From 2675bfd9cbf72cb827dfd631c11b6ccc8376254a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E7=83=AD=E5=BF=83=E5=B8=82=E6=B0=91=E9=92=9F=E5=B0=8F?= =?UTF-8?q?=E5=BC=BA?= Date: Sun, 7 Apr 2019 22:04:39 +0800 Subject: [PATCH 272/865] Update SUMMARY.md --- SUMMARY.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/SUMMARY.md b/SUMMARY.md index 81365eaa..b1e2e705 100644 --- a/SUMMARY.md +++ b/SUMMARY.md @@ -180,7 +180,7 @@ * [30.1. Redis](IV. Spring Boot features/30.1. Redis.md) * [30.1.1. 连接Redis](IV. Spring Boot features/30.1.1. Connecting to Redis.md) * [30.2. MongoDB](IV. Spring Boot features/30.2. MongoDB.md) - * [30.2.1. 连接MongoDB数据库](IV. Spring Boot features/30.2.1. Connecting to a MongoDB database.md) + * [30.2.1. 连接MongoDB数据库](IV. Spring Boot features/30.2.1. Connecting to a MongoDB Database.md) * [30.2.2. MongoDBTemplate](IV. Spring Boot features/30.2.2. MongoTemplate.md) * [30.2.3. Spring Data MongoDB仓库](IV. Spring Boot features/30.2.3. Spring Data MongoDB repositories.md) * [30.2.4 内嵌的Mongo](IV. Spring Boot features/30.2.4 Embedded Mongo.md) From f39ea717a2a8cf632869bc1e8ef09573226ab86c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E7=83=AD=E5=BF=83=E5=B8=82=E6=B0=91=E9=92=9F=E5=B0=8F?= =?UTF-8?q?=E5=BC=BA?= Date: Mon, 8 Apr 2019 23:29:47 +0800 Subject: [PATCH 273/865] Update 30.2.2. MongoTemplate.md --- IV. Spring Boot features/30.2.2. MongoTemplate.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/IV. Spring Boot features/30.2.2. MongoTemplate.md b/IV. Spring Boot features/30.2.2. MongoTemplate.md index 1ffdbcab..f2957c50 100644 --- a/IV. Spring Boot features/30.2.2. MongoTemplate.md +++ b/IV. Spring Boot features/30.2.2. MongoTemplate.md @@ -1,6 +1,6 @@ ### 30.2.2. MongoDBTemplate -Spring Data Mongo提供了一个[MongoTemplate](http://docs.spring.io/spring-data/mongodb/docs/current/api/org/springframework/data/mongodb/core/MongoTemplate.html)类,它的设计和Spring的`JdbcTemplate`很相似。跟`JdbcTemplate`一样,Spring Boot会为你自动配置一个bean,你只需简单的注入即可: +[Spring Data MongoDB](https://projects.spring.io/spring-data-mongodb/)提供了一个[MongoTemplate](https://docs.spring.io/spring-data/mongodb/docs/current/api/org/springframework/data/mongodb/core/MongoTemplate.html)类。它的设计和Spring的`JdbcTemplate`很相似。跟`JdbcTemplate`一样,Spring Boot会为你自动配置一个bean用来注入模版,如下: ```java import org.springframework.beans.factory.annotation.Autowired; import org.springframework.data.mongodb.core.MongoTemplate; @@ -18,4 +18,4 @@ public class MyBean { // ... } ``` -具体参考`MongoOperations` Javadoc。 +具体参考[`MongoOperations`Javadoc](https://docs.spring.io/spring-data/mongodb/docs/current/api/org/springframework/data/mongodb/core/MongoOperations.html)。 From 9caa482334f0bb84f1ab343a8483e6a13e5e0b71 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E7=83=AD=E5=BF=83=E5=B8=82=E6=B0=91=E9=92=9F=E5=B0=8F?= =?UTF-8?q?=E5=BC=BA?= Date: Tue, 9 Apr 2019 22:29:23 +0800 Subject: [PATCH 274/865] Update and rename 30.2.3. Spring Data MongoDB repositories.md to 30.2.3. Spring Data MongoDB Repositories.md --- ...ries.md => 30.2.3. Spring Data MongoDB Repositories.md} | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) rename IV. Spring Boot features/{30.2.3. Spring Data MongoDB repositories.md => 30.2.3. Spring Data MongoDB Repositories.md} (73%) diff --git a/IV. Spring Boot features/30.2.3. Spring Data MongoDB repositories.md b/IV. Spring Boot features/30.2.3. Spring Data MongoDB Repositories.md similarity index 73% rename from IV. Spring Boot features/30.2.3. Spring Data MongoDB repositories.md rename to IV. Spring Boot features/30.2.3. Spring Data MongoDB Repositories.md index c3b0ac54..7b109df6 100644 --- a/IV. Spring Boot features/30.2.3. Spring Data MongoDB repositories.md +++ b/IV. Spring Boot features/30.2.3. Spring Data MongoDB Repositories.md @@ -2,7 +2,7 @@ Spring Data包含的仓库也支持MongoDB,正如上面讨论的JPA仓库,基于方法名自动创建查询是基本的原则。 -实际上,不管是Spring Data JPA还是Spring Data MongoDB都共享相同的基础设施。所以你可以使用上面的JPA示例,并假设那个`City`现在是一个Mongo数据类而不是JPA `@Entity`,它将以同样的方式工作: +实际上,不管是Spring Data JPA还是Spring Data MongoDB都共享相同的基础设施。所以你可以使用上面的JPA示例,并假设那个`City`现在是一个Mongo数据类而不是JPA `@Entity`,它将以同样的方式工作,如下所示: ```java package com.example.myapp.domain; @@ -17,4 +17,7 @@ public interface CityRepository extends Repository { } ``` -**注** 想详细了解Spring Data MongoDB,包括它丰富的对象映射技术,可以查看它的[参考文档](http://projects.spring.io/spring-data-mongodb/)。 + +**注** 你可以通过`@EntityScan`注解自定义文档扫描位置。 + +**注** 想详细了解Spring Data MongoDB,包括它丰富的对象映射技术,可以查看它的[参考文档](https://projects.spring.io/spring-data-mongodb/)。 From ff503d09a6b6a85e14ad13dca04f752abab19b76 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E7=83=AD=E5=BF=83=E5=B8=82=E6=B0=91=E9=92=9F=E5=B0=8F?= =?UTF-8?q?=E5=BC=BA?= Date: Tue, 9 Apr 2019 22:29:56 +0800 Subject: [PATCH 275/865] Update SUMMARY.md --- SUMMARY.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/SUMMARY.md b/SUMMARY.md index b1e2e705..a41655a4 100644 --- a/SUMMARY.md +++ b/SUMMARY.md @@ -182,7 +182,7 @@ * [30.2. MongoDB](IV. Spring Boot features/30.2. MongoDB.md) * [30.2.1. 连接MongoDB数据库](IV. Spring Boot features/30.2.1. Connecting to a MongoDB Database.md) * [30.2.2. MongoDBTemplate](IV. Spring Boot features/30.2.2. MongoTemplate.md) - * [30.2.3. Spring Data MongoDB仓库](IV. Spring Boot features/30.2.3. Spring Data MongoDB repositories.md) + * [30.2.3. Spring Data MongoDB仓库](IV. Spring Boot features/30.2.3. Spring Data MongoDB Repositories.md) * [30.2.4 内嵌的Mongo](IV. Spring Boot features/30.2.4 Embedded Mongo.md) * [30.3 Neo4j](IV. Spring Boot features/30.3 Neo4j.md) * [30.3.1 连接Neo4j数据库](IV. Spring Boot features/30.3.1 Connecting to a Neo4j database.md) From f51472f807924b64af4514ddcde40b2588009064 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E7=83=AD=E5=BF=83=E5=B8=82=E6=B0=91=E9=92=9F=E5=B0=8F?= =?UTF-8?q?=E5=BC=BA?= Date: Tue, 9 Apr 2019 22:39:42 +0800 Subject: [PATCH 276/865] Update 30.3 Neo4j.md --- IV. Spring Boot features/30.3 Neo4j.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/IV. Spring Boot features/30.3 Neo4j.md b/IV. Spring Boot features/30.3 Neo4j.md index 5bdf5a01..51a57b41 100644 --- a/IV. Spring Boot features/30.3 Neo4j.md +++ b/IV. Spring Boot features/30.3 Neo4j.md @@ -1,3 +1,3 @@ ### 30.3 Neo4j -[Neo4j](http://neo4j.com/)是一个开源的NoSQL图数据库,它使用图(graph)相关的概念来描述数据模型,把数据保存为图中的节点以及节点之间的关系。相比传统rdbms(关系管理系统)的方式,Neo4j更适合大数据关系分析。Spring Boot为使用Neo4j提供很多便利,包括`spring-boot-starter-data-neo4j`‘Starter’。 +[Neo4j](http://neo4j.com/)是一个开源的NoSQL图数据库,它使用图(graph)相关的概念来描述数据模型,把数据保存为图中的节点以及节点之间的关系。相比传统rdbms(关系管理系统)的方式,Neo4j更适合大数据关系分析。Spring Boot为使用Neo4j提供很多便利,包括`spring-boot-starter-data-neo4j`“Starter”。 From 4729a427ba4a6704d74a343118e3c4b8ed97bceb Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E7=83=AD=E5=BF=83=E5=B8=82=E6=B0=91=E9=92=9F=E5=B0=8F?= =?UTF-8?q?=E5=BC=BA?= Date: Tue, 9 Apr 2019 22:45:15 +0800 Subject: [PATCH 277/865] Update and rename 30.3.1 Connecting to a Neo4j database.md to 30.3.1 Connecting to a Neo4j Database.md --- ... database.md => 30.3.1 Connecting to a Neo4j Database.md} | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) rename IV. Spring Boot features/{30.3.1 Connecting to a Neo4j database.md => 30.3.1 Connecting to a Neo4j Database.md} (83%) diff --git a/IV. Spring Boot features/30.3.1 Connecting to a Neo4j database.md b/IV. Spring Boot features/30.3.1 Connecting to a Neo4j Database.md similarity index 83% rename from IV. Spring Boot features/30.3.1 Connecting to a Neo4j database.md rename to IV. Spring Boot features/30.3.1 Connecting to a Neo4j Database.md index 6a95edc2..9a0f8b62 100644 --- a/IV. Spring Boot features/30.3.1 Connecting to a Neo4j database.md +++ b/IV. Spring Boot features/30.3.1 Connecting to a Neo4j Database.md @@ -1,6 +1,6 @@ ### 30.3.1 连接Neo4j数据库 -你可以注入一个自动配置的`Neo4jSession`,`Session`,或`Neo4jOperations`实例,就像使用其他Spring Bean那样。该实例默认使用`localhost:7474`连接Neo4j服务器: +你可以注入一个自动配置的`Neo4jSession`,`Session`,或`Neo4jOperations`实例,就像使用其他Spring Bean那样。该实例默认使用`localhost:7474`连接Neo4j服务器。下面的例子展示了怎么样注入一个Neo4j bean: ```java @Component public class MyBean { @@ -18,7 +18,8 @@ public class MyBean { ``` 添加自己的`org.neo4j.ogm.config.Configuration` `@Bean`,你就能完全控制该配置了。同时,添加一个`Neo4jOperations`类型的`@Bean`可以禁用自动配置。 -通过`spring.data.neo4j.*`属性可以配置使用的用户和凭证: +通过`spring.data.neo4j.*`属性可以配置使用的用户和凭证,如下所示: + ```properties spring.data.neo4j.uri=http://my-server:7474 spring.data.neo4j.username=neo4j From 25350df33f8edd68b50ff6f6e1258c9df4f67d67 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E7=83=AD=E5=BF=83=E5=B8=82=E6=B0=91=E9=92=9F=E5=B0=8F?= =?UTF-8?q?=E5=BC=BA?= Date: Tue, 9 Apr 2019 22:47:17 +0800 Subject: [PATCH 278/865] Update SUMMARY.md --- SUMMARY.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/SUMMARY.md b/SUMMARY.md index a41655a4..e378b51f 100644 --- a/SUMMARY.md +++ b/SUMMARY.md @@ -185,7 +185,7 @@ * [30.2.3. Spring Data MongoDB仓库](IV. Spring Boot features/30.2.3. Spring Data MongoDB Repositories.md) * [30.2.4 内嵌的Mongo](IV. Spring Boot features/30.2.4 Embedded Mongo.md) * [30.3 Neo4j](IV. Spring Boot features/30.3 Neo4j.md) - * [30.3.1 连接Neo4j数据库](IV. Spring Boot features/30.3.1 Connecting to a Neo4j database.md) + * [30.3.1 连接Neo4j数据库](IV. Spring Boot features/30.3.1 Connecting to a Neo4j Database.md) * [30.3.2 使用内嵌模式](IV. Spring Boot features/30.3.2 Using the embedded mode.md) * [30.3.3 Neo4jSession](IV. Spring Boot features/30.3.3 Neo4jSession.md) * [30.3.4 Spring Data Neo4j仓库](IV. Spring Boot features/30.3.4 Spring Data Neo4j repositories.md) From c49fbd50ba22e162015ea7ff4c007a4cc5bb7900 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E7=83=AD=E5=BF=83=E5=B8=82=E6=B0=91=E9=92=9F=E5=B0=8F?= =?UTF-8?q?=E5=BC=BA?= Date: Wed, 10 Apr 2019 20:08:58 +0800 Subject: [PATCH 279/865] =?UTF-8?q?=E4=BF=AE=E6=94=B9GitBook=E7=9A=84URL?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index e4aa1b60..f21dff7b 100644 --- a/README.md +++ b/README.md @@ -8,7 +8,7 @@ Spring Boot Reference Guide 2.0 中文翻译 -《Spring Boot参考指南》 本文档翻译的版本:[2.0.0.RELEASE](https://docs.spring.io/spring-boot/docs/2.0.0.RELEASE/reference/htmlsingle/) -GitBook : [Spring Boot参考指南](https://jack80342.gitbooks.io/spring-boot/content/) +GitBook : [Spring Boot参考指南](https://jack80342.gitbook.io/spring-boot/) GitHub : [Spring Boot参考指南](https://github.com/jack80342/Spring-Boot-Reference-Guide) From 51b5af8a0e4665f30504b2e07fb83bbdc6bc1bee Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E7=83=AD=E5=BF=83=E5=B8=82=E6=B0=91=E9=92=9F=E5=B0=8F?= =?UTF-8?q?=E5=BC=BA?= Date: Sun, 14 Apr 2019 21:19:05 +0800 Subject: [PATCH 280/865] Update and rename 30.3.2 Using the embedded mode.md to 30.3.2 Using the Embedded Mode.md --- ...he embedded mode.md => 30.3.2 Using the Embedded Mode.md} | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) rename IV. Spring Boot features/{30.3.2 Using the embedded mode.md => 30.3.2 Using the Embedded Mode.md} (79%) diff --git a/IV. Spring Boot features/30.3.2 Using the embedded mode.md b/IV. Spring Boot features/30.3.2 Using the Embedded Mode.md similarity index 79% rename from IV. Spring Boot features/30.3.2 Using the embedded mode.md rename to IV. Spring Boot features/30.3.2 Using the Embedded Mode.md index 9fe5981b..1a588e3f 100644 --- a/IV. Spring Boot features/30.3.2 Using the embedded mode.md +++ b/IV. Spring Boot features/30.3.2 Using the Embedded Mode.md @@ -1,8 +1,9 @@ ### 30.3.2 使用内嵌模式 -如果将`org.neo4j:neo4j-ogm-embedded-driver`依赖添加到应用中,Spring Boot会自动配置一个进程内(in-process)的内嵌Neo4j实例,当应用关闭时,该实例不会持久化任何数据。设置`spring.data.neo4j.embedded.enabled=false`可显式关闭该模式,你也可以启用内嵌模式的持久化特性: +如果将`org.neo4j:neo4j-ogm-embedded-driver`依赖添加到应用中,Spring Boot会自动配置一个进程内(in-process)的内嵌Neo4j实例,当应用关闭时,该实例不会持久化任何数据。设置`spring.data.neo4j.embedded.enabled=false`可显式关闭该模式。你也可以提供指向数据库文件的路径,来启用内嵌模式的持久化特性,如下所示: + ```properties spring.data.neo4j.uri=file://var/tmp/graph.db ``` -**注** Neo4j OGM内嵌的驱动不提供Neo4j内核。用户需要手动添加依赖,详情请查看[文档](http://neo4j.com/docs/ogm-manual/current/reference/#reference:getting-started)。 \ No newline at end of file +**注** Neo4j OGM内嵌的驱动不提供Neo4j内核。用户需要手动添加依赖,详情请查看[文档](http://neo4j.com/docs/ogm-manual/current/reference/#reference:getting-started)。 From 45059cffc5abf6a97cae3e93d92765a6ad851bbe Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E7=83=AD=E5=BF=83=E5=B8=82=E6=B0=91=E9=92=9F=E5=B0=8F?= =?UTF-8?q?=E5=BC=BA?= Date: Sun, 14 Apr 2019 21:19:37 +0800 Subject: [PATCH 281/865] Update SUMMARY.md --- SUMMARY.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/SUMMARY.md b/SUMMARY.md index e378b51f..46dfec68 100644 --- a/SUMMARY.md +++ b/SUMMARY.md @@ -186,7 +186,7 @@ * [30.2.4 内嵌的Mongo](IV. Spring Boot features/30.2.4 Embedded Mongo.md) * [30.3 Neo4j](IV. Spring Boot features/30.3 Neo4j.md) * [30.3.1 连接Neo4j数据库](IV. Spring Boot features/30.3.1 Connecting to a Neo4j Database.md) - * [30.3.2 使用内嵌模式](IV. Spring Boot features/30.3.2 Using the embedded mode.md) + * [30.3.2 使用内嵌模式](IV. Spring Boot features/30.3.2 Using the Embedded Mode.md) * [30.3.3 Neo4jSession](IV. Spring Boot features/30.3.3 Neo4jSession.md) * [30.3.4 Spring Data Neo4j仓库](IV. Spring Boot features/30.3.4 Spring Data Neo4j repositories.md) * [30.3.5 仓库示例](IV. Spring Boot features/30.3.5 Repository example.md) From d24a49138c223f02e77273c8730c8e9a732b7282 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E7=83=AD=E5=BF=83=E5=B8=82=E6=B0=91=E9=92=9F=E5=B0=8F?= =?UTF-8?q?=E5=BC=BA?= Date: Sun, 14 Apr 2019 21:23:16 +0800 Subject: [PATCH 282/865] Update 30.3.3 Neo4jSession.md --- IV. Spring Boot features/30.3.3 Neo4jSession.md | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/IV. Spring Boot features/30.3.3 Neo4jSession.md b/IV. Spring Boot features/30.3.3 Neo4jSession.md index 0780e43e..558f3039 100644 --- a/IV. Spring Boot features/30.3.3 Neo4jSession.md +++ b/IV. Spring Boot features/30.3.3 Neo4jSession.md @@ -1,6 +1,7 @@ ### 30.3.3 Neo4jSession -默认地,如果你正在运行一个网络应用,会话会被绑定到请求的整个处理过程的线程上(也就是“在视图中打开会话”模式)。如果你不想要这个行为,在你的`application.properties`中加入下面这句: +默认地,如果你正在运行一个网络应用,会话会被绑定到请求的整个处理过程的线程上(也就是,它使用“在视图中打开会话”模式)。如果你不想要这个行为,在你的`application.properties`中加入下面这行: + ```properties spring.data.neo4j.open-in-view=false -``` \ No newline at end of file +``` From 184145d42ea236cfcd296934eb573e5076456594 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E7=83=AD=E5=BF=83=E5=B8=82=E6=B0=91=E9=92=9F=E5=B0=8F?= =?UTF-8?q?=E5=BC=BA?= Date: Sun, 14 Apr 2019 21:36:59 +0800 Subject: [PATCH 283/865] Update and rename 30.3.4 Spring Data Neo4j repositories.md to 30.3.4 Spring Data Neo4j Repositories.md --- ... repositories.md => 30.3.4 Spring Data Neo4j Repositories.md} | 1 + 1 file changed, 1 insertion(+) rename IV. Spring Boot features/{30.3.4 Spring Data Neo4j repositories.md => 30.3.4 Spring Data Neo4j Repositories.md} (99%) diff --git a/IV. Spring Boot features/30.3.4 Spring Data Neo4j repositories.md b/IV. Spring Boot features/30.3.4 Spring Data Neo4j Repositories.md similarity index 99% rename from IV. Spring Boot features/30.3.4 Spring Data Neo4j repositories.md rename to IV. Spring Boot features/30.3.4 Spring Data Neo4j Repositories.md index d09d9bf6..de9a441f 100644 --- a/IV. Spring Boot features/30.3.4 Spring Data Neo4j repositories.md +++ b/IV. Spring Boot features/30.3.4 Spring Data Neo4j Repositories.md @@ -5,6 +5,7 @@ Spring Data包含的仓库也支持Neo4j,实际上,Spring Data JPA和Spring **注** 你可以使用`@EntityScan`注解定义实体扫描路径。 将以下两个注解添加到你的Spring configuration,可以启用repository支持(还有可选的对`@Transactional`的支持): + ```java @EnableNeo4jRepositories(basePackages = "com.example.myapp.repository") @EnableTransactionManagement From d9db56694391ae0276faa6df527bd5c5590f7656 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E7=83=AD=E5=BF=83=E5=B8=82=E6=B0=91=E9=92=9F=E5=B0=8F?= =?UTF-8?q?=E5=BC=BA?= Date: Sun, 14 Apr 2019 21:38:09 +0800 Subject: [PATCH 284/865] Update SUMMARY.md --- SUMMARY.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/SUMMARY.md b/SUMMARY.md index 46dfec68..b57e386d 100644 --- a/SUMMARY.md +++ b/SUMMARY.md @@ -188,7 +188,7 @@ * [30.3.1 连接Neo4j数据库](IV. Spring Boot features/30.3.1 Connecting to a Neo4j Database.md) * [30.3.2 使用内嵌模式](IV. Spring Boot features/30.3.2 Using the Embedded Mode.md) * [30.3.3 Neo4jSession](IV. Spring Boot features/30.3.3 Neo4jSession.md) - * [30.3.4 Spring Data Neo4j仓库](IV. Spring Boot features/30.3.4 Spring Data Neo4j repositories.md) + * [30.3.4 Spring Data Neo4j仓库](IV. Spring Boot features/30.3.4 Spring Data Neo4j Repositories.md) * [30.3.5 仓库示例](IV. Spring Boot features/30.3.5 Repository example.md) * [30.4 Gemfire](IV. Spring Boot features/30.4 Gemfire.md) * [30.5 Solr](IV. Spring Boot features/30.5 Solr.md) From 7dcec51a17fbb5487b6e12f9f86dfa9d473ba893 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E7=83=AD=E5=BF=83=E5=B8=82=E6=B0=91=E9=92=9F=E5=B0=8F?= =?UTF-8?q?=E5=BC=BA?= Date: Sun, 14 Apr 2019 21:51:05 +0800 Subject: [PATCH 285/865] Update SUMMARY.md --- SUMMARY.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/SUMMARY.md b/SUMMARY.md index b57e386d..9fdb905d 100644 --- a/SUMMARY.md +++ b/SUMMARY.md @@ -189,7 +189,7 @@ * [30.3.2 使用内嵌模式](IV. Spring Boot features/30.3.2 Using the Embedded Mode.md) * [30.3.3 Neo4jSession](IV. Spring Boot features/30.3.3 Neo4jSession.md) * [30.3.4 Spring Data Neo4j仓库](IV. Spring Boot features/30.3.4 Spring Data Neo4j Repositories.md) - * [30.3.5 仓库示例](IV. Spring Boot features/30.3.5 Repository example.md) + * [30.3.5 仓库示例](IV. Spring Boot features/30.3.5 Repository Example.md) * [30.4 Gemfire](IV. Spring Boot features/30.4 Gemfire.md) * [30.5 Solr](IV. Spring Boot features/30.5 Solr.md) * [30.5.1 连接Solr](IV. Spring Boot features/30.5.1 Connecting to Solr.md) From d3a93c4bc61faa197d5700c02f6123e771b7d4a0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E7=83=AD=E5=BF=83=E5=B8=82=E6=B0=91=E9=92=9F=E5=B0=8F?= =?UTF-8?q?=E5=BC=BA?= Date: Sun, 14 Apr 2019 22:05:14 +0800 Subject: [PATCH 286/865] Update and rename 30.3.5 Repository example.md to 30.3.5 Repository Example.md --- ....5 Repository example.md => 30.3.5 Repository Example.md} | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) rename IV. Spring Boot features/{30.3.5 Repository example.md => 30.3.5 Repository Example.md} (72%) diff --git a/IV. Spring Boot features/30.3.5 Repository example.md b/IV. Spring Boot features/30.3.5 Repository Example.md similarity index 72% rename from IV. Spring Boot features/30.3.5 Repository example.md rename to IV. Spring Boot features/30.3.5 Repository Example.md index 52c60862..72ae9f3e 100644 --- a/IV. Spring Boot features/30.3.5 Repository example.md +++ b/IV. Spring Boot features/30.3.5 Repository Example.md @@ -1,5 +1,7 @@ ### 30.3.5 仓库示例 +下面的例子展示了Neo4j仓库的接口定义: + ```java package com.example.myapp.domain; @@ -14,4 +16,5 @@ public interface CityRepository extends GraphRepository { } ``` -**注** 想详细了解Spring Data Neo4j,包括它丰富的对象映射技术,可查看它的[参考文档](http://projects.spring.io/spring-data-neo4j/)。 + +**注** 想详细了解Spring Data Neo4j,包括它丰富的对象映射技术,可查看它的[参考文档](https://projects.spring.io/spring-data-neo4j/)。 From cdd65b57b6be81cfd0942a55c853270ba48c715a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E7=83=AD=E5=BF=83=E5=B8=82=E6=B0=91=E9=92=9F=E5=B0=8F?= =?UTF-8?q?=E5=BC=BA?= Date: Tue, 16 Apr 2019 23:34:10 +0800 Subject: [PATCH 287/865] Update 30.4 Gemfire.md --- IV. Spring Boot features/30.4 Gemfire.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/IV. Spring Boot features/30.4 Gemfire.md b/IV. Spring Boot features/30.4 Gemfire.md index ad893b9c..b262b9f0 100644 --- a/IV. Spring Boot features/30.4 Gemfire.md +++ b/IV. Spring Boot features/30.4 Gemfire.md @@ -1,3 +1,3 @@ ### 30.4 Gemfire -[Spring Data Gemfire](https://github.com/spring-projects/spring-data-gemfire)为使用[Pivotal Gemfire](http://www.pivotal.io/big-data/pivotal-gemfire#details)数据管理平台提供了方便的,Spring友好的工具。Spring Boot提供了一个用于聚集依赖的`spring-boot-starter-data-gemfire`'Starter',目前不支持Gemfire的自动配置,但你只需使用[一个注解](https://github.com/spring-projects/spring-data-gemfire/blob/master/src/main/java/org/springframework/data/gemfire/repository/config/EnableGemfireRepositories.java)就能使Spring Data仓库支持它。 +[Spring Data Gemfire](https://github.com/spring-projects/spring-data-gemfire)为使用[Pivotal Gemfire](https://pivotal.io/big-data/pivotal-gemfire#details)数据管理平台提供了方便的、对Spring友好的工具。Spring Boot提供了一个用于聚集依赖的`spring-boot-starter-data-gemfire`“Starter”。虽然目前不支持Gemfire的自动配置,但是你可以使用[一个注解:`@EnableGemfireRepositories`](https://github.com/spring-projects/spring-data-gemfire/blob/master/src/main/java/org/springframework/data/gemfire/repository/config/EnableGemfireRepositories.java)启用Spring Data仓库。 From b107f73cbfe4076d9745ffaad528fd68cb3d538c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E7=83=AD=E5=BF=83=E5=B8=82=E6=B0=91=E9=92=9F=E5=B0=8F?= =?UTF-8?q?=E5=BC=BA?= Date: Tue, 16 Apr 2019 23:38:38 +0800 Subject: [PATCH 288/865] Update 30.5 Solr.md --- IV. Spring Boot features/30.5 Solr.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/IV. Spring Boot features/30.5 Solr.md b/IV. Spring Boot features/30.5 Solr.md index 0da856b0..93881693 100644 --- a/IV. Spring Boot features/30.5 Solr.md +++ b/IV. Spring Boot features/30.5 Solr.md @@ -1,3 +1,3 @@ ### 30.5 Solr -[Apache Solr](http://lucene.apache.org/solr/)是一个搜索引擎。Spring Boot为Solr 5客户端library提供基本的自动配置,[Spring Data Solr](https://github.com/spring-projects/spring-data-solr)提供了在它之上的抽象,还有用于收集依赖的`spring-boot-starter-data-solr`'Starter'。 +[Apache Solr](https://lucene.apache.org/solr/)是一个搜索引擎。Spring Boot为Solr 5客户端library提供基本的自动配置,[Spring Data Solr](https://github.com/spring-projects/spring-data-solr)提供了在它之上的抽象,还有用于收集依赖的`spring-boot-starter-data-solr`”Starter“。 From a627f2256dc08c541b2d1ac6a0ee90d0e24d151b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E7=83=AD=E5=BF=83=E5=B8=82=E6=B0=91=E9=92=9F=E5=B0=8F?= =?UTF-8?q?=E5=BC=BA?= Date: Tue, 16 Apr 2019 23:44:21 +0800 Subject: [PATCH 289/865] Update 30.5.1 Connecting to Solr.md --- IV. Spring Boot features/30.5.1 Connecting to Solr.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/IV. Spring Boot features/30.5.1 Connecting to Solr.md b/IV. Spring Boot features/30.5.1 Connecting to Solr.md index 25d2bda6..4a8f6684 100644 --- a/IV. Spring Boot features/30.5.1 Connecting to Solr.md +++ b/IV. Spring Boot features/30.5.1 Connecting to Solr.md @@ -1,6 +1,6 @@ ### 30.5.1 连接Solr -你可以注入一个自动配置的`SolrClient`实例,就像其他Spring beans那样,该实例默认使用`localhost:8983/solr`连接Solr服务器: +你可以注入一个自动配置的`SolrClient`实例。就像其他Spring beans那样,该实例默认使用`localhost:8983/solr`连接Solr服务器。下面的例子展示了怎样注入一个Solr bean: ```java @Component public class MyBean { From dadf5a476980b5611a788d7a88caed4ff9080913 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E7=83=AD=E5=BF=83=E5=B8=82=E6=B0=91=E9=92=9F=E5=B0=8F?= =?UTF-8?q?=E5=BC=BA?= Date: Tue, 16 Apr 2019 23:50:35 +0800 Subject: [PATCH 290/865] Update and rename 30.5.2 Spring Data Solr repositories.md to 30.5.2 Spring Data Solr Repositories.md --- .../30.5.2 Spring Data Solr Repositories.md | 7 +++++++ .../30.5.2 Spring Data Solr repositories.md | 7 ------- 2 files changed, 7 insertions(+), 7 deletions(-) create mode 100644 IV. Spring Boot features/30.5.2 Spring Data Solr Repositories.md delete mode 100644 IV. Spring Boot features/30.5.2 Spring Data Solr repositories.md diff --git a/IV. Spring Boot features/30.5.2 Spring Data Solr Repositories.md b/IV. Spring Boot features/30.5.2 Spring Data Solr Repositories.md new file mode 100644 index 00000000..e2470e99 --- /dev/null +++ b/IV. Spring Boot features/30.5.2 Spring Data Solr Repositories.md @@ -0,0 +1,7 @@ +### 30.5.2 Spring Data Solr仓库 + +Spring Data包含的仓库也支持Apache Solr,正如先前讨论的JPA仓库,基于方法名自动创建查询是基本的原则。 + +实际上,不管是Spring Data JPA还是Spring Data Solr都共享相同的基础设施。你可以使用先前的JPA示例,并假设那个`City`现在是一个`@SolrDocument`类而不是JPA `@Entity`,它将以同样的方式工作。 + +**注** 具体参考[Spring Data Solr文档](https://projects.spring.io/spring-data-solr/)。 diff --git a/IV. Spring Boot features/30.5.2 Spring Data Solr repositories.md b/IV. Spring Boot features/30.5.2 Spring Data Solr repositories.md deleted file mode 100644 index 86efff9e..00000000 --- a/IV. Spring Boot features/30.5.2 Spring Data Solr repositories.md +++ /dev/null @@ -1,7 +0,0 @@ -### 30.5.2 Spring Data Solr仓库 - -Spring Data包含的仓库也支持Apache Solr,正如先前讨论的JPA仓库,基于方法名自动创建查询是基本的原则。 - -实际上,不管是Spring Data JPA还是Spring Data Solr都共享相同的基础设施。所以你可以使用先前的JPA示例,并假设那个`City`现在是一个`@SolrDocument`类而不是JPA `@Entity`,它将以同样的方式工作。 - -**注** 具体参考[Spring Data Solr文档](http://projects.spring.io/spring-data-solr/)。 From 65801e584f36ee7b252077fef66f3781bdf5f518 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E7=83=AD=E5=BF=83=E5=B8=82=E6=B0=91=E9=92=9F=E5=B0=8F?= =?UTF-8?q?=E5=BC=BA?= Date: Tue, 16 Apr 2019 23:52:38 +0800 Subject: [PATCH 291/865] Update SUMMARY.md --- SUMMARY.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/SUMMARY.md b/SUMMARY.md index 9fdb905d..bdf1da90 100644 --- a/SUMMARY.md +++ b/SUMMARY.md @@ -193,7 +193,7 @@ * [30.4 Gemfire](IV. Spring Boot features/30.4 Gemfire.md) * [30.5 Solr](IV. Spring Boot features/30.5 Solr.md) * [30.5.1 连接Solr](IV. Spring Boot features/30.5.1 Connecting to Solr.md) - * [30.5.2 Spring Data Solr仓库](IV. Spring Boot features/30.5.2 Spring Data Solr repositories.md) + * [30.5.2 Spring Data Solr仓库](IV. Spring Boot features/30.5.2 Spring Data Solr Repositories.md) * [30.6 Elasticsearch](IV. Spring Boot features/30.6 Elasticsearch.md) * [30.6.1 使用Jest连接Elasticsearch](IV. Spring Boot features/30.6.1 Connecting to Elasticsearch using Jest.md) * [30.6.2 使用Spring Data连接Elasticsearch](IV. Spring Boot features/30.6.2 Connecting to Elasticsearch using Spring Data.md) From a542d226c8d813bb598f0e27c1bf5c58f879a0ec Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E7=83=AD=E5=BF=83=E5=B8=82=E6=B0=91=E9=92=9F=E5=B0=8F?= =?UTF-8?q?=E5=BC=BA?= Date: Wed, 17 Apr 2019 22:50:00 +0800 Subject: [PATCH 292/865] Update 30.6 Elasticsearch.md --- IV. Spring Boot features/30.6 Elasticsearch.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/IV. Spring Boot features/30.6 Elasticsearch.md b/IV. Spring Boot features/30.6 Elasticsearch.md index 7f035f96..fefa3ae4 100644 --- a/IV. Spring Boot features/30.6 Elasticsearch.md +++ b/IV. Spring Boot features/30.6 Elasticsearch.md @@ -1,3 +1,3 @@ ### 30.6 Elasticsearch -[Elastic Search](http://www.elasticsearch.org/)是一个开源的,分布式,实时搜索和分析引擎。Spring Boot为Elasticsearch提供基本的自动配置,[Spring Data Elasticsearch](https://github.com/spring-projects/spring-data-elasticsearch)提供在它之上的抽象,还有用于收集依赖的`spring-boot-starter-data-elasticsearch`'Starter'。 +[Elastic Search](http://www.elasticsearch.org/)是一个开源的、分布式的、实时搜索和分析引擎。Spring Boot为Elasticsearch提供基本的自动配置。[Spring Data Elasticsearch](https://github.com/spring-projects/spring-data-elasticsearch)提供在它之上的抽象。还有用于收集依赖的`spring-boot-starter-data-elasticsearch`“Starter”。Spring Boot也支持[Jest](https://github.com/searchbox-io/Jest)。 From 3bddffa33df2aee90dd8228fb18198b93bfd7297 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E7=83=AD=E5=BF=83=E5=B8=82=E6=B0=91=E9=92=9F=E5=B0=8F?= =?UTF-8?q?=E5=BC=BA?= Date: Wed, 17 Apr 2019 22:55:24 +0800 Subject: [PATCH 293/865] Update and rename 30.6.1 Connecting to Elasticsearch using Jest.md to 30.6.1 Connecting to Elasticsearch by Using Jest.md --- ... => 30.6.1 Connecting to Elasticsearch by Using Jest.md} | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) rename IV. Spring Boot features/{30.6.1 Connecting to Elasticsearch using Jest.md => 30.6.1 Connecting to Elasticsearch by Using Jest.md} (87%) diff --git a/IV. Spring Boot features/30.6.1 Connecting to Elasticsearch using Jest.md b/IV. Spring Boot features/30.6.1 Connecting to Elasticsearch by Using Jest.md similarity index 87% rename from IV. Spring Boot features/30.6.1 Connecting to Elasticsearch using Jest.md rename to IV. Spring Boot features/30.6.1 Connecting to Elasticsearch by Using Jest.md index 0a9fb0c6..d984f248 100644 --- a/IV. Spring Boot features/30.6.1 Connecting to Elasticsearch using Jest.md +++ b/IV. Spring Boot features/30.6.1 Connecting to Elasticsearch by Using Jest.md @@ -1,13 +1,16 @@ ### 30.6.1 使用Jest连接Elasticsearch -如果添加`Jest`依赖,你可以注入一个自动配置的`JestClient`,默认目标为`http://localhost:9200/`,也可以进一步配置该客户端: +如果添加`Jest`依赖,你可以注入一个自动配置的`JestClient`,默认目标为`http://localhost:9200/`。你也可以进一步配置该客户端,如下所示: + ```properties spring.elasticsearch.jest.uris=http://search.example.com:9200 spring.elasticsearch.jest.read-timeout=10000 spring.elasticsearch.jest.username=user spring.elasticsearch.jest.password=secret ``` + 为了实现更高级的定制,你也可以注册任意数量的实现了`HttpClientConfigBuilderCustomizer`的bean。下面的例子调整了额外的HTTP设置。 + ```java static class HttpSettingsCustomizer implements HttpClientConfigBuilderCustomizer { @@ -18,4 +21,5 @@ static class HttpSettingsCustomizer implements HttpClientConfigBuilderCustomizer } ``` + 定义一个`JestClient` bean以完全控制注册过程。 From 462d63ec70a7dc6f43e42be22d22f4650d5aa993 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E7=83=AD=E5=BF=83=E5=B8=82=E6=B0=91=E9=92=9F=E5=B0=8F?= =?UTF-8?q?=E5=BC=BA?= Date: Wed, 17 Apr 2019 22:57:27 +0800 Subject: [PATCH 294/865] Update SUMMARY.md --- SUMMARY.md | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/SUMMARY.md b/SUMMARY.md index bdf1da90..56a54f5e 100644 --- a/SUMMARY.md +++ b/SUMMARY.md @@ -195,9 +195,9 @@ * [30.5.1 连接Solr](IV. Spring Boot features/30.5.1 Connecting to Solr.md) * [30.5.2 Spring Data Solr仓库](IV. Spring Boot features/30.5.2 Spring Data Solr Repositories.md) * [30.6 Elasticsearch](IV. Spring Boot features/30.6 Elasticsearch.md) - * [30.6.1 使用Jest连接Elasticsearch](IV. Spring Boot features/30.6.1 Connecting to Elasticsearch using Jest.md) - * [30.6.2 使用Spring Data连接Elasticsearch](IV. Spring Boot features/30.6.2 Connecting to Elasticsearch using Spring Data.md) - * [30.6.3 Spring Data Elasticseach仓库](IV. Spring Boot features/30.6.3 Spring Data Elasticsearch repositories.md) + * [30.6.1 使用Jest连接Elasticsearch](IV. Spring Boot features/30.6.1 Connecting to Elasticsearch by Using Jest.md) + * [30.6.2 使用Spring Data连接Elasticsearch](IV. Spring Boot features/30.6.2 Connecting to Elasticsearch by Using Spring Data.md) + * [30.6.3 Spring Data Elasticseach仓库](IV. Spring Boot features/30.6.3 Spring Data Elasticsearch Repositories.md) * [30.7 Cassandra](IV. Spring Boot features/30.7 Cassandra.md) * [30.7.1 连接Cassandra](IV. Spring Boot features/30.7.1 Connecting to Cassandra.md) * [30.7.2 Spring Data Cassandra仓库](IV. Spring Boot features/30.7.2 Spring Data Cassandra repositories.md) From e4c511949547d44e57b1fc4296901374f38de4b1 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E7=83=AD=E5=BF=83=E5=B8=82=E6=B0=91=E9=92=9F=E5=B0=8F?= =?UTF-8?q?=E5=BC=BA?= Date: Wed, 17 Apr 2019 23:02:30 +0800 Subject: [PATCH 295/865] Update and rename 30.6.2 Connecting to Elasticsearch using Spring Data.md to 30.6.2 Connecting to Elasticsearch by Using Spring Data.md --- ....6.2 Connecting to Elasticsearch by Using Spring Data.md} | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) rename IV. Spring Boot features/{30.6.2 Connecting to Elasticsearch using Spring Data.md => 30.6.2 Connecting to Elasticsearch by Using Spring Data.md} (97%) diff --git a/IV. Spring Boot features/30.6.2 Connecting to Elasticsearch using Spring Data.md b/IV. Spring Boot features/30.6.2 Connecting to Elasticsearch by Using Spring Data.md similarity index 97% rename from IV. Spring Boot features/30.6.2 Connecting to Elasticsearch using Spring Data.md rename to IV. Spring Boot features/30.6.2 Connecting to Elasticsearch by Using Spring Data.md index cb3e3ab5..d1ea3f7a 100644 --- a/IV. Spring Boot features/30.6.2 Connecting to Elasticsearch using Spring Data.md +++ b/IV. Spring Boot features/30.6.2 Connecting to Elasticsearch by Using Spring Data.md @@ -1,9 +1,11 @@ ### 30.6.2 使用Spring Data连接Elasticsearch -为了连接Elasticsearch,你必须提供一个或者更多的集群节点的地址。可以通过设置`spring.data.elasticsearch.cluster-nodes`(逗号分隔的‘host:port’列表),来指定地址。当配置完成后,`ElasticsearchTemplate`或者`TransportClient`就能够像其它Spring bean一样被注入。 +为了连接Elasticsearch,你必须提供一个或者更多的集群节点的地址。可以通过设置`spring.data.elasticsearch.cluster-nodes`(逗号分隔的‘host:port’列表),来指定地址。当配置完成后,`ElasticsearchTemplate`或者`TransportClient`就能够像其它Spring bean一样被注入。如下所示: + ```properties spring.data.elasticsearch.cluster-nodes=localhost:9300 ``` + ```java @Component public class MyBean { @@ -18,4 +20,5 @@ public class MyBean { } ``` + 如果你添加自己的`ElasticsearchTemplate`或者`TransportClient``@Bean`,它将覆盖默认实例。 From 8ceea8a26d953a781a6009a92969aba931508f96 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E7=83=AD=E5=BF=83=E5=B8=82=E6=B0=91=E9=92=9F=E5=B0=8F?= =?UTF-8?q?=E5=BC=BA?= Date: Wed, 17 Apr 2019 23:03:21 +0800 Subject: [PATCH 296/865] Update 30.6.2 Connecting to Elasticsearch by Using Spring Data.md --- .../30.6.2 Connecting to Elasticsearch by Using Spring Data.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/IV. Spring Boot features/30.6.2 Connecting to Elasticsearch by Using Spring Data.md b/IV. Spring Boot features/30.6.2 Connecting to Elasticsearch by Using Spring Data.md index d1ea3f7a..5036fa55 100644 --- a/IV. Spring Boot features/30.6.2 Connecting to Elasticsearch by Using Spring Data.md +++ b/IV. Spring Boot features/30.6.2 Connecting to Elasticsearch by Using Spring Data.md @@ -21,4 +21,4 @@ public class MyBean { } ``` -如果你添加自己的`ElasticsearchTemplate`或者`TransportClient``@Bean`,它将覆盖默认实例。 +如果你添加自己的`ElasticsearchTemplate`或者`TransportClient` `@Bean`,它将覆盖默认实例。 From 0cddc57e208555152dfa7ab1c1cd65859ec9d8e4 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E7=83=AD=E5=BF=83=E5=B8=82=E6=B0=91=E9=92=9F=E5=B0=8F?= =?UTF-8?q?=E5=BC=BA?= Date: Wed, 17 Apr 2019 23:07:20 +0800 Subject: [PATCH 297/865] Update and rename 30.6.3 Spring Data Elasticsearch repositories.md to 30.6.3 Spring Data Elasticsearch Repositories.md --- ...ries.md => 30.6.3 Spring Data Elasticsearch Repositories.md} | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) rename IV. Spring Boot features/{30.6.3 Spring Data Elasticsearch repositories.md => 30.6.3 Spring Data Elasticsearch Repositories.md} (78%) diff --git a/IV. Spring Boot features/30.6.3 Spring Data Elasticsearch repositories.md b/IV. Spring Boot features/30.6.3 Spring Data Elasticsearch Repositories.md similarity index 78% rename from IV. Spring Boot features/30.6.3 Spring Data Elasticsearch repositories.md rename to IV. Spring Boot features/30.6.3 Spring Data Elasticsearch Repositories.md index f4a90366..43f2cc38 100644 --- a/IV. Spring Boot features/30.6.3 Spring Data Elasticsearch repositories.md +++ b/IV. Spring Boot features/30.6.3 Spring Data Elasticsearch Repositories.md @@ -4,4 +4,4 @@ Spring Data包含的仓库也支持Elasticsearch,正如前面讨论的JPA仓 实际上,不管是Spring Data JPA还是Spring Data Elasticsearch都共享相同的基础设施。所以你可以使用前面的JPA示例,并假设那个`City`现在是一个Elasticsearch `@Document`类而不是JPA `@Entity`,它将以同样的方式工作。 -**注** 具体参考[Spring Data Elasticsearch文档](http://docs.spring.io/spring-data/elasticsearch/docs/)。 +**注** 具体参考[Spring Data Elasticsearch文档](https://docs.spring.io/spring-data/elasticsearch/docs/)。 From 9ec50e77872c2e69e395f5e94de35567111a8369 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E7=83=AD=E5=BF=83=E5=B8=82=E6=B0=91=E9=92=9F=E5=B0=8F?= =?UTF-8?q?=E5=BC=BA?= Date: Fri, 19 Apr 2019 21:26:17 +0800 Subject: [PATCH 298/865] Update 30.7 Cassandra.md --- IV. Spring Boot features/30.7 Cassandra.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/IV. Spring Boot features/30.7 Cassandra.md b/IV. Spring Boot features/30.7 Cassandra.md index 55ee494f..53b9023f 100644 --- a/IV. Spring Boot features/30.7 Cassandra.md +++ b/IV. Spring Boot features/30.7 Cassandra.md @@ -1,3 +1,3 @@ ### 30.7 Cassandra -[Cassandra](http://cassandra.apache.org/)是一个开源,分布式数据库管理系统,设计用于处理跨很多商品服务器的大数据。Spring Boot为Cassandra提供自动配置,[Spring Data Cassandra](https://github.com/spring-projects/spring-data-cassandra)提供在它之上的抽象,还有收集依赖的`spring-boot-starter-data-cassandra`‘Starter’。 +[Cassandra](https://cassandra.apache.org/)是一个开源的、分布式数据库管理系统,设计用于处理跨很多商品服务器的大数据。Spring Boot为Cassandra提供自动配置。[Spring Data Cassandra](https://github.com/spring-projects/spring-data-cassandra)提供在它之上的抽象。`spring-boot-starter-data-cassandra`“Starter”方便地收集了依赖。 From 43829ea4137d2d182a4b66a6c98ee55195748ad5 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E7=83=AD=E5=BF=83=E5=B8=82=E6=B0=91=E9=92=9F=E5=B0=8F?= =?UTF-8?q?=E5=BC=BA?= Date: Fri, 19 Apr 2019 21:29:50 +0800 Subject: [PATCH 299/865] Update 30.7.1 Connecting to Cassandra.md --- IV. Spring Boot features/30.7.1 Connecting to Cassandra.md | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/IV. Spring Boot features/30.7.1 Connecting to Cassandra.md b/IV. Spring Boot features/30.7.1 Connecting to Cassandra.md index 247151a0..4682759d 100644 --- a/IV. Spring Boot features/30.7.1 Connecting to Cassandra.md +++ b/IV. Spring Boot features/30.7.1 Connecting to Cassandra.md @@ -1,10 +1,14 @@ ### 30.7.1 连接Cassandra -你可以注入一个自动配置的`CassandraTemplate`或Cassandra `Session`实例,就像注入其他Spring Bean那样。`spring.data.cassandra.*`属性可用来自定义该连接,通常你需要提供`keyspace-name`和`contact-points`属性: +你可以注入一个自动配置的`CassandraTemplate`或Cassandra `Session`实例,就像注入其他Spring Bean那样。`spring.data.cassandra.*`属性可用来自定义该连接,通常你需要提供`keyspace-name`和`contact-points`属性。如下所示: + ```properties spring.data.cassandra.keyspace-name=mykeyspace spring.data.cassandra.contact-points=cassandrahost1,cassandrahost2 ``` + +下面的代码展示了怎样注入Cassandra bean: + ```java @Component public class MyBean { @@ -20,4 +24,5 @@ public class MyBean { } ``` + 如果添加自己的`CassandraTemplate`类型的`@Bean`,它将替换默认实例。 From 42111571e032b15447c6344c9996058e1c72c23b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E7=83=AD=E5=BF=83=E5=B8=82=E6=B0=91=E9=92=9F=E5=B0=8F?= =?UTF-8?q?=E5=BC=BA?= Date: Fri, 19 Apr 2019 21:32:41 +0800 Subject: [PATCH 300/865] Update 30.7.2 Spring Data Cassandra repositories.md --- .../30.7.2 Spring Data Cassandra repositories.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/IV. Spring Boot features/30.7.2 Spring Data Cassandra repositories.md b/IV. Spring Boot features/30.7.2 Spring Data Cassandra repositories.md index a2441b2a..b6e24af0 100644 --- a/IV. Spring Boot features/30.7.2 Spring Data Cassandra repositories.md +++ b/IV. Spring Boot features/30.7.2 Spring Data Cassandra repositories.md @@ -2,4 +2,4 @@ Spring Data包含的仓库对Cassandra提供基本支持,目前受到的限制比先前讨论的JPA仓库要多,并且需要使用`@Query`注解相应的查找方法。 -**注** 想全面了解Spring Data Cassandra,可查看它的[参考指南](http://docs.spring.io/spring-data/cassandra/docs/)。 +**注** 想全面了解Spring Data Cassandra,可查看它的[参考指南](https://docs.spring.io/spring-data/cassandra/docs/)。 From e893bf423fd9ad933b1239ceb80ad765689c77f3 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E7=83=AD=E5=BF=83=E5=B8=82=E6=B0=91=E9=92=9F=E5=B0=8F?= =?UTF-8?q?=E5=BC=BA?= Date: Fri, 19 Apr 2019 21:33:06 +0800 Subject: [PATCH 301/865] Rename 30.7.2 Spring Data Cassandra repositories.md to 30.7.2 Spring Data Cassandra Repositories.md --- ...positories.md => 30.7.2 Spring Data Cassandra Repositories.md} | 0 1 file changed, 0 insertions(+), 0 deletions(-) rename IV. Spring Boot features/{30.7.2 Spring Data Cassandra repositories.md => 30.7.2 Spring Data Cassandra Repositories.md} (100%) diff --git a/IV. Spring Boot features/30.7.2 Spring Data Cassandra repositories.md b/IV. Spring Boot features/30.7.2 Spring Data Cassandra Repositories.md similarity index 100% rename from IV. Spring Boot features/30.7.2 Spring Data Cassandra repositories.md rename to IV. Spring Boot features/30.7.2 Spring Data Cassandra Repositories.md From 95a74def6d9d4b54286f4668e2f0b3102cb5cbce Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E7=83=AD=E5=BF=83=E5=B8=82=E6=B0=91=E9=92=9F=E5=B0=8F?= =?UTF-8?q?=E5=BC=BA?= Date: Fri, 19 Apr 2019 21:49:12 +0800 Subject: [PATCH 302/865] Update SUMMARY.md --- SUMMARY.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/SUMMARY.md b/SUMMARY.md index 56a54f5e..af2a98f2 100644 --- a/SUMMARY.md +++ b/SUMMARY.md @@ -200,7 +200,7 @@ * [30.6.3 Spring Data Elasticseach仓库](IV. Spring Boot features/30.6.3 Spring Data Elasticsearch Repositories.md) * [30.7 Cassandra](IV. Spring Boot features/30.7 Cassandra.md) * [30.7.1 连接Cassandra](IV. Spring Boot features/30.7.1 Connecting to Cassandra.md) - * [30.7.2 Spring Data Cassandra仓库](IV. Spring Boot features/30.7.2 Spring Data Cassandra repositories.md) + * [30.7.2 Spring Data Cassandra仓库](IV. Spring Boot features/30.7.2 Spring Data Cassandra Repositories.md) * [30.8 Couchbase](IV. Spring Boot features/30.8 Couchbase.md) * [30.8.1 连接Couchbase](IV. Spring Boot features/30.8.1 Connecting to Couchbase.md) * [30.8.2 Spring Data Couchbase仓库](IV. Spring Boot features/30.8.2 Spring Data Couchbase repositories.md) From 3720de1f82fe2aed7683a2f215a986cc1aa3c89d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E7=83=AD=E5=BF=83=E5=B8=82=E6=B0=91=E9=92=9F=E5=B0=8F?= =?UTF-8?q?=E5=BC=BA?= Date: Sat, 20 Apr 2019 00:12:53 +0800 Subject: [PATCH 303/865] Update README.md --- README.md | 2 ++ 1 file changed, 2 insertions(+) diff --git a/README.md b/README.md index f21dff7b..a18ce299 100644 --- a/README.md +++ b/README.md @@ -12,3 +12,5 @@ GitBook : [Spring Boot参考指南](https://jack80342.gitbook.io/spring-boot/) GitHub : [Spring Boot参考指南](https://github.com/jack80342/Spring-Boot-Reference-Guide) + 我从二零一七年夏天开始翻译这份文档。为什么翻译这份文档,原因我已经忘了。这份文档在[qibaoguang](https://github.com/qibaoguang)的1.4.1版本上新增了Spring Boot 2.0.0版本的内容,对修改的地方也做了更新。在杭州工作之后,九九六。如果没有大的翻译错误,就不做更新了。 + Good luck!🍭 From 2dee95591aaebd834666a85df25ff5df4e35a43d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E7=83=AD=E5=BF=83=E5=B8=82=E6=B0=91=E9=92=9F=E5=B0=8F?= =?UTF-8?q?=E5=BC=BA?= Date: Tue, 23 Apr 2019 22:05:02 +0800 Subject: [PATCH 304/865] Update 30.8 Couchbase.md --- IV. Spring Boot features/30.8 Couchbase.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/IV. Spring Boot features/30.8 Couchbase.md b/IV. Spring Boot features/30.8 Couchbase.md index b8f3d9d5..dab3d97e 100644 --- a/IV. Spring Boot features/30.8 Couchbase.md +++ b/IV. Spring Boot features/30.8 Couchbase.md @@ -1,3 +1,3 @@ ### 30.8 Couchbase -[Couchbase](http://www.couchbase.com/)是一个基于文档,分布式多模型的开源数据库,设计用于交互式应用程序。Spring Boot为Couchbase提供自动配置,[Spring Data Couchbase](https://github.com/spring-projects/spring-data-couchbase)提供在它之上的抽象,还有收集依赖的`spring-boot-starter-data-couchbase`‘Starter’。 +[Couchbase](https://www.couchbase.com/)是一个基于文档的、分布式多模型的开源数据库,设计用于交互式应用程序。Spring Boot为Couchbase提供自动配置,[Spring Data Couchbase](https://github.com/spring-projects/spring-data-couchbase)提供在它之上的抽象,还有收集依赖的`spring-boot-starter-data-couchbase`“Starter”。 From b09ad63bf5c98270644012d111de55943aea8c23 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E7=83=AD=E5=BF=83=E5=B8=82=E6=B0=91=E9=92=9F=E5=B0=8F?= =?UTF-8?q?=E5=BC=BA?= Date: Tue, 23 Apr 2019 22:07:25 +0800 Subject: [PATCH 305/865] Update 30.8.1 Connecting to Couchbase.md --- IV. Spring Boot features/30.8.1 Connecting to Couchbase.md | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/IV. Spring Boot features/30.8.1 Connecting to Couchbase.md b/IV. Spring Boot features/30.8.1 Connecting to Couchbase.md index 955dd326..cdd14d37 100644 --- a/IV. Spring Boot features/30.8.1 Connecting to Couchbase.md +++ b/IV. Spring Boot features/30.8.1 Connecting to Couchbase.md @@ -1,17 +1,21 @@ ### 30.8.1 连接Couchbase -通过添加Couchbase SDK和一些配置,你可以很容易获取一个`Bucket`和`Cluster`,`spring.couchbase.*`属性可用于自定义该连接。通常,你需要提供启动hosts,bucket name和password: +通过添加Couchbase SDK和一些配置,你可以获取一个`Bucket`和`Cluster`,`spring.couchbase.*`属性可用于自定义该连接。通常,你需要提供启动hosts、bucket name和password。如下所示: + ```properties spring.couchbase.bootstrap-hosts=my-host-1,192.168.1.123 spring.couchbase.bucket.name=my-bucket spring.couchbase.bucket.password=secret ``` + **注** 你至少需要提供启动host(s),在这种情况下,bucket name默认为`default`,password默认为空字符串。另外,你可以定义自己的`org.springframework.data.couchbase.config.CouchbaseConfigurer` `@Bean`来把控所有配置。 你也可以自定义一些`CouchbaseEnvironment`设置,例如,以下配置改变打开新`Bucket`的超时时间(timeout),还启用了SSL支持: + ```properties spring.couchbase.env.timeouts.connect=3000 spring.couchbase.env.ssl.key-store=/location/of/keystore.jks spring.couchbase.env.ssl.key-store-password=secret ``` + 具体查看`spring.couchbase.env.*`属性。 From 88a379b86e0fc07bc5fd80d6414f7ac0acabc1b5 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E7=83=AD=E5=BF=83=E5=B8=82=E6=B0=91=E9=92=9F=E5=B0=8F?= =?UTF-8?q?=E5=BC=BA?= Date: Tue, 23 Apr 2019 22:08:48 +0800 Subject: [PATCH 306/865] Update SUMMARY.md --- SUMMARY.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/SUMMARY.md b/SUMMARY.md index af2a98f2..8184f0f4 100644 --- a/SUMMARY.md +++ b/SUMMARY.md @@ -203,7 +203,7 @@ * [30.7.2 Spring Data Cassandra仓库](IV. Spring Boot features/30.7.2 Spring Data Cassandra Repositories.md) * [30.8 Couchbase](IV. Spring Boot features/30.8 Couchbase.md) * [30.8.1 连接Couchbase](IV. Spring Boot features/30.8.1 Connecting to Couchbase.md) - * [30.8.2 Spring Data Couchbase仓库](IV. Spring Boot features/30.8.2 Spring Data Couchbase repositories.md) + * [30.8.2 Spring Data Couchbase仓库](IV. Spring Boot features/30.8.2 Spring Data Couchbase Repositories.md) * [30.9 LDAP](IV. Spring Boot features/30.9 LDAP.md) * [30.9.1 连接LDAP服务器](IV. Spring Boot features/30.9.1 Connecting to an LDAP server.md) * [30.9.2 Spring Data LDAP仓库](IV. Spring Boot features/30.9.2 Spring Data LDAP repositories.md) From 515d86695f41f4289eac3973acf17ee618cd7289 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E7=83=AD=E5=BF=83=E5=B8=82=E6=B0=91=E9=92=9F=E5=B0=8F?= =?UTF-8?q?=E5=BC=BA?= Date: Tue, 23 Apr 2019 22:17:46 +0800 Subject: [PATCH 307/865] Update and rename 30.8.2 Spring Data Couchbase repositories.md to 30.8.2 Spring Data Couchbase Repositories.md --- ...es.md => 30.8.2 Spring Data Couchbase Repositories.md} | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) rename IV. Spring Boot features/{30.8.2 Spring Data Couchbase repositories.md => 30.8.2 Spring Data Couchbase Repositories.md} (88%) diff --git a/IV. Spring Boot features/30.8.2 Spring Data Couchbase repositories.md b/IV. Spring Boot features/30.8.2 Spring Data Couchbase Repositories.md similarity index 88% rename from IV. Spring Boot features/30.8.2 Spring Data Couchbase repositories.md rename to IV. Spring Boot features/30.8.2 Spring Data Couchbase Repositories.md index 8df2201c..e65a216e 100644 --- a/IV. Spring Boot features/30.8.2 Spring Data Couchbase repositories.md +++ b/IV. Spring Boot features/30.8.2 Spring Data Couchbase Repositories.md @@ -1,8 +1,11 @@ ### 30.8.2 Spring Data Couchbase仓库 -Spring Data包含的仓库也支持Couchbase,具体可查看Spring Data Couchbase的[参考文档](http://docs.spring.io/spring-data/couchbase/docs/current/reference/html/)。 +Spring Data包含的仓库也支持Couchbase,具体可查看Spring Data Couchbase的[参考文档](https://docs.spring.io/spring-data/couchbase/docs/current/reference/html/)。 你可以注入一个自动配置的`CouchbaseTemplate`实例,就像注入其他Spring Bean那样,只要默认的`CouchbaseConfigurer`可以使用。 + +下面的例子展示了怎么样注入一个Couchbase bean: + ```java @Component public class MyBean { @@ -18,6 +21,7 @@ public class MyBean { } ``` + 你可以在你自己的配置中定义一些bean,来覆盖自动配置中提供的那些: * `CouchbaseTemplate` `@Bean` ,称为`couchbaseTemplate` @@ -25,6 +29,7 @@ public class MyBean { * `CustomConversions` `@Bean`,称为`couchbaseCustomConversions` 为了避免在你的配置中硬编码那些名字,你可以重复使用由Spring Data Couchbase提供的`BeanNames`。例如,你可以像下面这样自定义要使用的转换器: + ```java @Configuration public class SomeConfiguration { @@ -38,4 +43,5 @@ public class SomeConfiguration { } ``` + **提示** 如果想完全关闭Spring Data Couchbase的自动配置,你可以提供自己的`org.springframework.data.couchbase.config.AbstractCouchbaseDataConfiguration`实现。 From 49d4adcb530fb94b1c0c084f9cb5cc2af592617c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E7=83=AD=E5=BF=83=E5=B8=82=E6=B0=91=E9=92=9F=E5=B0=8F?= =?UTF-8?q?=E5=BC=BA?= Date: Tue, 23 Apr 2019 22:21:09 +0800 Subject: [PATCH 308/865] Update 30.9 LDAP.md --- IV. Spring Boot features/30.9 LDAP.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/IV. Spring Boot features/30.9 LDAP.md b/IV. Spring Boot features/30.9 LDAP.md index 090a1ec8..83a153b4 100644 --- a/IV. Spring Boot features/30.9 LDAP.md +++ b/IV. Spring Boot features/30.9 LDAP.md @@ -1,5 +1,5 @@ ### 30.9 LDAP -[LDAP](https://zh.wikipedia.org/wiki/%E8%BD%BB%E5%9E%8B%E7%9B%AE%E5%BD%95%E8%AE%BF%E9%97%AE%E5%8D%8F%E8%AE%AE) (轻型目录访问协议)是一个开放的,中立的,工业标准的应用协议,通过IP协议提供访问控制和维护分布式信息的目录信息。Spring Boot为任何兼容的LDAP服务器提供自动配置,同时也支持[UnboundID](https://www.ldap.com/unboundid-ldap-sdk-for-java) 的嵌入式内存中LDAP服务器。 +[LDAP](https://en.wikipedia.org/wiki/Lightweight_Directory_Access_Protocol) (轻型目录访问协议)是一个开放的,中立的,工业标准的应用协议,通过IP协议提供访问控制和维护分布式信息的目录信息。Spring Boot为任何兼容的LDAP服务器提供自动配置,同时也支持[UnboundID](https://www.ldap.com/unboundid-ldap-sdk-for-java) 的嵌入式内存中LDAP服务器。 -[Spring Data LDAP](https://github.com/spring-projects/spring-data-ldap)提供了LDAP抽象. `spring-boot-starter-data-ldap`”Starter“方便地集合了依赖。 \ No newline at end of file +[Spring Data LDAP](https://github.com/spring-projects/spring-data-ldap)提供了LDAP抽象. `spring-boot-starter-data-ldap`”Starter“方便地集合了依赖。 From 0447e8f3e0267c4b0482282bf47177cabad85f12 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E7=83=AD=E5=BF=83=E5=B8=82=E6=B0=91=E9=92=9F=E5=B0=8F?= =?UTF-8?q?=E5=BC=BA?= Date: Tue, 23 Apr 2019 22:22:59 +0800 Subject: [PATCH 309/865] Update 30.9 LDAP.md --- IV. Spring Boot features/30.9 LDAP.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/IV. Spring Boot features/30.9 LDAP.md b/IV. Spring Boot features/30.9 LDAP.md index 83a153b4..4b0adb2f 100644 --- a/IV. Spring Boot features/30.9 LDAP.md +++ b/IV. Spring Boot features/30.9 LDAP.md @@ -1,5 +1,5 @@ ### 30.9 LDAP -[LDAP](https://en.wikipedia.org/wiki/Lightweight_Directory_Access_Protocol) (轻型目录访问协议)是一个开放的,中立的,工业标准的应用协议,通过IP协议提供访问控制和维护分布式信息的目录信息。Spring Boot为任何兼容的LDAP服务器提供自动配置,同时也支持[UnboundID](https://www.ldap.com/unboundid-ldap-sdk-for-java) 的嵌入式内存中LDAP服务器。 +[LDAP](https://en.wikipedia.org/wiki/Lightweight_Directory_Access_Protocol) (轻型目录访问协议)是一个开放的、中立的、工业标准的应用协议,通过IP协议提供访问控制和维护分布式信息的目录信息。Spring Boot为任何兼容的LDAP服务器提供自动配置,同时也支持[UnboundID](https://www.ldap.com/unboundid-ldap-sdk-for-java) 的嵌入式内存中LDAP服务器。 -[Spring Data LDAP](https://github.com/spring-projects/spring-data-ldap)提供了LDAP抽象. `spring-boot-starter-data-ldap`”Starter“方便地集合了依赖。 +[Spring Data LDAP](https://github.com/spring-projects/spring-data-ldap)提供了LDAP抽象。`spring-boot-starter-data-ldap`”Starter“方便地集合了依赖。 From cbe3e667148baee42141af0a4485d8240ef17bda Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E7=83=AD=E5=BF=83=E5=B8=82=E6=B0=91=E9=92=9F=E5=B0=8F?= =?UTF-8?q?=E5=BC=BA?= Date: Wed, 24 Apr 2019 09:42:54 +0800 Subject: [PATCH 310/865] Update and rename 30.9.1 Connecting to an LDAP server.md to 30.9.1 Connecting to an LDAP Server.md --- ...DAP server.md => 30.9.1 Connecting to an LDAP Server.md} | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) rename IV. Spring Boot features/{30.9.1 Connecting to an LDAP server.md => 30.9.1 Connecting to an LDAP Server.md} (83%) diff --git a/IV. Spring Boot features/30.9.1 Connecting to an LDAP server.md b/IV. Spring Boot features/30.9.1 Connecting to an LDAP Server.md similarity index 83% rename from IV. Spring Boot features/30.9.1 Connecting to an LDAP server.md rename to IV. Spring Boot features/30.9.1 Connecting to an LDAP Server.md index 290b0a85..54e6a39f 100644 --- a/IV. Spring Boot features/30.9.1 Connecting to an LDAP server.md +++ b/IV. Spring Boot features/30.9.1 Connecting to an LDAP Server.md @@ -1,9 +1,11 @@ ### 30.9.1 连接LDAP服务器 -为了连接LDAP服务器,你需要确保声明了`spring-boot-starter-data-ldap`“Starter”或者`spring-ldap-core`依赖,然后在你的`application.properties`中声明你的服务器的URLs。 +为了连接LDAP服务器,你需要确保声明了`spring-boot-starter-data-ldap`“Starter”或者`spring-ldap-core`依赖,然后在你的`application.properties`中声明你的服务器的URL。如下所示: + ```properties spring.ldap.urls=ldap://myserver:1235 spring.ldap.username=admin spring.ldap.password=secret ``` -如果你需要自定义连接设置,你可以使用`spring.ldap.base`或者`spring.ldap.base-environment`属性。 \ No newline at end of file + +如果你需要自定义连接设置,你可以使用`spring.ldap.base`或者`spring.ldap.base-environment`属性。 From 7f91d93228b8871e161c2037dba28c3603a7c2f5 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E7=83=AD=E5=BF=83=E5=B8=82=E6=B0=91=E9=92=9F=E5=B0=8F?= =?UTF-8?q?=E5=BC=BA?= Date: Wed, 24 Apr 2019 09:44:29 +0800 Subject: [PATCH 311/865] Update SUMMARY.md --- SUMMARY.md | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/SUMMARY.md b/SUMMARY.md index 8184f0f4..21853cfc 100644 --- a/SUMMARY.md +++ b/SUMMARY.md @@ -205,9 +205,9 @@ * [30.8.1 连接Couchbase](IV. Spring Boot features/30.8.1 Connecting to Couchbase.md) * [30.8.2 Spring Data Couchbase仓库](IV. Spring Boot features/30.8.2 Spring Data Couchbase Repositories.md) * [30.9 LDAP](IV. Spring Boot features/30.9 LDAP.md) - * [30.9.1 连接LDAP服务器](IV. Spring Boot features/30.9.1 Connecting to an LDAP server.md) - * [30.9.2 Spring Data LDAP仓库](IV. Spring Boot features/30.9.2 Spring Data LDAP repositories.md) - * [30.9.3 嵌入式内存中LDAP服务器](IV. Spring Boot features/30.9.3 Embedded in-memory LDAP server.md) + * [30.9.1 连接LDAP服务器](IV. Spring Boot features/30.9.1 Connecting to an LDAP Server.md) + * [30.9.2 Spring Data LDAP仓库](IV. Spring Boot features/30.9.2 Spring Data LDAP Repositories.md) + * [30.9.3 嵌入式内存中LDAP服务器](IV. Spring Boot features/30.9.3 Embedded In-memory LDAP Server.md) * [30.10 InfluxDB](IV. Spring Boot features/30.10 InfluxDB.md) * [30.10.1 连接InfluxDB](IV. Spring Boot features/30.10.1 Connecting to InfluxDB.md) * [31. 缓存](IV. Spring Boot features/31. Caching.md) From 4e67e51988bb5dc73b8229f0a13302b6717135f6 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E7=83=AD=E5=BF=83=E5=B8=82=E6=B0=91=E9=92=9F=E5=B0=8F?= =?UTF-8?q?=E5=BC=BA?= Date: Wed, 24 Apr 2019 09:47:20 +0800 Subject: [PATCH 312/865] Update and rename 30.9.2 Spring Data LDAP repositories.md to 30.9.2 Spring Data LDAP Repositories.md --- ...ositories.md => 30.9.2 Spring Data LDAP Repositories.md} | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) rename IV. Spring Boot features/{30.9.2 Spring Data LDAP repositories.md => 30.9.2 Spring Data LDAP Repositories.md} (76%) diff --git a/IV. Spring Boot features/30.9.2 Spring Data LDAP repositories.md b/IV. Spring Boot features/30.9.2 Spring Data LDAP Repositories.md similarity index 76% rename from IV. Spring Boot features/30.9.2 Spring Data LDAP repositories.md rename to IV. Spring Boot features/30.9.2 Spring Data LDAP Repositories.md index fdab9521..9633f606 100644 --- a/IV. Spring Boot features/30.9.2 Spring Data LDAP repositories.md +++ b/IV. Spring Boot features/30.9.2 Spring Data LDAP Repositories.md @@ -1,7 +1,9 @@ ### 30.9.2 Spring Data LDAP仓库 -Spring Data包含了支持LDAP的仓库。Spring Data LDAP的详细情况,请查看他们的[参考文档](http://docs.spring.io/spring-data/ldap/docs/1.0.x/reference/html/)。 +Spring Data包含了支持LDAP的仓库。Spring Data LDAP的详细情况,请查看他们的[参考文档](https://docs.spring.io/spring-data/ldap/docs/1.0.x/reference/html/)。 + 你也可以像其它Spring Bean一样,注入一个自动配置的`LdapTemplate`实例。 + ```java @Component public class MyBean { @@ -16,4 +18,4 @@ public class MyBean { // ... } -``` \ No newline at end of file +``` From a632ee0ee33b4e07608c8943f25c5d362399262e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E7=83=AD=E5=BF=83=E5=B8=82=E6=B0=91=E9=92=9F=E5=B0=8F?= =?UTF-8?q?=E5=BC=BA?= Date: Wed, 24 Apr 2019 10:08:36 +0800 Subject: [PATCH 313/865] Update and rename 30.9.3 Embedded in-memory LDAP server.md to 30.9.3 Embedded In-memory LDAP Server.md --- ... 30.9.3 Embedded In-memory LDAP Server.md} | 20 ++++++++++++++++++- 1 file changed, 19 insertions(+), 1 deletion(-) rename IV. Spring Boot features/{30.9.3 Embedded in-memory LDAP server.md => 30.9.3 Embedded In-memory LDAP Server.md} (61%) diff --git a/IV. Spring Boot features/30.9.3 Embedded in-memory LDAP server.md b/IV. Spring Boot features/30.9.3 Embedded In-memory LDAP Server.md similarity index 61% rename from IV. Spring Boot features/30.9.3 Embedded in-memory LDAP server.md rename to IV. Spring Boot features/30.9.3 Embedded In-memory LDAP Server.md index bc455274..604e5d18 100644 --- a/IV. Spring Boot features/30.9.3 Embedded in-memory LDAP server.md +++ b/IV. Spring Boot features/30.9.3 Embedded In-memory LDAP Server.md @@ -1,9 +1,27 @@ ### 30.9.3 嵌入式内存中LDAP服务器 为了方便测试,Spring Boot支持[UnboundID](https://www.ldap.com/unboundid-ldap-sdk-for-java) 的嵌入式内存中LDAP服务器的自动配置。在`com.unboundid:unboundid-ldapsdk`里添加依赖,声明`base-dn`属性,来配置服务器: + ```properties spring.ldap.embedded.base-dn=dc=spring,dc=io ``` + +**注** 定义多个base-dn的值是可行的。但是,识别名称通常包含逗号。它们必须使用正确的符号定义。 + +在yaml文件里,你可以使用yaml列表符号: +```properties +spring.ldap.embedded.base-dn: + - dc=spring,dc=io + - dc=pivotal,dc=io + ``` + +在properties文件里,你必须把索引作为属性名的一部分: +```properties +spring.ldap.embedded.base-dn[0]=dc=spring,dc=io +spring.ldap.embedded.base-dn[1]=dc=pivotal,dc=io +``` + 默认地,服务器会在一个随机的端口中开始运行。它们会触发常规的LDAP支持(不需要指定`spring.ldap.urls`属性)。 如果在你的类路径下存在`schema.ldif`文件,它会被用于初始化服务器。如果你想要从不同的资源加载初始化脚本,你可以使用`pring.ldap.embedded.ldif`属性。 -默认地,一个标准的模式会被用于验证`LDIF`文件,你可以使用`spring.ldap.embedded.validation.enabled`属性完全地关闭验证。如果你有自定义的属性,你可以使用`spring.ldap.embedded.validation.schema`来定义你的自定义属性类型或对象类。 \ No newline at end of file + +默认地,一个标准的模式会被用于验证`LDIF`文件,你可以设置`spring.ldap.embedded.validation.enabled`属性完全地关闭验证。如果你有自定义的属性,你可以使用`spring.ldap.embedded.validation.schema`来定义你的自定义属性类型或对象类。 From 07812d26097aaebbe3dbe210b140a80d0233ea0b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E7=83=AD=E5=BF=83=E5=B8=82=E6=B0=91=E9=92=9F=E5=B0=8F?= =?UTF-8?q?=E5=BC=BA?= Date: Wed, 24 Apr 2019 10:21:41 +0800 Subject: [PATCH 314/865] Update 30.10 InfluxDB.md --- IV. Spring Boot features/30.10 InfluxDB.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/IV. Spring Boot features/30.10 InfluxDB.md b/IV. Spring Boot features/30.10 InfluxDB.md index f4484298..3c82a223 100644 --- a/IV. Spring Boot features/30.10 InfluxDB.md +++ b/IV. Spring Boot features/30.10 InfluxDB.md @@ -1,3 +1,3 @@ ### 30.10 InfluxDB -[InfluxDB](https://www.influxdata.com/)是一个开源时序型数据库,着力于在操作监控、应用程序度量、物联网传感器数据和实时分析等领域,快速、高可靠性地存储与查询时序型数据。 \ No newline at end of file +[InfluxDB](https://www.influxdata.com/)是一个开源时序型数据库,着力于操作监控、应用程序度量、物联网传感器数据和实时分析等领域,快速、高可靠性地存储与查询时序型数据。 From 764c0b271d73d9e6800751a3b925f4cb18994219 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E7=83=AD=E5=BF=83=E5=B8=82=E6=B0=91=E9=92=9F=E5=B0=8F?= =?UTF-8?q?=E5=BC=BA?= Date: Wed, 24 Apr 2019 10:29:38 +0800 Subject: [PATCH 315/865] Update 30.10.1 Connecting to InfluxDB.md --- IV. Spring Boot features/30.10.1 Connecting to InfluxDB.md | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/IV. Spring Boot features/30.10.1 Connecting to InfluxDB.md b/IV. Spring Boot features/30.10.1 Connecting to InfluxDB.md index 2bb10fe1..b8605b2e 100644 --- a/IV. Spring Boot features/30.10.1 Connecting to InfluxDB.md +++ b/IV. Spring Boot features/30.10.1 Connecting to InfluxDB.md @@ -1,7 +1,10 @@ ### 30.10.1 连接InfluxDB -只要`influxdb-java`客户端在类路径下,而且如下所示,设置了数据库的url,Spring Boot就能自动配置InfluxDB实例。 +只要`influxdb-java`客户端在类路径下,而且设置了数据库的url,Spring Boot就能自动配置InfluxDB实例。如下所示: ```properties spring.influx.url=http://172.0.0.1:8086 ``` -如果连接InfluxDB需要用户名和密码,你可以相应地设置`spring.influx.user`和`spring.influx.password`。 \ No newline at end of file + +如果连接InfluxDB需要用户名和密码,你可以相应地设置`spring.influx.user`和`spring.influx.password`。 + +InfluxDB依赖OkHttp。如果你需要调整http客户端`InfluxDB`在幕后使用,你可以注册一个`OkHttpClient.Builder` bean。 From 062854371943cbfb5b60e331fbd22aac94b07d3b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E7=83=AD=E5=BF=83=E5=B8=82=E6=B0=91=E9=92=9F=E5=B0=8F?= =?UTF-8?q?=E5=BC=BA?= Date: Fri, 26 Apr 2019 14:02:50 +0800 Subject: [PATCH 316/865] Update 31. Caching.md --- IV. Spring Boot features/31. Caching.md | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/IV. Spring Boot features/31. Caching.md b/IV. Spring Boot features/31. Caching.md index 044a2bf7..394194cc 100644 --- a/IV. Spring Boot features/31. Caching.md +++ b/IV. Spring Boot features/31. Caching.md @@ -1,10 +1,10 @@ ### 31. 缓存 -Spring框架提供为应用透明添加缓存的支持,核心思想是,将抽象应用到缓存方法,基于缓存中可用信息减少方法的执行。缓存逻辑的应用是透明的,不会干扰调用者。只要通过`@EnableCaching`注解开启缓存支持,Spring Boot就会自动配置缓存基础结构。 +Spring框架提供为应用透明添加缓存的支持。其核心思想是:将抽象应用到缓存方法,基于缓存中可用信息减少方法的执行。缓存逻辑的应用是透明的,不会干扰调用者。只要通过`@EnableCaching`注解开启缓存支持,Spring Boot就会自动配置缓存基础结构。 -**注** 具体参考Spring框架指南的[相应章节](https://docs.spring.io/spring/docs/5.0.4.RELEASE/spring-framework-reference/htmlsingle/#cache)。 +**注** 具体参考Spring框架指南的[相应章节](https://docs.spring.io/spring/docs/5.0.4.RELEASE/spring-framework-reference/integration.html#cache)。 -简而言之,为服务的某个操作添加缓存跟为方法添加相应注解那样简单: +简而言之,为服务的某个操作添加缓存跟为方法添加相应注解那样简单。如下所示: ```java import org.springframework.cache.annotation.Cacheable import org.springframework.stereotype.Component; @@ -23,8 +23,8 @@ public class MathService { **注** 你也可以透明地使用标准的JSR-107 (JCache)注解(比如`@CacheResult`)。我们强烈建议你不要混淆使用。 -如果你不添加特定的缓存库,Spring Boot将会自动配置一个在内存中使用并发映射的[Simple提供商](../IV. Spring Boot features/31.1.10 Simple.md)。当需要缓存时(比如上面的例子里的`piDecimals`),提供商将会为你实时创建。不推荐你在产品环境中使用Simple提供商。但是它使得入门变得非常容易,确保了你理解特性。当你下定决心使用某个缓存提供商,请阅读这份文档理解如何配置缓存。实际上所有的提供商,都要求你明确地配置你在应用中使用的每一处缓存。有些提供了方法,通过`spring.cache.cache-names`来自定义默认的缓存。 +如果你不添加特定的缓存库,Spring Boot将会自动配置一个在内存中使用并发映射的[Simple提供商](../IV. Spring Boot features/31.1.9 Simple.md)。当需要缓存时(比如上面的例子里的`piDecimals`),提供商将会为你实时创建。不推荐你在产品环境中使用Simple提供商。但是它使得入门变得非常容易,确保了你理解特性。当你下定决心使用某个缓存提供商,请阅读这份文档理解如何配置缓存。实际上所有的提供商,都要求你明确地配置你在应用中使用的每一处缓存。有些提供了方法,通过`spring.cache.cache-names`来自定义默认的缓存。 -**提示** 透明地[更新](https://docs.spring.io/spring/docs/5.0.4.RELEASE/spring-framework-reference/htmlsingle/#cache-annotations-put)或[去除](https://docs.spring.io/spring/docs/5.0.4.RELEASE/spring-framework-reference/htmlsingle/#cache-annotations-evict)缓存数据也是可以的。 +**提示** 透明地[更新](https://docs.spring.io/spring/docs/5.0.4.RELEASE/spring-framework-reference/integration.html#cache-annotations-put)或[去除](https://docs.spring.io/spring/docs/5.0.4.RELEASE/spring-framework-reference/integration.html#cache-annotations-evict)缓存数据也是可以的。 **注** 如果你正在使用的缓存基础结构beans不是基于接口的,确保启用了`@EnableCaching`的`proxyTargetClass`属性。 From 348173af1ac3f0bf990f2d0cd4e47b116beca190 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E7=83=AD=E5=BF=83=E5=B8=82=E6=B0=91=E9=92=9F=E5=B0=8F?= =?UTF-8?q?=E5=BC=BA?= Date: Fri, 26 Apr 2019 14:40:57 +0800 Subject: [PATCH 317/865] Update and rename 31.1 Supported cache providers.md to 31.1 Supported Cache Providers.md --- ...rs.md => 31.1 Supported Cache Providers.md} | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) rename IV. Spring Boot features/{31.1 Supported cache providers.md => 31.1 Supported Cache Providers.md} (60%) diff --git a/IV. Spring Boot features/31.1 Supported cache providers.md b/IV. Spring Boot features/31.1 Supported Cache Providers.md similarity index 60% rename from IV. Spring Boot features/31.1 Supported cache providers.md rename to IV. Spring Boot features/31.1 Supported Cache Providers.md index 435fdd2a..fa9fcb13 100644 --- a/IV. Spring Boot features/31.1 Supported cache providers.md +++ b/IV. Spring Boot features/31.1 Supported Cache Providers.md @@ -4,15 +4,15 @@ 如果你还没有定义一个`CacheManager`类型的bean,或一个名为`cacheResolver`的`CacheResolver`(查看`CachingConfigurer`),Spring Boot将尝试以下提供商(按这个顺序): - * [Generic](https://docs.spring.io/spring-boot/docs/2.0.0.RELEASE/reference/htmlsingle/#boot-features-caching-provider-generic) - * [JCache (JSR-107)](https://docs.spring.io/spring-boot/docs/2.0.0.RELEASE/reference/htmlsingle/#boot-features-caching-provider-jcache)(EhCache 3, Hazelcast, Infinispan, etc) - * [EhCache 2.x](https://docs.spring.io/spring-boot/docs/2.0.0.RELEASE/reference/htmlsingle/#boot-features-caching-provider-ehcache2) - * [Hazelcast](https://docs.spring.io/spring-boot/docs/2.0.0.RELEASE/reference/htmlsingle/#boot-features-caching-provider-hazelcast) - * [Infinispan](https://docs.spring.io/spring-boot/docs/2.0.0.RELEASE/reference/htmlsingle/#boot-features-caching-provider-infinispan) - * [Couchbase](https://docs.spring.io/spring-boot/docs/2.0.0.RELEASE/reference/htmlsingle/#boot-features-caching-provider-couchbase) - * [Redis](https://docs.spring.io/spring-boot/docs/2.0.0.RELEASE/reference/htmlsingle/#boot-features-caching-provider-redis) - * [Caffeine](https://docs.spring.io/spring-boot/docs/2.0.0.RELEASE/reference/htmlsingle/#boot-features-caching-provider-caffeine) - * [Simple](https://docs.spring.io/spring-boot/docs/2.0.0.RELEASE/reference/htmlsingle/#boot-features-caching-provider-simple) + 1. [Generic](https://docs.spring.io/spring-boot/docs/2.0.0.RELEASE/reference/htmlsingle/#boot-features-caching-provider-generic) + 2. [JCache (JSR-107)](https://docs.spring.io/spring-boot/docs/2.0.0.RELEASE/reference/htmlsingle/#boot-features-caching-provider-jcache)(EhCache 3, Hazelcast, Infinispan, etc) + 3. [EhCache 2.x](https://docs.spring.io/spring-boot/docs/2.0.0.RELEASE/reference/htmlsingle/#boot-features-caching-provider-ehcache2) + 4. [Hazelcast](https://docs.spring.io/spring-boot/docs/2.0.0.RELEASE/reference/htmlsingle/#boot-features-caching-provider-hazelcast) + 5. [Infinispan](https://docs.spring.io/spring-boot/docs/2.0.0.RELEASE/reference/htmlsingle/#boot-features-caching-provider-infinispan) + 6. [Couchbase](https://docs.spring.io/spring-boot/docs/2.0.0.RELEASE/reference/htmlsingle/#boot-features-caching-provider-couchbase) + 7. [Redis](https://docs.spring.io/spring-boot/docs/2.0.0.RELEASE/reference/htmlsingle/#boot-features-caching-provider-redis) + 8. [Caffeine](https://docs.spring.io/spring-boot/docs/2.0.0.RELEASE/reference/htmlsingle/#boot-features-caching-provider-caffeine) + 9. [Simple](https://docs.spring.io/spring-boot/docs/2.0.0.RELEASE/reference/htmlsingle/#boot-features-caching-provider-simple) **提示** `spring.cache.type`属性可强制指定使用的缓存提供商,如果需要在一些环境(比如,测试)中[禁用全部缓存](https://docs.spring.io/spring-boot/docs/2.0.0.RELEASE/reference/htmlsingle/#boot-features-caching-provider-none)也可以使用该属性。 From 3fee434bb517e553766fa28e192bf8ea05572843 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E7=83=AD=E5=BF=83=E5=B8=82=E6=B0=91=E9=92=9F=E5=B0=8F?= =?UTF-8?q?=E5=BC=BA?= Date: Fri, 26 Apr 2019 14:41:40 +0800 Subject: [PATCH 318/865] Update SUMMARY.md --- SUMMARY.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/SUMMARY.md b/SUMMARY.md index 21853cfc..640c67dd 100644 --- a/SUMMARY.md +++ b/SUMMARY.md @@ -211,7 +211,7 @@ * [30.10 InfluxDB](IV. Spring Boot features/30.10 InfluxDB.md) * [30.10.1 连接InfluxDB](IV. Spring Boot features/30.10.1 Connecting to InfluxDB.md) * [31. 缓存](IV. Spring Boot features/31. Caching.md) - * [31.1 支持的缓存提供商](IV. Spring Boot features/31.1 Supported cache providers.md) + * [31.1 支持的缓存提供商](IV. Spring Boot features/31.1 Supported Cache Providers.md) * [31.1.1 Generic](IV. Spring Boot features/31.1.1 Generic.md) * [31.1.2 JCache (JSR-107)](IV. Spring Boot features/31.1.2 JCache(JSR-107).md) * [31.1.3 EhCache 2.x](IV. Spring Boot features/31.1.3 EhCache 2.x.md) From e85c52ad90d471a2b1f2ab65524e6183b50e9e74 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E7=83=AD=E5=BF=83=E5=B8=82=E6=B0=91=E9=92=9F=E5=B0=8F?= =?UTF-8?q?=E5=BC=BA?= Date: Sun, 28 Apr 2019 11:55:15 +0800 Subject: [PATCH 319/865] =?UTF-8?q?Update=2031.1.2=20JCache=EF=BC=88JSR-10?= =?UTF-8?q?7=EF=BC=89.md?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../31.1.2 JCache\357\274\210JSR-107\357\274\211.md" | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git "a/IV. Spring Boot features/31.1.2 JCache\357\274\210JSR-107\357\274\211.md" "b/IV. Spring Boot features/31.1.2 JCache\357\274\210JSR-107\357\274\211.md" index abca3fe1..4b72d9fb 100644 --- "a/IV. Spring Boot features/31.1.2 JCache\357\274\210JSR-107\357\274\211.md" +++ "b/IV. Spring Boot features/31.1.2 JCache\357\274\210JSR-107\357\274\211.md" @@ -1,6 +1,6 @@ ### 31.1.2 JCache (JSR-107) -classpath下存在`javax.cache.spi.CachingProvider`(比如,一个遵循JSR-107的缓存library),并且`spring-boot-starter-cache`“Starter”提供了`JCacheCacheManager`,则JCache将启动。这里有很多遵循JSR-107的libraries,Spring Boot为Ehcache 3, Hazelcast和Infinispan提供依赖管理,其他library也可以像这样添加。 +类路径下存在`javax.cache.spi.CachingProvider`(也就是,类路径下存在一个遵循JSR-107的缓存库),并且`spring-boot-starter-cache`“Starter”提供了`JCacheCacheManager`,则[JCache](https://jcp.org/en/jsr/detail?id=107)将启动。这里有很多遵循JSR-107的库,Spring Boot为Ehcache 3、Hazelcast和Infinispan提供依赖管理。也可以添加其他库。 如果出现多个提供商,你需要明确指定使用哪个(提供商)。尽管JSR-107标准没有强制定义配置文件的位置,Spring Boot会尽量配合各实现情况: ```properties @@ -8,9 +8,10 @@ classpath下存在`javax.cache.spi.CachingProvider`(比如,一个遵循JSR-1 spring.cache.jcache.provider=com.acme.MyCachingProvider spring.cache.jcache.config=classpath:acme.xml ``` + **注** 由于一个缓存library可能提供的既有native实现,也有JSR-107支持,Spring Boot将优先使用JSR-107支持,这样如果你切换到不同的JSR-107实现,相同特性依旧可以使用。 -**提示** Spring Boot对Hazelcast有[广泛支持](../IV. Spring Boot features/37. Hazelcast.md)。如果单个的`HazelcastInstance`可用,它就会被`CacheManager`重复使用,除非指定了`spring.cache.jcache.config`属性。 +**提示** Spring Boot对Hazelcast有[广泛支持](../IV. Spring Boot features/38. Hazelcast.md)。如果单个的`HazelcastInstance`可用,它就会被`CacheManager`重复使用,除非指定了`spring.cache.jcache.config`属性。 以下方式可以自定义底层的`javax.cache.cacheManager`: From 8a07d12dcf0ebdeec4b3683097a978d15f84ae78 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E7=83=AD=E5=BF=83=E5=B8=82=E6=B0=91=E9=92=9F=E5=B0=8F?= =?UTF-8?q?=E5=BC=BA?= Date: Sun, 28 Apr 2019 12:48:45 +0800 Subject: [PATCH 320/865] Update 31.1.3 EhCache 2.x.md --- IV. Spring Boot features/31.1.3 EhCache 2.x.md | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/IV. Spring Boot features/31.1.3 EhCache 2.x.md b/IV. Spring Boot features/31.1.3 EhCache 2.x.md index d370a78c..9913fd85 100644 --- a/IV. Spring Boot features/31.1.3 EhCache 2.x.md +++ b/IV. Spring Boot features/31.1.3 EhCache 2.x.md @@ -1,6 +1,7 @@ ### 31.1.3 EhCache 2.x -如果在classpath下的根目录可以找到一个名为`ehcache.xml`的文件,则缓存将使用EhCache 2.x。如果EhCache 2.x(由`spring-boot-starter-cache`”Starter“提供的`EhCacheCacheManager`)和这样的文件出现,那它们将用于启动缓存管理器,使用以下配置也可以提供替换的配置文件: +如果类路径下存在一个名为`ehcache.xml`的文件,则缓存将使用[EhCache](http://www.ehcache.org/) 2.x。如果存在EhCache 2.x,由`spring-boot-starter-cache`“Starter”提供的`EhCacheCacheManager`将用于启动缓存管理器。也可以提供一个替代的配置文件,如下所示: + ```properties spring.cache.ehcache.config=classpath:config/another-config.xml ``` From 10455f135b98f9f2524fd627aacc320a1963267f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E7=83=AD=E5=BF=83=E5=B8=82=E6=B0=91=E9=92=9F=E5=B0=8F?= =?UTF-8?q?=E5=BC=BA?= Date: Sun, 28 Apr 2019 15:00:12 +0800 Subject: [PATCH 321/865] Update 31.1.4 Hazelcast.md --- IV. Spring Boot features/31.1.4 Hazelcast.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/IV. Spring Boot features/31.1.4 Hazelcast.md b/IV. Spring Boot features/31.1.4 Hazelcast.md index b4f22dfa..51f1b084 100644 --- a/IV. Spring Boot features/31.1.4 Hazelcast.md +++ b/IV. Spring Boot features/31.1.4 Hazelcast.md @@ -1,3 +1,3 @@ ### 31.1.4 Hazelcast -Spring Boot为Hazelcast提供[通常的支持](https://docs.spring.io/spring-boot/docs/2.0.0.RELEASE/reference/htmlsingle/#boot-features-hazelcast),如果`HazelcastInstance`被自动配置,那它将自动包装进一个`CacheManager`。 +Spring Boot为Hazelcast提供[通常的支持](https://docs.spring.io/spring-boot/docs/2.0.0.RELEASE/reference/htmlsingle/#boot-features-hazelcast)。如果`HazelcastInstance`被自动配置,那它将自动包装进一个`CacheManager`。 From b390efc1daf44860405313c54b751224a8f8d8c4 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E7=83=AD=E5=BF=83=E5=B8=82=E6=B0=91=E9=92=9F=E5=B0=8F?= =?UTF-8?q?=E5=BC=BA?= Date: Sun, 28 Apr 2019 15:07:45 +0800 Subject: [PATCH 322/865] Update 31.1.5 Infinispan.md --- IV. Spring Boot features/31.1.5 Infinispan.md | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/IV. Spring Boot features/31.1.5 Infinispan.md b/IV. Spring Boot features/31.1.5 Infinispan.md index 98038dfa..34b36b0a 100644 --- a/IV. Spring Boot features/31.1.5 Infinispan.md +++ b/IV. Spring Boot features/31.1.5 Infinispan.md @@ -1,9 +1,10 @@ ### 31.1.5 Infinispan -Infinispan没有默认的配置文件位置,所以需要显式指定: +Infinispan没有默认的配置文件位置,所以必须显式指定。否则,会使用默认的启动。 ```properties spring.cache.infinispan.config=infinispan.xml ``` -通过设置`spring.cache.cache-names`属性可以让缓存在启动时就被创建,如果定义了`ConfigurationBuilder` bean,它将用来定义该实例。 -**提示** Spring Boot对Infinispan的嵌入模式的支持受限,而且相当基础。如果你需要更多的选择项,你应当使用官方的Infinispan Spring Boot starter,查看[文档](https://github.com/infinispan/infinispan-spring-boot)获取更多详细情况。 +通过设置`spring.cache.cache-names`属性可以让缓存在启动时就被创建。如果定义了自定义的`ConfigurationBuilder` bean,它将用来自定义缓存。 + +**提示** Spring Boot对Infinispan的嵌入模式的支持受限,而且相当基础。如果你需要更多的选择项,你应当使用官方的Infinispan Spring Boot starter。查看[文档](https://github.com/infinispan/infinispan-spring-boot)获取更多详细情况。 From 597bc54cb4c228aaf0d7b543bd93623f459c52a1 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E7=83=AD=E5=BF=83=E5=B8=82=E6=B0=91=E9=92=9F=E5=B0=8F?= =?UTF-8?q?=E5=BC=BA?= Date: Sun, 28 Apr 2019 16:07:02 +0800 Subject: [PATCH 323/865] Update 31.1.6 Couchbase.md --- IV. Spring Boot features/31.1.6 Couchbase.md | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/IV. Spring Boot features/31.1.6 Couchbase.md b/IV. Spring Boot features/31.1.6 Couchbase.md index 942a7c64..7eee3956 100644 --- a/IV. Spring Boot features/31.1.6 Couchbase.md +++ b/IV. Spring Boot features/31.1.6 Couchbase.md @@ -1,10 +1,12 @@ ### 31.1.6 Couchbase -如果Couchbase Java客户端和`couchbase-spring-cache`实现可用,并且已经配置好了,`CouchbaseCacheManager`将会自动配置,使用`spring.cache.cache-names`属性可以在启动时创建其他缓存。对`Bucket`的操作也是自动配置的,你可以使用customizer在另一个`Bucket`上创建其他缓存:假设你需要在“main” `Bucket`上存放两个缓存(`foo`和`bar`),在另一个`Bucket`上存放一个存活时间为2秒的`biz`缓存。首先,你通过配置创建两个缓存: +如果[Couchbase](https://www.couchbase.com/) Java客户端和`couchbase-spring-cache`实现可用,并且已经配置好了,`CouchbaseCacheManager`将会自动配置,使用`spring.cache.cache-names`属性可以在启动时创建其他缓存。对`Bucket`的操作也是自动配置的,你可以使用customizer在另一个`Bucket`上创建其他缓存:假设你需要在“main” `Bucket`上存放两个缓存(`cache1`和`cache2`),在另一个`Bucket`上存放一个存活时间为2秒的`cache3`缓存。首先,你通过配置创建两个缓存: + ```properties -spring.cache.cache-names=foo,bar +spring.cache.cache-names=cache1,cache2 ``` -然后定义其他`@Configuration`来配置另一个`Bucket`和`biz`缓存: + +然后定义其他`@Configuration`来配置另一个`Bucket`和`cache3`缓存: ```java @Configuration public class CouchbaseCacheConfiguration { @@ -23,7 +25,7 @@ public class CouchbaseCacheConfiguration { @Bean public CacheManagerCustomizer cacheManagerCustomizer() { return c -> { - c.prepareCache("biz", CacheBuilder.newInstance(anotherBucket()) + c.prepareCache("cache3", CacheBuilder.newInstance(anotherBucket()) .withExpiration(2)); }; } From fc6c3ca112d953b484f4c8d46559970efa746e42 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E7=83=AD=E5=BF=83=E5=B8=82=E6=B0=91=E9=92=9F=E5=B0=8F?= =?UTF-8?q?=E5=BC=BA?= Date: Tue, 30 Apr 2019 18:13:09 +0800 Subject: [PATCH 324/865] Update 31.1.7 Redis.md --- IV. Spring Boot features/31.1.7 Redis.md | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/IV. Spring Boot features/31.1.7 Redis.md b/IV. Spring Boot features/31.1.7 Redis.md index ad90dc6d..73487d76 100644 --- a/IV. Spring Boot features/31.1.7 Redis.md +++ b/IV. Spring Boot features/31.1.7 Redis.md @@ -1,5 +1,13 @@ ### 31.1.7 Redis -如果Redis可用,并配置好了,`RedisCacheManager`将被自动配置,使用`spring.cache.cache-names`可以在启动时创建其他缓存。 +如果[Redis](http://redis.io/)可用,并配置好了,`RedisCacheManager`将被自动配置,设置`spring.cache.cache-names`属性可以在启动时创建额外的缓存。and cache defaults can be configured by using `spring.cache.redis.*` properties. For instance, the following configuration creates `cache1` and `cache2` caches with a time to live of 10 minutes: + +```properties +spring.cache.cache-names=cache1,cache2 +spring.cache.redis.time-to-live=600000 +``` **注** 默认会添加key前缀以防止两个单独的缓存使用相同的key,否则Redis将存在重复的key,有可能返回不可用的值。如果创建自己的`RedisCacheManager`,强烈建议你保留该配置处于启用状态。 + + +**注** You can take full control of the configuration by adding a `RedisCacheConfiguration` `@Bean` of your own. This can be useful if you’re looking for customizing the serialization strategy. From 5d07758a03bf52b810c370f4966ca15d0532d2cc Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E7=83=AD=E5=BF=83=E5=B8=82=E6=B0=91=E9=92=9F=E5=B0=8F?= =?UTF-8?q?=E5=BC=BA?= Date: Tue, 30 Apr 2019 18:25:52 +0800 Subject: [PATCH 325/865] Update 31.1.7 Redis.md --- IV. Spring Boot features/31.1.7 Redis.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/IV. Spring Boot features/31.1.7 Redis.md b/IV. Spring Boot features/31.1.7 Redis.md index 73487d76..47d9d18e 100644 --- a/IV. Spring Boot features/31.1.7 Redis.md +++ b/IV. Spring Boot features/31.1.7 Redis.md @@ -1,6 +1,6 @@ ### 31.1.7 Redis -如果[Redis](http://redis.io/)可用,并配置好了,`RedisCacheManager`将被自动配置,设置`spring.cache.cache-names`属性可以在启动时创建额外的缓存。and cache defaults can be configured by using `spring.cache.redis.*` properties. For instance, the following configuration creates `cache1` and `cache2` caches with a time to live of 10 minutes: +如果[Redis](http://redis.io/)可用,并配置好了,`RedisCacheManager`将被自动配置。设置`spring.cache.cache-names`属性可以在启动时创建额外的缓存。使用`spring.cache.redis.*`属性可以配置缓存的默认值。比如,下面的配置会创建缓存`cache1`和`cache2`。它们的存活时间为10分钟。 ```properties spring.cache.cache-names=cache1,cache2 @@ -10,4 +10,4 @@ spring.cache.redis.time-to-live=600000 **注** 默认会添加key前缀以防止两个单独的缓存使用相同的key,否则Redis将存在重复的key,有可能返回不可用的值。如果创建自己的`RedisCacheManager`,强烈建议你保留该配置处于启用状态。 -**注** You can take full control of the configuration by adding a `RedisCacheConfiguration` `@Bean` of your own. This can be useful if you’re looking for customizing the serialization strategy. +**注** 你可以添加自己的`RedisCacheConfiguration` `@Bean`,完全掌控配置。如果你正在寻找自定义序列化策略,这会很有用。 From 02efc78aa08f83f91ec26b7e687399b2192430a9 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E7=83=AD=E5=BF=83=E5=B8=82=E6=B0=91=E9=92=9F=E5=B0=8F?= =?UTF-8?q?=E5=BC=BA?= Date: Sun, 5 May 2019 17:11:27 +0800 Subject: [PATCH 326/865] Update 31.1.8 Caffeine.md --- IV. Spring Boot features/31.1.8 Caffeine.md | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/IV. Spring Boot features/31.1.8 Caffeine.md b/IV. Spring Boot features/31.1.8 Caffeine.md index d4df468d..595e7ee0 100644 --- a/IV. Spring Boot features/31.1.8 Caffeine.md +++ b/IV. Spring Boot features/31.1.8 Caffeine.md @@ -1,14 +1,15 @@ ### 31.1.8 Caffeine -Caffeine是Java8对Guava缓存的重写版本,取代了Guava。如果出现Caffeine,`CaffeineCacheManager`(由`spring-boot-starter-cache` Starter提供)将会自动配置。使用`spring.cache.cache-names`属性可以在启动时创建缓存,并可以通过以下配置进行自定义(按顺序): +[Caffeine](https://github.com/ben-manes/caffeine)是Java 8对Guava缓存的重写版本,取代了Guava。如果出现Caffeine,`CaffeineCacheManager`(由`spring-boot-starter-cache` Starter提供)将会自动配置。使用`spring.cache.cache-names`属性可以在启动时创建缓存,并可以通过以下配置中的一个进行自定义(按指示的顺序): 1. `spring.cache.caffeine.spec`定义的特殊缓存 2. `com.github.benmanes.caffeine.cache.CaffeineSpec` bean定义 3. `com.github.benmanes.caffeine.cache.Caffeine` bean定义 -例如,以下配置创建一个`foo`和`bar`缓存,最大数量为500,存活时间为10分钟: +例如,以下配置创建一个`cache1 `和`cache2`缓存,最大数量为500,存活时间为10分钟: ```properties -spring.cache.cache-names=foo,bar +spring.cache.cache-names=cache1,cache2 spring.cache.caffeine.spec=maximumSize=500,expireAfterAccess=600s ``` -除此之外,如果定义了`com.github.benmanes.caffeine.cache.CacheLoader`,它会自动关联到`CaffeineCacheManager`。由于该`CacheLoader`将关联被该缓存管理器管理的所有缓存,所以它必须定义为`CacheLoader`,自动配置将忽略所有泛型类型。 + +除此之外,如果定义了`com.github.benmanes.caffeine.cache.CacheLoader`,它会自动关联到`CaffeineCacheManager`。由于该`CacheLoader`将关联被该缓存管理器管理的所有缓存,所以它必须定义为`CacheLoader`。自动配置将忽略所有泛型类型。 From 092fb3c3130423d288ea61a200ecd3ffc019e3b5 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E7=83=AD=E5=BF=83=E5=B8=82=E6=B0=91=E9=92=9F=E5=B0=8F?= =?UTF-8?q?=E5=BC=BA?= Date: Sun, 5 May 2019 17:20:09 +0800 Subject: [PATCH 327/865] Update 31.1.9 Simple.md --- IV. Spring Boot features/31.1.9 Simple.md | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/IV. Spring Boot features/31.1.9 Simple.md b/IV. Spring Boot features/31.1.9 Simple.md index cddae53b..bb3cd064 100644 --- a/IV. Spring Boot features/31.1.9 Simple.md +++ b/IV. Spring Boot features/31.1.9 Simple.md @@ -1,7 +1,8 @@ ### 31.1.9 Simple -如果找不到其它提供商,一个使用`ConcurrentHashMap`作为缓存存储的简单实现将被配置,这是应用没有添加缓存library的默认设置。默认地,缓存在运行中被创建。但是你可以通过使用`cache-names`属性来限制可用的缓存。例如,如果你只想要`foo`和`bar`缓存: +如果找不到其它提供商,一个使用`ConcurrentHashMap`作为缓存存储的简单实现将被配置。这是应用没有添加缓存库的默认设置。默认地,缓存按需被创建。但是你可以通过设置`cache-names`属性来限制可用的缓存。例如,如果你只想要`cache1`和`cache2`缓存,如下设置`cache-names`属性: ```properties -spring.cache.cache-names=foo,bar +spring.cache.cache-names=cache1,cache2 ``` -如果你这样做了,而你的应用使用了一个没有列举在以上列表中的缓存,那么当需要此缓存时,获取缓存的操作会在运行时失败,而不是在启动时。这和实际的缓存提供商的行为相似,如果你使用了一个没有声明的缓存。 \ No newline at end of file + +如果你这样做了,而你的应用使用了一个没有列举在以上列表中的缓存,那么当需要此缓存时,获取缓存的操作会在运行时失败,而不是在启动时。这和实际的缓存提供商的行为相似,如果你使用了一个没有声明的缓存。 From 1826f0b3f2fd88c8feed63705089f943f6b4fddf Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E7=83=AD=E5=BF=83=E5=B8=82=E6=B0=91=E9=92=9F=E5=B0=8F?= =?UTF-8?q?=E5=BC=BA?= Date: Sun, 5 May 2019 17:21:36 +0800 Subject: [PATCH 328/865] Update 31.1.10 None.md --- IV. Spring Boot features/31.1.10 None.md | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/IV. Spring Boot features/31.1.10 None.md b/IV. Spring Boot features/31.1.10 None.md index 4cc85f81..b4bf552a 100644 --- a/IV. Spring Boot features/31.1.10 None.md +++ b/IV. Spring Boot features/31.1.10 None.md @@ -1,6 +1,7 @@ ### 31.1.10 None -如果配置类中出现`@EnableCaching`,一个合适的缓存配置也同样被期待。如果在某些环境需要禁用全部缓存,强制将缓存类型设为`none`将会使用一个no-op实现(没有任何实现的实现): +如果配置类中出现`@EnableCaching`,一个合适的缓存配置也同样被期待。如果在某些环境需要禁用全部缓存,强制将缓存类型设为`none`将会使用一个no-op实现(没有任何实现的实现),如下所示: + ```properties spring.cache.type=none ``` From fc54d0c1e7aee5b3339f3352ef78995a6a88b435 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E7=83=AD=E5=BF=83=E5=B8=82=E6=B0=91=E9=92=9F=E5=B0=8F?= =?UTF-8?q?=E5=BC=BA?= Date: Sun, 5 May 2019 17:31:00 +0800 Subject: [PATCH 329/865] Update 32. Messaging.md --- IV. Spring Boot features/32. Messaging.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/IV. Spring Boot features/32. Messaging.md b/IV. Spring Boot features/32. Messaging.md index 2e5a0330..0d649174 100644 --- a/IV. Spring Boot features/32. Messaging.md +++ b/IV. Spring Boot features/32. Messaging.md @@ -1,3 +1,3 @@ ### 32. 消息 -Spring Framework框架为集成消息系统提供了扩展(extensive)支持:从使用`JmsTemplate`简化JMS API,到实现一个能够异步接收消息的完整的底层设施。Spring AMQP提供一个相似的用于'高级消息队列协议'的特征集,并且Spring Boot也为`RabbitTemplate`和RabbitMQ提供了自动配置选项。Spring Websocket提供原生的STOMP消息支持,并且Spring Boot也提供了starters和自动配置支持。Spring Boot也提供了对Apache Kafka的支持。 +Spring框架为集成消息系统提供了扩展支持:从使用`JmsTemplate`简化JMS API,到实现一个能够异步接收消息的完整的底层设施。Spring AMQP提供一个相似的用于“高级消息队列协议”的特征集。并且,Spring Boot也为`RabbitTemplate`和RabbitMQ提供了自动配置选项。Spring Websocket提供原生的STOMP消息支持,并且Spring Boot也提供了starters和自动配置支持。Spring Boot也提供了对Apache Kafka的支持。 From e96c9529e3959972df06042e77208df62aea636b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E7=83=AD=E5=BF=83=E5=B8=82=E6=B0=91=E9=92=9F=E5=B0=8F?= =?UTF-8?q?=E5=BC=BA?= Date: Mon, 13 May 2019 21:51:16 +0800 Subject: [PATCH 330/865] Update 32.1. JMS.md --- IV. Spring Boot features/32.1. JMS.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/IV. Spring Boot features/32.1. JMS.md b/IV. Spring Boot features/32.1. JMS.md index 7575b518..bdc45a0e 100644 --- a/IV. Spring Boot features/32.1. JMS.md +++ b/IV. Spring Boot features/32.1. JMS.md @@ -1,4 +1,4 @@ ### 32.1. JMS `javax.jms.ConnectionFactory`接口提供标准的用于创建`javax.jms.Connection`的方法,`javax.jms.Connection`用于和JMS代理(broker)交互。 -尽管Spring需要一个`ConnectionFactory`才能使用JMS,通常你不需要直接使用它,而是依赖于上层消息抽象(具体参考Spring框架的[相关章节](https://docs.spring.io/spring/docs/5.0.4.RELEASE/spring-framework-reference/htmlsingle/#jms)),Spring Boot会自动配置发送和接收消息需要的设施(infrastructure)。 +尽管Spring需要一个`ConnectionFactory`才能使用JMS,通常你不需要直接使用它,而是依赖于上层消息抽象(具体参考Spring框架的[相关章节](https://docs.spring.io/spring/docs/5.0.4.RELEASE/spring-framework-reference/integration.html#jms)),Spring Boot会自动配置发送和接收消息需要的设施(infrastructure)。 From 40fa6fc4c99d8eff6981b3e4294304263f0296e8 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E7=83=AD=E5=BF=83=E5=B8=82=E6=B0=91=E9=92=9F=E5=B0=8F?= =?UTF-8?q?=E5=BC=BA?= Date: Mon, 13 May 2019 21:59:54 +0800 Subject: [PATCH 331/865] Update and rename 32.1.1 ActiveMQ support.md to 32.1.1 ActiveMQ Support.md --- .../32.1.1 ActiveMQ Support.md | 20 +++++++++++++++++++ .../32.1.1 ActiveMQ support.md | 18 ----------------- 2 files changed, 20 insertions(+), 18 deletions(-) create mode 100644 IV. Spring Boot features/32.1.1 ActiveMQ Support.md delete mode 100644 IV. Spring Boot features/32.1.1 ActiveMQ support.md diff --git a/IV. Spring Boot features/32.1.1 ActiveMQ Support.md b/IV. Spring Boot features/32.1.1 ActiveMQ Support.md new file mode 100644 index 00000000..d45ee93f --- /dev/null +++ b/IV. Spring Boot features/32.1.1 ActiveMQ Support.md @@ -0,0 +1,20 @@ +### 32.1.1 ActiveQ支持 + +如果ActiveMQ在类路径下,Spring Boot会配置一个`ConnectionFactory`。如果需要代理,将会开启一个内嵌的,已经自动配置好的代理(只要配置中没有指定代理URL)。 + +ActiveMQ是通过`spring.activemq.*`外部配置来控制的,例如,你可能在`application.properties`中声明以下片段: +```properties +spring.activemq.broker-url=tcp://192.168.1.210:9876 +spring.activemq.user=admin +spring.activemq.password=secret +``` + +你也可以通过添加`org.apache.activemq:activemq-pool`来集合JMS资源,并如下配置`PooledConnectionFactory`。如下所示: +```properties +spring.activemq.pool.enabled=true +spring.activemq.pool.max-connections=50 +``` + +具体参考[ActiveMQProperties](https://github.com/spring-projects/spring-boot/tree/v2.0.0.RELEASE/spring-boot-project/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/jms/activemq/ActiveMQProperties.java)。你也可以注册任意数量的实现`ActiveMQConnectionFactoryCustomizer`的bean,来实现更多高级的自定义。 + +默认情况下,如果目标不存在,ActiveMQ将创建一个,所以目标是通过它们提供的名称解析出来的。 diff --git a/IV. Spring Boot features/32.1.1 ActiveMQ support.md b/IV. Spring Boot features/32.1.1 ActiveMQ support.md deleted file mode 100644 index 5a648e82..00000000 --- a/IV. Spring Boot features/32.1.1 ActiveMQ support.md +++ /dev/null @@ -1,18 +0,0 @@ -### 32.1.1 ActiveQ支持 - -如果发现ActiveMQ在classpath下可用,Spring Boot会配置一个`ConnectionFactory`。如果需要代理,将会开启一个内嵌的,已经自动配置好的代理(只要配置中没有指定代理URL)。 - -ActiveMQ是通过`spring.activemq.*`外部配置来控制的,例如,你可能在`application.properties`中声明以下片段: -```properties -spring.activemq.broker-url=tcp://192.168.1.210:9876 -spring.activemq.user=admin -spring.activemq.password=secret -``` -你也可以通过添加`org.apache.activemq:activemq-pool`来集合JMS资源,并如下配置`PooledConnectionFactory`: -```properties -spring.activemq.pool.enabled=true -spring.activemq.pool.max-connections=50 -``` -具体参考[ActiveMQProperties](http://github.com/spring-projects/spring-boot/tree/master/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/jms/activemq/ActiveMQProperties.java)。 - -默认情况下,如果目标不存在,ActiveMQ将创建一个,所以目标是通过它们提供的名称解析出来的。 From df66e82ddb2acf8c958022c1d23cbe5299cdb8a2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E7=83=AD=E5=BF=83=E5=B8=82=E6=B0=91=E9=92=9F=E5=B0=8F?= =?UTF-8?q?=E5=BC=BA?= Date: Mon, 13 May 2019 22:05:37 +0800 Subject: [PATCH 332/865] Update and rename 32.1.2 Artemis support.md to 32.1.2 Artemis Support.md --- .../{32.1.2 Artemis support.md => 32.1.2 Artemis Support.md} | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) rename IV. Spring Boot features/{32.1.2 Artemis support.md => 32.1.2 Artemis Support.md} (54%) diff --git a/IV. Spring Boot features/32.1.2 Artemis support.md b/IV. Spring Boot features/32.1.2 Artemis Support.md similarity index 54% rename from IV. Spring Boot features/32.1.2 Artemis support.md rename to IV. Spring Boot features/32.1.2 Artemis Support.md index 2d3617d8..41385f57 100644 --- a/IV. Spring Boot features/32.1.2 Artemis support.md +++ b/IV. Spring Boot features/32.1.2 Artemis Support.md @@ -1,6 +1,6 @@ ### 32.1.2 Artemis支持 -如果发现classpath下存在Artemis依赖,Spring Boot将自动配置一个`ConnectionFactory`。如果需要broker,Spring Boot将启动内嵌的broker,并对其自动配置(除非模式mode属性被显式设置)。支持的modes包括:`embedded`(明确需要内嵌broker,如果classpath下不存在则出错),`native`(使用`netty`传输协议连接broker)。当配置`native`模式,Spring Boot将配置一个连接broker的`ConnectionFactory`,该broker使用默认的设置运行在本地机器。 +如果发现classpath下存在[Artemis](http://activemq.apache.org/artemis/)依赖,Spring Boot将自动配置一个`ConnectionFactory`。如果需要broker,Spring Boot将启动内嵌的broker,并对其自动配置(除非模式mode属性被显式设置)。支持的modes包括:`embedded`(明确需要内嵌broker,如果classpath下不存在则出错),`native`(使用`netty`传输协议连接broker)。当配置`native`模式,Spring Boot将配置一个连接broker的`ConnectionFactory`,该broker使用默认的设置运行在本地机器。 **注** 使用`spring-boot-starter-artemis` 'Starter',则连接已存在的Artemis实例及Spring设施集成JMS所需依赖都会提供,添加`org.apache.activemq:artemis-jms-server`依赖,你可以使用内嵌模式。 Artemis配置控制在外部配置属性`spring.artemis.*`中,例如,在`application.properties`声明以下片段: @@ -11,4 +11,4 @@ spring.artemis.port=9876 spring.artemis.user=admin spring.artemis.password=secret ``` -当使用内嵌模式时,你可以选择是否启用持久化,及目的地列表。这些可以通过逗号分割的列表来指定,也可以分别定义`org.apache.activemq.artemis.jms.server.config.JMSQueueConfiguration`或`org.apache.activemq.artemis.jms.server.config.TopicConfiguration`类型的bean来进一步配置队列和topic,具体支持选项可参考[ArtemisProperties](https://github.com/spring-projects/spring-boot/tree/v2.0.0.RELEASE/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/jms/artemis/ArtemisProperties.java)。 +当使用内嵌模式时,你可以选择是否启用持久化,及目的地列表。这些可以通过逗号分割的列表来指定,也可以分别定义`org.apache.activemq.artemis.jms.server.config.JMSQueueConfiguration`或`org.apache.activemq.artemis.jms.server.config.TopicConfiguration`类型的bean来进一步配置队列和topic。具体支持选项可参考[ArtemisProperties](https://github.com/spring-projects/spring-boot/tree/v2.0.0.RELEASE/spring-boot-project/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/jms/artemis/ArtemisProperties.java)。 From 4d2906cbac2bced0207fccbd31613e2766020376 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E7=83=AD=E5=BF=83=E5=B8=82=E6=B0=91=E9=92=9F=E5=B0=8F?= =?UTF-8?q?=E5=BC=BA?= Date: Mon, 13 May 2019 22:07:29 +0800 Subject: [PATCH 333/865] Update SUMMARY.md --- SUMMARY.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/SUMMARY.md b/SUMMARY.md index 640c67dd..1431db9b 100644 --- a/SUMMARY.md +++ b/SUMMARY.md @@ -224,8 +224,8 @@ * [31.1.10 None](IV. Spring Boot features/31.1.10 None.md) * [32. 消息](IV. Spring Boot features/32. Messaging.md) * [32.1. JMS](IV. Spring Boot features/32.1. JMS.md) - * [32.1.1 ActiveQ支持](IV. Spring Boot features/32.1.1 ActiveMQ support.md) - * [32.1.2 Artemis支持](IV. Spring Boot features/32.1.2 Artemis support.md) + * [32.1.1 ActiveQ支持](IV. Spring Boot features/32.1.1 ActiveMQ Support.md) + * [32.1.2 Artemis支持](IV. Spring Boot features/32.1.2 Artemis Support.md) * [32.1.3 使用JNDI ConnectionFactory](IV. Spring Boot features/32.1.3 Using a JNDI ConnectionFactory.md) * [32.1.4 发送消息](IV. Spring Boot features/32.1.4 Sending a message.md) * [32.1.5 接收消息](IV. Spring Boot features/32.1.5 Receiving a message.md) From cf959c19db16ec91e99401b06330bef32167c8fc Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E7=83=AD=E5=BF=83=E5=B8=82=E6=B0=91=E9=92=9F=E5=B0=8F?= =?UTF-8?q?=E5=BC=BA?= Date: Wed, 15 May 2019 23:47:44 +0800 Subject: [PATCH 334/865] Update and rename 32.1.4 Sending a message.md to 32.1.4 Sending a Message.md --- ...32.1.4 Sending a message.md => 32.1.4 Sending a Message.md} | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) rename IV. Spring Boot features/{32.1.4 Sending a message.md => 32.1.4 Sending a Message.md} (83%) diff --git a/IV. Spring Boot features/32.1.4 Sending a message.md b/IV. Spring Boot features/32.1.4 Sending a Message.md similarity index 83% rename from IV. Spring Boot features/32.1.4 Sending a message.md rename to IV. Spring Boot features/32.1.4 Sending a Message.md index 057b61a9..57a9ab88 100644 --- a/IV. Spring Boot features/32.1.4 Sending a message.md +++ b/IV. Spring Boot features/32.1.4 Sending a Message.md @@ -1,6 +1,7 @@ ### 32.1.4 发送消息 Spring的`JmsTemplate`会被自动配置,你可以将它直接注入到自己的beans中: + ```java import org.springframework.beans.factory.annotation.Autowired; import org.springframework.jms.core.JmsTemplate; @@ -16,4 +17,4 @@ this.jmsTemplate = jmsTemplate; } ``` -**注** 你可以使用相同方式注入[JmsMessagingTemplate](https://docs.spring.io/spring/docs/5.0.4.RELEASE/javadoc-api/org/springframework/jms/core/JmsMessagingTemplate.html)。如果定义了`DestinationResolver`或`MessageConverter` beans,它们将自动关联到自动配置的`JmsTemplate`。 +**注** 你可以使用相同方式注入[JmsMessagingTemplate](https://docs.spring.io/spring/docs/5.0.4.RELEASE/javadoc-api/org/springframework/jms/core/JmsMessagingTemplate.html)。如果定义了`DestinationResolver`或`MessageConverter` bean,它们将自动关联到自动配置的`JmsTemplate`。 From 30e9686817d81ad7bff07a76e612edb9bf49d85b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E7=83=AD=E5=BF=83=E5=B8=82=E6=B0=91=E9=92=9F=E5=B0=8F?= =?UTF-8?q?=E5=BC=BA?= Date: Wed, 15 May 2019 23:48:59 +0800 Subject: [PATCH 335/865] Update 32.1.4 Sending a Message.md --- IV. Spring Boot features/32.1.4 Sending a Message.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/IV. Spring Boot features/32.1.4 Sending a Message.md b/IV. Spring Boot features/32.1.4 Sending a Message.md index 57a9ab88..22a74a2a 100644 --- a/IV. Spring Boot features/32.1.4 Sending a Message.md +++ b/IV. Spring Boot features/32.1.4 Sending a Message.md @@ -17,4 +17,4 @@ this.jmsTemplate = jmsTemplate; } ``` -**注** 你可以使用相同方式注入[JmsMessagingTemplate](https://docs.spring.io/spring/docs/5.0.4.RELEASE/javadoc-api/org/springframework/jms/core/JmsMessagingTemplate.html)。如果定义了`DestinationResolver`或`MessageConverter` bean,它们将自动关联到自动配置的`JmsTemplate`。 +**注** 你可以使用相同方式注入[JmsMessagingTemplate](https://docs.spring.io/spring/docs/5.0.4.RELEASE/javadoc-api/org/springframework/jms/core/JmsMessagingTemplate.html)。如果定义了一个`DestinationResolver`或`MessageConverter` bean,它将自动关联到自动配置的`JmsTemplate`。 From c3f818bddda62ee21a6e7c97dc5a625aa32ae0a0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E7=83=AD=E5=BF=83=E5=B8=82=E6=B0=91=E9=92=9F=E5=B0=8F?= =?UTF-8?q?=E5=BC=BA?= Date: Wed, 15 May 2019 23:54:05 +0800 Subject: [PATCH 336/865] Update and rename 32.1.5 Receiving a message.md to 32.1.5 Receiving a Message.md --- ...1.5 Receiving a message.md => 32.1.5 Receiving a Message.md} | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) rename IV. Spring Boot features/{32.1.5 Receiving a message.md => 32.1.5 Receiving a Message.md} (92%) diff --git a/IV. Spring Boot features/32.1.5 Receiving a message.md b/IV. Spring Boot features/32.1.5 Receiving a Message.md similarity index 92% rename from IV. Spring Boot features/32.1.5 Receiving a message.md rename to IV. Spring Boot features/32.1.5 Receiving a Message.md index ee438349..91f7aa77 100644 --- a/IV. Spring Boot features/32.1.5 Receiving a message.md +++ b/IV. Spring Boot features/32.1.5 Receiving a Message.md @@ -1,6 +1,6 @@ ### 32.1.5 接收消息 -当JMS基础设施能够使用时,任何bean都能够被`@JmsListener`注解,以创建一个监听者端点。如果没有定义`JmsListenerContainerFactory`,将自动配置一个默认的。如果定义`DestinationResolver`或`MessageConverter` beans,它们将自动关联该默认factory。 +当JMS基础设施能够使用时,任何bean都能够被`@JmsListener`注解,以创建一个监听者端点。如果没有定义`JmsListenerContainerFactory`,将自动配置一个默认的。如果定义了一个`DestinationResolver`或`MessageConverter` bean,它将自动关联该默认factory。 默认factory是事务性的,如果运行的设施出现`JtaTransactionManager`,它默认将关联到监听器容器。如果没有,`sessionTransacted`标记将启用。在后一场景中,你可以通过在监听器方法上添加`@Transactional`,以本地数据存储事务处理接收的消息,这可以确保接收的消息在本地事务完成后只确认一次。 From 02c2202be4c7bfdb51dd920137e639fb94c51aff Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E7=83=AD=E5=BF=83=E5=B8=82=E6=B0=91=E9=92=9F=E5=B0=8F?= =?UTF-8?q?=E5=BC=BA?= Date: Wed, 15 May 2019 23:55:42 +0800 Subject: [PATCH 337/865] Update SUMMARY.md --- SUMMARY.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/SUMMARY.md b/SUMMARY.md index 1431db9b..40528fa4 100644 --- a/SUMMARY.md +++ b/SUMMARY.md @@ -227,8 +227,8 @@ * [32.1.1 ActiveQ支持](IV. Spring Boot features/32.1.1 ActiveMQ Support.md) * [32.1.2 Artemis支持](IV. Spring Boot features/32.1.2 Artemis Support.md) * [32.1.3 使用JNDI ConnectionFactory](IV. Spring Boot features/32.1.3 Using a JNDI ConnectionFactory.md) - * [32.1.4 发送消息](IV. Spring Boot features/32.1.4 Sending a message.md) - * [32.1.5 接收消息](IV. Spring Boot features/32.1.5 Receiving a message.md) + * [32.1.4 发送消息](IV. Spring Boot features/32.1.4 Sending a Message.md) + * [32.1.5 接收消息](IV. Spring Boot features/32.1.5 Receiving a Message.md) * [32.2 AMQP](IV. Spring Boot features/32.2 AMQP.md) * [32.2.1 RabbitMQ支持](IV. Spring Boot features/32.2.1 RabbitMQ support.md) * [32.2.2 发送消息](IV. Spring Boot features/32.2.2 Sending a message.md) From 0e39aeabe2764e5ab7b0cb5304035065b83e16f1 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E7=83=AD=E5=BF=83=E5=B8=82=E6=B0=91=E9=92=9F=E5=B0=8F?= =?UTF-8?q?=E5=BC=BA?= Date: Fri, 17 May 2019 21:35:32 +0800 Subject: [PATCH 338/865] Update 32.2.1 RabbitMQ support.md --- IV. Spring Boot features/32.2.1 RabbitMQ support.md | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/IV. Spring Boot features/32.2.1 RabbitMQ support.md b/IV. Spring Boot features/32.2.1 RabbitMQ support.md index 00d27aca..cdb98dff 100644 --- a/IV. Spring Boot features/32.2.1 RabbitMQ support.md +++ b/IV. Spring Boot features/32.2.1 RabbitMQ support.md @@ -1,9 +1,12 @@ -###32.2.1 RabbitMQ支持 -RabbitMQ是一个基于AMQP协议,轻量级的,可靠的,可扩展的和可移植的消息代理,Spring就使用它进行消息传递。RabbitMQ配置被外部属性`spring.rabbitmq.*`控制,例如,在`application.properties`中声明以下片段: +### 32.2.1 RabbitMQ支持 + +[RabbitMQ](https://www.rabbitmq.com/)是一个基于AMQP协议的、轻量级的、可靠的、可扩展的和可移植的消息代理。Spring使用它进行消息传递。RabbitMQ配置被外部属性`spring.rabbitmq.*`控制,例如,在`application.properties`中声明以下片段: ```properties spring.rabbitmq.host=localhost spring.rabbitmq.port=5672 spring.rabbitmq.username=admin spring.rabbitmq.password=secret ``` -更多选项参考[RabbitProperties](https://github.com/spring-projects/spring-boot/tree/v2.0.0.RELEASE/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/amqp/RabbitProperties.java)。 +更多选项参考[RabbitProperties](https://github.com/spring-projects/spring-boot/tree/v2.0.0.RELEASE/spring-boot-project/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/amqp/RabbitProperties.java)。 + +**注** 更多细节,请查看[理解AMQP————RabbitMQ使用的协议](https://spring.io/blog/2010/06/14/understanding-amqp-the-protocol-used-by-rabbitmq/)。 From fdedcefd7b398c40601433c0cf9eb42bed07801b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E7=83=AD=E5=BF=83=E5=B8=82=E6=B0=91=E9=92=9F=E5=B0=8F?= =?UTF-8?q?=E5=BC=BA?= Date: Fri, 17 May 2019 21:35:49 +0800 Subject: [PATCH 339/865] Update 32.2.1 RabbitMQ support.md --- IV. Spring Boot features/32.2.1 RabbitMQ support.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/IV. Spring Boot features/32.2.1 RabbitMQ support.md b/IV. Spring Boot features/32.2.1 RabbitMQ support.md index cdb98dff..36f35c11 100644 --- a/IV. Spring Boot features/32.2.1 RabbitMQ support.md +++ b/IV. Spring Boot features/32.2.1 RabbitMQ support.md @@ -9,4 +9,4 @@ spring.rabbitmq.password=secret ``` 更多选项参考[RabbitProperties](https://github.com/spring-projects/spring-boot/tree/v2.0.0.RELEASE/spring-boot-project/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/amqp/RabbitProperties.java)。 -**注** 更多细节,请查看[理解AMQP————RabbitMQ使用的协议](https://spring.io/blog/2010/06/14/understanding-amqp-the-protocol-used-by-rabbitmq/)。 +**注** 更多细节,请查看[理解AMQP,RabbitMQ使用的协议](https://spring.io/blog/2010/06/14/understanding-amqp-the-protocol-used-by-rabbitmq/)。 From e4d91ae6a07ceb401641fa3f13ff935e5cf4bcda Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E7=83=AD=E5=BF=83=E5=B8=82=E6=B0=91=E9=92=9F=E5=B0=8F?= =?UTF-8?q?=E5=BC=BA?= Date: Fri, 17 May 2019 21:36:19 +0800 Subject: [PATCH 340/865] Update 32.2.1 RabbitMQ support.md --- IV. Spring Boot features/32.2.1 RabbitMQ support.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/IV. Spring Boot features/32.2.1 RabbitMQ support.md b/IV. Spring Boot features/32.2.1 RabbitMQ support.md index 36f35c11..6a70452c 100644 --- a/IV. Spring Boot features/32.2.1 RabbitMQ support.md +++ b/IV. Spring Boot features/32.2.1 RabbitMQ support.md @@ -1,6 +1,6 @@ ### 32.2.1 RabbitMQ支持 -[RabbitMQ](https://www.rabbitmq.com/)是一个基于AMQP协议的、轻量级的、可靠的、可扩展的和可移植的消息代理。Spring使用它进行消息传递。RabbitMQ配置被外部属性`spring.rabbitmq.*`控制,例如,在`application.properties`中声明以下片段: +[RabbitMQ](https://www.rabbitmq.com/)是一个基于AMQP协议的、轻量级的、可靠的、可扩展的和可移植的消息代理。Spring使用它进行消息传递。RabbitMQ配置被外部属性`spring.rabbitmq.*`控制。例如,在`application.properties`中声明以下片段: ```properties spring.rabbitmq.host=localhost spring.rabbitmq.port=5672 From 1e87e6469da1e5a64669539758c3508350f3f7e4 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E7=83=AD=E5=BF=83=E5=B8=82=E6=B0=91=E9=92=9F=E5=B0=8F?= =?UTF-8?q?=E5=BC=BA?= Date: Fri, 17 May 2019 21:41:04 +0800 Subject: [PATCH 341/865] Update and rename 32.2.2 Sending a message.md to 32.2.2 Sending a Message.md --- ...32.2.2 Sending a message.md => 32.2.2 Sending a Message.md} | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) rename IV. Spring Boot features/{32.2.2 Sending a message.md => 32.2.2 Sending a Message.md} (97%) diff --git a/IV. Spring Boot features/32.2.2 Sending a message.md b/IV. Spring Boot features/32.2.2 Sending a Message.md similarity index 97% rename from IV. Spring Boot features/32.2.2 Sending a message.md rename to IV. Spring Boot features/32.2.2 Sending a Message.md index dcdcc247..06393719 100644 --- a/IV. Spring Boot features/32.2.2 Sending a message.md +++ b/IV. Spring Boot features/32.2.2 Sending a Message.md @@ -1,4 +1,5 @@ -###32.2.2 发送消息 +### 32.2.2 发送消息 + Spring的`AmqpTemplate`和`AmqpAdmin`会被自动配置,你可以将它们直接注入beans中: ```java import org.springframework.amqp.core.AmqpAdmin; From 09d49955373679b466ea8f6a4568fe7a34ce2fe7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E7=83=AD=E5=BF=83=E5=B8=82=E6=B0=91=E9=92=9F=E5=B0=8F?= =?UTF-8?q?=E5=BC=BA?= Date: Fri, 17 May 2019 21:42:12 +0800 Subject: [PATCH 342/865] Update SUMMARY.md --- SUMMARY.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/SUMMARY.md b/SUMMARY.md index 40528fa4..3a056dcb 100644 --- a/SUMMARY.md +++ b/SUMMARY.md @@ -231,8 +231,8 @@ * [32.1.5 接收消息](IV. Spring Boot features/32.1.5 Receiving a Message.md) * [32.2 AMQP](IV. Spring Boot features/32.2 AMQP.md) * [32.2.1 RabbitMQ支持](IV. Spring Boot features/32.2.1 RabbitMQ support.md) - * [32.2.2 发送消息](IV. Spring Boot features/32.2.2 Sending a message.md) - * [32.2.3 接收消息](IV. Spring Boot features/32.2.3 Receiving a message.md) + * [32.2.2 发送消息](IV. Spring Boot features/32.2.2 Sending a Message.md) + * [32.2.3 接收消息](IV. Spring Boot features/32.2.3 Receiving a Message.md) * [32.3 Apache Kafka支持](IV. Spring Boot features/32.3 Apache Kafka Support.md) * [32.3.1 发送消息](IV. Spring Boot features/32.3.1 Sending a Message.md) * [32.3.2 接收消息](IV. Spring Boot features/32.3.2 Receiving a Message.md) From 0d5fc0eb30023186bbf82a0edb375603543c5689 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E7=83=AD=E5=BF=83=E5=B8=82=E6=B0=91=E9=92=9F=E5=B0=8F?= =?UTF-8?q?=E5=BC=BA?= Date: Fri, 17 May 2019 21:45:06 +0800 Subject: [PATCH 343/865] Update 32.2.2 Sending a Message.md --- IV. Spring Boot features/32.2.2 Sending a Message.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/IV. Spring Boot features/32.2.2 Sending a Message.md b/IV. Spring Boot features/32.2.2 Sending a Message.md index 06393719..d605da34 100644 --- a/IV. Spring Boot features/32.2.2 Sending a Message.md +++ b/IV. Spring Boot features/32.2.2 Sending a Message.md @@ -23,6 +23,6 @@ public class MyBean { } ``` -**注** 可以使用相似方式注入`RabbitMessagingTemplate`,如果定义`MessageConverter` bean,它将自动关联到自动配置的`AmqpTemplate`。 +**注** 可以使用相似方式注入[`RabbitMessagingTemplate`](https://docs.spring.io/spring-amqp/docs/current/api/org/springframework/amqp/rabbit/core/RabbitMessagingTemplate.html),如果定义`MessageConverter` bean,它将自动关联到自动配置的`AmqpTemplate`。 如果需要的话,所有定义为bean的`org.springframework.amqp.core.Queue`将自动在RabbitMQ实例中声明相应的队列。你可以启用`AmqpTemplate`的重试选项,例如代理连接丢失时,重试默认不启用。 From 2318e8709fdb8b3e0ade1ada8c85c52187df6bfd Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E7=83=AD=E5=BF=83=E5=B8=82=E6=B0=91=E9=92=9F=E5=B0=8F?= =?UTF-8?q?=E5=BC=BA?= Date: Fri, 17 May 2019 22:05:36 +0800 Subject: [PATCH 344/865] Update 32.2.3 Receiving a message.md --- .../32.2.3 Receiving a message.md | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/IV. Spring Boot features/32.2.3 Receiving a message.md b/IV. Spring Boot features/32.2.3 Receiving a message.md index 2a5bb290..23aa2cc7 100644 --- a/IV. Spring Boot features/32.2.3 Receiving a message.md +++ b/IV. Spring Boot features/32.2.3 Receiving a message.md @@ -1,5 +1,6 @@ -###32.2.3 接收消息 -当Rabbit设施出现时,所有bean都可以注解`@RabbitListener`来创建一个监听器端点。如果没有定义`RabbitListenerContainerFactory`,Spring Boot将自动配置一个默认的`SimpleRabbitListenerContainerFactory`。你可以使用`spring.rabbitmq.listener.type`属性,转换到一个直接的容器。如果定义`MessageConverter` 或者`MessageRecoverer`beans,它们将自动关联到默认的factory。 +### 32.2.3 接收消息 + +当Rabbit设施出现时,所有bean都可以注解`@RabbitListener`来创建一个监听器端点。如果没有定义`RabbitListenerContainerFactory`,Spring Boot将自动配置一个默认的`SimpleRabbitListenerContainerFactory`。你可以使用`spring.rabbitmq.listener.type`属性,转换到一个直接的容器。如果定义`MessageConverter` 或者`MessageRecoverer` bean,它将自动关联到默认的factory。 下面的组件创建一个`someQueue`队列上的监听器端点: ```java @@ -13,13 +14,13 @@ public class MyBean { } ``` -**注** 具体参考[@EnableRabbit](http://docs.spring.io/spring-amqp/docs/current/api/org/springframework/amqp/rabbit/annotation/EnableRabbit.html)。 +**注** 具体参考[@EnableRabbit的Javadoc](https://docs.spring.io/spring-amqp/docs/current/api/org/springframework/amqp/rabbit/annotation/EnableRabbit.html)。 如果需要创建多个`RabbitListenerContainerFactory`实例,或想覆盖默认实例,你可以使用Spring Boot提供的`SimpleRabbitListenerContainerFactoryConfigurer`和`DirectRabbitListenerContainerFactoryConfigurer`,通过它们可以使用跟自动配置实例相同的配置初始化`SimpleRabbitListenerContainerFactory`。 **提示** 使用哪个容器无关紧要,自动配置将会暴露那两个bean。 -例如,下面使用一个特殊的`MessageConverter`创建了另一个factory: +例如,下面使用一个特殊的`MessageConverter`配置类创建了另一个factory: ```java @Configuration static class RabbitConfiguration { @@ -35,6 +36,7 @@ static class RabbitConfiguration { } } + ``` 然后,你可以像下面那样在所有`@RabbitListener`注解方法中使用: ```java @@ -50,4 +52,4 @@ public class MyBean { ``` 你可以启动重试处理那些监听器抛出异常的情况。默认地,`RejectAndDontRequeueRecoverer`被使用,但是你可以定义一个你自己的`MessageRecoverer`。当重试次数达到限制时,该消息将被拒绝,要不被丢弃,要不路由到一个dead-letter交换器,如果broker这样配置的话,默认禁用重试。 -**重要** 如果没启用重试,且监听器抛出异常,则Rabbit会不定期进行重试。你可以采用两种方式修改该行为:设置`defaultRequeueRejected`属性为`false`,这样就不会重试;或抛出一个`AmqpRejectAndDontRequeueException`异常表示该消息应该被拒绝,这是开启重试,且达到最大重试次数时使用的策略。 +**重要** 默认的,如果禁用了重试,且监听器抛出异常,则Rabbit会无限期地进行重试。你可以采用两种方式修改该行为:设置`defaultRequeueRejected`属性为`false`,这样就不会重试,或者抛出一个`AmqpRejectAndDontRequeueException`异常表示该消息应该被拒绝。后面这个是开启重试,且达到最大重试次数时使用的策略。 From 3252e6000c2fc85b9ece8650d7cc836eeeb65ead Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E7=83=AD=E5=BF=83=E5=B8=82=E6=B0=91=E9=92=9F=E5=B0=8F?= =?UTF-8?q?=E5=BC=BA?= Date: Sat, 18 May 2019 10:10:28 +0800 Subject: [PATCH 345/865] Rename 32.2.3 Receiving a message.md to 32.2.3 Receiving a Message.md --- ...2.2.3 Receiving a message.md => 32.2.3 Receiving a Message.md} | 0 1 file changed, 0 insertions(+), 0 deletions(-) rename IV. Spring Boot features/{32.2.3 Receiving a message.md => 32.2.3 Receiving a Message.md} (100%) diff --git a/IV. Spring Boot features/32.2.3 Receiving a message.md b/IV. Spring Boot features/32.2.3 Receiving a Message.md similarity index 100% rename from IV. Spring Boot features/32.2.3 Receiving a message.md rename to IV. Spring Boot features/32.2.3 Receiving a Message.md From 133a80702c3c71a2a3783edd6bd9e8f08db6a9b0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E7=83=AD=E5=BF=83=E5=B8=82=E6=B0=91=E9=92=9F=E5=B0=8F?= =?UTF-8?q?=E5=BC=BA?= Date: Sat, 18 May 2019 10:46:39 +0800 Subject: [PATCH 346/865] Update 32.3 Apache Kafka Support.md --- IV. Spring Boot features/32.3 Apache Kafka Support.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/IV. Spring Boot features/32.3 Apache Kafka Support.md b/IV. Spring Boot features/32.3 Apache Kafka Support.md index d1c66114..dce75bc5 100644 --- a/IV. Spring Boot features/32.3 Apache Kafka Support.md +++ b/IV. Spring Boot features/32.3 Apache Kafka Support.md @@ -6,4 +6,4 @@ Kafka配置在外部的配置属性中,定义在`spring.kafka.*`。例如, spring.kafka.bootstrap-servers=localhost:9092 spring.kafka.consumer.group-id=myGroup ``` -更多支持的选项,请查看[`KafkaProperties`](https://github.com/spring-projects/spring-boot/tree/v2.0.0.RELEASE/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/kafka/KafkaProperties.java)。 +更多支持的选项,请查看[`KafkaProperties`](https://github.com/spring-projects/spring-boot/tree/v2.0.0.RELEASE/spring-boot-project/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/kafka/KafkaProperties.java)。 From 34645ba4e3f7c1d7023bc31c4f989fbe824fe942 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E7=83=AD=E5=BF=83=E5=B8=82=E6=B0=91=E9=92=9F=E5=B0=8F?= =?UTF-8?q?=E5=BC=BA?= Date: Sat, 18 May 2019 10:51:16 +0800 Subject: [PATCH 347/865] Update 32.3.1 Sending a Message.md --- IV. Spring Boot features/32.3.1 Sending a Message.md | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/IV. Spring Boot features/32.3.1 Sending a Message.md b/IV. Spring Boot features/32.3.1 Sending a Message.md index 46765ed6..088dac55 100644 --- a/IV. Spring Boot features/32.3.1 Sending a Message.md +++ b/IV. Spring Boot features/32.3.1 Sending a Message.md @@ -1,6 +1,7 @@ ### 32.3.1 发送消息 -Spring的`KafkaTemplate`会自动配置。你可以直接在你自己的bean里面自动装配它们: +Spring的`KafkaTemplate`会自动配置。你可以直接在你自己的bean里面自动装配它。如下所示: + ```java @Component public class MyBean { @@ -16,3 +17,5 @@ public class MyBean { } ``` + +**注** 如果定义了`RecordMessageConverter` bean,它会自动关联到自动配置好的`KafkaTemplate`。 From dba94115f9138ad4c1c9f07ab77895ddec4ab8b7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E7=83=AD=E5=BF=83=E5=B8=82=E6=B0=91=E9=92=9F=E5=B0=8F?= =?UTF-8?q?=E5=BC=BA?= Date: Sat, 18 May 2019 10:58:55 +0800 Subject: [PATCH 348/865] Update 32.3.2 Receiving a Message.md --- IV. Spring Boot features/32.3.2 Receiving a Message.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/IV. Spring Boot features/32.3.2 Receiving a Message.md b/IV. Spring Boot features/32.3.2 Receiving a Message.md index 41ffe51a..c57396ff 100644 --- a/IV. Spring Boot features/32.3.2 Receiving a Message.md +++ b/IV. Spring Boot features/32.3.2 Receiving a Message.md @@ -1,6 +1,6 @@ ### 32.3.2 接收消息 -当完成Apache Kafka的基础配置,任何的bean都可以标注为`@KafkaListener`,来创建一个监听器端点。如果没有定义`KafkaListenerContainerFactory`,一个默认的将会用定义在`spring.kafka.listener.*`里的键值自动配置。 +当完成Apache Kafka的基础配置,任何的bean都可以标注为`@KafkaListener`,来创建一个监听器端点。如果没有定义`KafkaListenerContainerFactory`,一个默认的将会用定义在`spring.kafka.listener.*`里的键值自动配置。另外,如果定义了一个`RecordMessageConverter` bean,它会自动关联到默认的工厂。 下面的组件在`someTopic`主题上创建了一个监听器端点: ```java From 533db24365d66ead3e23a69b94c58b40bed77888 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E7=83=AD=E5=BF=83=E5=B8=82=E6=B0=91=E9=92=9F=E5=B0=8F?= =?UTF-8?q?=E5=BC=BA?= Date: Sat, 18 May 2019 11:39:26 +0800 Subject: [PATCH 349/865] Update 32.3.3 Additional Kafka Properties.md --- .../32.3.3 Additional Kafka Properties.md | 50 +++++++------------ 1 file changed, 17 insertions(+), 33 deletions(-) diff --git a/IV. Spring Boot features/32.3.3 Additional Kafka Properties.md b/IV. Spring Boot features/32.3.3 Additional Kafka Properties.md index a2e0fd92..f73279e3 100644 --- a/IV. Spring Boot features/32.3.3 Additional Kafka Properties.md +++ b/IV. Spring Boot features/32.3.3 Additional Kafka Properties.md @@ -6,40 +6,24 @@ 只有Kafka支持的属性的一个子集能够通过`KafkaProperties`类来定义。如果你希望用其它的不被直接支持的属性,来配置生产者或者消费者,使用下面的例子: ```properties -spring.kafka.properties.foo.bar=baz +spring.kafka.properties.prop.one=first +spring.kafka.admin.properties.prop.two=second +spring.kafka.consumer.properties.prop.three=third +spring,kafka.producer.properties.prop.four=fourth ``` -这把通常的`foo.bar`Kafka属性设置为`baz`。 +这把通常的`prop.one`Kafka属性设置为`first`(应用到producers、consumers和admins)。`prop.two`admin属性设置为`second`。`prop.three`consumer属性设置为`third`。`prop.four`producer属性设置为`fourth`。 -这些属性会被生产者和消费者的工厂bean共同分享。如果你想用不同的属性自定义这些组件,例如为了各种使用不同的度量读取器,你可以如下重写bean定义: -```java -@Configuration -public static class CustomKafkaBeans { - - /** - * Customized ProducerFactory bean. - * @param properties the kafka properties. - * @return the bean. - */ - @Bean - public ProducerFactory kafkaProducerFactory(KafkaProperties properties) { - Map producerProperties = properties.buildProducerProperties(); - producerProperties.put(CommonClientConfigs.METRIC_REPORTER_CLASSES_CONFIG, - MyProducerMetricsReporter.class); - return new DefaultKafkaProducerFactory<>(producerProperties); - } - - /** - * Customized ConsumerFactory bean. - * @param properties the kafka properties. - * @return the bean. - */ - @Bean - public ConsumerFactory kafkaConsumerFactory(KafkaProperties properties) { - Map consumerProperties = properties.buildConsumerProperties(); - consumerProperties.put(CommonClientConfigs.METRIC_REPORTER_CLASSES_CONFIG, - MyConsumerMetricsReporter.class); - return new DefaultKafkaConsumerFactory<>(consumerProperties); - } +你也可以如下配置Spring Kafka `JsonDeserializer`: +```properties +spring.kafka.consumer.value-deserializer=org.springframework.kafka.support.serializer.JsonDeserializer +spring.kafka.consumer.properties.spring.json.value.default.type=org.foo.Invoice +spring.kafka.consumer.properties.spring.json.trusted.packages=org.foo,org.bar +``` -} +相似地,你可以禁用`JsonSerializer`的默认行为——在header里传递类型信息: +```properties +spring.kafka.producer.value-serializer=org.springframework.kafka.support.serializer.JsonSerializer +spring.kafka.producer.properties.spring.json.add.type.headers=false ``` + +**重要** 以此种方式定义的属性会覆盖任何Spring Boot明确支持的配置项。 From 721677f7f019bd9029fdfa1352d58e8b4e0e87d4 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E7=83=AD=E5=BF=83=E5=B8=82=E6=B0=91=E9=92=9F=E5=B0=8F?= =?UTF-8?q?=E5=BC=BA?= Date: Sat, 18 May 2019 11:52:17 +0800 Subject: [PATCH 350/865] Update and rename 33. Calling REST services.md to 33. Calling REST Services with RestTemplate.md --- ...s.md => 33. Calling REST Services with RestTemplate.md} | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) rename IV. Spring Boot features/{33. Calling REST services.md => 33. Calling REST Services with RestTemplate.md} (71%) diff --git a/IV. Spring Boot features/33. Calling REST services.md b/IV. Spring Boot features/33. Calling REST Services with RestTemplate.md similarity index 71% rename from IV. Spring Boot features/33. Calling REST services.md rename to IV. Spring Boot features/33. Calling REST Services with RestTemplate.md index c972aed1..b95590bc 100644 --- a/IV. Spring Boot features/33. Calling REST services.md +++ b/IV. Spring Boot features/33. Calling REST Services with RestTemplate.md @@ -1,10 +1,11 @@ -###33. 调用REST服务 -如果应用需要调用远程REST服务,你可以使用Spring框架的`RestTemplate`类。由于`RestTemplate`实例经常在使用前需要自定义,Spring Boot就没有提供任何自动配置的`RestTemplate` bean,不过你可以通过自动配置的`RestTemplateBuilder`创建自己需要的`RestTemplate`实例。自动配置的`RestTemplateBuilder`会确保应用到`RestTemplate`实例的`HttpMessageConverters`是合适的。 +### 33. 使用RestTemplate调用REST服务 + +如果应用需要调用远程REST服务,你可以使用Spring框架的`RestTemplate`类。由于`RestTemplate`实例经常在使用前需要自定义,Spring Boot就没有提供任何自动配置的`RestTemplate` bean。不过,你可以通过自动配置的`RestTemplateBuilder`创建自己需要的`RestTemplate`实例。自动配置的`RestTemplateBuilder`会确保应用到`RestTemplate`实例的`HttpMessageConverters`是合适的。 以下是典型的示例: ```java @Service -public class MyBean { +public class MyService { private final RestTemplate restTemplate; From 840cf20ec820c78dc5d72bf1354cd2c5be8a119b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E7=83=AD=E5=BF=83=E5=B8=82=E6=B0=91=E9=92=9F=E5=B0=8F?= =?UTF-8?q?=E5=BC=BA?= Date: Sat, 18 May 2019 11:55:05 +0800 Subject: [PATCH 351/865] Update SUMMARY.md --- SUMMARY.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/SUMMARY.md b/SUMMARY.md index 3a056dcb..574b282e 100644 --- a/SUMMARY.md +++ b/SUMMARY.md @@ -237,8 +237,8 @@ * [32.3.1 发送消息](IV. Spring Boot features/32.3.1 Sending a Message.md) * [32.3.2 接收消息](IV. Spring Boot features/32.3.2 Receiving a Message.md) * [32.3.3 其它的Kafka属性](IV. Spring Boot features/32.3.3 Additional Kafka Properties.md) - * [33. 调用REST服务](IV. Spring Boot features/33. Calling REST services.md) - * [33.1 自定义RestTemplate](IV. Spring Boot features/33.1 RestTemplate customization.md) + * [33. 使用RestTemplate调用REST服务](IV. Spring Boot features/33. Calling REST Services with RestTemplate.md) + * [33.1 自定义RestTemplate](IV. Spring Boot features/33.1 RestTemplate Customization.md) * [34. 验证](IV. Spring Boot features/34. Validation.md) * [35. 发送邮件](IV. Spring Boot features/35. Sending email.md) * [36. 使用JTA处理分布式事务](IV. Spring Boot features/36. Distributed Transactions with JTA.md) From c16f28c6ea09c02430cc3ca55845ddae5d789373 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E7=83=AD=E5=BF=83=E5=B8=82=E6=B0=91=E9=92=9F=E5=B0=8F?= =?UTF-8?q?=E5=BC=BA?= Date: Sat, 18 May 2019 11:57:49 +0800 Subject: [PATCH 352/865] Rename 33.1 RestTemplate customization.md to 33.1 RestTemplate Customization.md --- ...mplate customization.md => 33.1 RestTemplate Customization.md} | 0 1 file changed, 0 insertions(+), 0 deletions(-) rename IV. Spring Boot features/{33.1 RestTemplate customization.md => 33.1 RestTemplate Customization.md} (100%) diff --git a/IV. Spring Boot features/33.1 RestTemplate customization.md b/IV. Spring Boot features/33.1 RestTemplate Customization.md similarity index 100% rename from IV. Spring Boot features/33.1 RestTemplate customization.md rename to IV. Spring Boot features/33.1 RestTemplate Customization.md From f3a3d19124778bcf32410e80223e3220ab4ce2af Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E7=83=AD=E5=BF=83=E5=B8=82=E6=B0=91=E9=92=9F=E5=B0=8F?= =?UTF-8?q?=E5=BC=BA?= Date: Sat, 18 May 2019 14:53:23 +0800 Subject: [PATCH 353/865] Create 34. Calling REST Services with WebClient.md --- ...4. Calling REST Services with WebClient.md | 24 +++++++++++++++++++ 1 file changed, 24 insertions(+) create mode 100644 IV. Spring Boot features/34. Calling REST Services with WebClient.md diff --git a/IV. Spring Boot features/34. Calling REST Services with WebClient.md b/IV. Spring Boot features/34. Calling REST Services with WebClient.md new file mode 100644 index 00000000..87b22ddf --- /dev/null +++ b/IV. Spring Boot features/34. Calling REST Services with WebClient.md @@ -0,0 +1,24 @@ +### 34. 使用WebClient调用REST服务 + +如果你的类路径上存在Spring WebFlux,你也可以选择使用`WebClient`调用REST服务。与`RestTemplate`相比,`WebClient`更有函数式的感觉,而且完全是响应式的。你可以使用`WebClient.create()`创建你自己的client实例。查看[与WebClient有关的章节](https://docs.spring.io/spring/docs/5.0.4.RELEASE/spring-framework-reference/web.html#web-reactive-client)。 + +Spring Boot为你创建并预先配置了这样一个builder。比如,客户端HTTP编解码器会以与服务器端相同的方式被配置好(查看[WebFlux HTTP编解码器的自动配置](https://docs.spring.io/spring-boot/docs/2.0.0.RELEASE/reference/htmlsingle/#boot-features-webflux-httpcodecs))。 + +以下是典型的示例: +```java +@Service +public class MyService { + + private final WebClient webClient; + + public MyBean(WebClient.Builder webClientBuilder) { + this.webClient = webClientBuilder.baseUrl("http://example.org/").build(); + } + + public Mono
someRestCall(String name) { + return this.webClient.get().url("http://github.com/%7Bname%7D/details%22,%20name) + .retrieve().bodyToMono(Details.class); + } + +} +``` From e3d1baf177b5ede8664425050dbbf53bf9433659 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E7=83=AD=E5=BF=83=E5=B8=82=E6=B0=91=E9=92=9F=E5=B0=8F?= =?UTF-8?q?=E5=BC=BA?= Date: Sat, 18 May 2019 14:57:11 +0800 Subject: [PATCH 354/865] Update SUMMARY.md --- SUMMARY.md | 2 ++ 1 file changed, 2 insertions(+) diff --git a/SUMMARY.md b/SUMMARY.md index 574b282e..da73ce38 100644 --- a/SUMMARY.md +++ b/SUMMARY.md @@ -239,6 +239,8 @@ * [32.3.3 其它的Kafka属性](IV. Spring Boot features/32.3.3 Additional Kafka Properties.md) * [33. 使用RestTemplate调用REST服务](IV. Spring Boot features/33. Calling REST Services with RestTemplate.md) * [33.1 自定义RestTemplate](IV. Spring Boot features/33.1 RestTemplate Customization.md) + * [34. 使用WebClient调用REST服务](IV. Spring Boot features/34. Calling REST Services with WebClient.md) + * [34.1 自定义WebClient](IV. Spring Boot features/34.1 WebClient Customization.md) * [34. 验证](IV. Spring Boot features/34. Validation.md) * [35. 发送邮件](IV. Spring Boot features/35. Sending email.md) * [36. 使用JTA处理分布式事务](IV. Spring Boot features/36. Distributed Transactions with JTA.md) From cffcf5f4fccad398b206fed8b0cf640863062b35 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E7=83=AD=E5=BF=83=E5=B8=82=E6=B0=91=E9=92=9F=E5=B0=8F?= =?UTF-8?q?=E5=BC=BA?= Date: Sat, 18 May 2019 15:37:12 +0800 Subject: [PATCH 355/865] Create 34.1 WebClient Customization.md --- IV. Spring Boot features/34.1 WebClient Customization.md | 9 +++++++++ 1 file changed, 9 insertions(+) create mode 100644 IV. Spring Boot features/34.1 WebClient Customization.md diff --git a/IV. Spring Boot features/34.1 WebClient Customization.md b/IV. Spring Boot features/34.1 WebClient Customization.md new file mode 100644 index 00000000..6fcb8214 --- /dev/null +++ b/IV. Spring Boot features/34.1 WebClient Customization.md @@ -0,0 +1,9 @@ +### 34.1 自定义WebClient + +有三种主要的方式实现`WebClient`的自定义,用哪种方式取决于你想多大范围地应用自定义。 + +为了使自定义的范围尽可能的小,注入自动配置的`WebClient.Builder`,然后根据需要调用它的方法。`WebClient.Builder`实例有状态:在builder上的任何改变都会反映在其后创建的所有客户端里。如果你想要使用相同的builder创建几个客户端,你也可以使用`WebClient.Builder other = builder.clone();`克隆builder。。 + +为了对`WebClient.Builder`实例实现整个应用范围的自定义,你可以声明`WebClientCustomizer` bean,并且在注入时局部地改变`WebClient.Builder`。 + +最后,你可以回到原始API,使用`WebClient.create()`。那种情况下,不会应用自动配置或者`WebClientCustomizer`。 From 6a96d4a8f85f64b03eac8e4755232ecf4d5d360f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E7=83=AD=E5=BF=83=E5=B8=82=E6=B0=91=E9=92=9F=E5=B0=8F?= =?UTF-8?q?=E5=BC=BA?= Date: Wed, 22 May 2019 11:07:54 +0800 Subject: [PATCH 356/865] Update and rename 34. Validation.md to 35. Validation.md --- .../{34. Validation.md => 35. Validation.md} | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) rename IV. Spring Boot features/{34. Validation.md => 35. Validation.md} (97%) diff --git a/IV. Spring Boot features/34. Validation.md b/IV. Spring Boot features/35. Validation.md similarity index 97% rename from IV. Spring Boot features/34. Validation.md rename to IV. Spring Boot features/35. Validation.md index cfa17e9c..539c9414 100644 --- a/IV. Spring Boot features/34. Validation.md +++ b/IV. Spring Boot features/35. Validation.md @@ -1,4 +1,4 @@ -### 34. 验证 +### 35. 验证 只要在类路径上存在JSR-303实现(比如Hibernate validator),Bean Validation 1.1支持的方法验证特性就会自动启用。这允许bean方法的参数和/或者返回值,被标注为`javax.validation`约束。为了让这样的带标注的方法在搜索行内约束标注时被找到,拥有它们的目标类,需要在类型层次上被标注为`@Validated`。 From 0b1a7ab944fd064b05f77807804edd5026de8edf Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E7=83=AD=E5=BF=83=E5=B8=82=E6=B0=91=E9=92=9F=E5=B0=8F?= =?UTF-8?q?=E5=BC=BA?= Date: Wed, 22 May 2019 11:13:29 +0800 Subject: [PATCH 357/865] Update SUMMARY.md --- SUMMARY.md | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/SUMMARY.md b/SUMMARY.md index da73ce38..b092f8ad 100644 --- a/SUMMARY.md +++ b/SUMMARY.md @@ -241,15 +241,15 @@ * [33.1 自定义RestTemplate](IV. Spring Boot features/33.1 RestTemplate Customization.md) * [34. 使用WebClient调用REST服务](IV. Spring Boot features/34. Calling REST Services with WebClient.md) * [34.1 自定义WebClient](IV. Spring Boot features/34.1 WebClient Customization.md) - * [34. 验证](IV. Spring Boot features/34. Validation.md) - * [35. 发送邮件](IV. Spring Boot features/35. Sending email.md) - * [36. 使用JTA处理分布式事务](IV. Spring Boot features/36. Distributed Transactions with JTA.md) - * [36.1 使用Atomikos事务管理器](IV. Spring Boot features/36.1 Using an Atomikos transaction manager.md) - * [36.2 使用Bitronix事务管理器](IV. Spring Boot features/36.2 Using a Bitronix transaction manager.md) - * [36.3 使用Narayana事务管理器](IV. Spring Boot features/36.3 Using a Narayana transaction manager.md) - * [36.4 使用J2EE管理的事务管理器](IV. Spring Boot features/36.4 Using a Java EE managed transaction manager.md) - * [36.5 混合XA和non-XA的JMS连接](IV. Spring Boot features/36.5 Mixing XA and non-XA JMS connections.md) - * [36.6 支持可替代的内嵌事务管理器](IV. Spring Boot features/36.6 Supporting an alternative embedded transaction manager.md) + * [35. 验证](IV. Spring Boot features/35. Validation.md) + * [36. 发送邮件](IV. Spring Boot features/36. Sending Email.md) + * [37. 使用JTA处理分布式事务](IV. Spring Boot features/37. Distributed Transactions with JTA.md) + * [37.1 使用Atomikos事务管理器](IV. Spring Boot features/37.1 Using an Atomikos transaction manager.md) + * [37.2 使用Bitronix事务管理器](IV. Spring Boot features/37.2 Using a Bitronix transaction manager.md) + * [37.3 使用Narayana事务管理器](IV. Spring Boot features/37.3 Using a Narayana transaction manager.md) + * [37.4 使用J2EE管理的事务管理器](IV. Spring Boot features/37.4 Using a Java EE managed transaction manager.md) + * [37.5 混合XA和non-XA的JMS连接](IV. Spring Boot features/37.5 Mixing XA and non-XA JMS connections.md) + * [37.6 支持可替代的内嵌事务管理器](IV. Spring Boot features/37.6 Supporting an alternative embedded transaction manager.md) * [37. Hazelcast](IV. Spring Boot features/37. Hazelcast.md) * [38. Quartz调度器](IV. Spring Boot features/38. Quartz Scheduler.md) * [39. Spring集成](IV. Spring Boot features/39. Spring Integration.md) From b7e376c938d5f19ba09c64770b3faae961eb10e0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E7=83=AD=E5=BF=83=E5=B8=82=E6=B0=91=E9=92=9F=E5=B0=8F?= =?UTF-8?q?=E5=BC=BA?= Date: Wed, 22 May 2019 11:15:44 +0800 Subject: [PATCH 358/865] Update and rename 35. Sending email.md to 36. Sending Email.md --- .../{35. Sending email.md => 36. Sending Email.md} | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) rename IV. Spring Boot features/{35. Sending email.md => 36. Sending Email.md} (76%) diff --git a/IV. Spring Boot features/35. Sending email.md b/IV. Spring Boot features/36. Sending Email.md similarity index 76% rename from IV. Spring Boot features/35. Sending email.md rename to IV. Spring Boot features/36. Sending Email.md index 8c633921..4fd2a873 100644 --- a/IV. Spring Boot features/35. Sending email.md +++ b/IV. Spring Boot features/36. Sending Email.md @@ -1,12 +1,12 @@ -### 35. 发送邮件 +### 36. 发送邮件 Spring框架通过`JavaMailSender`接口为发送邮件提供了一个简单的抽象,并且Spring Boot也为它提供了自动配置和一个starter模块。 -具体查看[`JavaMailSender`参考文档](https://docs.spring.io/spring/docs/5.0.4.RELEASE/spring-framework-reference/htmlsingle/#mail)。 +具体查看[`JavaMailSender`参考文档](https://docs.spring.io/spring/docs/5.0.4.RELEASE/spring-framework-reference/integration.html#mail)。 -如果`spring.mail.host`和相关的libraries(通过`spring-boot-starter-mail`定义的)都可用,Spring Boot将创建一个默认的`JavaMailSender`,该sender可以通过`spring.mail`命名空间下的配置项进一步自定义,具体参考[MailProperties](https://github.com/spring-projects/spring-boot/tree/v2.0.0.RELEASE/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/mail/MailProperties.java)。 +如果`spring.mail.host`和相关的libraries(通过`spring-boot-starter-mail`定义的)都可用,Spring Boot将创建一个默认的`JavaMailSender`,该sender可以通过`spring.mail`命名空间下的配置项进一步自定义,具体参考[MailProperties](https://github.com/spring-projects/spring-boot/tree/v2.0.0.RELEASE/spring-boot-project/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/mail/MailProperties.java)。 特别地,某些默认的超时值是无限的。你可能想改变它,以避免由无响应的邮件服务器引起的线程阻塞: ```properties spring.mail.properties.mail.smtp.connectiontimeout=5000 spring.mail.properties.mail.smtp.timeout=3000 spring.mail.properties.mail.smtp.writetimeout=5000 -``` \ No newline at end of file +``` From 6595ef84760e235e39f3c696ad3c019ffc5c5f54 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E7=83=AD=E5=BF=83=E5=B8=82=E6=B0=91=E9=92=9F=E5=B0=8F?= =?UTF-8?q?=E5=BC=BA?= Date: Wed, 22 May 2019 11:18:59 +0800 Subject: [PATCH 359/865] Update and rename 36. Distributed Transactions with JTA.md to 37. Distributed Transactions with JTA.md --- ...s with JTA.md => 37. Distributed Transactions with JTA.md} | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) rename IV. Spring Boot features/{36. Distributed Transactions with JTA.md => 37. Distributed Transactions with JTA.md} (68%) diff --git a/IV. Spring Boot features/36. Distributed Transactions with JTA.md b/IV. Spring Boot features/37. Distributed Transactions with JTA.md similarity index 68% rename from IV. Spring Boot features/36. Distributed Transactions with JTA.md rename to IV. Spring Boot features/37. Distributed Transactions with JTA.md index 2663cfcd..110ce871 100644 --- a/IV. Spring Boot features/36. Distributed Transactions with JTA.md +++ b/IV. Spring Boot features/37. Distributed Transactions with JTA.md @@ -1,5 +1,5 @@ -### 36. 使用JTA处理分布式事务 +### 37. 使用JTA处理分布式事务 -Spring Boot通过[Atomkos](http://www.atomikos.com/)或[Bitronix](http://docs.codehaus.org/display/BTM/Home)的内嵌事务管理器支持跨多个XA资源的分布式JTA事务,当部署到恰当的J2EE应用服务器时也会支持JTA事务。 +Spring Boot通过[Atomkos](http://www.atomikos.com/)或[Bitronix](https://github.com/bitronix/btm)的内嵌事务管理器支持跨多个XA资源的分布式JTA事务,当部署到恰当的J2EE应用服务器时也会支持JTA事务。 当发现JTA环境时,Spring Boot将使用Spring的`JtaTransactionManager`来管理事务。自动配置的JMS,DataSource和JPA beans将被升级以支持XA事务。你可以使用标准的Spring idioms,比如`@Transactional`,来参与到一个分布式事务中。如果处于JTA环境,但仍想使用本地事务,你可以将`spring.jta.enabled`属性设置为`false`来禁用JTA自动配置功能。 From b0245f4ca9710f1beb8bad8ab2f6753ba75aa41f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E7=83=AD=E5=BF=83=E5=B8=82=E6=B0=91=E9=92=9F=E5=B0=8F?= =?UTF-8?q?=E5=BC=BA?= Date: Wed, 22 May 2019 11:21:46 +0800 Subject: [PATCH 360/865] Update and rename 36.1 Using an Atomikos transaction manager.md to 37.1 Using an Atomikos Transaction Manager.md --- ...ger.md => 37.1 Using an Atomikos Transaction Manager.md} | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) rename IV. Spring Boot features/{36.1 Using an Atomikos transaction manager.md => 37.1 Using an Atomikos Transaction Manager.md} (57%) diff --git a/IV. Spring Boot features/36.1 Using an Atomikos transaction manager.md b/IV. Spring Boot features/37.1 Using an Atomikos Transaction Manager.md similarity index 57% rename from IV. Spring Boot features/36.1 Using an Atomikos transaction manager.md rename to IV. Spring Boot features/37.1 Using an Atomikos Transaction Manager.md index 9ee10c86..61cf8e67 100644 --- a/IV. Spring Boot features/36.1 Using an Atomikos transaction manager.md +++ b/IV. Spring Boot features/37.1 Using an Atomikos Transaction Manager.md @@ -1,7 +1,7 @@ -### 36.1 使用Atomikos事务管理器 +### 37.1 使用Atomikos事务管理器 -Atomikos是一个非常流行的开源事务管理器,并且可以嵌入到你的Spring Boot应用中。你可以使用`spring-boot-starter-jta-atomikos`Starter去获取正确的Atomikos库。Spring Boot会自动配置Atomikos,并将合适的`depends-on`应用到你的Spring Beans上,确保它们以正确的顺序启动和关闭。 +[Atomikos](https://www.atomikos.com/)是一个非常流行的开源事务管理器,并且可以嵌入到你的Spring Boot应用中。你可以使用`spring-boot-starter-jta-atomikos`Starter去获取正确的Atomikos库。Spring Boot会自动配置Atomikos,并将合适的`depends-on`应用到你的Spring Beans上,确保它们以正确的顺序启动和关闭。 -默认情况下,Atomikos事务日志将被记录在应用home目录(你的应用jar文件放置的目录)下的`transaction-logs`文件夹中。你可以在`application.properties`文件中通过设置`spring.jta.log-dir`属性来定义该目录,以`spring.jta.atomikos.properties`开头的属性能用来定义Atomikos的`UserTransactionServiceIml`实现,具体参考[AtomikosProperties javadoc](http://docs.spring.io/spring-boot/docs/2.0.0.RELEASE/api/org/springframework/boot/jta/atomikos/AtomikosProperties.html)。 +默认情况下,Atomikos事务日志将被记录在应用home目录(你的应用jar文件放置的目录)下的`transaction-logs`文件夹中。你可以在`application.properties`文件中通过设置`spring.jta.log-dir`属性来定义该目录,以`spring.jta.atomikos.properties`开头的属性能用来定义Atomikos的`UserTransactionServiceIml`实现,具体参考[AtomikosProperties javadoc](https://docs.spring.io/spring-boot/docs/2.0.0.RELEASE/api/org/springframework/boot/jta/atomikos/AtomikosProperties.html)。 **注** 为了确保多个事务管理器能够安全地和相应的资源管理器配合,每个Atomikos实例必须设置一个唯一的ID。默认情况下,该ID是Atomikos实例运行的机器上的IP地址。为了确保生产环境中该ID的唯一性,你需要为应用的每个实例设置不同的`spring.jta.transaction-manager-id`属性值。 From 93d320e88306df40678760feb465947dafeb9a9a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E7=83=AD=E5=BF=83=E5=B8=82=E6=B0=91=E9=92=9F=E5=B0=8F?= =?UTF-8?q?=E5=BC=BA?= Date: Wed, 22 May 2019 11:23:44 +0800 Subject: [PATCH 361/865] Update SUMMARY.md --- SUMMARY.md | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/SUMMARY.md b/SUMMARY.md index b092f8ad..6bb75278 100644 --- a/SUMMARY.md +++ b/SUMMARY.md @@ -244,10 +244,10 @@ * [35. 验证](IV. Spring Boot features/35. Validation.md) * [36. 发送邮件](IV. Spring Boot features/36. Sending Email.md) * [37. 使用JTA处理分布式事务](IV. Spring Boot features/37. Distributed Transactions with JTA.md) - * [37.1 使用Atomikos事务管理器](IV. Spring Boot features/37.1 Using an Atomikos transaction manager.md) - * [37.2 使用Bitronix事务管理器](IV. Spring Boot features/37.2 Using a Bitronix transaction manager.md) - * [37.3 使用Narayana事务管理器](IV. Spring Boot features/37.3 Using a Narayana transaction manager.md) - * [37.4 使用J2EE管理的事务管理器](IV. Spring Boot features/37.4 Using a Java EE managed transaction manager.md) + * [37.1 使用Atomikos事务管理器](IV. Spring Boot features/37.1 Using an Atomikos Transaction Manager.md) + * [37.2 使用Bitronix事务管理器](IV. Spring Boot features/37.2 Using a Bitronix Transaction Manager.md) + * [37.3 使用Narayana事务管理器](IV. Spring Boot features/37.3 Using a Narayana Transaction Manager.md) + * [37.4 使用J2EE管理的事务管理器](IV. Spring Boot features/37.4 Using a Java EE managed Transaction Manager.md) * [37.5 混合XA和non-XA的JMS连接](IV. Spring Boot features/37.5 Mixing XA and non-XA JMS connections.md) * [37.6 支持可替代的内嵌事务管理器](IV. Spring Boot features/37.6 Supporting an alternative embedded transaction manager.md) * [37. Hazelcast](IV. Spring Boot features/37. Hazelcast.md) From 843f04d4a09a2d90891f16faa844da8e7a6f3d54 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E7=83=AD=E5=BF=83=E5=B8=82=E6=B0=91=E9=92=9F=E5=B0=8F?= =?UTF-8?q?=E5=BC=BA?= Date: Wed, 22 May 2019 11:26:47 +0800 Subject: [PATCH 362/865] Update and rename 36.2 Using a Bitronix transaction manager.md to 37.2 Using a Bitronix Transaction Manager.md --- ...anager.md => 37.2 Using a Bitronix Transaction Manager.md} | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) rename IV. Spring Boot features/{36.2 Using a Bitronix transaction manager.md => 37.2 Using a Bitronix Transaction Manager.md} (67%) diff --git a/IV. Spring Boot features/36.2 Using a Bitronix transaction manager.md b/IV. Spring Boot features/37.2 Using a Bitronix Transaction Manager.md similarity index 67% rename from IV. Spring Boot features/36.2 Using a Bitronix transaction manager.md rename to IV. Spring Boot features/37.2 Using a Bitronix Transaction Manager.md index 1e65936f..c6d7dd74 100644 --- a/IV. Spring Boot features/36.2 Using a Bitronix transaction manager.md +++ b/IV. Spring Boot features/37.2 Using a Bitronix Transaction Manager.md @@ -1,6 +1,6 @@ -### 36.2 使用Bitronix事务管理器 +### 37.2 使用Bitronix事务管理器 -Bitronix是一个流行的开源JTA事务管理器实现,你可以使用`spring-boot-starter-jta-bitronix`starter为项目添加合适的Birtronix依赖。和Atomikos类似,Spring Boot将自动配置Bitronix,并对beans进行后处理(post-process)以确保它们以正确的顺序启动和关闭。 +[Bitronix](https://github.com/bitronix/btm)是一个流行的开源JTA事务管理器实现,你可以使用`spring-boot-starter-jta-bitronix`starter为项目添加合适的Birtronix依赖。和Atomikos类似,Spring Boot将自动配置Bitronix,并对beans进行后处理(post-process)以确保它们以正确的顺序启动和关闭。 默认情况下,Bitronix事务日志(`part1.btm`和`part2.btm`)将被记录到应用home目录下的`transaction-logs`文件夹中,你可以通过设置`spring.jta.log-dir`属性来自定义该目录。以`spring.jta.bitronix.properties`开头的属性将被绑定到`bitronix.tm.Configuration` bean,你可以通过这完成进一步的自定义,具体参考[Bitronix文档](https://github.com/bitronix/btm/wiki/Transaction-manager-configuration)。 From 3e5d5c7e5bdd66d6c8153e7daefb670171507a53 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E7=83=AD=E5=BF=83=E5=B8=82=E6=B0=91=E9=92=9F=E5=B0=8F?= =?UTF-8?q?=E5=BC=BA?= Date: Wed, 22 May 2019 11:29:35 +0800 Subject: [PATCH 363/865] Update and rename 36.3 Using a Narayana transaction manager.md to 37.3 Using a Narayana Transaction Manager.md --- ...ager.md => 37.3 Using a Narayana Transaction Manager.md} | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) rename IV. Spring Boot features/{36.3 Using a Narayana transaction manager.md => 37.3 Using a Narayana Transaction Manager.md} (53%) diff --git a/IV. Spring Boot features/36.3 Using a Narayana transaction manager.md b/IV. Spring Boot features/37.3 Using a Narayana Transaction Manager.md similarity index 53% rename from IV. Spring Boot features/36.3 Using a Narayana transaction manager.md rename to IV. Spring Boot features/37.3 Using a Narayana Transaction Manager.md index b15e6256..eae6ead7 100644 --- a/IV. Spring Boot features/36.3 Using a Narayana transaction manager.md +++ b/IV. Spring Boot features/37.3 Using a Narayana Transaction Manager.md @@ -1,7 +1,7 @@ -### 36.3 使用Narayana事务管理器 +### 37.3 使用Narayana事务管理器 -Narayana是一个流行的开源JTA事务管理器实现,目前只有JBoss支持。你可以使用`spring-boot-starter-jta-narayana` starter添加合适的Narayana依赖,像Atomikos和Bitronix那样,Spring Boot将自动配置Narayana,并对你的beans后处理(post-process)以确保正确启动和关闭。 +[Narayana](http://narayana.io/)是一个流行的开源JTA事务管理器实现,目前只有JBoss支持。你可以使用`spring-boot-starter-jta-narayana` starter添加合适的Narayana依赖,像Atomikos和Bitronix那样,Spring Boot将自动配置Narayana,并对你的beans后处理(post-process)以确保正确启动和关闭。 -Narayana事务日志默认记录到应用home目录(放置应用jar的目录)的`transaction-logs`目录下,你可以通过设置`application.properties`中的`spring.jta.log-dir`属性自定义该目录。以`spring.jta.narayana.properties`开头的属性可用于自定义Narayana配置,具体参考[NarayanaProperties](http://docs.spring.io/spring-boot/docs/2.0.0.RELEASE/api/org/springframework/boot/jta/narayana/NarayanaProperties.html)。 +Narayana事务日志默认记录到应用home目录(放置应用jar的目录)的`transaction-logs`目录下,你可以通过设置`application.properties`中的`spring.jta.log-dir`属性自定义该目录。以`spring.jta.narayana.properties`开头的属性可用于自定义Narayana配置,具体参考[NarayanaProperties](https://docs.spring.io/spring-boot/docs/2.0.0.RELEASE/api/org/springframework/boot/jta/narayana/NarayanaProperties.html)。 **注** 为了确保多事务管理器能够安全配合相应资源管理器,每个Narayana实例必须配置唯一的ID,默认ID设为`1`。为确保生产环境中ID唯一性,你可以为应用的每个实例配置不同的`spring.jta.transaction-manager-id`属性值。 From b3c826283045afd81af0b6aa63af822e4fb156e3 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E7=83=AD=E5=BF=83=E5=B8=82=E6=B0=91=E9=92=9F=E5=B0=8F?= =?UTF-8?q?=E5=BC=BA?= Date: Wed, 22 May 2019 11:45:27 +0800 Subject: [PATCH 364/865] Update and rename 36.4 Using a Java EE managed transaction manager.md to 37.4 Using a Java EE Managed Transaction Manager.md --- ...md => 37.4 Using a Java EE Managed Transaction Manager.md} | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) rename IV. Spring Boot features/{36.4 Using a Java EE managed transaction manager.md => 37.4 Using a Java EE Managed Transaction Manager.md} (58%) diff --git a/IV. Spring Boot features/36.4 Using a Java EE managed transaction manager.md b/IV. Spring Boot features/37.4 Using a Java EE Managed Transaction Manager.md similarity index 58% rename from IV. Spring Boot features/36.4 Using a Java EE managed transaction manager.md rename to IV. Spring Boot features/37.4 Using a Java EE Managed Transaction Manager.md index 862a8afa..78a7f785 100644 --- a/IV. Spring Boot features/36.4 Using a Java EE managed transaction manager.md +++ b/IV. Spring Boot features/37.4 Using a Java EE Managed Transaction Manager.md @@ -1,3 +1,3 @@ -### 36.4 使用J2EE管理的事务管理器 +### 37.4 使用J2EE管理的事务管理器 -如果你将Spring Boot应用打包为一个`war`或`ear`文件,并将它部署到一个J2EE的应用服务器中,那你就能使用应用服务器内建的事务管理器。Spring Boot将尝试通过查找常见的JNDI路径(`java:comp/UserTransaction`, `java:comp/TransactionManager`等)来自动配置一个事务管理器。如果使用应用服务器提供的事务服务,你通常需要确保所有的资源都被应用服务器管理,并通过JNDI暴露出去。Spring Boot通过查找JNDI路径`java:/JmsXA`或`java:/XAConnectionFactory`获取一个`ConnectionFactory`来自动配置JMS,并且你可以使用`spring.datasource.jndi-name`属性配置你的`DataSource`。 +如果你将Spring Boot应用打包为一个`war`或`ear`文件,并将它部署到一个J2EE的应用服务器中,那你就能使用应用服务器内建的事务管理器。Spring Boot将尝试通过查找常见的JNDI路径(`java:comp/UserTransaction`, `java:comp/TransactionManager`等)来自动配置一个事务管理器。如果使用应用服务器提供的事务服务,你通常需要确保所有的资源都被应用服务器管理,并通过JNDI暴露出去。Spring Boot通过查找JNDI路径(`java:/JmsXA`或`java:/XAConnectionFactory`),获取一个`ConnectionFactory`来自动配置JMS,并且你可以使用[`spring.datasource.jndi-name`属性](https://docs.spring.io/spring-boot/docs/2.0.0.RELEASE/reference/htmlsingle/#boot-features-connecting-to-a-jndi-datasource)配置你的`DataSource`。 From a7c59cb2dd9125dfd250e3fad83ba8b32a281086 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E7=83=AD=E5=BF=83=E5=B8=82=E6=B0=91=E9=92=9F=E5=B0=8F?= =?UTF-8?q?=E5=BC=BA?= Date: Wed, 22 May 2019 11:47:37 +0800 Subject: [PATCH 365/865] Update SUMMARY.md --- SUMMARY.md | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/SUMMARY.md b/SUMMARY.md index 6bb75278..6c102d14 100644 --- a/SUMMARY.md +++ b/SUMMARY.md @@ -247,9 +247,9 @@ * [37.1 使用Atomikos事务管理器](IV. Spring Boot features/37.1 Using an Atomikos Transaction Manager.md) * [37.2 使用Bitronix事务管理器](IV. Spring Boot features/37.2 Using a Bitronix Transaction Manager.md) * [37.3 使用Narayana事务管理器](IV. Spring Boot features/37.3 Using a Narayana Transaction Manager.md) - * [37.4 使用J2EE管理的事务管理器](IV. Spring Boot features/37.4 Using a Java EE managed Transaction Manager.md) - * [37.5 混合XA和non-XA的JMS连接](IV. Spring Boot features/37.5 Mixing XA and non-XA JMS connections.md) - * [37.6 支持可替代的内嵌事务管理器](IV. Spring Boot features/37.6 Supporting an alternative embedded transaction manager.md) + * [37.4 使用J2EE管理的事务管理器](IV. Spring Boot features/37.4 Using a Java EE Managed Transaction Manager.md) + * [37.5 混合XA和non-XA的JMS连接](IV. Spring Boot features/37.5 Mixing XA and Non-XA JMS Connections.md) + * [37.6 支持可替代的内嵌事务管理器](IV. Spring Boot features/37.6 Supporting an Alternative Embedded Transaction Manager.md) * [37. Hazelcast](IV. Spring Boot features/37. Hazelcast.md) * [38. Quartz调度器](IV. Spring Boot features/38. Quartz Scheduler.md) * [39. Spring集成](IV. Spring Boot features/39. Spring Integration.md) From 444c2c0443dae06260851d324eff8a07a454f5ed Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E7=83=AD=E5=BF=83=E5=B8=82=E6=B0=91=E9=92=9F=E5=B0=8F?= =?UTF-8?q?=E5=BC=BA?= Date: Wed, 22 May 2019 11:51:06 +0800 Subject: [PATCH 366/865] Update and rename 36.5 Mixing XA and non-XA JMS connections.md to 37.5 Mixing XA and Non-XA JMS Connections.md --- ...nections.md => 37.5 Mixing XA and Non-XA JMS Connections.md} | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) rename IV. Spring Boot features/{36.5 Mixing XA and non-XA JMS connections.md => 37.5 Mixing XA and Non-XA JMS Connections.md} (94%) diff --git a/IV. Spring Boot features/36.5 Mixing XA and non-XA JMS connections.md b/IV. Spring Boot features/37.5 Mixing XA and Non-XA JMS Connections.md similarity index 94% rename from IV. Spring Boot features/36.5 Mixing XA and non-XA JMS connections.md rename to IV. Spring Boot features/37.5 Mixing XA and Non-XA JMS Connections.md index 80f9d14d..16b3b540 100644 --- a/IV. Spring Boot features/36.5 Mixing XA and non-XA JMS connections.md +++ b/IV. Spring Boot features/37.5 Mixing XA and Non-XA JMS Connections.md @@ -1,4 +1,4 @@ -### 36.5 混合XA和non-XA的JMS连接 +### 37.5 混合XA和non-XA的JMS连接 当使用JTA时,primary JMS `ConnectionFactory`bean将能识别XA,并参与到分布式事务中。有些情况下,你可能需要使用non-XA的`ConnectionFactory`去处理一些JMS消息。例如,你的JMS处理逻辑可能比XA超时时间长。 From 84fc8f55d180473c7ae982bab60bd0e1e172d07d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E7=83=AD=E5=BF=83=E5=B8=82=E6=B0=91=E9=92=9F=E5=B0=8F?= =?UTF-8?q?=E5=BC=BA?= Date: Wed, 22 May 2019 11:52:53 +0800 Subject: [PATCH 367/865] Update and rename 36.6 Supporting an alternative embedded transaction manager.md to 37.6 Supporting an Alternative Embedded Transaction Manager.md --- ...6 Supporting an Alternative Embedded Transaction Manager.md} | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) rename IV. Spring Boot features/{36.6 Supporting an alternative embedded transaction manager.md => 37.6 Supporting an Alternative Embedded Transaction Manager.md} (95%) diff --git a/IV. Spring Boot features/36.6 Supporting an alternative embedded transaction manager.md b/IV. Spring Boot features/37.6 Supporting an Alternative Embedded Transaction Manager.md similarity index 95% rename from IV. Spring Boot features/36.6 Supporting an alternative embedded transaction manager.md rename to IV. Spring Boot features/37.6 Supporting an Alternative Embedded Transaction Manager.md index 8a21f233..64d2be4f 100644 --- a/IV. Spring Boot features/36.6 Supporting an alternative embedded transaction manager.md +++ b/IV. Spring Boot features/37.6 Supporting an Alternative Embedded Transaction Manager.md @@ -1,4 +1,4 @@ -### 36.6 支持可替代的内嵌事务管理器 +7### 36.6 支持可替代的内嵌事务管理器 [XAConnectionFactoryWrapper](http://github.com/spring-projects/spring-boot/tree/master/spring-boot/src/main/java/org/springframework/boot/jta/XAConnectionFactoryWrapper.java)和[XADataSourceWrapper](http://github.com/spring-projects/spring-boot/tree/master/spring-boot/src/main/java/org/springframework/boot/jta/XADataSourceWrapper.java)接口用于支持可替换的内嵌事务管理器。该接口用于包装`XAConnectionFactory`和`XADataSource` beans,并将它们暴露为普通的`ConnectionFactory`和`DataSource` beans,这样在分布式事务中可以透明使用。Spring Boot将使用注册到`ApplicationContext`的合适的XA包装器及`JtaTransactionManager` bean自动配置你的DataSource和JMS。 From c82f86e06226e130347eafd7d4b7a6d5f93b262a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E7=83=AD=E5=BF=83=E5=B8=82=E6=B0=91=E9=92=9F=E5=B0=8F?= =?UTF-8?q?=E5=BC=BA?= Date: Wed, 22 May 2019 11:56:31 +0800 Subject: [PATCH 368/865] Update 37.6 Supporting an Alternative Embedded Transaction Manager.md --- ...upporting an Alternative Embedded Transaction Manager.md | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/IV. Spring Boot features/37.6 Supporting an Alternative Embedded Transaction Manager.md b/IV. Spring Boot features/37.6 Supporting an Alternative Embedded Transaction Manager.md index 64d2be4f..2de48e85 100644 --- a/IV. Spring Boot features/37.6 Supporting an Alternative Embedded Transaction Manager.md +++ b/IV. Spring Boot features/37.6 Supporting an Alternative Embedded Transaction Manager.md @@ -1,5 +1,5 @@ -7### 36.6 支持可替代的内嵌事务管理器 +### 37.6 支持可替代的内嵌事务管理器 -[XAConnectionFactoryWrapper](http://github.com/spring-projects/spring-boot/tree/master/spring-boot/src/main/java/org/springframework/boot/jta/XAConnectionFactoryWrapper.java)和[XADataSourceWrapper](http://github.com/spring-projects/spring-boot/tree/master/spring-boot/src/main/java/org/springframework/boot/jta/XADataSourceWrapper.java)接口用于支持可替换的内嵌事务管理器。该接口用于包装`XAConnectionFactory`和`XADataSource` beans,并将它们暴露为普通的`ConnectionFactory`和`DataSource` beans,这样在分布式事务中可以透明使用。Spring Boot将使用注册到`ApplicationContext`的合适的XA包装器及`JtaTransactionManager` bean自动配置你的DataSource和JMS。 +[XAConnectionFactoryWrapper](https://github.com/spring-projects/spring-boot/tree/v2.0.0.RELEASE/spring-boot-project/spring-boot/src/main/java/org/springframework/boot/jms/XAConnectionFactoryWrapper.java)和[XADataSourceWrapper](https://github.com/spring-projects/spring-boot/tree/v2.0.0.RELEASE/spring-boot-project/spring-boot/src/main/java/org/springframework/boot/jdbc/XADataSourceWrapper.java)接口用于支持可替换的内嵌事务管理器。该接口用于包装`XAConnectionFactory`和`XADataSource` beans,并将它们暴露为普通的`ConnectionFactory`和`DataSource` beans,这样在分布式事务中可以透明使用。Spring Boot将使用注册到`ApplicationContext`的合适的XA包装器及`JtaTransactionManager` bean自动配置你的DataSource和JMS。 -[BitronixXAConnectionFactoryWrapper](https://github.com/spring-projects/spring-boot/tree/v2.0.0.RELEASE/spring-boot/src/main/java/org/springframework/boot/jta/bitronix/BitronixXAConnectionFactoryWrapper.java)和[BitronixXADataSourceWrapper](https://github.com/spring-projects/spring-boot/tree/v2.0.0.RELEASE/spring-boot/src/main/java/org/springframework/boot/jta/bitronix/BitronixXADataSourceWrapper.java)提供很好的示例用于演示怎么编写XA包装器。 +[BitronixXAConnectionFactoryWrapper](https://github.com/spring-projects/spring-boot/tree/v2.0.0.RELEASE/spring-boot-project/spring-boot/src/main/java/org/springframework/boot/jta/bitronix/BitronixXAConnectionFactoryWrapper.java)和[BitronixXADataSourceWrapper](https://github.com/spring-projects/spring-boot/tree/v2.0.0.RELEASE/spring-boot-project/spring-boot/src/main/java/org/springframework/boot/jta/bitronix/BitronixXADataSourceWrapper.java)提供很好的示例用于演示怎么编写XA包装器。 From 63045ebea587e6ee9984ea346eaf5e61eda17861 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E7=83=AD=E5=BF=83=E5=B8=82=E6=B0=91=E9=92=9F=E5=B0=8F?= =?UTF-8?q?=E5=BC=BA?= Date: Wed, 22 May 2019 13:37:35 +0800 Subject: [PATCH 369/865] Update SUMMARY.md --- SUMMARY.md | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/SUMMARY.md b/SUMMARY.md index 6c102d14..f290847a 100644 --- a/SUMMARY.md +++ b/SUMMARY.md @@ -250,12 +250,12 @@ * [37.4 使用J2EE管理的事务管理器](IV. Spring Boot features/37.4 Using a Java EE Managed Transaction Manager.md) * [37.5 混合XA和non-XA的JMS连接](IV. Spring Boot features/37.5 Mixing XA and Non-XA JMS Connections.md) * [37.6 支持可替代的内嵌事务管理器](IV. Spring Boot features/37.6 Supporting an Alternative Embedded Transaction Manager.md) - * [37. Hazelcast](IV. Spring Boot features/37. Hazelcast.md) - * [38. Quartz调度器](IV. Spring Boot features/38. Quartz Scheduler.md) - * [39. Spring集成](IV. Spring Boot features/39. Spring Integration.md) - * [40. Spring Session](IV. Spring Boot features/40. Spring Session.md) - * [41. 基于JMX的监控和管理](IV. Spring Boot features/41. Monitoring and management over JMX.md) - * [42. 测试](IV. Spring Boot features/42. Testing.md) + * [38. Hazelcast](IV. Spring Boot features/38. Hazelcast.md) + * [39. Quartz调度器](IV. Spring Boot features/39. Quartz Scheduler.md) + * [40. Spring集成](IV. Spring Boot features/40. Spring Integration.md) + * [41. Spring Session](IV. Spring Boot features/41. Spring Session.md) + * [42. 基于JMX的监控和管理](IV. Spring Boot features/42. Monitoring and management over JMX.md) + * [43. 测试](IV. Spring Boot features/43. Testing.md) * [42.1 测试作用域依赖](IV. Spring Boot features/42.1 Test scope dependencies.md) * [42.2 测试Spring应用](IV. Spring Boot features/42.2 Testing Spring applications.md) * [42.3 测试Spring Boot应用](IV. Spring Boot features/42.3 Testing Spring Boot applications.md) From 50581b746f273fa2275cbf68e327e0752ccdc988 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E7=83=AD=E5=BF=83=E5=B8=82=E6=B0=91=E9=92=9F=E5=B0=8F?= =?UTF-8?q?=E5=BC=BA?= Date: Wed, 22 May 2019 13:49:23 +0800 Subject: [PATCH 370/865] Update and rename 37. Hazelcast.md to 38. Hazelcast.md --- .../{37. Hazelcast.md => 38. Hazelcast.md} | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) rename IV. Spring Boot features/{37. Hazelcast.md => 38. Hazelcast.md} (86%) diff --git a/IV. Spring Boot features/37. Hazelcast.md b/IV. Spring Boot features/38. Hazelcast.md similarity index 86% rename from IV. Spring Boot features/37. Hazelcast.md rename to IV. Spring Boot features/38. Hazelcast.md index bbd74315..a0d8d7a0 100644 --- a/IV. Spring Boot features/37. Hazelcast.md +++ b/IV. Spring Boot features/38. Hazelcast.md @@ -1,6 +1,7 @@ -### 37. Hazelcast +### 38. Hazelcast + +如果添加[Hazelcast](https://hazelcast.com/)依赖并正确配置好了,Spring Boot将自动配置一个`HazelcastInstance`,你可以注入到应用中。 -如果添加hazelcast依赖并正确配置好了,Spring Boot将自动配置一个`HazelcastInstance`,你可以注入到应用中。 如果定义了`com.hazelcast.config.Config` bean,则Spring Boot将使用它。如果你的配置指定了实例的名称,Spring Boot将尝试定位已存在的而不是创建一个新实例。你可以在配置中指定将要使用的`hazelcast.xml`配置文件: ```properties spring.hazelcast.config=classpath:config/my-hazelcast.xml From 4f3f8eb4f538e408e7a855493080ced22805575f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E7=83=AD=E5=BF=83=E5=B8=82=E6=B0=91=E9=92=9F=E5=B0=8F?= =?UTF-8?q?=E5=BC=BA?= Date: Wed, 22 May 2019 13:52:55 +0800 Subject: [PATCH 371/865] Update and rename 38. Quartz Scheduler.md to 39. Quartz Scheduler.md --- .../{38. Quartz Scheduler.md => 39. Quartz Scheduler.md} | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) rename IV. Spring Boot features/{38. Quartz Scheduler.md => 39. Quartz Scheduler.md} (85%) diff --git a/IV. Spring Boot features/38. Quartz Scheduler.md b/IV. Spring Boot features/39. Quartz Scheduler.md similarity index 85% rename from IV. Spring Boot features/38. Quartz Scheduler.md rename to IV. Spring Boot features/39. Quartz Scheduler.md index 5df3fd03..e472643e 100644 --- a/IV. Spring Boot features/38. Quartz Scheduler.md +++ b/IV. Spring Boot features/39. Quartz Scheduler.md @@ -1,6 +1,6 @@ -### 38. Quartz调度器 +### 39. Quartz调度器 -Spring Boot包含有`spring-boot-starter-quartz`Starter,方便了使用Quartz调度器。如果Quartz可用,调度器会被自动配置(通过SchedulerFactoryBean抽象)。 +Spring Boot包含有`spring-boot-starter-quartz`Starter,方便了使用[Quartz调度器](http://www.quartz-scheduler.org/)。如果Quartz可用,调度器会被自动配置(通过SchedulerFactoryBean抽象)。 以下类型的bean会被自动捡起并关联到调度器: * `JobDetail`:定义一个特别的Job。`JobDetail`实例能够容易地用`JobBuilder`API创建 @@ -13,7 +13,7 @@ spring.quartz.job-store-type=jdbc ``` 当jdbc store被使用,模式能够在启动时被初始化: ```properties -spring.quartz.jdbc.initialize-schema=true +spring.quartz.jdbc.initialize-schema=always ``` **注** 数据库会默认被检查,而且会被初始化(使用由Quartz库提供的标准脚本)。也可以使用`spring.quartz.jdbc.schema`属性提供一个自定义脚本。 From 3c9ba282bfd44676847a9b7b4e9b9477830a57a1 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E7=83=AD=E5=BF=83=E5=B8=82=E6=B0=91=E9=92=9F=E5=B0=8F?= =?UTF-8?q?=E5=BC=BA?= Date: Wed, 22 May 2019 13:54:46 +0800 Subject: [PATCH 372/865] Update 38. Hazelcast.md --- IV. Spring Boot features/38. Hazelcast.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/IV. Spring Boot features/38. Hazelcast.md b/IV. Spring Boot features/38. Hazelcast.md index a0d8d7a0..c994c699 100644 --- a/IV. Spring Boot features/38. Hazelcast.md +++ b/IV. Spring Boot features/38. Hazelcast.md @@ -14,4 +14,4 @@ spring.hazelcast.config=classpath:config/my-hazelcast.xml * `hazelcast.client.config`系统属性 * 一个在工作目录或者类路径的根目录中的`hazelcast-client.xml` -**注** Spring Boot为Hazelcast提供了缓存支持,如果开启缓存的话,`HazelcastInstance`实例将自动包装进一个`CacheManager`实现中。 +**注** Spring Boot[为Hazelcast提供了缓存支持](https://docs.spring.io/spring-boot/docs/2.0.0.RELEASE/reference/htmlsingle/#boot-features-caching-provider-hazelcast)。如果开启缓存的话,`HazelcastInstance`实例将自动包装进一个`CacheManager`实现中。 From 42c6ce5935420eec437a0b42c841bff83e9b0876 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E7=83=AD=E5=BF=83=E5=B8=82=E6=B0=91=E9=92=9F=E5=B0=8F?= =?UTF-8?q?=E5=BC=BA?= Date: Wed, 22 May 2019 13:59:10 +0800 Subject: [PATCH 373/865] Update and rename 39. Spring Integration.md to 40. Spring Integration.md --- IV. Spring Boot features/39. Spring Integration.md | 10 ---------- IV. Spring Boot features/40. Spring Integration.md | 11 +++++++++++ 2 files changed, 11 insertions(+), 10 deletions(-) delete mode 100644 IV. Spring Boot features/39. Spring Integration.md create mode 100644 IV. Spring Boot features/40. Spring Integration.md diff --git a/IV. Spring Boot features/39. Spring Integration.md b/IV. Spring Boot features/39. Spring Integration.md deleted file mode 100644 index f5a23874..00000000 --- a/IV. Spring Boot features/39. Spring Integration.md +++ /dev/null @@ -1,10 +0,0 @@ -### 39. Spring集成 - -Spring Boot为Spring集成提供了一些便利,包括`spring-boot-starter-integration` ‘Starter’。 -Spring集成提供基于消息和其他传输协议的抽象,比如HTTP,TCP等。如果添加Spring集成依赖,使用`@EnableIntegration`注解可以初始化它。 - -Spring Boot也会配置一些由另外的Spring集成模块触发的特性。如果classpath下存在`'spring-integration-jmx'`依赖,则消息处理统计分析将通过JMX发布出去。如果`'spring-integration-jdbc'`可用,默认的数据库模式会在启动时被创建: -```properties -spring.integration.jdbc.initializer.enabled =true -``` -更多细节请查看[`IntegrationAutoConfiguration`](https://github.com/spring-projects/spring-boot/tree/v2.0.0.RELEASE/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/integration/IntegrationAutoConfiguration.java)和[`IntegrationProperties`](https://github.com/spring-projects/spring-boot/tree/v2.0.0.RELEASE/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/integration/IntegrationProperties.java)类。 diff --git a/IV. Spring Boot features/40. Spring Integration.md b/IV. Spring Boot features/40. Spring Integration.md new file mode 100644 index 00000000..db1f6160 --- /dev/null +++ b/IV. Spring Boot features/40. Spring Integration.md @@ -0,0 +1,11 @@ +### 40. Spring集成 + +Spring Boot为[Spring集成](https://projects.spring.io/spring-integration/)提供了一些便利,包括`spring-boot-starter-integration` ‘Starter’。 +Spring集成提供基于消息和其他传输协议的抽象,比如HTTP,TCP等。如果添加Spring集成依赖,使用`@EnableIntegration`注解可以初始化它。 + +Spring Boot也会配置一些由另外的Spring集成模块触发的特性。如果classpath下存在`'spring-integration-jmx'`依赖,则消息处理统计分析将通过JMX发布出去。如果`'spring-integration-jdbc'`可用,默认的数据库模式会在启动时被创建: +```properties +spring.integration.jdbc.initialize-schema=always +``` + +更多细节请查看[`IntegrationAutoConfiguration`](https://github.com/spring-projects/spring-boot/tree/v2.0.0.RELEASE/spring-boot-project/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/integration/IntegrationAutoConfiguration.java)和[`IntegrationProperties`](https://github.com/spring-projects/spring-boot/tree/v2.0.0.RELEASE/spring-boot-project/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/integration/IntegrationProperties.java)类。 From c919dc64c9370356a965afe337d83a55f0076af0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E7=83=AD=E5=BF=83=E5=B8=82=E6=B0=91=E9=92=9F=E5=B0=8F?= =?UTF-8?q?=E5=BC=BA?= Date: Wed, 22 May 2019 14:09:50 +0800 Subject: [PATCH 374/865] Update and rename 40. Spring Session.md to 41. Spring Session.md --- .../40. Spring Session.md | 19 -------------- .../41. Spring Session.md | 25 +++++++++++++++++++ 2 files changed, 25 insertions(+), 19 deletions(-) delete mode 100644 IV. Spring Boot features/40. Spring Session.md create mode 100644 IV. Spring Boot features/41. Spring Session.md diff --git a/IV. Spring Boot features/40. Spring Session.md b/IV. Spring Boot features/40. Spring Session.md deleted file mode 100644 index 89dab69d..00000000 --- a/IV. Spring Boot features/40. Spring Session.md +++ /dev/null @@ -1,19 +0,0 @@ -###40. Spring Session -Spring Boot为Spring Session自动配置了各种存储: - -* JDBC -* Redis -* Hazelcast -* HashMap - -如果Spring Session可用,你必须选择想要的存储sessions的存储类型[StoreType](https://github.com/spring-projects/spring-boot/tree/v2.0.0.RELEASE/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/session/StoreType.java)。例如,按如下配置将使用JDBC作为后端存储: -```properties -spring.session.store-type=jdbc -``` - -**提醒** 设置`store-type`为`none`可以禁用Spring Session。 - -每个存储都有特殊设置,例如,对于jdbc存储可自定义表名: -```properties -spring.session.jdbc.table-name=SESSIONS -``` diff --git a/IV. Spring Boot features/41. Spring Session.md b/IV. Spring Boot features/41. Spring Session.md new file mode 100644 index 00000000..ab45b197 --- /dev/null +++ b/IV. Spring Boot features/41. Spring Session.md @@ -0,0 +1,25 @@ +### 41. Spring Session + +Spring Boot为Spring Session自动配置了各种数据存储。当构建Servlet网络应用时,以下存储方式会被自动配置: + +* JDBC +* Redis +* Hazelcast +* MongoDB + +当构建响应式网络应用时,以下存储方式会被自动配置: + +* Redis +* MongoDB + +如果Spring Session可用,你必须选择想要的存储sessions的存储类型[StoreType](https://github.com/spring-projects/spring-boot/tree/v2.0.0.RELEASE/spring-boot-project/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/session/StoreType.java)。例如,按如下配置将使用JDBC作为后端存储: +```properties +spring.session.store-type=jdbc +``` + +**提醒** 设置`store-type`为`none`可以禁用Spring Session。 + +每个存储都有特殊设置,例如,对于jdbc存储可自定义表名: +```properties +spring.session.jdbc.table-name=SESSIONS +``` From f0d6258e01ce5fd66bac1c4306800d88e79b1d36 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E7=83=AD=E5=BF=83=E5=B8=82=E6=B0=91=E9=92=9F=E5=B0=8F?= =?UTF-8?q?=E5=BC=BA?= Date: Wed, 22 May 2019 14:12:37 +0800 Subject: [PATCH 375/865] Update and rename 41. Monitoring and management over JMX.md to 42. Monitoring and Management over JMX.md --- .../41. Monitoring and management over JMX.md | 3 --- .../42. Monitoring and Management over JMX.md | 3 +++ 2 files changed, 3 insertions(+), 3 deletions(-) delete mode 100644 IV. Spring Boot features/41. Monitoring and management over JMX.md create mode 100644 IV. Spring Boot features/42. Monitoring and Management over JMX.md diff --git a/IV. Spring Boot features/41. Monitoring and management over JMX.md b/IV. Spring Boot features/41. Monitoring and management over JMX.md deleted file mode 100644 index ebfe17ff..00000000 --- a/IV. Spring Boot features/41. Monitoring and management over JMX.md +++ /dev/null @@ -1,3 +0,0 @@ -### 41. 基于JMX的监控和管理 - -Java管理扩展(JMX)提供了一个标准的用于监控和管理应用的机制。默认情况下,Spring Boot将创建一个id为‘mbeanServer’的`MBeanServer`,并导出任何被Spring JMX注解(`@ManagedResource`,`@ManagedAttribute`,`@ManagedOperation`)的beans,具体参考[JmxAutoConfiguration类](https://github.com/spring-projects/spring-boot/tree/v2.0.0.RELEASE/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/jmx/JmxAutoConfiguration.java)。 diff --git a/IV. Spring Boot features/42. Monitoring and Management over JMX.md b/IV. Spring Boot features/42. Monitoring and Management over JMX.md new file mode 100644 index 00000000..1d13ba58 --- /dev/null +++ b/IV. Spring Boot features/42. Monitoring and Management over JMX.md @@ -0,0 +1,3 @@ +### 42. 基于JMX的监控和管理 + +Java管理扩展(JMX)提供了一个标准的用于监控和管理应用的机制。默认情况下,Spring Boot将创建一个ID为`mbeanServer`的`MBeanServer`,并导出任何被Spring JMX注解(`@ManagedResource`,`@ManagedAttribute`,`@ManagedOperation`)的bean,具体参考[JmxAutoConfiguration类](https://github.com/spring-projects/spring-boot/tree/v2.0.0.RELEASE/spring-boot-project/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/jmx/JmxAutoConfiguration.java)。 From 0702180ce7f19487261f517dc1a2c7b812cc0183 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E7=83=AD=E5=BF=83=E5=B8=82=E6=B0=91=E9=92=9F=E5=B0=8F?= =?UTF-8?q?=E5=BC=BA?= Date: Wed, 22 May 2019 14:14:18 +0800 Subject: [PATCH 376/865] Update SUMMARY.md --- SUMMARY.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/SUMMARY.md b/SUMMARY.md index f290847a..f3c51a75 100644 --- a/SUMMARY.md +++ b/SUMMARY.md @@ -254,7 +254,7 @@ * [39. Quartz调度器](IV. Spring Boot features/39. Quartz Scheduler.md) * [40. Spring集成](IV. Spring Boot features/40. Spring Integration.md) * [41. Spring Session](IV. Spring Boot features/41. Spring Session.md) - * [42. 基于JMX的监控和管理](IV. Spring Boot features/42. Monitoring and management over JMX.md) + * [42. 基于JMX的监控和管理](IV. Spring Boot features/42. Monitoring and Management over JMX.md) * [43. 测试](IV. Spring Boot features/43. Testing.md) * [42.1 测试作用域依赖](IV. Spring Boot features/42.1 Test scope dependencies.md) * [42.2 测试Spring应用](IV. Spring Boot features/42.2 Testing Spring applications.md) From e6955db44c197f564c167fd47a9fbaff55fe547b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E7=83=AD=E5=BF=83=E5=B8=82=E6=B0=91=E9=92=9F=E5=B0=8F?= =?UTF-8?q?=E5=BC=BA?= Date: Wed, 22 May 2019 14:17:01 +0800 Subject: [PATCH 377/865] Update and rename 42. Testing.md to 43. Testing.md --- IV. Spring Boot features/{42. Testing.md => 43. Testing.md} | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) rename IV. Spring Boot features/{42. Testing.md => 43. Testing.md} (63%) diff --git a/IV. Spring Boot features/42. Testing.md b/IV. Spring Boot features/43. Testing.md similarity index 63% rename from IV. Spring Boot features/42. Testing.md rename to IV. Spring Boot features/43. Testing.md index de09e8f2..1ebd49e0 100644 --- a/IV. Spring Boot features/42. Testing.md +++ b/IV. Spring Boot features/43. Testing.md @@ -1,5 +1,5 @@ -###42. 测试 +### 43. 测试 Spring Boot提供很多有用的工具类和注解用于帮助你测试应用,主要分两个模块:`spring-boot-test`包含核心组件,`spring-boot-test-autoconfigure`为测试提供自动配置。 -大多数开发者只需要引用`spring-boot-starter-test` ‘Starter’,它既提供Spring Boot测试模块,也提供JUnit,AssertJ,Hamcrest和很多有用的依赖。 +大多数开发者只需要引用`spring-boot-starter-test` “Starter”,它既提供Spring Boot测试模块,也提供JUnit,AssertJ,Hamcrest和很多有用的依赖。 From f381a6d618c093282f7ef2c704d78aee22e60b88 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E7=83=AD=E5=BF=83=E5=B8=82=E6=B0=91=E9=92=9F=E5=B0=8F?= =?UTF-8?q?=E5=BC=BA?= Date: Wed, 22 May 2019 19:54:04 +0800 Subject: [PATCH 378/865] Update and rename 42.1 Test scope dependencies.md to 43.1 Test Scope Dependencies.md --- .../42.1 Test scope dependencies.md | 13 ------------- .../43.1 Test Scope Dependencies.md | 13 +++++++++++++ 2 files changed, 13 insertions(+), 13 deletions(-) delete mode 100644 IV. Spring Boot features/42.1 Test scope dependencies.md create mode 100644 IV. Spring Boot features/43.1 Test Scope Dependencies.md diff --git a/IV. Spring Boot features/42.1 Test scope dependencies.md b/IV. Spring Boot features/42.1 Test scope dependencies.md deleted file mode 100644 index b55f922d..00000000 --- a/IV. Spring Boot features/42.1 Test scope dependencies.md +++ /dev/null @@ -1,13 +0,0 @@ -###42.1 测试作用域依赖 - -如果使用`spring-boot-starter-test` ‘Starter’(在`test` `scope`内),你将发现下列被提供的库: - -- [JUnit](http://junit.org/) - 事实上的(de-facto)标准,用于Java应用的单元测试。 -- [Spring Test](https://docs.spring.io/spring/docs/5.0.4.RELEASE/spring-framework-reference/htmlsingle/#integration-testing.html) & Spring Boot Test  - 对Spring应用的集成测试支持。 -- [AssertJ](http://joel-costigliola.github.io/assertj/) - 一个流式断言库。 -- [Hamcrest](http://hamcrest.org/JavaHamcrest/) - 一个匹配对象的库(也称为约束或前置条件)。 -- [Mockito](http://mockito.org/) - 一个Java模拟框架。 -- [JSONassert](https://github.com/skyscreamer/JSONassert) - 一个针对JSON的断言库。 -- [JsonPath](https://github.com/jayway/JsonPath) - 用于JSON的XPath。 - -这是写测试用例经常用到的库,如果它们不能满足要求,你可以随意添加其他的依赖。 diff --git a/IV. Spring Boot features/43.1 Test Scope Dependencies.md b/IV. Spring Boot features/43.1 Test Scope Dependencies.md new file mode 100644 index 00000000..f716ae25 --- /dev/null +++ b/IV. Spring Boot features/43.1 Test Scope Dependencies.md @@ -0,0 +1,13 @@ +### 43.1 测试作用域依赖 + +`spring-boot-starter-test`“Starter”(在`test` `scope`内)包含下列库: + +- [JUnit](http://junit.org/):事实上的(de-facto)标准,用于Java应用的单元测试。 +- [Spring Test](https://docs.spring.io/spring/docs/5.0.4.RELEASE/spring-framework-reference/testing.html#integration-testing) & Spring Boot Test:实用工具以及对Spring应用的集成测试支持。 +- [AssertJ](https://joel-costigliola.github.io/assertj/):一个流式断言库。 +- [Hamcrest](http://hamcrest.org/JavaHamcrest/):一个匹配对象的库(也称为约束或前置条件)。 +- [Mockito](http://mockito.org/):一个Java模拟框架。 +- [JSONassert](https://github.com/skyscreamer/JSONassert):一个针对JSON的断言库。 +- [JsonPath](https://github.com/jayway/JsonPath):用于JSON的XPath。 + +这是写测试用例经常用到的库,如果它们不能满足要求,你可以随意添加其他的依赖。 From cb2c3ce6b7f173e7fb3250364822964931695218 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E7=83=AD=E5=BF=83=E5=B8=82=E6=B0=91=E9=92=9F=E5=B0=8F?= =?UTF-8?q?=E5=BC=BA?= Date: Wed, 22 May 2019 20:02:22 +0800 Subject: [PATCH 379/865] Update and rename 42.2 Testing Spring applications.md to 43.2 Testing Spring Applications.md --- .../42.2 Testing Spring applications.md | 7 ------- .../43.2 Testing Spring Applications.md | 7 +++++++ 2 files changed, 7 insertions(+), 7 deletions(-) delete mode 100644 IV. Spring Boot features/42.2 Testing Spring applications.md create mode 100644 IV. Spring Boot features/43.2 Testing Spring Applications.md diff --git a/IV. Spring Boot features/42.2 Testing Spring applications.md b/IV. Spring Boot features/42.2 Testing Spring applications.md deleted file mode 100644 index 13dc8fb1..00000000 --- a/IV. Spring Boot features/42.2 Testing Spring applications.md +++ /dev/null @@ -1,7 +0,0 @@ -###42.2 测试Spring应用 - -依赖注入主要优势之一就是它能够让你的代码更容易进行单元测试。你只需简单的通过`new`操作符实例化对象,甚至不需要涉及Spring,也可以使用模拟对象替换真正的依赖。 - -你常常需要在进行单元测试后,开始集成测试(在这个过程中只需要涉及到Spring的`ApplicationContext`)。在执行集成测试时,不需要部署应用或连接到其他基础设施是非常有用的,Spring框架为实现这样的集成测试提供了一个专用的测试模块,通过声明`org.springframework:spring-test`的依赖,或使用`spring-boot-starter-test` ‘Starter’就可以使用它了。 - -如果以前没有使用过`spring-test`模块,可以查看Spring框架参考文档中的[相关章节](https://docs.spring.io/spring/docs/5.0.4.RELEASE/spring-framework-reference/testing.html#testing)。 diff --git a/IV. Spring Boot features/43.2 Testing Spring Applications.md b/IV. Spring Boot features/43.2 Testing Spring Applications.md new file mode 100644 index 00000000..9fe1d611 --- /dev/null +++ b/IV. Spring Boot features/43.2 Testing Spring Applications.md @@ -0,0 +1,7 @@ +### 43.2 测试Spring应用 + +依赖注入主要优势之一就是它能够让你的代码更容易进行单元测试。你只需简单的通过`new`操作符实例化对象,甚至不需要涉及Spring,也可以使用模拟对象替换真正的依赖。 + +你常常需要超出单元测试,开始集成测试(涉及到Spring的`ApplicationContext`)。在执行集成测试时,不需要部署应用或连接到其他基础设施是非常有用的。Spring框架为实现这样的集成测试提供了一个专用的测试模块。通过声明`org.springframework:spring-test`的依赖,或使用`spring-boot-starter-test`“Starter”就可以使用它了。 + +如果以前没有使用过`spring-test`模块,可以查看Spring框架参考文档中的[相关章节](https://docs.spring.io/spring/docs/5.0.4.RELEASE/spring-framework-reference/testing.html#testing)。 From 64dc083ae786925906c700cfe85e8778b74eacd2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E7=83=AD=E5=BF=83=E5=B8=82=E6=B0=91=E9=92=9F=E5=B0=8F?= =?UTF-8?q?=E5=BC=BA?= Date: Wed, 22 May 2019 20:46:12 +0800 Subject: [PATCH 380/865] Update and rename 42.3 Testing Spring Boot applications.md to 43.3 Testing Spring Boot Applications.md --- ... 43.3 Testing Spring Boot Applications.md} | 20 ++++++++++--------- 1 file changed, 11 insertions(+), 9 deletions(-) rename IV. Spring Boot features/{42.3 Testing Spring Boot applications.md => 43.3 Testing Spring Boot Applications.md} (54%) diff --git a/IV. Spring Boot features/42.3 Testing Spring Boot applications.md b/IV. Spring Boot features/43.3 Testing Spring Boot Applications.md similarity index 54% rename from IV. Spring Boot features/42.3 Testing Spring Boot applications.md rename to IV. Spring Boot features/43.3 Testing Spring Boot Applications.md index 000b4cf7..a0e2f731 100644 --- a/IV. Spring Boot features/42.3 Testing Spring Boot applications.md +++ b/IV. Spring Boot features/43.3 Testing Spring Boot Applications.md @@ -1,21 +1,23 @@ -### 42.3 测试Spring Boot应用 +### 43.3 测试Spring Boot应用 -Spring Boot应用只是一个Spring `ApplicationContext`,所以在测试时对它只需要像处理普通Spring context那样即可。唯一需要注意的是,如果你使用`SpringApplication`创建上下文,外部配置,日志和Spring Boot的其他特性只会在默认的上下文中起作用。 +Spring Boot应用只是一个Spring `ApplicationContext`,所以在测试时对它只需要像处理普通Spring context那样即可。 -Spring Boot提供一个`@SpringApplicationConfiguration`注解用于替换标准的`spring-test` `@ContextConfiguration`注解,该组件工作方式是通过`SpringApplication`创建用于测试的`ApplicationContext`。 +**注** 只有使用`SpringApplication`创建上下文时,外部配置、日志和Spring Boot的其他特性才会默认安装在上下文里。 + +Spring Boot提供一个`@SpringBootTest`注解。当你需要Spring Boot特性时,它可以作为标准的`spring-test``@ContextConfiguration`注解的另一种选择。该组件通过`SpringApplication`创建用于测试的`ApplicationContext`。 你可以使用`@SpringBootTest`的`webEnvironment`属性定义怎么运行测试: -* `MOCK` - 加载`WebApplicationContext`,并提供一个mock servlet环境,使用该注解时内嵌servlet容器将不会启动。如果classpath下不存在servlet APIs,该模式将创建一个常规的non-web `ApplicationContext`。Can be used in conjunction with @AutoConfigureMockMvc for MockMvc -based testing of your application. +* `MOCK`:加载`WebApplicationContext`,并提供一个mock servlet环境,使用该注解时内嵌servlet容器将不会启动。如果classpath下不存在servlet APIs,该模式将创建一个常规的non-web `ApplicationContext`。Can be used in conjunction with @AutoConfigureMockMvc for MockMvc -based testing of your application. -* `RANDOM_PORT` - 加载`ServletWebServerApplicationContext`,并提供一个真实的servlet环境。使用该模式内嵌容器将启动,并监听在一个随机端口。 +* `RANDOM_PORT`:加载`ServletWebServerApplicationContext`,并提供一个真实的servlet环境。使用该模式内嵌容器将启动,并监听在一个随机端口。 -* `DEFINED_PORT` - 加载`ServletWebServerApplicationContext`,并提供一个真实的servlet环境。使用该模式内嵌容器将启动,并监听一个定义好的端口(比如`application.properties`中定义的或默认的`8080`端口)。 +* `DEFINED_PORT`:加载`ServletWebServerApplicationContext`,并提供一个真实的servlet环境。使用该模式内嵌容器将启动,并监听一个定义好的端口(比如`application.properties`中定义的或默认的`8080`端口)。 -* `NONE` - 使用`SpringApplication`加载一个`ApplicationContext`,但不提供任何servlet环境(不管是mock还是其他)。 +* `NONE`:使用`SpringApplication`加载一个`ApplicationContext`,但不提供任何servlet环境(不管是mock还是其他)。 -**注** 如果你的测试标注了`@Transactional`,默认的,在每一个测试方法结束时,它将会回滚事务。如果你正是此种情况,而且用了`RANDOM_PORT`或是`DEFINED_PORT`。那么,任何在服务器上初始化的事务都不会回滚,因为测试正运行在一个不同的线程上,服务器不会进行处理。 +**注** 如果你的测试标注了`@Transactional`,默认的,在每一个测试方法结束时,它将会回滚事务。如果你正是此种情况,而且用了`RANDOM_PORT`或是`DEFINED_PORT`,隐式提供了一个真实的servlet环境。那么,HTTP客户端和服务端跑在不同的线程上,因此在不同的事务里。在这种情况下,任何在服务端初始化的事务不会回滚。 -**注** 除了`@SpringBootTest`,还有许多另外的注解被提供,用来测试应用的更多特定的部分。细节请看下面。 +**注** 除了`@SpringBootTest`,还有许多另外的注解被提供,用来测试应用的更多特定的部分。你可以在这一章里找到更多细节。 **注** 不要忘记在测试用例上添加`@RunWith(SpringRunner.class)`,否则该注解将被忽略。 From 9e6c7c8f19275de380bdb08a87ce81e5120527a9 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E7=83=AD=E5=BF=83=E5=B8=82=E6=B0=91=E9=92=9F=E5=B0=8F?= =?UTF-8?q?=E5=BC=BA?= Date: Wed, 22 May 2019 20:49:57 +0800 Subject: [PATCH 381/865] Update SUMMARY.md --- SUMMARY.md | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/SUMMARY.md b/SUMMARY.md index f3c51a75..f9190ba7 100644 --- a/SUMMARY.md +++ b/SUMMARY.md @@ -256,9 +256,9 @@ * [41. Spring Session](IV. Spring Boot features/41. Spring Session.md) * [42. 基于JMX的监控和管理](IV. Spring Boot features/42. Monitoring and Management over JMX.md) * [43. 测试](IV. Spring Boot features/43. Testing.md) - * [42.1 测试作用域依赖](IV. Spring Boot features/42.1 Test scope dependencies.md) - * [42.2 测试Spring应用](IV. Spring Boot features/42.2 Testing Spring applications.md) - * [42.3 测试Spring Boot应用](IV. Spring Boot features/42.3 Testing Spring Boot applications.md) + * [43.1 测试作用域依赖](IV. Spring Boot features/43.1 Test Scope Dependencies.md) + * [43.2 测试Spring应用](IV. Spring Boot features/43.2 Testing Spring Applications.md) + * [43.3 测试Spring Boot应用](IV. Spring Boot features/43.3 Testing Spring Boot Applications.md) * [42.3.1 发现测试配置](IV. Spring Boot features/42.3.1 Detecting test configuration.md) * [42.3.2 排除测试配置](IV. Spring Boot features/42.3.2 Excluding test configuration.md) * [42.3.3 使用随机端口](IV. Spring Boot features/42.3.3 Working with random ports.md) From d766537f597bc94c3d4173835b1de015910f9722 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E7=83=AD=E5=BF=83=E5=B8=82=E6=B0=91=E9=92=9F=E5=B0=8F?= =?UTF-8?q?=E5=BC=BA?= Date: Thu, 23 May 2019 09:50:06 +0800 Subject: [PATCH 382/865] Create 43.3.1 Detecting Web Application Type --- .../43.3.1 Detecting Web Application Type | 11 +++++++++++ 1 file changed, 11 insertions(+) create mode 100644 IV. Spring Boot features/43.3.1 Detecting Web Application Type diff --git a/IV. Spring Boot features/43.3.1 Detecting Web Application Type b/IV. Spring Boot features/43.3.1 Detecting Web Application Type new file mode 100644 index 00000000..ae2f04c3 --- /dev/null +++ b/IV. Spring Boot features/43.3.1 Detecting Web Application Type @@ -0,0 +1,11 @@ +### 43.3.1 检测网络应用类型 + +如果Spring MVC可用,一个常规的基于MVC的应用上下文会被配置好。如果你只有Spring WebFlux,我们会检测并配置一个基于WebFlux的应用上下文。 + +如果两个都有,Spring MVC优先。在这种情况下,如果你想要测试一个响应式的网络应用,你必须设置`spring.main.web-application-type`属性: + +```java +@RunWith(SpringRunner.class) +@SpringBootTest(properties = "spring.main.web-application-type=reactive") +public class MyWebFluxTests { ... } +``` From 2e99a08667a264ed80246baa9930a3b55609a761 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E7=83=AD=E5=BF=83=E5=B8=82=E6=B0=91=E9=92=9F=E5=B0=8F?= =?UTF-8?q?=E5=BC=BA?= Date: Thu, 23 May 2019 09:59:52 +0800 Subject: [PATCH 383/865] Update SUMMARY.md --- SUMMARY.md | 35 ++++++++++++++++++----------------- 1 file changed, 18 insertions(+), 17 deletions(-) diff --git a/SUMMARY.md b/SUMMARY.md index f9190ba7..dd339af8 100644 --- a/SUMMARY.md +++ b/SUMMARY.md @@ -259,23 +259,24 @@ * [43.1 测试作用域依赖](IV. Spring Boot features/43.1 Test Scope Dependencies.md) * [43.2 测试Spring应用](IV. Spring Boot features/43.2 Testing Spring Applications.md) * [43.3 测试Spring Boot应用](IV. Spring Boot features/43.3 Testing Spring Boot Applications.md) - * [42.3.1 发现测试配置](IV. Spring Boot features/42.3.1 Detecting test configuration.md) - * [42.3.2 排除测试配置](IV. Spring Boot features/42.3.2 Excluding test configuration.md) - * [42.3.3 使用随机端口](IV. Spring Boot features/42.3.3 Working with random ports.md) - * [42.3.4 模拟和监视beans](IV. Spring Boot features/42.3.4 Mocking and spying beans.md) - * [42.3.5 自动配置测试](IV. Spring Boot features/42.3.5 Auto-configured tests.md) - * [42.3.6 自动配置的JSON测试](IV. Spring Boot features/42.3.6 Auto-configured JSON tests.md) - * [42.3.7 自动配置的Spring MVC测试](IV. Spring Boot features/42.3.7 Auto-configured Spring MVC tests.md) - * [42.3.8 自动配置的Data JPA测试](IV. Spring Boot features/42.3.8 Auto-configured Data JPA tests.md) - * [42.3.9 自动配置的JDBC测试](IV. Spring Boot features/42.3.9 Auto-configured JDBC tests.md) - * [42.3.10 自动配置的jOOQ测试](IV. Spring Boot features/42.3.10 Auto-configured jOOQ tests.md) - * [42.3.11 自动配置的Data MongoDB测试](IV. Spring Boot features/42.3.11 Auto-configured Data MongoDB tests.md) - * [42.3.12 自动配置的Data Neo4j测试](IV. Spring Boot features/42.3.12 Auto-configured Data Neo4j tests.md) - * [42.3.13 自动配置的Data Redis测试](IV. Spring Boot features/42.3.13 Auto-configured Data Redis tests.md) - * [42.3.14 自动配置的Data LDAP测试](IV. Spring Boot features/42.3.14 Auto-configured Data LDAP tests.md) - * [42.3.15 自动配置的REST客户端](IV. Spring Boot features/42.3.15 Auto-configured REST clients.md) - * [42.3.16 自动配置的Spring REST Docs测试](IV. Spring Boot features/42.3.16 Auto-configured Spring REST Docs tests.md) - * [42.3.17 使用Spock测试Spring Boot应用](IV. Spring Boot features/42.3.17 Using Spock to test Spring Boot applications.md) + * [43.3.1 检测网络应用类型](IV. Spring Boot features/43.3.1 Detecting Web Application Type.md) + * [42.3.2 检测测试配置](IV. Spring Boot features/42.3.2 Detecting Test Configuration.md) + * [42.3.3 排除测试配置](IV. Spring Boot features/42.3.3 Excluding Test Configuration.md) + * [42.3.4 使用随机端口](IV. Spring Boot features/42.3.4 Working with random ports.md) + * [42.3.5 模拟和监视beans](IV. Spring Boot features/42.3.5 Mocking and Spying Beans.md) + * [42.3.6 自动配置测试](IV. Spring Boot features/42.3.6 Auto-configured Tests.md) + * [42.3.7 自动配置的JSON测试](IV. Spring Boot features/42.3.7 Auto-configured JSON Tests.md) + * [42.3.8 自动配置的Spring MVC测试](IV. Spring Boot features/42.3.8 Auto-configured Spring MVC Tests.md) + * [42.3.9 自动配置的Data JPA测试](IV. Spring Boot features/42.3.9 Auto-configured Data JPA Tests.md) + * [42.3.10 自动配置的JDBC测试](IV. Spring Boot features/42.3.10 Auto-configured JDBC Tests.md) + * [42.3.11 自动配置的jOOQ测试](IV. Spring Boot features/42.3.11 Auto-configured jOOQ Tests.md) + * [42.3.12 自动配置的Data MongoDB测试](IV. Spring Boot features/42.3.12 Auto-configured Data MongoDB Tests.md) + * [42.3.13 自动配置的Data Neo4j测试](IV. Spring Boot features/42.3.13 Auto-configured Data Neo4j Tests.md) + * [42.3.14 自动配置的Data Redis测试](IV. Spring Boot features/42.3.14 Auto-configured Data Redis Tests.md) + * [42.3.15 自动配置的Data LDAP测试](IV. Spring Boot features/42.3.15 Auto-configured Data LDAP Tests.md) + * [42.3.16 自动配置的REST客户端](IV. Spring Boot features/42.3.16 Auto-configured REST Clients.md) + * [42.3.17 自动配置的Spring REST Docs测试](IV. Spring Boot features/42.3.17 Auto-configured Spring REST Docs Tests.md) + * [42.3.18 使用Spock测试Spring Boot应用](IV. Spring Boot features/42.3.18 Using Spock to Test Spring Boot Applications.md) * [42.4 测试工具类](IV. Spring Boot features/42.4 Test utilities.md) * [42.4.1 ConfigFileApplicationContextInitializer](IV. Spring Boot features/42.4.1 ConfigFileApplicationContextInitializer.md) * [42.4.2 EnvironmentTestUtils](IV. Spring Boot features/42.4.2 EnvironmentTestUtils.md) From 1408bed9e6ec65f1d496096521917a7c2d238e7e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E7=83=AD=E5=BF=83=E5=B8=82=E6=B0=91=E9=92=9F=E5=B0=8F?= =?UTF-8?q?=E5=BC=BA?= Date: Thu, 23 May 2019 10:03:37 +0800 Subject: [PATCH 384/865] Update SUMMARY.md --- SUMMARY.md | 34 +++++++++++++++++----------------- 1 file changed, 17 insertions(+), 17 deletions(-) diff --git a/SUMMARY.md b/SUMMARY.md index dd339af8..a75e2638 100644 --- a/SUMMARY.md +++ b/SUMMARY.md @@ -260,23 +260,23 @@ * [43.2 测试Spring应用](IV. Spring Boot features/43.2 Testing Spring Applications.md) * [43.3 测试Spring Boot应用](IV. Spring Boot features/43.3 Testing Spring Boot Applications.md) * [43.3.1 检测网络应用类型](IV. Spring Boot features/43.3.1 Detecting Web Application Type.md) - * [42.3.2 检测测试配置](IV. Spring Boot features/42.3.2 Detecting Test Configuration.md) - * [42.3.3 排除测试配置](IV. Spring Boot features/42.3.3 Excluding Test Configuration.md) - * [42.3.4 使用随机端口](IV. Spring Boot features/42.3.4 Working with random ports.md) - * [42.3.5 模拟和监视beans](IV. Spring Boot features/42.3.5 Mocking and Spying Beans.md) - * [42.3.6 自动配置测试](IV. Spring Boot features/42.3.6 Auto-configured Tests.md) - * [42.3.7 自动配置的JSON测试](IV. Spring Boot features/42.3.7 Auto-configured JSON Tests.md) - * [42.3.8 自动配置的Spring MVC测试](IV. Spring Boot features/42.3.8 Auto-configured Spring MVC Tests.md) - * [42.3.9 自动配置的Data JPA测试](IV. Spring Boot features/42.3.9 Auto-configured Data JPA Tests.md) - * [42.3.10 自动配置的JDBC测试](IV. Spring Boot features/42.3.10 Auto-configured JDBC Tests.md) - * [42.3.11 自动配置的jOOQ测试](IV. Spring Boot features/42.3.11 Auto-configured jOOQ Tests.md) - * [42.3.12 自动配置的Data MongoDB测试](IV. Spring Boot features/42.3.12 Auto-configured Data MongoDB Tests.md) - * [42.3.13 自动配置的Data Neo4j测试](IV. Spring Boot features/42.3.13 Auto-configured Data Neo4j Tests.md) - * [42.3.14 自动配置的Data Redis测试](IV. Spring Boot features/42.3.14 Auto-configured Data Redis Tests.md) - * [42.3.15 自动配置的Data LDAP测试](IV. Spring Boot features/42.3.15 Auto-configured Data LDAP Tests.md) - * [42.3.16 自动配置的REST客户端](IV. Spring Boot features/42.3.16 Auto-configured REST Clients.md) - * [42.3.17 自动配置的Spring REST Docs测试](IV. Spring Boot features/42.3.17 Auto-configured Spring REST Docs Tests.md) - * [42.3.18 使用Spock测试Spring Boot应用](IV. Spring Boot features/42.3.18 Using Spock to Test Spring Boot Applications.md) + * [43.3.2 检测测试配置](IV. Spring Boot features/43.3.2 Detecting Test Configuration.md) + * [43.3.3 排除测试配置](IV. Spring Boot features/43.3.3 Excluding Test Configuration.md) + * [43.3.4 使用随机端口](IV. Spring Boot features/43.3.4 Working with random ports.md) + * [43.3.5 模拟和监视beans](IV. Spring Boot features/43.3.5 Mocking and Spying Beans.md) + * [43.3.6 自动配置测试](IV. Spring Boot features/43.3.6 Auto-configured Tests.md) + * [43.3.7 自动配置的JSON测试](IV. Spring Boot features/43.3.7 Auto-configured JSON Tests.md) + * [43.3.8 自动配置的Spring MVC测试](IV. Spring Boot features/43.3.8 Auto-configured Spring MVC Tests.md) + * [43.3.9 自动配置的Data JPA测试](IV. Spring Boot features/43.3.9 Auto-configured Data JPA Tests.md) + * [43.3.10 自动配置的JDBC测试](IV. Spring Boot features/43.3.10 Auto-configured JDBC Tests.md) + * [43.3.11 自动配置的jOOQ测试](IV. Spring Boot features/43.3.11 Auto-configured jOOQ Tests.md) + * [43.3.12 自动配置的Data MongoDB测试](IV. Spring Boot features/43.3.12 Auto-configured Data MongoDB Tests.md) + * [43.3.13 自动配置的Data Neo4j测试](IV. Spring Boot features/43.3.13 Auto-configured Data Neo4j Tests.md) + * [43.3.14 自动配置的Data Redis测试](IV. Spring Boot features/43.3.14 Auto-configured Data Redis Tests.md) + * [43.3.15 自动配置的Data LDAP测试](IV. Spring Boot features/43.3.15 Auto-configured Data LDAP Tests.md) + * [43.3.16 自动配置的REST客户端](IV. Spring Boot features/43.3.16 Auto-configured REST Clients.md) + * [43.3.17 自动配置的Spring REST Docs测试](IV. Spring Boot features/43.3.17 Auto-configured Spring REST Docs Tests.md) + * [43.3.18 使用Spock测试Spring Boot应用](IV. Spring Boot features/43.3.18 Using Spock to Test Spring Boot Applications.md) * [42.4 测试工具类](IV. Spring Boot features/42.4 Test utilities.md) * [42.4.1 ConfigFileApplicationContextInitializer](IV. Spring Boot features/42.4.1 ConfigFileApplicationContextInitializer.md) * [42.4.2 EnvironmentTestUtils](IV. Spring Boot features/42.4.2 EnvironmentTestUtils.md) From 79e5af8dfedff25ab229060aa19dc953eba21e98 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E7=83=AD=E5=BF=83=E5=B8=82=E6=B0=91=E9=92=9F=E5=B0=8F?= =?UTF-8?q?=E5=BC=BA?= Date: Thu, 23 May 2019 10:36:52 +0800 Subject: [PATCH 385/865] Rename 43.3.1 Detecting Web Application Type to 43.3.1 Detecting Web Application Type.md --- ... Application Type => 43.3.1 Detecting Web Application Type.md} | 0 1 file changed, 0 insertions(+), 0 deletions(-) rename IV. Spring Boot features/{43.3.1 Detecting Web Application Type => 43.3.1 Detecting Web Application Type.md} (100%) diff --git a/IV. Spring Boot features/43.3.1 Detecting Web Application Type b/IV. Spring Boot features/43.3.1 Detecting Web Application Type.md similarity index 100% rename from IV. Spring Boot features/43.3.1 Detecting Web Application Type rename to IV. Spring Boot features/43.3.1 Detecting Web Application Type.md From 66ef02d9db0e0521d80b4ad0ea7c55d261aac58f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E7=83=AD=E5=BF=83=E5=B8=82=E6=B0=91=E9=92=9F=E5=B0=8F?= =?UTF-8?q?=E5=BC=BA?= Date: Thu, 23 May 2019 10:37:27 +0800 Subject: [PATCH 386/865] Update and rename 42.3.1 Detecting test configuration.md to 43.3.2 Detecting Test Configuration.md --- .../42.3.1 Detecting test configuration.md | 8 -------- .../43.3.2 Detecting Test Configuration.md | 13 +++++++++++++ 2 files changed, 13 insertions(+), 8 deletions(-) delete mode 100644 IV. Spring Boot features/42.3.1 Detecting test configuration.md create mode 100644 IV. Spring Boot features/43.3.2 Detecting Test Configuration.md diff --git a/IV. Spring Boot features/42.3.1 Detecting test configuration.md b/IV. Spring Boot features/42.3.1 Detecting test configuration.md deleted file mode 100644 index 14e91c50..00000000 --- a/IV. Spring Boot features/42.3.1 Detecting test configuration.md +++ /dev/null @@ -1,8 +0,0 @@ -###42.3.1 发现测试配置 -如果熟悉Spring测试框架,你可能经常通过`@ContextConfiguration(classes=…)`指定加载哪些Spring `@Configuration`,也可能经常在测试类中使用内嵌`@Configuration`类。当测试Spring Boot应用时这些就不需要了,Spring Boot的`@*Test`注解会自动搜索主配置类,即使你没有显式定义它。 - -搜索算法是从包含测试类的package开始搜索,直到发现`@SpringBootApplication`或`@SpringBootConfiguration`注解的类,只要按[恰当的方式组织代码](http://docs.spring.io/spring-boot/docs/2.0.0.RELEASE/reference/htmlsingle/#using-boot-structuring-your-code),通常都会发现主配置类。 - -如果想自定义主配置类,你可以使用一个内嵌的`@TestConfiguration`类。不像内嵌的`@Configuration`类(会替换应用主配置类),内嵌的`@TestConfiguration`类是可以跟应用主配置类一块使用的。 - -**注** Spring测试框架在测试过程中会缓存应用上下文,因此,只要你的测试共享相同的配置(不管是怎么发现的),加载上下文的潜在时间消耗都只会发生一次。 diff --git a/IV. Spring Boot features/43.3.2 Detecting Test Configuration.md b/IV. Spring Boot features/43.3.2 Detecting Test Configuration.md new file mode 100644 index 00000000..7c8fb5ad --- /dev/null +++ b/IV. Spring Boot features/43.3.2 Detecting Test Configuration.md @@ -0,0 +1,13 @@ +### 43.3.2 检测测试配置 + +如果熟悉Spring测试框架,你可能经常通过`@ContextConfiguration(classes=…)`指定加载哪些Spring `@Configuration`,也可能经常在测试类中使用内嵌`@Configuration`类。 + +当测试Spring Boot应用时这些就不需要了,Spring Boot的`@*Test`注解会自动搜索主配置类,即使你没有显式定义它。 + +搜索算法是从包含测试类的包开始搜索,直到发现`@SpringBootApplication`或`@SpringBootConfiguration`注解的类,只要按[恰当的方式组织代码](https://docs.spring.io/spring-boot/docs/2.0.0.RELEASE/reference/htmlsingle/#using-boot-structuring-your-code),通常都会发现主配置类。 + +**注** 如果你使用一个[测试注解来测试你应用的一个更加特定的部分](https://docs.spring.io/spring-boot/docs/2.0.0.RELEASE/reference/htmlsingle/#boot-features-testing-spring-boot-applications-testing-autoconfigured-tests),你应当避免添加针对[main方法应用类](https://docs.spring.io/spring-boot/docs/2.0.0.RELEASE/reference/htmlsingle/#boot-features-testing-spring-boot-applications-testing-user-configuration)的特定区域的配置设置。 + +如果想自定义主配置类,你可以使用一个内嵌的`@TestConfiguration`类。不像内嵌的`@Configuration`类(会替换应用主配置类),内嵌的`@TestConfiguration`类是可以跟应用主配置类一块使用的。 + +**注** Spring测试框架在测试过程中会缓存应用上下文,因此,只要你的测试共享相同的配置(不管是怎么发现的),加载上下文的潜在时间消耗都只会发生一次。 From 1412b9dcd44797aa62c2c1f1d91a7b8c22e4c7c8 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E7=83=AD=E5=BF=83=E5=B8=82=E6=B0=91=E9=92=9F=E5=B0=8F?= =?UTF-8?q?=E5=BC=BA?= Date: Thu, 23 May 2019 10:42:12 +0800 Subject: [PATCH 387/865] Update and rename 42.3.2 Excluding test configuration.md to 43.3.3 Excluding Test Configuration.md --- ...onfiguration.md => 43.3.3 Excluding Test Configuration.md} | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) rename IV. Spring Boot features/{42.3.2 Excluding test configuration.md => 43.3.3 Excluding Test Configuration.md} (57%) diff --git a/IV. Spring Boot features/42.3.2 Excluding test configuration.md b/IV. Spring Boot features/43.3.3 Excluding Test Configuration.md similarity index 57% rename from IV. Spring Boot features/42.3.2 Excluding test configuration.md rename to IV. Spring Boot features/43.3.3 Excluding Test Configuration.md index af77d73e..6e8b0106 100644 --- a/IV. Spring Boot features/42.3.2 Excluding test configuration.md +++ b/IV. Spring Boot features/43.3.3 Excluding Test Configuration.md @@ -1,8 +1,8 @@ -### 42.3.2 排除测试配置 +### 43.3.3 排除测试配置 如果应用使用组件扫描,比如`@SpringBootApplication`或`@ComponentScan`,你可能发现为测试类创建的顶级配置类在任何地方都可能偶然被扫描到。 -向[上面看到](./42.3.1 Detecting test configuration.md)的那样,为了自定义原始的配置,`@TestConfiguration`可以用在一个测试的内部类上。当把`@TestConfiguration`放在顶级类上时,`@TestConfiguration`表明在`src/test/java`中的类扫描无效。你可以在需要的地方,明确地导入那个类: +向[上面看到](https://docs.spring.io/spring-boot/docs/2.0.0.RELEASE/reference/htmlsingle/#boot-features-testing-spring-boot-applications-detecting-config)的那样,为了自定义原始的配置,`@TestConfiguration`可以用在一个测试的内部类上。当把`@TestConfiguration`放在顶级类上时,`@TestConfiguration`表明在`src/test/java`中的类扫描无效。你可以在需要的地方,明确地导入那个类: ```java @RunWith(SpringRunner.class) @SpringBootTest From ee7354139ca629be409e6180ed5efb5f4786b52a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E7=83=AD=E5=BF=83=E5=B8=82=E6=B0=91=E9=92=9F=E5=B0=8F?= =?UTF-8?q?=E5=BC=BA?= Date: Thu, 23 May 2019 11:06:10 +0800 Subject: [PATCH 388/865] Update and rename 42.3.3 Working with random ports.md to 43.3.4 Testing with a running server.md --- .../42.3.3 Working with random ports.md | 32 ---------- .../43.3.4 Testing with a running server.md | 59 +++++++++++++++++++ 2 files changed, 59 insertions(+), 32 deletions(-) delete mode 100644 IV. Spring Boot features/42.3.3 Working with random ports.md create mode 100644 IV. Spring Boot features/43.3.4 Testing with a running server.md diff --git a/IV. Spring Boot features/42.3.3 Working with random ports.md b/IV. Spring Boot features/42.3.3 Working with random ports.md deleted file mode 100644 index 1abc30f7..00000000 --- a/IV. Spring Boot features/42.3.3 Working with random ports.md +++ /dev/null @@ -1,32 +0,0 @@ -### 42.3.3 使用随机端口 - -如果你需要为测试启动一个完整运行的服务器,我们建议你使用随机端口。如果你使用`@SpringBootTest(webEnvironment=WebEnvironment.RANDOM_PORT)`,每次运行测试都会为你分配一个可用的随机端口。 - -`@LocalServerPort`注解用于[注入测试用例实际使用的端口](https://docs.spring.io/spring-boot/docs/2.0.0.RELEASE/reference/htmlsingle/#howto-discover-the-http-port-at-runtime),简单起见,需要发起REST调用到启动服务器的测试可以额外`@Autowire`一个`TestRestTemplate`,它可以解析到运行服务器的相关链接: -```java -import org.junit.Test; -import org.junit.runner.RunWith; - -import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.boot.test.context.SpringBootTest; -import org.springframework.boot.test.context.SpringBootTest.WebEnvironment; -import org.springframework.boot.test.web.client.TestRestTemplate; -import org.springframework.test.context.junit4.SpringRunner; - -import static org.assertj.core.api.Assertions.assertThat; - -@RunWith(SpringRunner.class) -@SpringBootTest(webEnvironment = WebEnvironment.RANDOM_PORT) -public class RandomPortExampleTests { - - @Autowired - private TestRestTemplate restTemplate; - - @Test - public void exampleTest() { - String body = this.restTemplate.getForObject("/", String.class); - assertThat(body).isEqualTo("Hello World"); - } - -} -``` diff --git a/IV. Spring Boot features/43.3.4 Testing with a running server.md b/IV. Spring Boot features/43.3.4 Testing with a running server.md new file mode 100644 index 00000000..23d6da5f --- /dev/null +++ b/IV. Spring Boot features/43.3.4 Testing with a running server.md @@ -0,0 +1,59 @@ +### 42.3.3 使用运行的服务器测试 + +如果你需要启动一个完整运行的服务器,我们建议你使用随机端口。如果你使用`@SpringBootTest(webEnvironment=WebEnvironment.RANDOM_PORT)`,每次运行测试都会为你分配一个可用的随机端口。 + +`@LocalServerPort`注解用于[注入测试用例实际使用的端口](https://docs.spring.io/spring-boot/docs/2.0.0.RELEASE/reference/htmlsingle/#howto-discover-the-http-port-at-runtime),简单起见,需要发起REST调用到启动服务器的测试可以额外`@Autowire`一个[`WebTestClient`](https://docs.spring.io/spring/docs/5.0.4.RELEASE/spring-framework-reference/testing.html#webtestclient-tests),它可以解析到运行服务器的相关链接,并且带有验证响应的专用API。如下所示: +```java +import org.junit.Test; +import org.junit.runner.RunWith; + +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.boot.test.context.SpringBootTest; +import org.springframework.boot.test.context.SpringBootTest.WebEnvironment; +import org.springframework.test.context.junit4.SpringRunner; +import org.springframework.test.web.reactive.server.WebTestClient; + +@RunWith(SpringRunner.class) +@SpringBootTest(webEnvironment = WebEnvironment.RANDOM_PORT) +public class RandomPortWebTestClientExampleTests { + + @Autowired + private WebTestClient webClient; + + @Test + public void exampleTest() { + this.webClient.get().uri("/").exchange().expectStatus().isOk() + .expectBody(String.class).isEqualTo("Hello World"); + } + +} +``` + +Spring Boot也提供了一个`TestRestTemplate`设施: +```java +import org.junit.Test; +import org.junit.runner.RunWith; + +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.boot.test.context.SpringBootTest; +import org.springframework.boot.test.context.SpringBootTest.WebEnvironment; +import org.springframework.boot.test.web.client.TestRestTemplate; +import org.springframework.test.context.junit4.SpringRunner; + +import static org.assertj.core.api.Assertions.assertThat; + +@RunWith(SpringRunner.class) +@SpringBootTest(webEnvironment = WebEnvironment.RANDOM_PORT) +public class RandomPortTestRestTemplateExampleTests { + + @Autowired + private TestRestTemplate restTemplate; + + @Test + public void exampleTest() { + String body = this.restTemplate.getForObject("/", String.class); + assertThat(body).isEqualTo("Hello World"); + } + +} +``` From ace92320719e47738f2c53294cf02d0403e9b903 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E7=83=AD=E5=BF=83=E5=B8=82=E6=B0=91=E9=92=9F=E5=B0=8F?= =?UTF-8?q?=E5=BC=BA?= Date: Thu, 23 May 2019 11:07:49 +0800 Subject: [PATCH 389/865] Update 43.3.4 Testing with a running server.md --- .../43.3.4 Testing with a running server.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/IV. Spring Boot features/43.3.4 Testing with a running server.md b/IV. Spring Boot features/43.3.4 Testing with a running server.md index 23d6da5f..01477c46 100644 --- a/IV. Spring Boot features/43.3.4 Testing with a running server.md +++ b/IV. Spring Boot features/43.3.4 Testing with a running server.md @@ -1,4 +1,4 @@ -### 42.3.3 使用运行的服务器测试 +### 43.3.4 使用运行的服务器测试 如果你需要启动一个完整运行的服务器,我们建议你使用随机端口。如果你使用`@SpringBootTest(webEnvironment=WebEnvironment.RANDOM_PORT)`,每次运行测试都会为你分配一个可用的随机端口。 From c2da6d1633f501e943a0fc009dad67592ba4c1c8 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E7=83=AD=E5=BF=83=E5=B8=82=E6=B0=91=E9=92=9F=E5=B0=8F?= =?UTF-8?q?=E5=BC=BA?= Date: Thu, 23 May 2019 11:40:11 +0800 Subject: [PATCH 390/865] Update and rename 42.3.4 Mocking and spying beans.md to 43.3.5 Mocking and Spying Beans.md --- .../42.3.4 Mocking and spying beans.md | 39 --------------- .../43.3.5 Mocking and Spying Beans.md | 47 +++++++++++++++++++ 2 files changed, 47 insertions(+), 39 deletions(-) delete mode 100644 IV. Spring Boot features/42.3.4 Mocking and spying beans.md create mode 100644 IV. Spring Boot features/43.3.5 Mocking and Spying Beans.md diff --git a/IV. Spring Boot features/42.3.4 Mocking and spying beans.md b/IV. Spring Boot features/42.3.4 Mocking and spying beans.md deleted file mode 100644 index 0541868d..00000000 --- a/IV. Spring Boot features/42.3.4 Mocking and spying beans.md +++ /dev/null @@ -1,39 +0,0 @@ -### 42.3.4 模拟和监视beans - -有时候需要在运行测试用例时mock一些组件,例如,你可能需要一些远程服务的门面,但在开发期间不可用。Mocking在模拟真实环境很难复现的失败情况时非常有用。 - -Spring Boot提供一个`@MockBean`注解,可用于为`ApplicationContext`中的bean定义一个Mockito mock,你可以使用该注解添加新beans,或替换已存在的bean定义。该注解可直接用于测试类,也可用于测试类的字段,或用于`@Configuration`注解的类和字段。当用于字段时,创建mock的实例也会被注入。Mock beans每次调用完测试方法后会自动重置。 - -下面是一个典型示例,演示使用mock实现替换真实存在的`RemoteService` bean: -```java -import org.junit.*; -import org.junit.runner.*; -import org.springframework.beans.factory.annotation.*; -import org.springframework.boot.test.context.*; -import org.springframework.boot.test.mock.mockito.*; -import org.springframework.test.context.junit4.*; - -import static org.assertj.core.api.Assertions.*; -import static org.mockito.BDDMockito.*; - -@RunWith(SpringRunner.class) -@SpringBootTest -public class MyTests { - - @MockBean - private RemoteService remoteService; - - @Autowired - private Reverser reverser; - - @Test - public void exampleTest() { - // RemoteService has been injected into the reverser bean - given(this.remoteService.someCall()).willReturn("mock"); - String reverse = reverser.reverseSomeCall(); - assertThat(reverse).isEqualTo("kcom"); - } - -} -``` -此外,你可以使用`@SpyBean`和Mockito `spy`包装一个已存在的bean,具体参考文档。 diff --git a/IV. Spring Boot features/43.3.5 Mocking and Spying Beans.md b/IV. Spring Boot features/43.3.5 Mocking and Spying Beans.md new file mode 100644 index 00000000..e9bb1d15 --- /dev/null +++ b/IV. Spring Boot features/43.3.5 Mocking and Spying Beans.md @@ -0,0 +1,47 @@ +### 43.3.5 模拟和监视bean + +有时候需要在运行测试用例时mock一些组件,例如,你可能需要一些远程服务的门面,但在开发期间不可用。Mocking在模拟真实环境很难复现的失败情况时非常有用。 + +Spring Boot提供一个`@MockBean`注解,可用于为`ApplicationContext`中的bean定义一个Mockito mock,你可以使用该注解添加新beans,或替换已存在的bean定义。该注解可直接用于测试类,也可用于测试类的字段,或用于`@Configuration`注解的类和字段。当用于字段时,创建mock的实例也会被注入。Mock bean每次调用完测试方法后会自动重置。 + +**注** 如果你的测试使用了Spring Boot的测试注解(比如`@SpringBootTest`),这个特性会被自动启用。要换一种方式使用这个特性的话,需要明确地添加一个监听器。如下所示: +```java +@TestExecutionListeners(MockitoTestExecutionListener.class) +``` + +下面的示例使用mock实现替换存在的`RemoteService` bean: +```java +import org.junit.*; +import org.junit.runner.*; +import org.springframework.beans.factory.annotation.*; +import org.springframework.boot.test.context.*; +import org.springframework.boot.test.mock.mockito.*; +import org.springframework.test.context.junit4.*; + +import static org.assertj.core.api.Assertions.*; +import static org.mockito.BDDMockito.*; + +@RunWith(SpringRunner.class) +@SpringBootTest +public class MyTests { + + @MockBean + private RemoteService remoteService; + + @Autowired + private Reverser reverser; + + @Test + public void exampleTest() { + // RemoteService has been injected into the reverser bean + given(this.remoteService.someCall()).willReturn("mock"); + String reverse = reverser.reverseSomeCall(); + assertThat(reverse).isEqualTo("kcom"); + } + +} +``` + +此外,你可以使用`@SpyBean`,来用Mockito`spy`包装任何已存在的bean。具体参考[Javadoc](https://docs.spring.io/spring-boot/docs/2.0.0.RELEASE/api/org/springframework/boot/test/mock/mockito/SpyBean.html)。 + +**注** Spring的测试框架会缓存测试之间应用上下文,并为共享相同配置的测试重用上下文。使用`@MockBean`或者`@SpyBean`会影响缓存键,很可能会增加上下文的数量。 From 2150d8fddc9e3675349dc75f19e95694e774df78 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E7=83=AD=E5=BF=83=E5=B8=82=E6=B0=91=E9=92=9F=E5=B0=8F?= =?UTF-8?q?=E5=BC=BA?= Date: Thu, 23 May 2019 11:53:51 +0800 Subject: [PATCH 391/865] Update SUMMARY.md --- SUMMARY.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/SUMMARY.md b/SUMMARY.md index a75e2638..c03aefe9 100644 --- a/SUMMARY.md +++ b/SUMMARY.md @@ -262,8 +262,8 @@ * [43.3.1 检测网络应用类型](IV. Spring Boot features/43.3.1 Detecting Web Application Type.md) * [43.3.2 检测测试配置](IV. Spring Boot features/43.3.2 Detecting Test Configuration.md) * [43.3.3 排除测试配置](IV. Spring Boot features/43.3.3 Excluding Test Configuration.md) - * [43.3.4 使用随机端口](IV. Spring Boot features/43.3.4 Working with random ports.md) - * [43.3.5 模拟和监视beans](IV. Spring Boot features/43.3.5 Mocking and Spying Beans.md) + * [43.3.4 使用运行的服务器测试](IV. Spring Boot features/43.3.4 Testing with a running server.md) + * [43.3.5 模拟和监视bean](IV. Spring Boot features/43.3.5 Mocking and Spying Beans.md) * [43.3.6 自动配置测试](IV. Spring Boot features/43.3.6 Auto-configured Tests.md) * [43.3.7 自动配置的JSON测试](IV. Spring Boot features/43.3.7 Auto-configured JSON Tests.md) * [43.3.8 自动配置的Spring MVC测试](IV. Spring Boot features/43.3.8 Auto-configured Spring MVC Tests.md) From ed4c488c2004ae81c56671d6824eb798ba0fbe0d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E7=83=AD=E5=BF=83=E5=B8=82=E6=B0=91=E9=92=9F=E5=B0=8F?= =?UTF-8?q?=E5=BC=BA?= Date: Sat, 25 May 2019 11:26:13 +0800 Subject: [PATCH 392/865] Update and rename 42.3.5 Auto-configured tests.md to 43.3.6 Auto-configured Tests.md --- ...-configured tests.md => 43.3.6 Auto-configured Tests.md} | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) rename IV. Spring Boot features/{42.3.5 Auto-configured tests.md => 43.3.6 Auto-configured Tests.md} (74%) diff --git a/IV. Spring Boot features/42.3.5 Auto-configured tests.md b/IV. Spring Boot features/43.3.6 Auto-configured Tests.md similarity index 74% rename from IV. Spring Boot features/42.3.5 Auto-configured tests.md rename to IV. Spring Boot features/43.3.6 Auto-configured Tests.md index a2c2616f..5358c860 100644 --- a/IV. Spring Boot features/42.3.5 Auto-configured tests.md +++ b/IV. Spring Boot features/43.3.6 Auto-configured Tests.md @@ -1,9 +1,9 @@ -### 42.3.5 自动配置测试 +### 43.3.6 自动配置测试 -Spring Boot的自动配置系统对应用来说很合适,但用于测试就有点杀鸡用牛刀了,测试时只加载需要的应用片段(slice)通常是有好处的。例如,你可能想测试Spring MVC控制器映射URLs是否正确,且不想在这些测试中涉及到数据库调用;或者你想测试JPA实体,那测试运行时你可能对web层不感兴趣。 +Spring Boot的自动配置系统对应用来说很合适,但用于测试就有点杀鸡用牛刀了,测试时只加载需要的应用片段(slice)通常是有好处的。例如,你可能想测试Spring MVC控制器映射URLs是否正确,且不想在这些测试中涉及到数据库调用。或者,你想测试JPA实体,那测试运行时你可能对web层不感兴趣。 `spring-boot-test-autoconfigure`模块包含很多用来自动配置这些片段(slices)的注解,每个工作方式都相似,都是提供一个`@…Test`注解,然后加载`ApplicationContext`,使用一个或多个`@AutoConfigure…`注解自定义设置。 -**注** 每个部分加载了自动配置类的一个非常受限的集合。如果你需要排除它们中的一个,大部分`@…​Test`注解提供了一个`excludeAutoConfiguration`属性。或者,你可以使用`@ImportAutoConfiguration#exclude`。 +**注** 每个部分加载了自动配置类的一个非常受限的集合。如果你需要排除它们中的一个,大部分`@…Test`注解提供了一个`excludeAutoConfiguration`属性。或者,你可以使用`@ImportAutoConfiguration#exclude`。 **注** `@AutoConfigure…`注解也可以跟标准的`@SpringBootTest`注解一块使用,如果对应用片段不感兴趣,只是想获取自动配置的一些测试beans,你可以使用该组合。 From f9998b1acbf4252fc5becdfddfe5b71ff38ff48c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E7=83=AD=E5=BF=83=E5=B8=82=E6=B0=91=E9=92=9F=E5=B0=8F?= =?UTF-8?q?=E5=BC=BA?= Date: Sat, 25 May 2019 11:58:42 +0800 Subject: [PATCH 393/865] Update and rename 42.3.6 Auto-configured JSON tests.md to 43.3.7 Auto-configured JSON Tests.md --- .../42.3.6 Auto-configured JSON tests.md | 46 ---------------- .../43.3.7 Auto-configured JSON Tests.md | 54 +++++++++++++++++++ 2 files changed, 54 insertions(+), 46 deletions(-) delete mode 100644 IV. Spring Boot features/42.3.6 Auto-configured JSON tests.md create mode 100644 IV. Spring Boot features/43.3.7 Auto-configured JSON Tests.md diff --git a/IV. Spring Boot features/42.3.6 Auto-configured JSON tests.md b/IV. Spring Boot features/42.3.6 Auto-configured JSON tests.md deleted file mode 100644 index 1c835cf8..00000000 --- a/IV. Spring Boot features/42.3.6 Auto-configured JSON tests.md +++ /dev/null @@ -1,46 +0,0 @@ -###42.3.6 自动配置的JSON测试 -你可以使用`@JsonTest`测试对象JSON序列化和反序列化是否工作正常,该注解将自动配置Jackson `ObjectMapper`,`@JsonComponent`和Jackson `Modules`。如果碰巧使用gson代替Jackson,该注解将配置`Gson`。使用`@AutoConfigureJsonTesters`可以配置auto-configuration的元素。 - -Spring Boot提供基于AssertJ的帮助类(helpers),可用来配合JSONassert和JsonPath libraries检测JSON是否为期望的,`JacksonTester`,`GsonTester`,`BasicJsonTester`分别用于Jackson,Gson,Strings。当使用`@JsonTest`时,你可以在测试类中`@Autowired`任何helper字段: -```java -import org.junit.*; -import org.junit.runner.*; -import org.springframework.beans.factory.annotation.*; -import org.springframework.boot.test.autoconfigure.json.*; -import org.springframework.boot.test.context.*; -import org.springframework.boot.test.json.*; -import org.springframework.test.context.junit4.*; - -import static org.assertj.core.api.Assertions.*; - -@RunWith(SpringRunner.class) -@JsonTest -public class MyJsonTests { - - @Autowired - private JacksonTester json; - - @Test - public void testSerialize() throws Exception { - VehicleDetails details = new VehicleDetails("Honda", "Civic"); - // Assert against a `.json` file in the same package as the test - assertThat(this.json.write(details)).isEqualToJson("expected.json"); - // Or use JSON path based assertions - assertThat(this.json.write(details)).hasJsonPathStringValue("@.make"); - assertThat(this.json.write(details)).extractingJsonPathStringValue("@.make") - .isEqualTo("Honda"); - } - - @Test - public void testDeserialize() throws Exception { - String content = "{\"make\":\"Ford\",\"model\":\"Focus\"}"; - assertThat(this.json.parse(content)) - .isEqualTo(new VehicleDetails("Ford", "Focus")); - assertThat(this.json.parseObject(content).getMake()).isEqualTo("Ford"); - } - -} -``` -**注** JSON帮助类可用于标准单元测试类,如果没有使用`@JsonTest`,你需要在`@Before`方法中调用帮助类的`initFields`方法。 - -在[附录](http://docs.spring.io/spring-boot/docs/2.0.0.RELEASE/reference/htmlsingle/#test-auto-configuration)中可以查看`@JsonTest`开启的自动配置列表。 diff --git a/IV. Spring Boot features/43.3.7 Auto-configured JSON Tests.md b/IV. Spring Boot features/43.3.7 Auto-configured JSON Tests.md new file mode 100644 index 00000000..11da343f --- /dev/null +++ b/IV. Spring Boot features/43.3.7 Auto-configured JSON Tests.md @@ -0,0 +1,54 @@ +### 42.3.6 自动配置的JSON测试 + +你可以使用`@JsonTest`测试对象JSON序列化和反序列化是否工作正常。该注解将自动配置支持JSON映射器的可用库。可以是下列库里的一种: + +- `Jackson ObjectMapper`,任何`@JsonComponent` bean,任何Jackson `模块` +- `Gson` +- `Jsonb` + +使用`@AutoConfigureJsonTesters`可以配置auto-configuration的元素。 + +Spring Boot提供基于AssertJ的帮助类(helpers),可用来配合JSONassert和JsonPath库检测JSON是否和期望的一样。`JacksonTester`、`GsonTester`、`JsonbTester`和`BasicJsonTester`分别用于Jackson、Gson、Jsonb、Strings。当使用`@JsonTest`时,你可以在测试类中`@Autowired`任何helper字段。下面的例子展示了一个用于Jackson的测试类: +```java +import org.junit.*; +import org.junit.runner.*; +import org.springframework.beans.factory.annotation.*; +import org.springframework.boot.test.autoconfigure.json.*; +import org.springframework.boot.test.context.*; +import org.springframework.boot.test.json.*; +import org.springframework.test.context.junit4.*; + +import static org.assertj.core.api.Assertions.*; + +@RunWith(SpringRunner.class) +@JsonTest +public class MyJsonTests { + + @Autowired + private JacksonTester json; + + @Test + public void testSerialize() throws Exception { + VehicleDetails details = new VehicleDetails("Honda", "Civic"); + // Assert against a `.json` file in the same package as the test + assertThat(this.json.write(details)).isEqualToJson("expected.json"); + // Or use JSON path based assertions + assertThat(this.json.write(details)).hasJsonPathStringValue("@.make"); + assertThat(this.json.write(details)).extractingJsonPathStringValue("@.make") + .isEqualTo("Honda"); + } + + @Test + public void testDeserialize() throws Exception { + String content = "{\"make\":\"Ford\",\"model\":\"Focus\"}"; + assertThat(this.json.parse(content)) + .isEqualTo(new VehicleDetails("Ford", "Focus")); + assertThat(this.json.parseObject(content).getMake()).isEqualTo("Ford"); + } + +} +``` + +**注** JSON帮助类可用于标准单元测试类,如果没有使用`@JsonTest`,你需要在`@Before`方法中调用帮助类的`initFields`方法。 + +在[附录](https://docs.spring.io/spring-boot/docs/2.0.0.RELEASE/reference/htmlsingle/#test-auto-configuration)中可以查看`@JsonTest`开启的自动配置列表。 From ad07cd039f14efa9116e9d6e7eee79f7c56fbe70 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E7=83=AD=E5=BF=83=E5=B8=82=E6=B0=91=E9=92=9F=E5=B0=8F?= =?UTF-8?q?=E5=BC=BA?= Date: Sat, 25 May 2019 11:59:58 +0800 Subject: [PATCH 394/865] Update 43.3.7 Auto-configured JSON Tests.md --- IV. Spring Boot features/43.3.7 Auto-configured JSON Tests.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/IV. Spring Boot features/43.3.7 Auto-configured JSON Tests.md b/IV. Spring Boot features/43.3.7 Auto-configured JSON Tests.md index 11da343f..4fe88c17 100644 --- a/IV. Spring Boot features/43.3.7 Auto-configured JSON Tests.md +++ b/IV. Spring Boot features/43.3.7 Auto-configured JSON Tests.md @@ -1,4 +1,4 @@ -### 42.3.6 自动配置的JSON测试 +### 43.3.7 自动配置的JSON测试 你可以使用`@JsonTest`测试对象JSON序列化和反序列化是否工作正常。该注解将自动配置支持JSON映射器的可用库。可以是下列库里的一种: From 48fef9ff5af5dd2587623210bfc86f8f96ae604d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E7=83=AD=E5=BF=83=E5=B8=82=E6=B0=91=E9=92=9F=E5=B0=8F?= =?UTF-8?q?=E5=BC=BA?= Date: Sat, 25 May 2019 13:23:13 +0800 Subject: [PATCH 395/865] Update and rename 42.3.7 Auto-configured Spring MVC tests.md to 43.3.8 Auto-configured Spring MVC tests.md --- ...3.3.8 Auto-configured Spring MVC tests.md} | 37 +++++++++++-------- 1 file changed, 21 insertions(+), 16 deletions(-) rename IV. Spring Boot features/{42.3.7 Auto-configured Spring MVC tests.md => 43.3.8 Auto-configured Spring MVC tests.md} (64%) diff --git a/IV. Spring Boot features/42.3.7 Auto-configured Spring MVC tests.md b/IV. Spring Boot features/43.3.8 Auto-configured Spring MVC tests.md similarity index 64% rename from IV. Spring Boot features/42.3.7 Auto-configured Spring MVC tests.md rename to IV. Spring Boot features/43.3.8 Auto-configured Spring MVC tests.md index 91640150..af5f655b 100644 --- a/IV. Spring Boot features/42.3.7 Auto-configured Spring MVC tests.md +++ b/IV. Spring Boot features/43.3.8 Auto-configured Spring MVC tests.md @@ -1,10 +1,12 @@ -### 42.3.7 自动配置的Spring MVC测试 +### 43.3.8 自动配置的Spring MVC测试 -你可以使用`@WebMvcTest`检测Spring MVC控制器是否工作正常,该注解将自动配置Spring MVC设施,并且只扫描注解`@Controller`,`@ControllerAdvice`,`@JsonComponent`,`Filter`,`WebMvcConfigurer`和`HandlerMethodArgumentResolver`的beans,其他常规的`@Component` beans将不会被扫描。 +你可以使用`@WebMvcTest`检测Spring MVC控制器是否工作正常。该注解将自动配置Spring MVC设施,并且只扫描注解`@Controller`、`@ControllerAdvice`、`@JsonComponent`、`Converter`、`GenericConverter`、`Filter`、`WebMvcConfigurer`和`HandlerMethodArgumentResolver`的bean。其他常规的`@Component` bean将不会被扫描。 + +**注** 如果你需要注册额外的组件,比如Jackson`模块`,你可以在你的测试上使用`@Import`来导入另外的配置类。 通常`@WebMvcTest`只限于单个控制器(controller)使用,并结合`@MockBean`以提供需要的协作者(collaborators)的mock实现。`@WebMvcTest`也会自动配置`MockMvc`,Mock MVC为快速测试MVC控制器提供了一种强大的方式,并且不需要启动一个完整的HTTP服务器。 -**注** 使用`@AutoConfigureMockMvc`注解一个non-`@WebMvcTest`的类(比如`SpringBootTest`)也可以自动配置`MockMvc`。 +**注** 使用`@AutoConfigureMockMvc`注解一个non-`@WebMvcTest`的类(比如`SpringBootTest`)也可以自动配置`MockMvc`。下面的例子使用了`MockMvc`: ```java import org.junit.*; @@ -40,7 +42,7 @@ public class MyControllerTests { ``` **注** 如果需要定义自定配置(auto-configuration)的元素(比如什么时候使用servlet filters),你可以使用`@AutoConfigureMockMvc`的属性。 -如果你使用HtmlUnit或Selenium, 自动配置将提供一个`WebClient` bean和/或`WebDriver` bean,以下是使用HtmlUnit的示例: +如果你使用HtmlUnit或Selenium, 自动配置将提供一个HTMLUnit `WebClient` bean和/或`WebDriver` bean,以下是使用HtmlUnit的示例: ```java import com.gargoylesoftware.htmlunit.*; import org.junit.*; @@ -56,22 +58,25 @@ import static org.mockito.BDDMockito.*; @WebMvcTest(UserVehicleController.class) public class MyHtmlUnitTests { - @Autowired - private WebClient webClient; + @Autowired + private WebClient webClient; - @MockBean - private UserVehicleService userVehicleService; + @MockBean + private UserVehicleService userVehicleService; - @Test - public void testExample() throws Exception { - given(this.userVehicleService.getVehicleDetails("sboot")) - .willReturn(new VehicleDetails("Honda", "Civic")); - HtmlPage page = this.webClient.getPage("/sboot/vehicle.html"); - assertThat(page.getBody().getTextContent()).isEqualTo("Honda Civic"); - } + @Test + public void testExample() throws Exception { + given(this.userVehicleService.getVehicleDetails("sboot")) + .willReturn(new VehicleDetails("Honda", "Civic")); + HtmlPage page = this.webClient.getPage("/sboot/vehicle.html"); + assertThat(page.getBody().getTextContent()).isEqualTo("Honda Civic"); + } } ``` -**注** 默认地,为了确保驱动器在每个测试后停止,而且一个新的实例被注入,Spring Boot将会把`WebDriver`bean放在一个特殊的“作用域”里。如果你不想要这个行为,你可以在你的`WebDriver``@Bean`定义上加上`@Scope("singleton")`。 + +**注** 默认地,为了确保驱动器在每个测试后退出,而且一个新的实例被注入,Spring Boot将会把`WebDriver`bean放在一个特殊的“作用域”里。如果你不想要这个行为,你可以在你的`WebDriver``@Bean`定义上加上`@Scope("singleton")`。 在[附录](https://docs.spring.io/spring-boot/docs/2.0.0.RELEASE/reference/htmlsingle/#test-auto-configuration)中可以查看`@WebMvcTest`开启的自动配置列表。 + +**注** 有时,光光编写Spring MVC测试是不够的。Spring Boot可以帮助你[在实际的服务器上运行完整的端到端的测试](https://docs.spring.io/spring-boot/docs/2.0.0.RELEASE/reference/htmlsingle/#boot-features-testing-spring-boot-applications-testing-with-running-server)。 From a28c9fd6cf98f7a6251ffd562228ae33f0a60ba1 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E7=83=AD=E5=BF=83=E5=B8=82=E6=B0=91=E9=92=9F=E5=B0=8F?= =?UTF-8?q?=E5=BC=BA?= Date: Sat, 25 May 2019 13:55:30 +0800 Subject: [PATCH 396/865] Update SUMMARY.md --- SUMMARY.md | 21 +++++++++++---------- 1 file changed, 11 insertions(+), 10 deletions(-) diff --git a/SUMMARY.md b/SUMMARY.md index c03aefe9..a39e0291 100644 --- a/SUMMARY.md +++ b/SUMMARY.md @@ -267,16 +267,17 @@ * [43.3.6 自动配置测试](IV. Spring Boot features/43.3.6 Auto-configured Tests.md) * [43.3.7 自动配置的JSON测试](IV. Spring Boot features/43.3.7 Auto-configured JSON Tests.md) * [43.3.8 自动配置的Spring MVC测试](IV. Spring Boot features/43.3.8 Auto-configured Spring MVC Tests.md) - * [43.3.9 自动配置的Data JPA测试](IV. Spring Boot features/43.3.9 Auto-configured Data JPA Tests.md) - * [43.3.10 自动配置的JDBC测试](IV. Spring Boot features/43.3.10 Auto-configured JDBC Tests.md) - * [43.3.11 自动配置的jOOQ测试](IV. Spring Boot features/43.3.11 Auto-configured jOOQ Tests.md) - * [43.3.12 自动配置的Data MongoDB测试](IV. Spring Boot features/43.3.12 Auto-configured Data MongoDB Tests.md) - * [43.3.13 自动配置的Data Neo4j测试](IV. Spring Boot features/43.3.13 Auto-configured Data Neo4j Tests.md) - * [43.3.14 自动配置的Data Redis测试](IV. Spring Boot features/43.3.14 Auto-configured Data Redis Tests.md) - * [43.3.15 自动配置的Data LDAP测试](IV. Spring Boot features/43.3.15 Auto-configured Data LDAP Tests.md) - * [43.3.16 自动配置的REST客户端](IV. Spring Boot features/43.3.16 Auto-configured REST Clients.md) - * [43.3.17 自动配置的Spring REST Docs测试](IV. Spring Boot features/43.3.17 Auto-configured Spring REST Docs Tests.md) - * [43.3.18 使用Spock测试Spring Boot应用](IV. Spring Boot features/43.3.18 Using Spock to Test Spring Boot Applications.md) + * [43.3.9 自动配置的Spring WebFlux测试](IV. Spring Boot features/43.3.9 Auto-configured Spring WebFlux Tests.md) + * [43.3.10 自动配置的Data JPA测试](IV. Spring Boot features/43.3.10 Auto-configured Data JPA Tests.md) + * [43.3.11 自动配置的JDBC测试](IV. Spring Boot features/43.3.11 Auto-configured JDBC Tests.md) + * [43.3.12 自动配置的jOOQ测试](IV. Spring Boot features/43.3.12 Auto-configured jOOQ Tests.md) + * [43.3.13 自动配置的Data MongoDB测试](IV. Spring Boot features/43.3.13 Auto-configured Data MongoDB Tests.md) + * [43.3.14 自动配置的Data Neo4j测试](IV. Spring Boot features/43.3.14 Auto-configured Data Neo4j Tests.md) + * [43.3.15 自动配置的Data Redis测试](IV. Spring Boot features/43.3.15 Auto-configured Data Redis Tests.md) + * [43.3.16 自动配置的Data LDAP测试](IV. Spring Boot features/43.3.16 Auto-configured Data LDAP Tests.md) + * [43.3.17 自动配置的REST客户端](IV. Spring Boot features/43.3.17 Auto-configured REST Clients.md) + * [43.3.18 自动配置的Spring REST Docs测试](IV. Spring Boot features/43.3.18 Auto-configured Spring REST Docs Tests.md) + * [43.3.19 使用Spock测试Spring Boot应用](IV. Spring Boot features/43.3.19 Using Spock to Test Spring Boot Applications.md) * [42.4 测试工具类](IV. Spring Boot features/42.4 Test utilities.md) * [42.4.1 ConfigFileApplicationContextInitializer](IV. Spring Boot features/42.4.1 ConfigFileApplicationContextInitializer.md) * [42.4.2 EnvironmentTestUtils](IV. Spring Boot features/42.4.2 EnvironmentTestUtils.md) From dbb7736a31ec8d54df49e38fdbeb9d1313a377c5 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E7=83=AD=E5=BF=83=E5=B8=82=E6=B0=91=E9=92=9F=E5=B0=8F?= =?UTF-8?q?=E5=BC=BA?= Date: Sat, 25 May 2019 13:58:22 +0800 Subject: [PATCH 397/865] Rename 43.3.8 Auto-configured Spring MVC tests.md to 43.3.8 Auto-configured Spring MVC Tests.md --- ...ng MVC tests.md => 43.3.8 Auto-configured Spring MVC Tests.md} | 0 1 file changed, 0 insertions(+), 0 deletions(-) rename IV. Spring Boot features/{43.3.8 Auto-configured Spring MVC tests.md => 43.3.8 Auto-configured Spring MVC Tests.md} (100%) diff --git a/IV. Spring Boot features/43.3.8 Auto-configured Spring MVC tests.md b/IV. Spring Boot features/43.3.8 Auto-configured Spring MVC Tests.md similarity index 100% rename from IV. Spring Boot features/43.3.8 Auto-configured Spring MVC tests.md rename to IV. Spring Boot features/43.3.8 Auto-configured Spring MVC Tests.md From 8adfaf716a5074973b19c6f7a05b0558e2349a0b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E7=83=AD=E5=BF=83=E5=B8=82=E6=B0=91=E9=92=9F=E5=B0=8F?= =?UTF-8?q?=E5=BC=BA?= Date: Sat, 25 May 2019 14:16:46 +0800 Subject: [PATCH 398/865] Create 43.3.9 Auto-configured Spring WebFlux Tests.md --- ....9 Auto-configured Spring WebFlux Tests.md | 48 +++++++++++++++++++ 1 file changed, 48 insertions(+) create mode 100644 IV. Spring Boot features/43.3.9 Auto-configured Spring WebFlux Tests.md diff --git a/IV. Spring Boot features/43.3.9 Auto-configured Spring WebFlux Tests.md b/IV. Spring Boot features/43.3.9 Auto-configured Spring WebFlux Tests.md new file mode 100644 index 00000000..293a48cf --- /dev/null +++ b/IV. Spring Boot features/43.3.9 Auto-configured Spring WebFlux Tests.md @@ -0,0 +1,48 @@ +### 43.3.9 自动配置的Spring WebFlux测试 + +你可以使用`@WebFluxTest`检测[Spring WebFlux](https://docs.spring.io/spring/docs/5.0.4.RELEASE/spring-framework-reference//web-reactive.html)控制器是否工作正常。该注解将自动配置Spring WebFlux设施,并且只扫描注解`@Controller`、`@ControllerAdvice`、`@JsonComponent`、`Converter`、`GenericConverter`、`Filter`和`WebFluxConfigurer`的bean。其他常规的`@Component` bean将不会被扫描。 + +**注** 如果你需要注册额外的组件,比如Jackson`模块`,你可以在你的测试上使用`@Import`来导入另外的配置类。 + +通常`@WebFluxTest`只限于单个控制器(controller)使用,并结合`@MockBean`以提供需要的协作者(collaborators)的mock实现。 + +`@WebFluxTest`也会自动配置[`WebTestClient`](https://docs.spring.io/spring/docs/5.0.4.RELEASE/spring-framework-reference/testing.html#webtestclient)。WebTestClient为快速测试WebFlux控制器提供了一种强大的方式,并且不需要启动一个完整的HTTP服务器。 + +**注** 使用`@AutoConfigureWebTestClient`注解一个non-`@WebFluxTest`的类(比如`@SpringBootTest`)也可以自动配置`WebTestClient`。下面的例子展示了一个同时使用`@WebFluxTest`和`WebTestClient`的类: + +```java +import org.junit.Test; +import org.junit.runner.RunWith; + +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.boot.test.autoconfigure.web.reactive.WebFluxTest; +import org.springframework.http.MediaType; +import org.springframework.test.context.junit4.SpringRunner; +import org.springframework.test.web.reactive.server.WebTestClient; + +@RunWith(SpringRunner.class) +@WebFluxTest(UserVehicleController.class) +public class MyControllerTests { + + @Autowired + private WebTestClient webClient; + + @MockBean + private UserVehicleService userVehicleService; + + @Test + public void testExample() throws Exception { + given(this.userVehicleService.getVehicleDetails("sboot")) + .willReturn(new VehicleDetails("Honda", "Civic")); + this.webClient.get().uri("/sboot/vehicle").accept(MediaType.TEXT_PLAIN) + .exchange() + .expectStatus().isOk() + .expectBody(String.class).isEqualTo("Honda Civic"); + } + +} +``` + +在[附录](https://docs.spring.io/spring-boot/docs/2.0.0.RELEASE/reference/htmlsingle/#test-auto-configuration)中可以查看`@WebFluxTest`开启的自动配置列表。 + +**注** 有时,光光编写Spring MVC测试是不够的。Spring Boot可以帮助你[在实际的服务器上运行完整的端到端的测试](https://docs.spring.io/spring-boot/docs/2.0.0.RELEASE/reference/htmlsingle/#boot-features-testing-spring-boot-applications-testing-with-running-server)。 From cd7c0254e6879a684537caf93c1c09c9db5738f3 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E7=83=AD=E5=BF=83=E5=B8=82=E6=B0=91=E9=92=9F=E5=B0=8F?= =?UTF-8?q?=E5=BC=BA?= Date: Sat, 25 May 2019 14:17:31 +0800 Subject: [PATCH 399/865] Update 43.3.8 Auto-configured Spring MVC Tests.md --- .../43.3.8 Auto-configured Spring MVC Tests.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/IV. Spring Boot features/43.3.8 Auto-configured Spring MVC Tests.md b/IV. Spring Boot features/43.3.8 Auto-configured Spring MVC Tests.md index af5f655b..3e44f9e2 100644 --- a/IV. Spring Boot features/43.3.8 Auto-configured Spring MVC Tests.md +++ b/IV. Spring Boot features/43.3.8 Auto-configured Spring MVC Tests.md @@ -6,7 +6,7 @@ 通常`@WebMvcTest`只限于单个控制器(controller)使用,并结合`@MockBean`以提供需要的协作者(collaborators)的mock实现。`@WebMvcTest`也会自动配置`MockMvc`,Mock MVC为快速测试MVC控制器提供了一种强大的方式,并且不需要启动一个完整的HTTP服务器。 -**注** 使用`@AutoConfigureMockMvc`注解一个non-`@WebMvcTest`的类(比如`SpringBootTest`)也可以自动配置`MockMvc`。下面的例子使用了`MockMvc`: +**注** 使用`@AutoConfigureMockMvc`注解一个non-`@WebMvcTest`的类(比如`@SpringBootTest`)也可以自动配置`MockMvc`。下面的例子使用了`MockMvc`: ```java import org.junit.*; From 8602b8d592677846640cc48ab814c4363d41e92e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E7=83=AD=E5=BF=83=E5=B8=82=E6=B0=91=E9=92=9F=E5=B0=8F?= =?UTF-8?q?=E5=BC=BA?= Date: Sat, 25 May 2019 14:45:23 +0800 Subject: [PATCH 400/865] Update and rename 42.3.8 Auto-configured Data JPA tests.md to 43.3.10 Auto-configured Data JPA Tests.md --- ...s.md => 43.3.10 Auto-configured Data JPA Tests.md} | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) rename IV. Spring Boot features/{42.3.8 Auto-configured Data JPA tests.md => 43.3.10 Auto-configured Data JPA Tests.md} (71%) diff --git a/IV. Spring Boot features/42.3.8 Auto-configured Data JPA tests.md b/IV. Spring Boot features/43.3.10 Auto-configured Data JPA Tests.md similarity index 71% rename from IV. Spring Boot features/42.3.8 Auto-configured Data JPA tests.md rename to IV. Spring Boot features/43.3.10 Auto-configured Data JPA Tests.md index fec32e39..2472a54f 100644 --- a/IV. Spring Boot features/42.3.8 Auto-configured Data JPA tests.md +++ b/IV. Spring Boot features/43.3.10 Auto-configured Data JPA Tests.md @@ -1,8 +1,8 @@ -### 42.3.8 自动配置的Data JPA测试 +### 43.3.10 自动配置的Data JPA测试 -你可以使用`@DataJpaTest`测试JPA应用,它默认配置一个内存型的内嵌数据库,扫描`@Entity`类,并配置Spring Data JPA仓库,其他常规的`@Component` beans不会加载进`ApplicationContext`。 +你可以使用`@DataJpaTest`测试JPA应用。它默认配置一个内存型的内嵌数据库,扫描`@Entity`类,并配置Spring Data JPA仓库。其他常规的`@Component` beans不会加载进`ApplicationContext`。 -Data JPA测试类是事务型的,默认在每个测试结束时回滚,具体查看Spring参考文档的[相关章节](https://docs.spring.io/spring/docs/5.0.4.RELEASE/spring-framework-reference/htmlsingle#testcontext-tx-enabling-transactions)。如果这不是你想要的结果,你可以按如下方式对一个测试或是整个类禁用事务管理: +Data JPA测试类是事务型的,默认在每个测试结束时回滚,具体查看Spring参考文档的[相关章节](https://docs.spring.io/spring/docs/5.0.4.RELEASE/spring-framework-reference/testing.html#testcontext-tx-enabling-transactions)。如果这不是你想要的结果,你可以按如下方式对一个测试或是整个类禁用事务管理: ```java import org.junit.Test; import org.junit.runner.RunWith; @@ -18,7 +18,8 @@ public class ExampleNonTransactionalTests { } ``` -Data JPA测试类可能会注入一个专为测试设计的[`TestEntityManager`](https://github.com/spring-projects/spring-boot/tree/v2.0.0.RELEASE/spring-boot-test-autoconfigure/src/main/java/org/springframework/boot/test/autoconfigure/orm/jpa/TestEntityManager.java)bean以替换标准的JPA `EntityManager`。如果想在`@DataJpaTests`外使用`TestEntityManager`,你可以使用`@AutoConfigureTestEntityManager`注解。如果需要,`JdbcTemplate `也是可用的。 + +Data JPA测试类可能会注入一个专为测试设计的[`TestEntityManager`](https://github.com/spring-projects/spring-boot/tree/v2.0.0.RELEASE/spring-boot-project/spring-boot-test-autoconfigure/src/main/java/org/springframework/boot/test/autoconfigure/orm/jpa/TestEntityManager.java)bean以替换标准的JPA `EntityManager`。如果想在`@DataJpaTests`外使用`TestEntityManager`,你可以使用`@AutoConfigureTestEntityManager`注解。如果需要,`JdbcTemplate `也是可用的。下面的例子展示了使用中的`@DataJpaTest`注解: ```java import org.junit.*; import org.junit.runner.*; @@ -46,7 +47,7 @@ public class ExampleRepositoryTests { } ``` -对于测试来说,内存型的内嵌数据库通常是足够的,因为它们既快又不需要任何安装。如果比较喜欢在真实数据库上运行测试,你可以使用`@AutoConfigureTestDatabase`注解: +对于测试来说,内存型的内嵌数据库通常是足够的,因为它们既快又不需要任何安装。如果比较喜欢在真实数据库上运行测试,你可以使用`@AutoConfigureTestDatabase`注解。如下所示: ```java @RunWith(SpringRunner.class) @DataJpaTest From 13345eb594a810129076bea130539a92f0ffcec8 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E7=83=AD=E5=BF=83=E5=B8=82=E6=B0=91=E9=92=9F=E5=B0=8F?= =?UTF-8?q?=E5=BC=BA?= Date: Sat, 25 May 2019 14:56:38 +0800 Subject: [PATCH 401/865] Update and rename 42.3.9 Auto-configured JDBC tests.md to 43.3.11 Auto-configured JDBC Tests.md --- ... tests.md => 43.3.11 Auto-configured JDBC Tests.md} | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) rename IV. Spring Boot features/{42.3.9 Auto-configured JDBC tests.md => 43.3.11 Auto-configured JDBC Tests.md} (66%) diff --git a/IV. Spring Boot features/42.3.9 Auto-configured JDBC tests.md b/IV. Spring Boot features/43.3.11 Auto-configured JDBC Tests.md similarity index 66% rename from IV. Spring Boot features/42.3.9 Auto-configured JDBC tests.md rename to IV. Spring Boot features/43.3.11 Auto-configured JDBC Tests.md index 4096e765..8dcfe314 100644 --- a/IV. Spring Boot features/42.3.9 Auto-configured JDBC tests.md +++ b/IV. Spring Boot features/43.3.11 Auto-configured JDBC Tests.md @@ -1,8 +1,8 @@ -### 42.3.9 自动配置的JDBC测试 +### 43.3.11 自动配置的JDBC测试 -`@JdbcTest`同`@DataJpaTest`相似,不过是给纯jdbc相关的测试用的。默认的,它将会配置一个内存数据库和一个`JdbcTemplate`。常规的`@Component`bean将不会加载进`ApplicationContext`。 +`@JdbcTest`同`@DataJpaTest`相似,不过是给纯JDBC相关的测试用的。默认的,它将会配置一个内存数据库和一个`JdbcTemplate`。常规的`@Component`bean将不会加载进`ApplicationContext`。 -JDBC测试类是事务型的,默认在每个测试结束时回滚,具体查看Spring参考文档的[相关章节](https://docs.spring.io/spring/docs/5.0.4.RELEASE/spring-framework-reference/htmlsingle#testcontext-tx-enabling-transactions)。如果这不是你想要的结果,你可以按如下方式对一个测试或是整个类禁用事务管理: +JDBC测试类是事务型的,默认在每个测试结束时回滚,具体查看Spring参考文档的[相关章节](https://docs.spring.io/spring/docs/5.0.4.RELEASE/spring-framework-reference/testing.html#testcontext-tx-enabling-transactions)。如果这不是你想要的结果,你可以按如下方式对一个测试或是整个类禁用事务管理: ```java import org.junit.Test; import org.junit.runner.RunWith; @@ -18,6 +18,6 @@ public class ExampleNonTransactionalTests { } ``` -如果你更喜欢在非真实的数据库上运行你的测试,你可以和`DataJpaTest`一样,使用`@AutoConfigureTestDatabase`注解。 +如果你更喜欢在非真实的数据库上运行你的测试,你可以和`DataJpaTest`一样,使用`@AutoConfigureTestDatabase`注解。(查看[43.3.10 自动配置的Data JPA测试](https://docs.spring.io/spring-boot/docs/2.0.0.RELEASE/reference/htmlsingle/#boot-features-testing-spring-boot-applications-testing-autoconfigured-jpa-test)) -在[附录](https://docs.spring.io/spring-boot/docs/2.0.0.RELEASE/reference/htmlsingle/#test-auto-configuration)中可以查看`@JdbcTest`开启的自动配置列表。 \ No newline at end of file +在[附录](https://docs.spring.io/spring-boot/docs/2.0.0.RELEASE/reference/htmlsingle/#test-auto-configuration)中可以查看`@JdbcTest`开启的自动配置列表。 From a9e565b9a8ae56143b7cc821a2509b9f13dc35c5 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E7=83=AD=E5=BF=83=E5=B8=82=E6=B0=91=E9=92=9F=E5=B0=8F?= =?UTF-8?q?=E5=BC=BA?= Date: Sat, 15 Jun 2019 16:07:08 +0800 Subject: [PATCH 402/865] Update and rename 42.3.10 Auto-configured jOOQ tests.md to 43.3.12 Auto-configured jOOQ Tests.md --- ...OQ tests.md => 43.3.12 Auto-configured jOOQ Tests.md} | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) rename IV. Spring Boot features/{42.3.10 Auto-configured jOOQ tests.md => 43.3.12 Auto-configured jOOQ Tests.md} (61%) diff --git a/IV. Spring Boot features/42.3.10 Auto-configured jOOQ tests.md b/IV. Spring Boot features/43.3.12 Auto-configured jOOQ Tests.md similarity index 61% rename from IV. Spring Boot features/42.3.10 Auto-configured jOOQ tests.md rename to IV. Spring Boot features/43.3.12 Auto-configured jOOQ Tests.md index 0ea0ab2b..161ae3fa 100644 --- a/IV. Spring Boot features/42.3.10 Auto-configured jOOQ tests.md +++ b/IV. Spring Boot features/43.3.12 Auto-configured jOOQ Tests.md @@ -1,8 +1,9 @@ -### 42.3.10 自动配置的jOOQ测试 +### 43.3.12 自动配置的jOOQ测试 -`@JooqTest`的使用方式同`@JdbcTest`相似,不过是给jOOQ相关的测试用的。由于jOOQ严重依靠与数据库模式相对应的基于Java的模式,既存的`DataSource`将会被使用。如果你想要用一个内存数据库代替它,你可以使用`@AutoconfigureTestDatabase`来覆盖那些设置。 +`@JooqTest`的使用方式同`@JdbcTest`相似,不过是给jOOQ相关的测试用的。由于jOOQ严重依靠与数据库模式相对应的基于Java的模式,既存的`DataSource`将会被使用。如果你想要用一个内存数据库代替它,你可以使用`@AutoconfigureTestDatabase`来覆盖那些设置。(在Spring Boot里使用jOOQ的更多信息,请查看[章节 29.5 使用jOOQ](https://docs.spring.io/spring-boot/docs/2.0.0.RELEASE/reference/htmlsingle/#boot-features-jooq)。) + +`@JooqTest`将会配置一个`DSLContext`。常规的`@Component`bean将不会加载进`ApplicationContext`。下面的例子展示了使用中的`@JooqTest`注解: -`@JooqTest`将会配置一个`DSLContext`。常规的`@Component`bean将不会加载进`ApplicationContext`: ```java import org.jooq.DSLContext; import org.junit.Test; @@ -18,6 +19,6 @@ public class ExampleJooqTests { private DSLContext dslContext; } ``` -JOOQ测试类是事务型的,默认在每个测试结束时回滚。如果这不是你想要的结果,你可以按照[上面例子中的方式](./42.3.9 Auto-configured JDBC tests.md)对一个测试或是整个类禁用事务管理。 +JOOQ测试类是事务型的,默认在每个测试结束时回滚。如果这不是你想要的结果,你可以按照[JDBC例子中的方式](https://docs.spring.io/spring-boot/docs/2.0.0.RELEASE/reference/htmlsingle/#boot-features-testing-spring-boot-applications-testing-autoconfigured-jdbc-test)对一个测试或是整个类禁用事务管理。 在[附录](https://docs.spring.io/spring-boot/docs/2.0.0.RELEASE/reference/htmlsingle/#test-auto-configuration)中可以查看`@JooqTest`开启的自动配置列表。 From a34cf8f38cb9a9efe00fd7d4dc2b363d0e084ecf Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E7=83=AD=E5=BF=83=E5=B8=82=E6=B0=91=E9=92=9F=E5=B0=8F?= =?UTF-8?q?=E5=BC=BA?= Date: Sat, 15 Jun 2019 16:25:07 +0800 Subject: [PATCH 403/865] Update and rename 42.3.11 Auto-configured Data MongoDB tests.md to 43.3.13 Auto-configured Data MongoDB Tests.md --- ...d => 43.3.13 Auto-configured Data MongoDB Tests.md} | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) rename IV. Spring Boot features/{42.3.11 Auto-configured Data MongoDB tests.md => 43.3.13 Auto-configured Data MongoDB Tests.md} (64%) diff --git a/IV. Spring Boot features/42.3.11 Auto-configured Data MongoDB tests.md b/IV. Spring Boot features/43.3.13 Auto-configured Data MongoDB Tests.md similarity index 64% rename from IV. Spring Boot features/42.3.11 Auto-configured Data MongoDB tests.md rename to IV. Spring Boot features/43.3.13 Auto-configured Data MongoDB Tests.md index f23874bd..7f41c7a2 100644 --- a/IV. Spring Boot features/42.3.11 Auto-configured Data MongoDB tests.md +++ b/IV. Spring Boot features/43.3.13 Auto-configured Data MongoDB Tests.md @@ -1,6 +1,8 @@ -### 42.3.11 自动配置的Data MongoDB测试 +### 43.3.13 自动配置的Data MongoDB测试 -如果你想要测试MongoDB应用,你可以使用`@DataMongoTest`。默认的,它将会配置一个内存MongoDB(如果可用),配置一个`@MongoTemplate`,扫描`@Document`类和配置Spring Data MongoDB仓库。常规的`@Component`bean将不会加载进`ApplicationContext`: +你可以使用`@DataMongoTest`测试MongoDB应用。默认的,它将会配置一个内存MongoDB(如果可用),配置一个`@MongoTemplate`,扫描`@Document`类和配置Spring Data MongoDB仓库。常规的`@Component`bean将不会加载进`ApplicationContext`。(在Spring Boot里使用MongoDB的更多信息,请查看[章节 30.2 MongoDB](https://docs.spring.io/spring-boot/docs/2.0.0.RELEASE/reference/htmlsingle/#boot-features-mongodb)。) + +下面的例子展示了使用中的`@DataMongoTest`注解: ```java import org.junit.runner.RunWith; import org.springframework.beans.factory.annotation.Autowired; @@ -18,7 +20,7 @@ public class ExampleDataMongoTests { // } ``` -由于内存MongoDB快,而且不需要任何开发者安装,它总体上在测试中工作得很好。但是,如果你更喜欢在一个非真实的MongoDB服务器上运行你的测试,你应当排除内嵌的MongoDB自动配置: +由于内存MongoDB快,而且不需要任何开发者安装,它总体上在测试中工作得很好。但是,如果你更喜欢在一个非真实的MongoDB服务器上运行你的测试,你应当排除内嵌的MongoDB自动配置。如下所示: ```java import org.junit.runner.RunWith; import org.springframework.boot.autoconfigure.mongo.embedded.EmbeddedMongoAutoConfiguration; @@ -31,4 +33,4 @@ public class ExampleDataMongoNonEmbeddedTests { } ``` -在[附录](https://docs.spring.io/spring-boot/docs/2.0.0.RELEASE/reference/htmlsingle/#test-auto-configuration)中可以查看`@DataMongoTest`开启的自动配置列表。 \ No newline at end of file +在[附录](https://docs.spring.io/spring-boot/docs/2.0.0.RELEASE/reference/htmlsingle/#test-auto-configuration)中可以查看`@DataMongoTest`开启的自动配置列表。 From e38a043221c770cf85bff8a449b5006add21f5b9 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E7=83=AD=E5=BF=83=E5=B8=82=E6=B0=91=E9=92=9F=E5=B0=8F?= =?UTF-8?q?=E5=BC=BA?= Date: Sat, 15 Jun 2019 16:45:09 +0800 Subject: [PATCH 404/865] Update and rename 42.3.12 Auto-configured Data Neo4j tests.md to 43.3.14 Auto-configured Data Neo4j Tests.md --- ...sts.md => 43.3.14 Auto-configured Data Neo4j Tests.md} | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) rename IV. Spring Boot features/{42.3.12 Auto-configured Data Neo4j tests.md => 43.3.14 Auto-configured Data Neo4j Tests.md} (69%) diff --git a/IV. Spring Boot features/42.3.12 Auto-configured Data Neo4j tests.md b/IV. Spring Boot features/43.3.14 Auto-configured Data Neo4j Tests.md similarity index 69% rename from IV. Spring Boot features/42.3.12 Auto-configured Data Neo4j tests.md rename to IV. Spring Boot features/43.3.14 Auto-configured Data Neo4j Tests.md index 7c508828..d77ffef3 100644 --- a/IV. Spring Boot features/42.3.12 Auto-configured Data Neo4j tests.md +++ b/IV. Spring Boot features/43.3.14 Auto-configured Data Neo4j Tests.md @@ -1,6 +1,8 @@ -### 42.3.12 自动配置的Data Neo4j测试 +### 43.3.14 自动配置的Data Neo4j测试 -如果你想要测试Neo4j应用,你可以使用`@DataNeo4jTest`。默认的,它将会配置一个内存Neo4j(如果内嵌的驱动可用),扫描`@NodeEntity`类和配置Spring Data Neo4j仓库。常规的`@Component`bean将不会加载进`ApplicationContext`: +你可以使用`@DataNeo4jTest`测试Neo4j应用。默认的,它将会配置一个内存Neo4j(如果内嵌的驱动可用),扫描`@NodeEntity`类和配置Spring Data Neo4j仓库。常规的`@Component`bean将不会加载进`ApplicationContext`。(在Spring Boot里使用Neo4J的更多信息,请查看[章节 30.3 Neo4j](https://docs.spring.io/spring-boot/docs/2.0.0.RELEASE/reference/htmlsingle/#boot-features-neo4j)。) + +下面的例子展示了在Spring Boot里使用Neo4J测试的典型设置: ```java import org.junit.runner.RunWith; import org.springframework.beans.factory.annotation.Autowired; @@ -33,4 +35,4 @@ public class ExampleNonTransactionalTests { } ``` -在[附录](https://docs.spring.io/spring-boot/docs/2.0.0.RELEASE/reference/htmlsingle/#test-auto-configuration)中可以查看`@DataNeo4jTest`开启的自动配置列表。 \ No newline at end of file +在[附录](https://docs.spring.io/spring-boot/docs/2.0.0.RELEASE/reference/htmlsingle/#test-auto-configuration)中可以查看`@DataNeo4jTest`开启的自动配置列表。 From 2cb4cc1bc276e009f94325fe4bfc890d0893ca43 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E7=83=AD=E5=BF=83=E5=B8=82=E6=B0=91=E9=92=9F=E5=B0=8F?= =?UTF-8?q?=E5=BC=BA?= Date: Sat, 15 Jun 2019 16:54:43 +0800 Subject: [PATCH 405/865] Update and rename 42.3.13 Auto-configured Data Redis tests.md to 43.3.15 Auto-configured Data Redis Tests.md --- ...2.3.13 Auto-configured Data Redis tests.md | 20 ----------------- ...3.3.15 Auto-configured Data Redis Tests.md | 22 +++++++++++++++++++ 2 files changed, 22 insertions(+), 20 deletions(-) delete mode 100644 IV. Spring Boot features/42.3.13 Auto-configured Data Redis tests.md create mode 100644 IV. Spring Boot features/43.3.15 Auto-configured Data Redis Tests.md diff --git a/IV. Spring Boot features/42.3.13 Auto-configured Data Redis tests.md b/IV. Spring Boot features/42.3.13 Auto-configured Data Redis tests.md deleted file mode 100644 index e584a121..00000000 --- a/IV. Spring Boot features/42.3.13 Auto-configured Data Redis tests.md +++ /dev/null @@ -1,20 +0,0 @@ -### 42.3.13 自动配置的Data Redis测试 - -如果你想要测试Redis应用,你可以使用`@DataRedisTest`。默认的,它将会扫描`@RedisHash`类和配置Spring Data Redis仓库。常规的`@Component`bean将不会加载进`ApplicationContext`: -```java -import org.junit.runner.RunWith; -import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.boot.test.autoconfigure.data.redis.DataRedisTest; -import org.springframework.test.context.junit4.SpringRunner; - -@RunWith(SpringRunner.class) -@DataRedisTest -public class ExampleDataRedisTests { - - @Autowired - private YourRepository repository; - - // -} -``` -在[附录](https://docs.spring.io/spring-boot/docs/2.0.0.RELEASE/reference/htmlsingle/#test-auto-configuration)中可以查看`@DataRedisTest`开启的自动配置列表。 \ No newline at end of file diff --git a/IV. Spring Boot features/43.3.15 Auto-configured Data Redis Tests.md b/IV. Spring Boot features/43.3.15 Auto-configured Data Redis Tests.md new file mode 100644 index 00000000..b035c104 --- /dev/null +++ b/IV. Spring Boot features/43.3.15 Auto-configured Data Redis Tests.md @@ -0,0 +1,22 @@ +### 43.3.15 自动配置的Data Redis测试 + +你可以使用`@DataRedisTest`测试Redis应用。默认的,它将会扫描`@RedisHash`类和配置Spring Data Redis仓库。常规的`@Component`bean将不会加载进`ApplicationContext`。(在Spring Boot里使用Redis的更多信息,请查看[章节 30.1 Redis](https://docs.spring.io/spring-boot/docs/2.0.0.RELEASE/reference/htmlsingle/#boot-features-redis)。) + +下面的例子展示了使用中的`@DataRedisTest`注解: +```java +import org.junit.runner.RunWith; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.boot.test.autoconfigure.data.redis.DataRedisTest; +import org.springframework.test.context.junit4.SpringRunner; + +@RunWith(SpringRunner.class) +@DataRedisTest +public class ExampleDataRedisTests { + + @Autowired + private YourRepository repository; + + // +} +``` +在[附录](https://docs.spring.io/spring-boot/docs/2.0.0.RELEASE/reference/htmlsingle/#test-auto-configuration)中可以查看`@DataRedisTest`开启的自动配置列表。 From fac951c98b4059a2763da1ad75ce12005f59bf30 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E7=83=AD=E5=BF=83=E5=B8=82=E6=B0=91=E9=92=9F=E5=B0=8F?= =?UTF-8?q?=E5=BC=BA?= Date: Sat, 15 Jun 2019 17:28:52 +0800 Subject: [PATCH 406/865] Update and rename 42.3.14 Auto-configured Data LDAP tests.md to 43.3.16 Auto-configured Data LDAP Tests.md --- ...md => 43.3.16 Auto-configured Data LDAP Tests.md} | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) rename IV. Spring Boot features/{42.3.14 Auto-configured Data LDAP tests.md => 43.3.16 Auto-configured Data LDAP Tests.md} (64%) diff --git a/IV. Spring Boot features/42.3.14 Auto-configured Data LDAP tests.md b/IV. Spring Boot features/43.3.16 Auto-configured Data LDAP Tests.md similarity index 64% rename from IV. Spring Boot features/42.3.14 Auto-configured Data LDAP tests.md rename to IV. Spring Boot features/43.3.16 Auto-configured Data LDAP Tests.md index fd88428f..a76a1e1d 100644 --- a/IV. Spring Boot features/42.3.14 Auto-configured Data LDAP tests.md +++ b/IV. Spring Boot features/43.3.16 Auto-configured Data LDAP Tests.md @@ -1,6 +1,8 @@ -### 42.3.14 自动配置的Data LDAP测试 +### 43.3.16 自动配置的Data LDAP测试 -如果你想要测试LDAP应用,你可以使用`@DataLdapTest`。默认的,它将会配置一个内存LDAP(如果可用)、一个`@LdapTemplate`,扫描`@Entry`类和配置Spring Data LDAP仓库。常规的`@Component`bean将不会加载进`ApplicationContext`: +你可以使用`@DataLdapTest`测试LDAP应用。默认的,它将会配置一个内存LDAP(如果可用)、一个`@LdapTemplate`,扫描`@Entry`类和配置Spring Data LDAP仓库。常规的`@Component`bean将不会加载进`ApplicationContext`。(在Spring Boot里使用LDAP的更多信息,请查看[章节 30.9 LDAP](https://docs.spring.io/spring-boot/docs/2.0.0.RELEASE/reference/htmlsingle/#boot-features-ldap)。) + +下面的例子展示了使用中的`@DataLdapTest`注解: ```java import org.junit.runner.RunWith; import org.springframework.beans.factory.annotation.Autowired; @@ -18,8 +20,8 @@ public class ExampleDataLdapTests { // } ``` -由于内存LDAP快,而且不需要任何开发者安装,它总体上在测试中工作得很好。但是,如果你更喜欢在一个非真实的LDAP服务器上运行你的测试,你应当排除内嵌的LDAP自动配置: -In-memory embedded LDAP generally works well for tests since it is fast and doesn’t require any developer installation. If, however, you prefer to run tests against a real LDAP server you should exclude the embedded LDAP auto-configuration: + +由于内存LDAP快,而且不需要任何开发者安装,它总体上在测试中工作得很好。但是,如果你更喜欢在一个非真实的LDAP服务器上运行你的测试,你应当排除内嵌的LDAP自动配置。如下所示: ```java import org.junit.runner.RunWith; import org.springframework.boot.autoconfigure.ldap.embedded.EmbeddedLdapAutoConfiguration; @@ -32,4 +34,4 @@ public class ExampleDataLdapNonEmbeddedTests { } ``` -在[附录](https://docs.spring.io/spring-boot/docs/2.0.0.RELEASE/reference/htmlsingle/#test-auto-configuration)中可以查看`@DataLdapTest`开启的自动配置列表。 \ No newline at end of file +在[附录](https://docs.spring.io/spring-boot/docs/2.0.0.RELEASE/reference/htmlsingle/#test-auto-configuration)中可以查看`@DataLdapTest`开启的自动配置列表。 From c11f39075444bece53cea895a47e7c3ea5f12a7e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E7=83=AD=E5=BF=83=E5=B8=82=E6=B0=91=E9=92=9F=E5=B0=8F?= =?UTF-8?q?=E5=BC=BA?= Date: Sat, 15 Jun 2019 17:38:16 +0800 Subject: [PATCH 407/865] Update and rename 42.3.15 Auto-configured REST clients.md to 43.3.17 Auto-configured REST Clients.md --- ...ST clients.md => 43.3.17 Auto-configured REST Clients.md} | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) rename IV. Spring Boot features/{42.3.15 Auto-configured REST clients.md => 43.3.17 Auto-configured REST Clients.md} (71%) diff --git a/IV. Spring Boot features/42.3.15 Auto-configured REST clients.md b/IV. Spring Boot features/43.3.17 Auto-configured REST Clients.md similarity index 71% rename from IV. Spring Boot features/42.3.15 Auto-configured REST clients.md rename to IV. Spring Boot features/43.3.17 Auto-configured REST Clients.md index 6146b820..d60726a9 100644 --- a/IV. Spring Boot features/42.3.15 Auto-configured REST clients.md +++ b/IV. Spring Boot features/43.3.17 Auto-configured REST Clients.md @@ -1,5 +1,6 @@ -###42.3.15 自动配置的REST客户端 -你可以使用`@RestClientTest`测试REST客户端,它默认会自动配置Jackson和GSON,配置`RestTemplateBuilder`,并添加`MockRestServiceServer`支持。你需要将`@RestClientTest`的`value`或`components`属性值设置为待测试类: +### 43.3.17 自动配置的REST客户端 + +你可以使用`@RestClientTest`测试REST客户端。它默认会自动配置Jackson、GSON和Jsonb,配置`RestTemplateBuilder`,并添加`MockRestServiceServer`支持。你需要将`@RestClientTest`的`value`或`components`属性值设置为待测试类。如下所示: ```java @RunWith(SpringRunner.class) @RestClientTest(RemoteVehicleDetailsService.class) From fe6120d00cff7303ff9f55334548a9291227c543 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E7=83=AD=E5=BF=83=E5=B8=82=E6=B0=91=E9=92=9F=E5=B0=8F?= =?UTF-8?q?=E5=BC=BA?= Date: Sat, 15 Jun 2019 17:54:21 +0800 Subject: [PATCH 408/865] Update and rename 42.3.16 Auto-configured Spring REST Docs tests.md to 43.3.18 Auto-configured Spring REST Docs Tests.md --- ...ts.md => 43.3.18 Auto-configured Spring REST Docs Tests.md} | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) rename IV. Spring Boot features/{42.3.16 Auto-configured Spring REST Docs tests.md => 43.3.18 Auto-configured Spring REST Docs Tests.md} (97%) diff --git a/IV. Spring Boot features/42.3.16 Auto-configured Spring REST Docs tests.md b/IV. Spring Boot features/43.3.18 Auto-configured Spring REST Docs Tests.md similarity index 97% rename from IV. Spring Boot features/42.3.16 Auto-configured Spring REST Docs tests.md rename to IV. Spring Boot features/43.3.18 Auto-configured Spring REST Docs Tests.md index ae060274..4e3f777f 100644 --- a/IV. Spring Boot features/42.3.16 Auto-configured Spring REST Docs tests.md +++ b/IV. Spring Boot features/43.3.18 Auto-configured Spring REST Docs Tests.md @@ -1,4 +1,5 @@ -###42.3.16 自动配置的Spring REST Docs测试 +### 43.3.18 自动配置的Spring REST Docs测试 + 如果想在测试类中使用Spring REST Docs,你可以使用`@AutoConfigureRestDocs`注解,它会自动配置`MockMvc`去使用Spring REST Docs,并移除对Spring REST Docs的JUnit规则的需要。 ```java import org.junit.Test; From f9489293314bf85ac8869f1054680872aa680752 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E7=83=AD=E5=BF=83=E5=B8=82=E6=B0=91=E9=92=9F=E5=B0=8F?= =?UTF-8?q?=E5=BC=BA?= Date: Sat, 15 Jun 2019 20:30:39 +0800 Subject: [PATCH 409/865] Update 43.3.18 Auto-configured Spring REST Docs Tests.md --- ... Auto-configured Spring REST Docs Tests.md | 68 ++++++++++++++++++- 1 file changed, 66 insertions(+), 2 deletions(-) diff --git a/IV. Spring Boot features/43.3.18 Auto-configured Spring REST Docs Tests.md b/IV. Spring Boot features/43.3.18 Auto-configured Spring REST Docs Tests.md index 4e3f777f..3251970b 100644 --- a/IV. Spring Boot features/43.3.18 Auto-configured Spring REST Docs Tests.md +++ b/IV. Spring Boot features/43.3.18 Auto-configured Spring REST Docs Tests.md @@ -1,6 +1,12 @@ ### 43.3.18 自动配置的Spring REST Docs测试 -如果想在测试类中使用Spring REST Docs,你可以使用`@AutoConfigureRestDocs`注解,它会自动配置`MockMvc`去使用Spring REST Docs,并移除对Spring REST Docs的JUnit规则的需要。 +为了在测试里使用[Spring REST Docs](https://projects.spring.io/spring-restdocs/),你可以使用`@AutoConfigureRestDocs`注解。它移除了Spring REST Docs里对JUnit规则的需要。 + +`@AutoConfigureRestDocs`可用于覆盖默认的输出目录(如果你使用Maven,目录是`target/generated-snippets`。如果你使用Gradle,则是`build/generated-snippets`)。它也可以用于配置出现在任何文档化的URI里的主机、方案、端口。 + +**使用Mock MVC的自动配置的Spring REST Docs测试** + +`@AutoConfigureRestDocs`自定义`MockMvc` bean来使用Spring REST Docs。当你使用Mock MVC和Spring REST Docs时,你可以使用`@Autowired`将其注入,好在测试里使用。如下所示: ```java import org.junit.Test; import org.junit.runner.RunWith; @@ -32,7 +38,10 @@ public class UserDocumentationTests { } ``` + `@AutoConfigureRestDocs`能够用于覆盖默认的输出目录(如果你使用的是Maven,默认的输出目录是`target/generated-snippets`。使用的是Gradle的话,就是`build/generated-snippets`)。`@AutoConfigureRestDocs`也能配置将出现在任何文档化的URLs中的部分,比如host,scheme和port等。如果需要控制更多Spring REST Docs的配置,你可以使用`RestDocsMockMvcConfigurationCustomizer` bean: + +如果你需要控制更多的Spring REST Docs的配置,这些配置超出了`@AutoConfigureRestDocs`属性提供的范围。那么,你可以使用`RestDocsMockMvcConfigurationCustomizer` bean。如下所示: ```java @TestConfiguration static class CustomizationConfiguration @@ -45,7 +54,8 @@ static class CustomizationConfiguration } ``` -如果想充分利用Spring REST Docs对参数化输出目录的支持,你可以创建一个`RestDocumentationResultHandler` bean,自动配置将使用它调用`alwaysDo`方法,进而促使每个`MockMvc`调用都会自动产生默认片段: + +如果想充分利用Spring REST Docs对参数化输出目录的支持,你可以创建一个`RestDocumentationResultHandler` bean,自动配置将使用它调用`alwaysDo`方法,进而促使每个`MockMvc`调用都会自动产生默认片段。下面的例子展示了一个定义好的`RestDocumentationResultHandler`: ```java @TestConfiguration static class ResultHandlerConfiguration { @@ -57,3 +67,57 @@ static class ResultHandlerConfiguration { } ``` + +**Auto-configured Spring REST Docs Tests with REST Assured** + +`@AutoConfigureRestDocs`创建了一个`RequestSpecification` bean,预配置为使用Spring REST Docs。当你使用REST Assured和Spring REST Docs时,你可以使用`@Autowired`将其注入,好在测试里使用。如下所示: + +```java +import io.restassured.specification.RequestSpecification; +import org.junit.Test; +import org.junit.runner.RunWith; + +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.boot.test.autoconfigure.restdocs.AutoConfigureRestDocs; +import org.springframework.boot.test.context.SpringBootTest; +import org.springframework.boot.test.context.SpringBootTest.WebEnvironment; +import org.springframework.boot.web.server.LocalServerPort; +import org.springframework.test.context.junit4.SpringRunner; + +import static io.restassured.RestAssured.given; +import static org.hamcrest.CoreMatchers.is; +import static org.springframework.restdocs.restassured3.RestAssuredRestDocumentation.document; + +@RunWith(SpringRunner.class) +@SpringBootTest(webEnvironment = WebEnvironment.RANDOM_PORT) +@AutoConfigureRestDocs +public class UserDocumentationTests { + + @LocalServerPort + private int port; + + @Autowired + private RequestSpecification documentationSpec; + + @Test + public void listUsers() { + given(this.documentationSpec).filter(document("list-users")).when() + .port(this.port).get("/").then().assertThat().statusCode(is(200)); + } + +} +``` + +如果你需要控制更多的Spring REST Docs的配置,这些配置超出了`@AutoConfigureRestDocs`属性提供的范围。那么,你可以使用`RestDocsRestAssuredConfigurationCustomizer` bean。如下所示: +```java +@TestConfiguration +public static class CustomizationConfiguration + implements RestDocsRestAssuredConfigurationCustomizer { + + @Override + public void customize(RestAssuredRestDocumentationConfigurer configurer) { + configurer.snippets().withTemplateFormat(TemplateFormats.markdown()); + } + +} +``` From 0f0cc95fc8bc21a581b736e71079463908398db5 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E7=83=AD=E5=BF=83=E5=B8=82=E6=B0=91=E9=92=9F=E5=B0=8F?= =?UTF-8?q?=E5=BC=BA?= Date: Sat, 15 Jun 2019 20:46:05 +0800 Subject: [PATCH 410/865] Create 43.3.19 User Configuration and Slicing.md --- .../43.3.19 User Configuration and Slicing.md | 30 +++++++++++++++++++ 1 file changed, 30 insertions(+) create mode 100644 IV. Spring Boot features/43.3.19 User Configuration and Slicing.md diff --git a/IV. Spring Boot features/43.3.19 User Configuration and Slicing.md b/IV. Spring Boot features/43.3.19 User Configuration and Slicing.md new file mode 100644 index 00000000..cf447ed4 --- /dev/null +++ b/IV. Spring Boot features/43.3.19 User Configuration and Slicing.md @@ -0,0 +1,30 @@ +### 43.3.19 用户配置与切片 + +If you [structure your code](https://docs.spring.io/spring-boot/docs/2.0.0.RELEASE/reference/htmlsingle/#using-boot-structuring-your-code) in a sensible way, your `@SpringBootApplication` class is [used by default](https://docs.spring.io/spring-boot/docs/2.0.0.RELEASE/reference/htmlsingle/#boot-features-testing-spring-boot-applications-detecting-config) as the configuration of your tests. + +It then becomes important not to litter the application’s main class with configuration settings that are specific to a particular area of its functionality. + +Assume that you are using Spring Batch and you rely on the auto-configuration for it. You could define your `@SpringBootApplication` as follows: +```java +@SpringBootApplication +@EnableBatchProcessing +public class SampleApplication { ... } +``` +Because this class is the source configuration for the test, any slice test actually tries to start Spring Batch, which is definitely not what you want to do. A recommended approach is to move that area-specific configuration to a separate `@Configuration` class at the same level as your application, as shown in the following example: +```java +@Configuration +@EnableBatchProcessing +public class BatchConfiguration { ... } +``` + +**注** Depending on the complexity of your application, you may either have a single `@Configuration` class for your customizations or one class per domain area. The latter approach lets you enable it in one of your tests, if necessary, with the `@Import` annotation. + +Another source of confusion is classpath scanning. Assume that, while you structured your code in a sensible way, you need to scan an additional package. Your application may resemble the following code: +```java +@SpringBootApplication +@ComponentScan({ "com.example.app", "org.acme.another" }) +public class SampleApplication { ... } +``` +Doing so effectively overrides the default component scan directive with the side effect of scanning those two packages regardless of the slice that you chose. For instance, a `@DataJpaTest` seems to suddenly scan components and user configurations of your application. Again, moving the custom directive to a separate class is a good way to fix this issue. + +**注** If this is not an option for you, you can create a `@SpringBootConfiguration` somewhere in the hierarchy of your test so that it is used instead. Alternatively, you can specify a source for your test, which disables the behavior of finding a default one. From 93a290ed058c03e879dd56139cf674eb802bf501 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E7=83=AD=E5=BF=83=E5=B8=82=E6=B0=91=E9=92=9F=E5=B0=8F?= =?UTF-8?q?=E5=BC=BA?= Date: Sat, 15 Jun 2019 20:48:25 +0800 Subject: [PATCH 411/865] Update SUMMARY.md --- SUMMARY.md | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/SUMMARY.md b/SUMMARY.md index a39e0291..accce38e 100644 --- a/SUMMARY.md +++ b/SUMMARY.md @@ -277,7 +277,8 @@ * [43.3.16 自动配置的Data LDAP测试](IV. Spring Boot features/43.3.16 Auto-configured Data LDAP Tests.md) * [43.3.17 自动配置的REST客户端](IV. Spring Boot features/43.3.17 Auto-configured REST Clients.md) * [43.3.18 自动配置的Spring REST Docs测试](IV. Spring Boot features/43.3.18 Auto-configured Spring REST Docs Tests.md) - * [43.3.19 使用Spock测试Spring Boot应用](IV. Spring Boot features/43.3.19 Using Spock to Test Spring Boot Applications.md) + * [43.3.19 用户配置与切片](IV. Spring Boot features/43.3.19 User Configuration and Slicing.md) + * [43.3.20 使用Spock测试Spring Boot应用](IV. Spring Boot features/43.3.19 Using Spock to Test Spring Boot Applications.md) * [42.4 测试工具类](IV. Spring Boot features/42.4 Test utilities.md) * [42.4.1 ConfigFileApplicationContextInitializer](IV. Spring Boot features/42.4.1 ConfigFileApplicationContextInitializer.md) * [42.4.2 EnvironmentTestUtils](IV. Spring Boot features/42.4.2 EnvironmentTestUtils.md) From 4cb7c61047ce77eec4de02d6e03e13e44404c6b0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E7=83=AD=E5=BF=83=E5=B8=82=E6=B0=91=E9=92=9F=E5=B0=8F?= =?UTF-8?q?=E5=BC=BA?= Date: Sat, 15 Jun 2019 20:49:05 +0800 Subject: [PATCH 412/865] Update SUMMARY.md --- SUMMARY.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/SUMMARY.md b/SUMMARY.md index accce38e..b2f2a8d4 100644 --- a/SUMMARY.md +++ b/SUMMARY.md @@ -278,7 +278,7 @@ * [43.3.17 自动配置的REST客户端](IV. Spring Boot features/43.3.17 Auto-configured REST Clients.md) * [43.3.18 自动配置的Spring REST Docs测试](IV. Spring Boot features/43.3.18 Auto-configured Spring REST Docs Tests.md) * [43.3.19 用户配置与切片](IV. Spring Boot features/43.3.19 User Configuration and Slicing.md) - * [43.3.20 使用Spock测试Spring Boot应用](IV. Spring Boot features/43.3.19 Using Spock to Test Spring Boot Applications.md) + * [43.3.20 使用Spock测试Spring Boot应用](IV. Spring Boot features/43.3.20 Using Spock to Test Spring Boot Applications.md) * [42.4 测试工具类](IV. Spring Boot features/42.4 Test utilities.md) * [42.4.1 ConfigFileApplicationContextInitializer](IV. Spring Boot features/42.4.1 ConfigFileApplicationContextInitializer.md) * [42.4.2 EnvironmentTestUtils](IV. Spring Boot features/42.4.2 EnvironmentTestUtils.md) From b6f7047c6632c3cd25010d04488d1f072f388705 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E7=83=AD=E5=BF=83=E5=B8=82=E6=B0=91=E9=92=9F=E5=B0=8F?= =?UTF-8?q?=E5=BC=BA?= Date: Sat, 15 Jun 2019 20:50:55 +0800 Subject: [PATCH 413/865] Update and rename 42.3.17 Using Spock to test Spring Boot applications.md to 43.3.20 Using Spock to Test Spring Boot Applications.md --- ...> 43.3.20 Using Spock to Test Spring Boot Applications.md} | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) rename IV. Spring Boot features/{42.3.17 Using Spock to test Spring Boot applications.md => 43.3.20 Using Spock to Test Spring Boot Applications.md} (87%) diff --git a/IV. Spring Boot features/42.3.17 Using Spock to test Spring Boot applications.md b/IV. Spring Boot features/43.3.20 Using Spock to Test Spring Boot Applications.md similarity index 87% rename from IV. Spring Boot features/42.3.17 Using Spock to test Spring Boot applications.md rename to IV. Spring Boot features/43.3.20 Using Spock to Test Spring Boot Applications.md index 938f57d2..8f1f394e 100644 --- a/IV. Spring Boot features/42.3.17 Using Spock to test Spring Boot applications.md +++ b/IV. Spring Boot features/43.3.20 Using Spock to Test Spring Boot Applications.md @@ -1,3 +1,3 @@ -###42.3.17 使用Spock测试Spring Boot应用 +### 42.3.17 使用Spock测试Spring Boot应用 -如果想使用Spock测试Spring Boot应用,你需要为应用添加Spock的`spock-spring`依赖,该依赖已将Spring测试框架集成进Spock。推荐使用Spock 1.1或之后的版本,以便获得最近关于Spock的Spring框架和Spring Boot的集成的大量改进。详细内容请查看[Spock的Spring模块的文档](http://spockframework.org/spock/docs/1.1/modules.html)。 \ No newline at end of file +如果想使用Spock测试Spring Boot应用,你需要为应用添加Spock的`spock-spring`依赖,该依赖已将Spring测试框架集成进Spock。推荐使用Spock 1.1或之后的版本,以便获得最近关于Spock的Spring框架和Spring Boot的集成的大量改进。详细内容请查看[Spock的Spring模块的文档](http://spockframework.org/spock/docs/1.1/modules.html)。 From 94a4ba55816662cc4d9e537167ce98127531d6bc Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E7=83=AD=E5=BF=83=E5=B8=82=E6=B0=91=E9=92=9F=E5=B0=8F?= =?UTF-8?q?=E5=BC=BA?= Date: Mon, 17 Jun 2019 18:53:13 +0800 Subject: [PATCH 414/865] Update 43.3.18 Auto-configured Spring REST Docs Tests.md --- .../43.3.18 Auto-configured Spring REST Docs Tests.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/IV. Spring Boot features/43.3.18 Auto-configured Spring REST Docs Tests.md b/IV. Spring Boot features/43.3.18 Auto-configured Spring REST Docs Tests.md index 3251970b..3a477949 100644 --- a/IV. Spring Boot features/43.3.18 Auto-configured Spring REST Docs Tests.md +++ b/IV. Spring Boot features/43.3.18 Auto-configured Spring REST Docs Tests.md @@ -68,7 +68,7 @@ static class ResultHandlerConfiguration { } ``` -**Auto-configured Spring REST Docs Tests with REST Assured** +**使用REST Assured的自动配置的Spring REST Docs测试** `@AutoConfigureRestDocs`创建了一个`RequestSpecification` bean,预配置为使用Spring REST Docs。当你使用REST Assured和Spring REST Docs时,你可以使用`@Autowired`将其注入,好在测试里使用。如下所示: From 5b41f64d699b1e8783236270cc451169187fef91 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E7=83=AD=E5=BF=83=E5=B8=82=E6=B0=91=E9=92=9F=E5=B0=8F?= =?UTF-8?q?=E5=BC=BA?= Date: Tue, 2 Jul 2019 16:37:46 +0800 Subject: [PATCH 415/865] Update 43.3.19 User Configuration and Slicing.md --- .../43.3.19 User Configuration and Slicing.md | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/IV. Spring Boot features/43.3.19 User Configuration and Slicing.md b/IV. Spring Boot features/43.3.19 User Configuration and Slicing.md index cf447ed4..7e37122c 100644 --- a/IV. Spring Boot features/43.3.19 User Configuration and Slicing.md +++ b/IV. Spring Boot features/43.3.19 User Configuration and Slicing.md @@ -1,30 +1,30 @@ ### 43.3.19 用户配置与切片 -If you [structure your code](https://docs.spring.io/spring-boot/docs/2.0.0.RELEASE/reference/htmlsingle/#using-boot-structuring-your-code) in a sensible way, your `@SpringBootApplication` class is [used by default](https://docs.spring.io/spring-boot/docs/2.0.0.RELEASE/reference/htmlsingle/#boot-features-testing-spring-boot-applications-detecting-config) as the configuration of your tests. +如果你合理地[组织你的代码](https://docs.spring.io/spring-boot/docs/2.0.0.RELEASE/reference/htmlsingle/#using-boot-structuring-your-code),Spring Boot默认会把`@SpringBootApplication`类[当做测试的配置使用](https://docs.spring.io/spring-boot/docs/2.0.0.RELEASE/reference/htmlsingle/#boot-features-testing-spring-boot-applications-detecting-config)。 -It then becomes important not to litter the application’s main class with configuration settings that are specific to a particular area of its functionality. +所以,不要把针对特定功能区域的配置放置在应用的主类上。 -Assume that you are using Spring Batch and you rely on the auto-configuration for it. You could define your `@SpringBootApplication` as follows: +假设你正在使用Spring Batch,并依赖自动配置。你会如下定义你的`@SpringBootApplication`: ```java @SpringBootApplication @EnableBatchProcessing public class SampleApplication { ... } ``` -Because this class is the source configuration for the test, any slice test actually tries to start Spring Batch, which is definitely not what you want to do. A recommended approach is to move that area-specific configuration to a separate `@Configuration` class at the same level as your application, as shown in the following example: +因为这个类是测试的源配置,任何切片测试实际上都会尝试启动Spring Batch。这肯定不是你想做的。一种推荐的方法是把那个针对特定区域的配置移到一个独立的在应用的同一级上的`@Configuration`类。如下所示: ```java @Configuration @EnableBatchProcessing public class BatchConfiguration { ... } ``` -**注** Depending on the complexity of your application, you may either have a single `@Configuration` class for your customizations or one class per domain area. The latter approach lets you enable it in one of your tests, if necessary, with the `@Import` annotation. +**注** 根据应用的复杂度,你可能有一个定义所有配置的`@Configuration`类,或者每个域区域一个类。后面的方法让你在其中的一个测试里启用它。如果需要,加上`@Import`注解。 -Another source of confusion is classpath scanning. Assume that, while you structured your code in a sensible way, you need to scan an additional package. Your application may resemble the following code: +另一个困惑的根源是类路径扫描。假设你合理地组织了代码,你需要扫描一个额外的包。你的应用代码可能是这样的: ```java @SpringBootApplication @ComponentScan({ "com.example.app", "org.acme.another" }) public class SampleApplication { ... } ``` -Doing so effectively overrides the default component scan directive with the side effect of scanning those two packages regardless of the slice that you chose. For instance, a `@DataJpaTest` seems to suddenly scan components and user configurations of your application. Again, moving the custom directive to a separate class is a good way to fix this issue. +这样做实际上覆盖了默认的组件扫描指令,产生了不顾所选的切片而扫描那两个包的副作用。比如,`@DataJpaTest`突然扫描了应用的组件和用户配置。同样的,把自定义的指令移到独立的类上是修复此方法的好办法。 -**注** If this is not an option for you, you can create a `@SpringBootConfiguration` somewhere in the hierarchy of your test so that it is used instead. Alternatively, you can specify a source for your test, which disables the behavior of finding a default one. +**注** 如果这不是你的一个选项,你可以在测试的某个层级里创建`@SpringBootConfiguration`。另外,你可以为你的测试指定一个源。这会禁用寻找默认源的行为。 From 16369513d5290ad6281ba4fa203c9b577d6b3c83 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E7=83=AD=E5=BF=83=E5=B8=82=E6=B0=91=E9=92=9F=E5=B0=8F?= =?UTF-8?q?=E5=BC=BA?= Date: Tue, 2 Jul 2019 16:56:01 +0800 Subject: [PATCH 416/865] Update 43.3.20 Using Spock to Test Spring Boot Applications.md --- .../43.3.20 Using Spock to Test Spring Boot Applications.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/IV. Spring Boot features/43.3.20 Using Spock to Test Spring Boot Applications.md b/IV. Spring Boot features/43.3.20 Using Spock to Test Spring Boot Applications.md index 8f1f394e..5f68c43c 100644 --- a/IV. Spring Boot features/43.3.20 Using Spock to Test Spring Boot Applications.md +++ b/IV. Spring Boot features/43.3.20 Using Spock to Test Spring Boot Applications.md @@ -1,3 +1,3 @@ -### 42.3.17 使用Spock测试Spring Boot应用 +### 43.3.20 使用Spock测试Spring Boot应用 -如果想使用Spock测试Spring Boot应用,你需要为应用添加Spock的`spock-spring`依赖,该依赖已将Spring测试框架集成进Spock。推荐使用Spock 1.1或之后的版本,以便获得最近关于Spock的Spring框架和Spring Boot的集成的大量改进。详细内容请查看[Spock的Spring模块的文档](http://spockframework.org/spock/docs/1.1/modules.html)。 +如果想使用Spock测试Spring Boot应用,你需要为应用添加Spock的`spock-spring`依赖。该依赖已将Spring测试框架集成进Spock。推荐使用Spock 1.1或之后的版本,以便获得关于Spock的Spring框架和Spring Boot的集成的大量改进。详细内容请查看[Spock的Spring模块的文档](http://spockframework.org/spock/docs/1.1/modules.html)。 From abeea48d857e6aa332cde6c69f64d57c300571bc Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E7=83=AD=E5=BF=83=E5=B8=82=E6=B0=91=E9=92=9F=E5=B0=8F?= =?UTF-8?q?=E5=BC=BA?= Date: Wed, 3 Jul 2019 21:58:58 +0800 Subject: [PATCH 417/865] Update SUMMARY.md --- SUMMARY.md | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/SUMMARY.md b/SUMMARY.md index b2f2a8d4..edf3dd83 100644 --- a/SUMMARY.md +++ b/SUMMARY.md @@ -279,11 +279,11 @@ * [43.3.18 自动配置的Spring REST Docs测试](IV. Spring Boot features/43.3.18 Auto-configured Spring REST Docs Tests.md) * [43.3.19 用户配置与切片](IV. Spring Boot features/43.3.19 User Configuration and Slicing.md) * [43.3.20 使用Spock测试Spring Boot应用](IV. Spring Boot features/43.3.20 Using Spock to Test Spring Boot Applications.md) - * [42.4 测试工具类](IV. Spring Boot features/42.4 Test utilities.md) - * [42.4.1 ConfigFileApplicationContextInitializer](IV. Spring Boot features/42.4.1 ConfigFileApplicationContextInitializer.md) - * [42.4.2 EnvironmentTestUtils](IV. Spring Boot features/42.4.2 EnvironmentTestUtils.md) - * [42.4.3 OutputCapture](IV. Spring Boot features/42.4.3 OutputCapture.md) - * [42.4.4 TestRestTemplate](IV. Spring Boot features/42.4.4 TestRestTemplate.md) + * [43.4 测试工具类](IV. Spring Boot features/43.4 Test Utilities.md) + * [43.4.1 ConfigFileApplicationContextInitializer](IV. Spring Boot features/43.4.1 ConfigFileApplicationContextInitializer.md) + * [43.4.2 EnvironmentTestUtils](IV. Spring Boot features/43.4.2 EnvironmentTestUtils.md) + * [43.4.3 OutputCapture](IV. Spring Boot features/43.4.3 OutputCapture.md) + * [43.4.4 TestRestTemplate](IV. Spring Boot features/43.4.4 TestRestTemplate.md) * [43. WebSockets](IV. Spring Boot features/43. WebSockets.md) * [44. Web Services](IV. Spring Boot features/44. Web Services.md) * [45. 创建自己的auto-configuration](IV. Spring Boot features/45. Creating your own auto-configuration.md) From 9d36161a98a67c6b92ffa728540ddc5aea3a28a6 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E7=83=AD=E5=BF=83=E5=B8=82=E6=B0=91=E9=92=9F=E5=B0=8F?= =?UTF-8?q?=E5=BC=BA?= Date: Wed, 3 Jul 2019 22:03:06 +0800 Subject: [PATCH 418/865] Update and rename 42.4 Test utilities.md to 43.4 Test Utilities.md --- .../{42.4 Test utilities.md => 43.4 Test Utilities.md} | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) rename IV. Spring Boot features/{42.4 Test utilities.md => 43.4 Test Utilities.md} (77%) diff --git a/IV. Spring Boot features/42.4 Test utilities.md b/IV. Spring Boot features/43.4 Test Utilities.md similarity index 77% rename from IV. Spring Boot features/42.4 Test utilities.md rename to IV. Spring Boot features/43.4 Test Utilities.md index 0ad2cda4..ecb015a7 100644 --- a/IV. Spring Boot features/42.4 Test utilities.md +++ b/IV. Spring Boot features/43.4 Test Utilities.md @@ -1,2 +1,3 @@ -### 42.4 测试工具类 +### 43.4 测试工具类 + 一些测试工具类也打包进了`spring-boot`,在测试时使用它们会有很大帮助。 From 42f64994871fa22bb2b5a1852416ad42c101257f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E7=83=AD=E5=BF=83=E5=B8=82=E6=B0=91=E9=92=9F=E5=B0=8F?= =?UTF-8?q?=E5=BC=BA?= Date: Wed, 3 Jul 2019 22:07:15 +0800 Subject: [PATCH 419/865] Update and rename 42.4.1 ConfigFileApplicationContextInitializer.md to 43.4.1 ConfigFileApplicationContextInitializer.md --- ...md => 43.4.1 ConfigFileApplicationContextInitializer.md} | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) rename IV. Spring Boot features/{42.4.1 ConfigFileApplicationContextInitializer.md => 43.4.1 ConfigFileApplicationContextInitializer.md} (83%) diff --git a/IV. Spring Boot features/42.4.1 ConfigFileApplicationContextInitializer.md b/IV. Spring Boot features/43.4.1 ConfigFileApplicationContextInitializer.md similarity index 83% rename from IV. Spring Boot features/42.4.1 ConfigFileApplicationContextInitializer.md rename to IV. Spring Boot features/43.4.1 ConfigFileApplicationContextInitializer.md index 2642847f..aae8889c 100644 --- a/IV. Spring Boot features/42.4.1 ConfigFileApplicationContextInitializer.md +++ b/IV. Spring Boot features/43.4.1 ConfigFileApplicationContextInitializer.md @@ -1,8 +1,8 @@ -###42.4.1 ConfigFileApplicationContextInitializer - -`ConfigFileApplicationContextInitializer`是一个`ApplicationContextInitializer`,可在测试类中用于加载Spring Boot的`application.properties`文件。当不需要使用`@SpringBootTest`提供的全部特性时,你可以使用它。 +### 43.4.1 ConfigFileApplicationContextInitializer +`ConfigFileApplicationContextInitializer`是一个`ApplicationContextInitializer`,可在测试类中用于加载Spring Boot的`application.properties`文件。当不需要使用`@SpringBootTest`提供的全部特性时,你可以使用它。如下所示: ```java @ContextConfiguration(classes = Config.class,initializers = ConfigFileApplicationContextInitializer.class) ``` + **注** 单独使用`ConfigFileApplicationContextInitializer`不会提供`@Value("${…}")`注入支持,它只负责确保`application.properties`文件加载进Spring的`Environment`。为了`@Value`支持,你需要额外配置一个`PropertySourcesPlaceholderConfigurer`或使用`@SpringBootTest`为你自动配置一个。 From a9b761fbdf243fd5cfa112764d591d2d1dc3bf1e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E7=83=AD=E5=BF=83=E5=B8=82=E6=B0=91=E9=92=9F=E5=B0=8F?= =?UTF-8?q?=E5=BC=BA?= Date: Wed, 3 Jul 2019 22:09:02 +0800 Subject: [PATCH 420/865] Update and rename 42.4.2 EnvironmentTestUtils.md to 43.4.2 EnvironmentTestUtils.md --- ...EnvironmentTestUtils.md => 43.4.2 EnvironmentTestUtils.md} | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) rename IV. Spring Boot features/{42.4.2 EnvironmentTestUtils.md => 43.4.2 EnvironmentTestUtils.md} (84%) diff --git a/IV. Spring Boot features/42.4.2 EnvironmentTestUtils.md b/IV. Spring Boot features/43.4.2 EnvironmentTestUtils.md similarity index 84% rename from IV. Spring Boot features/42.4.2 EnvironmentTestUtils.md rename to IV. Spring Boot features/43.4.2 EnvironmentTestUtils.md index d39f8b37..8689fca6 100644 --- a/IV. Spring Boot features/42.4.2 EnvironmentTestUtils.md +++ b/IV. Spring Boot features/43.4.2 EnvironmentTestUtils.md @@ -1,4 +1,6 @@ -###42.4.2 EnvironmentTestUtils +### 43.4.2 EnvironmentTestUtils + 使用简单的`key=value`字符串调用`EnvironmentTestUtils`就可以快速添加属性到`ConfigurableEnvironment`或`ConfigurableApplicationContext`: ```java EnvironmentTestUtils.addEnvironment(env, "org=Spring", "name=Boot"); +``` From 597c18cca0e4878da2e6590ef9810c3f4bd63e93 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E7=83=AD=E5=BF=83=E5=B8=82=E6=B0=91=E9=92=9F=E5=B0=8F?= =?UTF-8?q?=E5=BC=BA?= Date: Wed, 3 Jul 2019 22:13:36 +0800 Subject: [PATCH 421/865] Update and rename 42.4.3 OutputCapture.md to 43.4.3 OutputCapture.md --- .../42.4.3 OutputCapture.md | 20 ---------------- .../43.4.3 OutputCapture.md | 24 +++++++++++++++++++ 2 files changed, 24 insertions(+), 20 deletions(-) delete mode 100644 IV. Spring Boot features/42.4.3 OutputCapture.md create mode 100644 IV. Spring Boot features/43.4.3 OutputCapture.md diff --git a/IV. Spring Boot features/42.4.3 OutputCapture.md b/IV. Spring Boot features/42.4.3 OutputCapture.md deleted file mode 100644 index f2c31a51..00000000 --- a/IV. Spring Boot features/42.4.3 OutputCapture.md +++ /dev/null @@ -1,20 +0,0 @@ -###42.4.3 OutputCapture - -`OutputCapture`是JUnit的一个`Rule`,用于捕获`System.out`和`System.err`输出,只需简单的将`@Rule`注解capture,然后在断言中调用`toString()`: -```java -import org.junit.Rule; -import org.junit.Test; -import org.springframework.boot.test.OutputCapture; -import static org.hamcrest.Matchers.*; -import static org.junit.Assert.*; - -public class MyTest { -@Rule -public OutputCapture capture = new OutputCapture(); -@Test -public void testName() throws Exception { -System.out.println("Hello World!"); -assertThat(capture.toString(), containsString("World")); -} -} -``` diff --git a/IV. Spring Boot features/43.4.3 OutputCapture.md b/IV. Spring Boot features/43.4.3 OutputCapture.md new file mode 100644 index 00000000..ec2f1f25 --- /dev/null +++ b/IV. Spring Boot features/43.4.3 OutputCapture.md @@ -0,0 +1,24 @@ +### 43.4.3 OutputCapture + +`OutputCapture`是JUnit的一个`Rule`,用于捕获`System.out`和`System.err`输出。你可以将`@Rule`注解capture,然后在断言中调用`toString()`。如下所示: +```java +import org.junit.Rule; +import org.junit.Test; +import org.springframework.boot.test.rule.OutputCapture; + +import static org.hamcrest.Matchers.*; +import static org.junit.Assert.*; + +public class MyTest { + + @Rule + public OutputCapture capture = new OutputCapture(); + + @Test + public void testName() throws Exception { + System.out.println("Hello World!"); + assertThat(capture.toString(), containsString("World")); + } + +} +``` From 013ce55cbf84bea7286255569abd09306e5c81c7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E7=83=AD=E5=BF=83=E5=B8=82=E6=B0=91=E9=92=9F=E5=B0=8F?= =?UTF-8?q?=E5=BC=BA?= Date: Wed, 3 Jul 2019 22:35:06 +0800 Subject: [PATCH 422/865] Update and rename 42.4.4 TestRestTemplate.md to 43.4.4 TestRestTemplate.md --- .../42.4.4 TestRestTemplate.md | 50 ------------------ .../43.4.4 TestRestTemplate.md | 52 +++++++++++++++++++ 2 files changed, 52 insertions(+), 50 deletions(-) delete mode 100644 IV. Spring Boot features/42.4.4 TestRestTemplate.md create mode 100644 IV. Spring Boot features/43.4.4 TestRestTemplate.md diff --git a/IV. Spring Boot features/42.4.4 TestRestTemplate.md b/IV. Spring Boot features/42.4.4 TestRestTemplate.md deleted file mode 100644 index 48db185b..00000000 --- a/IV. Spring Boot features/42.4.4 TestRestTemplate.md +++ /dev/null @@ -1,50 +0,0 @@ -###42.4.4 TestRestTemplate -在集成测试中,`TestRestTemplate`是Spring `RestTemplate`的便利替代。你可以获取一个普通的或发送基本HTTP认证(使用用户名和密码)的模板,不管哪种情况, -这些模板都对测试友好,对于服务端错误不会抛出异常。推荐使用Apache HTTP Client(4.3.2或更高版本),但不强制这样做,如果相关库在classpath下存在,`TestRestTemplate`将以正确配置的client进行响应。如果你使用Apache的HTTP客户端,一些额外的测试友好的特性将会被启用: - -- 重定向不会被跟踪(所以你可以断言回应的位置) -- Cookies将会被忽略(所以模版是无状态的) - -`TestRestTemplate`能够在你的集成测试中被直接实例化: -```java -public class MyTest { - - private TestRestTemplate template = new TestRestTemplate(); - - @Test - public void testRequest() throws Exception { - HttpHeaders headers = template.getForEntity("http://myhost.com/example", String.class).getHeaders(); - assertThat(headers.getLocation().toString(), containsString("myotherhost")); - } - -} -``` -或者,如果你正在使用`@SpringBootTest`,且设置了`WebEnvironment.RANDOM_PORT`或`WebEnvironment.DEFINED_PORT`属性,你可以注入一个配置完全的`TestRestTemplate`,并开始使用它。如果有需要,你还可以通过`RestTemplateBuilder` bean进行额外的自定义。任何没有指定主机和端口的URL将会自动连接到内嵌的服务器: -```java -@RunWith(SpringRunner.class) -@SpringBootTest -public class MyTest { - - @Autowired - private TestRestTemplate template; - - @Test - public void testRequest() throws Exception { - HttpHeaders headers = template.getForEntity("/example", String.class).getHeaders(); - assertThat(headers.getLocation().toString(), containsString("myotherhost")); - } - - @TestConfiguration - static class Config { - - @Bean - public RestTemplateBuilder restTemplateBuilder() { - return new RestTemplateBuilder() - .additionalMessageConverters(...) - .customizers(...); - } - - } - -} -``` diff --git a/IV. Spring Boot features/43.4.4 TestRestTemplate.md b/IV. Spring Boot features/43.4.4 TestRestTemplate.md new file mode 100644 index 00000000..e6a9fb9f --- /dev/null +++ b/IV. Spring Boot features/43.4.4 TestRestTemplate.md @@ -0,0 +1,52 @@ +### 43.4.4 TestRestTemplate + +**注** Spring Framework 5.0提供了一个新的`WebTestClient`。它服务于[WebFlux集成测试](https://docs.spring.io/spring-boot/docs/2.0.0.RELEASE/reference/htmlsingle/#boot-features-testing-spring-boot-applications-testing-autoconfigured-webflux-tests)与[WebFlux与MVC端到端测试](https://docs.spring.io/spring-boot/docs/2.0.0.RELEASE/reference/htmlsingle/#boot-features-testing-spring-boot-applications-testing-with-running-server)。不像`TestRestTemplate`,它为断言提供了流畅的API。 + +在集成测试中,`TestRestTemplate`是Spring `RestTemplate`的便利替代。你可以获取一个普通的或发送基本HTTP认证(使用用户名和密码)的模板。不管哪种情况,这些模板都对测试友好,对于服务端错误不会抛出异常。推荐使用Apache HTTP Client(4.3.2或更高版本),但不强制这样做。如果相关库在classpath下存在,`TestRestTemplate`将以正确配置的client进行响应。如果你使用Apache的HTTP客户端,一些额外的测试友好的特性将会被启用: + +- 重定向不会被跟踪(所以你可以断言回应的位置) +- Cookies将会被忽略(所以模版是无状态的) + +`TestRestTemplate`能够在你的集成测试中被直接实例化: +```java +public class MyTest { + + private TestRestTemplate template = new TestRestTemplate(); + + @Test + public void testRequest() throws Exception { + HttpHeaders headers = this.template.getForEntity( + "http://myhost.example.com/example", String.class).getHeaders(); + assertThat(headers.getLocation()).hasHost("other.example.com"); + } + +} +``` +或者,如果你正在使用`@SpringBootTest`,且设置了`WebEnvironment.RANDOM_PORT`或`WebEnvironment.DEFINED_PORT`属性,你可以注入一个配置完全的`TestRestTemplate`,并开始使用它。如果有需要,你还可以通过`RestTemplateBuilder` bean进行额外的自定义。任何没有指定主机和端口的URL将会自动连接到内嵌的服务器: +```java +@RunWith(SpringRunner.class) +@SpringBootTest(webEnvironment = WebEnvironment.RANDOM_PORT) +public class SampleWebClientTests { + + @Autowired + private TestRestTemplate template; + + @Test + public void testRequest() { + HttpHeaders headers = this.template.getForEntity("/example", String.class) + .getHeaders(); + assertThat(headers.getLocation()).hasHost("other.example.com"); + } + + @TestConfiguration + static class Config { + + @Bean + public RestTemplateBuilder restTemplateBuilder() { + return new RestTemplateBuilder().setConnectTimeout(1000).setReadTimeout(1000); + } + + } + +} +``` From 5fc1506efbe3b7657eb004613ab2a84dfa1fc0c4 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E7=83=AD=E5=BF=83=E5=B8=82=E6=B0=91=E9=92=9F=E5=B0=8F?= =?UTF-8?q?=E5=BC=BA?= Date: Thu, 4 Jul 2019 14:54:09 +0800 Subject: [PATCH 423/865] Update and rename 43. WebSockets.md to 44. WebSockets.md --- IV. Spring Boot features/43. WebSockets.md | 2 -- IV. Spring Boot features/44. WebSockets.md | 3 +++ 2 files changed, 3 insertions(+), 2 deletions(-) delete mode 100644 IV. Spring Boot features/43. WebSockets.md create mode 100644 IV. Spring Boot features/44. WebSockets.md diff --git a/IV. Spring Boot features/43. WebSockets.md b/IV. Spring Boot features/43. WebSockets.md deleted file mode 100644 index 7d3abdb2..00000000 --- a/IV. Spring Boot features/43. WebSockets.md +++ /dev/null @@ -1,2 +0,0 @@ -### 43. WebSockets -Spring Boot为内嵌的Tomcat(8和7),Jetty 9和Undertow提供WebSockets自动配置。如果你正在将war包部署到独立容器中,Spring Boot将假设该容器会负责配置WebSocket。Spring框架提供[丰富的WebSocket支持](https://docs.spring.io/spring/docs/5.0.4.RELEASE/spring-framework-reference/htmlsingle/#websocket),只需要添加`spring-boot-starter-websocket`模块即可。 diff --git a/IV. Spring Boot features/44. WebSockets.md b/IV. Spring Boot features/44. WebSockets.md new file mode 100644 index 00000000..654350d0 --- /dev/null +++ b/IV. Spring Boot features/44. WebSockets.md @@ -0,0 +1,3 @@ +### 44. WebSockets + +Spring Boot为内嵌的Tomcat 8.5、Jetty 9和Undertow提供WebSockets自动配置。如果你正在将war包部署到独立容器中,Spring Boot将假设该容器会负责配置WebSocket。Spring框架提供[丰富的WebSocket支持](https://docs.spring.io/spring/docs/5.0.4.RELEASE/spring-framework-reference/web.html#websocket),只需要添加`spring-boot-starter-websocket`模块即可。 From 96c1435650311e43a5e6dd773ed1512eda5a3014 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E7=83=AD=E5=BF=83=E5=B8=82=E6=B0=91=E9=92=9F=E5=B0=8F?= =?UTF-8?q?=E5=BC=BA?= Date: Thu, 4 Jul 2019 14:58:41 +0800 Subject: [PATCH 424/865] Update SUMMARY.md --- SUMMARY.md | 34 +++++++++++++++++----------------- 1 file changed, 17 insertions(+), 17 deletions(-) diff --git a/SUMMARY.md b/SUMMARY.md index edf3dd83..f58ccf9f 100644 --- a/SUMMARY.md +++ b/SUMMARY.md @@ -284,23 +284,23 @@ * [43.4.2 EnvironmentTestUtils](IV. Spring Boot features/43.4.2 EnvironmentTestUtils.md) * [43.4.3 OutputCapture](IV. Spring Boot features/43.4.3 OutputCapture.md) * [43.4.4 TestRestTemplate](IV. Spring Boot features/43.4.4 TestRestTemplate.md) - * [43. WebSockets](IV. Spring Boot features/43. WebSockets.md) - * [44. Web Services](IV. Spring Boot features/44. Web Services.md) - * [45. 创建自己的auto-configuration](IV. Spring Boot features/45. Creating your own auto-configuration.md) - * [45.1 理解自动配置的beans](IV. Spring Boot features/45.1 Understanding auto-configured beans.md) - * [45.2 定位自动配置候选者](IV. Spring Boot features/45.2 Locating auto-configuration candidates.md) - * [45.3 条件注解](IV. Spring Boot features/45.3 Condition annotations.md) - * [45.3.1 Class条件](IV. Spring Boot features/45.3.1 Class conditions.md) - * [45.3.2 Bean条件](IV. Spring Boot features/45.3.2 Bean conditions.md) - * [45.3.3 Property条件](IV. Spring Boot features/45.3.3 Property conditions.md) - * [45.3.4 Resource条件](IV. Spring Boot features/45.3.4 Resource conditions.md) - * [45.3.5 Web Application条件](IV. Spring Boot features/45.3.5 Web Application Conditions.md) - * [45.3.6 SpEL表达式条件](IV. Spring Boot features/45.3.6 SpEL expression conditions.md) - * [45.4 创建自己的starter](IV. Spring Boot features/45.4 Creating your own starter.md) - * [45.4.1 命名](IV. Spring Boot features/45.4.1 Naming.md) - * [45.4.2 自动配置模块](IV. Spring Boot features/45.4.2 Autoconfigure module.md) - * [45.4.3 Starter模块](IV. Spring Boot features/45.4.3 Starter module.md) - * [46. 接下来阅读什么](IV. Spring Boot features/46. What to read next.md) + * [44. WebSockets](IV. Spring Boot features/44. WebSockets.md) + * [45. Web Services](IV. Spring Boot features/45. Web Services.md) + * [46. 创建自己的auto-configuration](IV. Spring Boot features/46. Creating your own auto-configuration.md) + * [46.1 理解自动配置的beans](IV. Spring Boot features/46.1 Understanding auto-configured beans.md) + * [46.2 定位自动配置候选者](IV. Spring Boot features/46.2 Locating auto-configuration candidates.md) + * [46.3 条件注解](IV. Spring Boot features/46.3 Condition annotations.md) + * [46.3.1 Class条件](IV. Spring Boot features/46.3.1 Class conditions.md) + * [46.3.2 Bean条件](IV. Spring Boot features/46.3.2 Bean conditions.md) + * [46.3.3 Property条件](IV. Spring Boot features/46.3.3 Property conditions.md) + * [46.3.4 Resource条件](IV. Spring Boot features/46.3.4 Resource conditions.md) + * [46.3.5 Web Application条件](IV. Spring Boot features/46.3.5 Web Application Conditions.md) + * [46.3.6 SpEL表达式条件](IV. Spring Boot features/46.3.6 SpEL expression conditions.md) + * [46.4 创建自己的starter](IV. Spring Boot features/46.4 Creating your own starter.md) + * [46.4.1 命名](IV. Spring Boot features/46.4.1 Naming.md) + * [46.4.2 自动配置模块](IV. Spring Boot features/46.4.2 Autoconfigure module.md) + * [46.4.3 Starter模块](IV. Spring Boot features/46.4.3 Starter module.md) + * [47. 接下来阅读什么](IV. Spring Boot features/47. What to read next.md) * [V. Spring Boot执行器: Production-ready特性](V. Spring Boot Actuator/README.md) * [47. 开启production-ready特性](V. Spring Boot Actuator/47. Enabling production-ready features.md) * [48. 端点](V. Spring Boot Actuator/48. Endpoints.md) From 6816ddf852760d1a56862d65455207ec213265d5 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E7=83=AD=E5=BF=83=E5=B8=82=E6=B0=91=E9=92=9F=E5=B0=8F?= =?UTF-8?q?=E5=BC=BA?= Date: Thu, 4 Jul 2019 15:12:35 +0800 Subject: [PATCH 425/865] Update and rename 44. Web Services.md to 45. Web Services.md --- IV. Spring Boot features/44. Web Services.md | 2 -- IV. Spring Boot features/45. Web Services.md | 8 ++++++++ 2 files changed, 8 insertions(+), 2 deletions(-) delete mode 100644 IV. Spring Boot features/44. Web Services.md create mode 100644 IV. Spring Boot features/45. Web Services.md diff --git a/IV. Spring Boot features/44. Web Services.md b/IV. Spring Boot features/44. Web Services.md deleted file mode 100644 index b901dfe0..00000000 --- a/IV. Spring Boot features/44. Web Services.md +++ /dev/null @@ -1,2 +0,0 @@ -###44. Web Services -Spring Boot提供Web Services自动配置,你需要的就是定义`Endpoints`。通过添加`spring-boot-starter-webservices`模块可以获取[Spring Web Services特性](http://docs.spring.io/spring-ws/docs/2.3.0.RELEASE/reference/htmlsingle)。 diff --git a/IV. Spring Boot features/45. Web Services.md b/IV. Spring Boot features/45. Web Services.md new file mode 100644 index 00000000..28094c52 --- /dev/null +++ b/IV. Spring Boot features/45. Web Services.md @@ -0,0 +1,8 @@ +### 45. Web Services + +Spring Boot提供Web Services自动配置,你需要的就是定义`Endpoints`。通过添加`spring-boot-starter-webservices`模块可以获取[Spring Web Services特性](https://docs.spring.io/spring-ws/docs/3.0.0.RELEASE/reference/)。 + +Spring Boot会自动为你的WSDL和XSD各自创建`SimpleWsdl11Definition`和`SimpleXsdSchema` bean。如下,配置它们的位置: +```properties +spring.webservices.wsdl-locations=classpath:/wsdl +``` From c443e3a8540dc130bef58ab20184a9cfef0592e3 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E7=83=AD=E5=BF=83=E5=B8=82=E6=B0=91=E9=92=9F=E5=B0=8F?= =?UTF-8?q?=E5=BC=BA?= Date: Sun, 7 Jul 2019 15:29:40 +0800 Subject: [PATCH 426/865] Update SUMMARY.md --- SUMMARY.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/SUMMARY.md b/SUMMARY.md index f58ccf9f..7318655e 100644 --- a/SUMMARY.md +++ b/SUMMARY.md @@ -286,8 +286,8 @@ * [43.4.4 TestRestTemplate](IV. Spring Boot features/43.4.4 TestRestTemplate.md) * [44. WebSockets](IV. Spring Boot features/44. WebSockets.md) * [45. Web Services](IV. Spring Boot features/45. Web Services.md) - * [46. 创建自己的auto-configuration](IV. Spring Boot features/46. Creating your own auto-configuration.md) - * [46.1 理解自动配置的beans](IV. Spring Boot features/46.1 Understanding auto-configured beans.md) + * [46. 创建自己的自动配置](IV. Spring Boot features/46. Creating Your Own Auto-configuration.md) + * [46.1 理解自动配置的bean](IV. Spring Boot features/46.1 Understanding auto-configured beans.md) * [46.2 定位自动配置候选者](IV. Spring Boot features/46.2 Locating auto-configuration candidates.md) * [46.3 条件注解](IV. Spring Boot features/46.3 Condition annotations.md) * [46.3.1 Class条件](IV. Spring Boot features/46.3.1 Class conditions.md) From ad5173e11ca5e785d9c42c9c3b4d13cd0573b6f5 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E7=83=AD=E5=BF=83=E5=B8=82=E6=B0=91=E9=92=9F=E5=B0=8F?= =?UTF-8?q?=E5=BC=BA?= Date: Sun, 7 Jul 2019 15:36:13 +0800 Subject: [PATCH 427/865] Update and rename 45. Creating your own auto-configuration.md to 46. Creating Your Own Auto-configuration.md --- .../45. Creating your own auto-configuration.md | 4 ---- .../46. Creating Your Own Auto-configuration.md | 5 +++++ 2 files changed, 5 insertions(+), 4 deletions(-) delete mode 100644 IV. Spring Boot features/45. Creating your own auto-configuration.md create mode 100644 IV. Spring Boot features/46. Creating Your Own Auto-configuration.md diff --git a/IV. Spring Boot features/45. Creating your own auto-configuration.md b/IV. Spring Boot features/45. Creating your own auto-configuration.md deleted file mode 100644 index f6ebb478..00000000 --- a/IV. Spring Boot features/45. Creating your own auto-configuration.md +++ /dev/null @@ -1,4 +0,0 @@ -###45. 创建自己的auto-configuration -如果你在公司里开发共享libraries,或者正在开发一个开源或商业library,你可能想开发自己的自动配置(auto-configuration)。自动配置类可以打包到外部jars,并且依旧可以被Spring Boot识别。自动配置可以关联一个"starter",用于提供auto-configuration的代码及需要引用的libraries。我们首先讲解构建自己的auto-configuration需要知道哪些内容,然后讲解[创建自定义starter的常见步骤](http://docs.spring.io/spring-boot/docs/2.0.0.RELEASE/reference/htmlsingle/#boot-features-custom-starter)。 - -**注** 可参考[demo工程](https://github.com/snicoll-demos/spring-boot-master-auto-configuration)了解如何一步步创建一个starter。 diff --git a/IV. Spring Boot features/46. Creating Your Own Auto-configuration.md b/IV. Spring Boot features/46. Creating Your Own Auto-configuration.md new file mode 100644 index 00000000..b882cf39 --- /dev/null +++ b/IV. Spring Boot features/46. Creating Your Own Auto-configuration.md @@ -0,0 +1,5 @@ +### 45. 创建自己的自动配置 + +如果你在公司里开发共享库,或者正在开发一个开源或商业库,你可能想开发自己的自动配置(auto-configuration)。自动配置类可以打包到外部jars,并且依旧可以被Spring Boot识别。自动配置可以关联一个“starter”,用于提供自动配置的代码及需要引用的libraries。我们首先讲解构建自己的自动配置需要知道哪些内容,然后讲解[创建自定义starter的常见步骤](https://docs.spring.io/spring-boot/docs/2.0.0.RELEASE/reference/htmlsingle/#boot-features-custom-starter)。 + +**注** 可参考[demo工程](https://github.com/snicoll-demos/spring-boot-master-auto-configuration)了解如何一步步创建一个starter。 From 3635a3133b5a4b390273a504bf75d6c7d0d62452 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E7=83=AD=E5=BF=83=E5=B8=82=E6=B0=91=E9=92=9F=E5=B0=8F?= =?UTF-8?q?=E5=BC=BA?= Date: Sun, 7 Jul 2019 15:38:17 +0800 Subject: [PATCH 428/865] Update SUMMARY.md --- SUMMARY.md | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/SUMMARY.md b/SUMMARY.md index 7318655e..4122d124 100644 --- a/SUMMARY.md +++ b/SUMMARY.md @@ -287,9 +287,9 @@ * [44. WebSockets](IV. Spring Boot features/44. WebSockets.md) * [45. Web Services](IV. Spring Boot features/45. Web Services.md) * [46. 创建自己的自动配置](IV. Spring Boot features/46. Creating Your Own Auto-configuration.md) - * [46.1 理解自动配置的bean](IV. Spring Boot features/46.1 Understanding auto-configured beans.md) - * [46.2 定位自动配置候选者](IV. Spring Boot features/46.2 Locating auto-configuration candidates.md) - * [46.3 条件注解](IV. Spring Boot features/46.3 Condition annotations.md) + * [46.1 理解自动配置的bean](IV. Spring Boot features/46.1 Understanding Auto-configured beans.md) + * [46.2 定位自动配置候选者](IV. Spring Boot features/46.2 Locating Auto-configuration Candidates.md) + * [46.3 条件注解](IV. Spring Boot features/46.3 Condition Annotations.md) * [46.3.1 Class条件](IV. Spring Boot features/46.3.1 Class conditions.md) * [46.3.2 Bean条件](IV. Spring Boot features/46.3.2 Bean conditions.md) * [46.3.3 Property条件](IV. Spring Boot features/46.3.3 Property conditions.md) From c02109bb9439a3c7c7a3c509eb4d4f7a66f19b3d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E7=83=AD=E5=BF=83=E5=B8=82=E6=B0=91=E9=92=9F=E5=B0=8F?= =?UTF-8?q?=E5=BC=BA?= Date: Sun, 7 Jul 2019 15:39:43 +0800 Subject: [PATCH 429/865] Update SUMMARY.md --- SUMMARY.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/SUMMARY.md b/SUMMARY.md index 4122d124..d8f83937 100644 --- a/SUMMARY.md +++ b/SUMMARY.md @@ -287,7 +287,7 @@ * [44. WebSockets](IV. Spring Boot features/44. WebSockets.md) * [45. Web Services](IV. Spring Boot features/45. Web Services.md) * [46. 创建自己的自动配置](IV. Spring Boot features/46. Creating Your Own Auto-configuration.md) - * [46.1 理解自动配置的bean](IV. Spring Boot features/46.1 Understanding Auto-configured beans.md) + * [46.1 理解自动配置的bean](IV. Spring Boot features/46.1 Understanding Auto-configured Beans.md) * [46.2 定位自动配置候选者](IV. Spring Boot features/46.2 Locating Auto-configuration Candidates.md) * [46.3 条件注解](IV. Spring Boot features/46.3 Condition Annotations.md) * [46.3.1 Class条件](IV. Spring Boot features/46.3.1 Class conditions.md) From 143edabfb29aa3f9f98d45fb35e226d2afb2e5e5 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E7=83=AD=E5=BF=83=E5=B8=82=E6=B0=91=E9=92=9F=E5=B0=8F?= =?UTF-8?q?=E5=BC=BA?= Date: Sun, 7 Jul 2019 15:44:11 +0800 Subject: [PATCH 430/865] Update and rename 45.1 Understanding auto-configured beans.md to 46.1 Understanding Auto-configured Beans.md --- ... beans.md => 46.1 Understanding Auto-configured Beans.md} | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) rename IV. Spring Boot features/{45.1 Understanding auto-configured beans.md => 46.1 Understanding Auto-configured Beans.md} (51%) diff --git a/IV. Spring Boot features/45.1 Understanding auto-configured beans.md b/IV. Spring Boot features/46.1 Understanding Auto-configured Beans.md similarity index 51% rename from IV. Spring Boot features/45.1 Understanding auto-configured beans.md rename to IV. Spring Boot features/46.1 Understanding Auto-configured Beans.md index 72c7723e..8928a33e 100644 --- a/IV. Spring Boot features/45.1 Understanding auto-configured beans.md +++ b/IV. Spring Boot features/46.1 Understanding Auto-configured Beans.md @@ -1,2 +1,3 @@ -###45.1 理解自动配置的beans -从底层来讲,自动配置(auto-configuration)是通过标准的`@Configuration`类实现的。此外,`@Conditional`注解用来约束自动配置生效的条件。通常自动配置类需要使用`@ConditionalOnClass`和`@ConditionalOnMissingBean`注解,这是为了确保只有在相关的类被发现及没有声明自定义的`@Configuration`时才应用自动配置,具体查看[`spring-boot-autoconfigure`](https://github.com/spring-projects/spring-boot/tree/v2.0.0.RELEASE/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure)源码中的`@Configuration`类(`META-INF/spring.factories`文件)。 +### 46.1 理解自动配置的bean + +从底层来讲,自动配置(auto-configuration)是通过标准的`@Configuration`类实现的。此外,`@Conditional`注解用来约束自动配置生效的条件。通常自动配置类需要使用`@ConditionalOnClass`和`@ConditionalOnMissingBean`注解,这是为了确保只有在相关的类被发现及没有声明自定义的`@Configuration`时才应用自动配置,具体查看[`spring-boot-autoconfigure`](https://github.com/spring-projects/spring-boot/tree/v2.0.0.RELEASE/spring-boot-project/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure)源码中的`@Configuration`类([`META-INF/spring.factories`](https://github.com/spring-projects/spring-boot/tree/v2.0.0.RELEASE/spring-boot-project/spring-boot-autoconfigure/src/main/resources/META-INF/spring.factories)文件)。 From 040f02ad69498658d71f4324d0d4ea4bdee4387c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E7=83=AD=E5=BF=83=E5=B8=82=E6=B0=91=E9=92=9F=E5=B0=8F?= =?UTF-8?q?=E5=BC=BA?= Date: Sun, 7 Jul 2019 15:44:39 +0800 Subject: [PATCH 431/865] Update 46. Creating Your Own Auto-configuration.md --- .../46. Creating Your Own Auto-configuration.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/IV. Spring Boot features/46. Creating Your Own Auto-configuration.md b/IV. Spring Boot features/46. Creating Your Own Auto-configuration.md index b882cf39..a9cdf0f0 100644 --- a/IV. Spring Boot features/46. Creating Your Own Auto-configuration.md +++ b/IV. Spring Boot features/46. Creating Your Own Auto-configuration.md @@ -1,4 +1,4 @@ -### 45. 创建自己的自动配置 +### 46. 创建自己的自动配置 如果你在公司里开发共享库,或者正在开发一个开源或商业库,你可能想开发自己的自动配置(auto-configuration)。自动配置类可以打包到外部jars,并且依旧可以被Spring Boot识别。自动配置可以关联一个“starter”,用于提供自动配置的代码及需要引用的libraries。我们首先讲解构建自己的自动配置需要知道哪些内容,然后讲解[创建自定义starter的常见步骤](https://docs.spring.io/spring-boot/docs/2.0.0.RELEASE/reference/htmlsingle/#boot-features-custom-starter)。 From 83de76312e9ad638dcfec769e24654c29496238f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E7=83=AD=E5=BF=83=E5=B8=82=E6=B0=91=E9=92=9F=E5=B0=8F?= =?UTF-8?q?=E5=BC=BA?= Date: Sun, 7 Jul 2019 15:48:37 +0800 Subject: [PATCH 432/865] Update and rename 45.2 Locating auto-configuration candidates.md to 46.2 Locating Auto-configuration Candidates.md --- ...s.md => 46.2 Locating Auto-configuration Candidates.md} | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) rename IV. Spring Boot features/{45.2 Locating auto-configuration candidates.md => 46.2 Locating Auto-configuration Candidates.md} (86%) diff --git a/IV. Spring Boot features/45.2 Locating auto-configuration candidates.md b/IV. Spring Boot features/46.2 Locating Auto-configuration Candidates.md similarity index 86% rename from IV. Spring Boot features/45.2 Locating auto-configuration candidates.md rename to IV. Spring Boot features/46.2 Locating Auto-configuration Candidates.md index a72bac0c..bef18013 100644 --- a/IV. Spring Boot features/45.2 Locating auto-configuration candidates.md +++ b/IV. Spring Boot features/46.2 Locating Auto-configuration Candidates.md @@ -1,5 +1,6 @@ -###45.2 定位自动配置候选者 -Spring Boot会检查你发布的jar中是否存在`META-INF/spring.factories`文件,该文件中以`EnableAutoConfiguration`为key的属性应该列出你的配置类: +### 46.2 定位自动配置候选者 + +Spring Boot会检查你发布的jar中是否存在`META-INF/spring.factories`文件,该文件中以`EnableAutoConfiguration`为key的属性应该列出你的配置类。如下所示: ```java org.springframework.boot.autoconfigure.EnableAutoConfiguration=\ com.mycorp.libx.autoconfigure.LibXAutoConfiguration,\ @@ -7,6 +8,6 @@ com.mycorp.libx.autoconfigure.LibXWebAutoConfiguration ``` 你可以使用[`@AutoConfigureAfter`](http://github.com/spring-projects/spring-boot/tree/master/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/AutoConfigureAfter.java)或[`@AutoConfigureBefore`](http://github.com/spring-projects/spring-boot/tree/master/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/AutoConfigureBefore.java)注解为配置类指定特定的顺序。例如,如果你提供web-specific配置,你的类就需要应用在`WebMvcAutoConfiguration`后面。 -你也可以使用`@AutoconfigureOrder`注解为那些相互不知道存在的自动配置类提供排序,该注解语义跟常规的`@Order`注解相同,但专为自动配置类提供顺序。 +你也可以使用`@AutoConfigureOrder`注解为那些相互不知道存在的自动配置类提供排序,该注解语义跟常规的`@Order`注解相同,但专为自动配置类提供顺序。 **注** 自动配置类只能通过这种方式加载,确保它们定义在一个特殊的package中,特别是不能成为组件扫描的目标。 From 1ffc2cb7f3e805de640692c2ab9f201cf81ab786 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E7=83=AD=E5=BF=83=E5=B8=82=E6=B0=91=E9=92=9F=E5=B0=8F?= =?UTF-8?q?=E5=BC=BA?= Date: Sun, 7 Jul 2019 15:58:02 +0800 Subject: [PATCH 433/865] Update and rename 45.3 Condition annotations.md to 46.3 Condition Annotations.md --- .../45.3 Condition annotations.md | 5 ----- .../46.3 Condition Annotations.md | 12 ++++++++++++ 2 files changed, 12 insertions(+), 5 deletions(-) delete mode 100644 IV. Spring Boot features/45.3 Condition annotations.md create mode 100644 IV. Spring Boot features/46.3 Condition Annotations.md diff --git a/IV. Spring Boot features/45.3 Condition annotations.md b/IV. Spring Boot features/45.3 Condition annotations.md deleted file mode 100644 index 0c2cd03c..00000000 --- a/IV. Spring Boot features/45.3 Condition annotations.md +++ /dev/null @@ -1,5 +0,0 @@ -### 45.3 条件注解 - -你几乎总是需要在自己的自动配置类里添加一个或更多的`@Conditional`注解。`@ConditionalOnMissingBean`注解是一个常见的示例,开发者可以用它覆盖自动配置类提供的默认行为。 - -Spring Boot包含很多`@Conditional`注解,你可以在自己的代码中通过注解`@Configuration`类或单独的`@Bean`方法来重用它们。 diff --git a/IV. Spring Boot features/46.3 Condition Annotations.md b/IV. Spring Boot features/46.3 Condition Annotations.md new file mode 100644 index 00000000..572fcc03 --- /dev/null +++ b/IV. Spring Boot features/46.3 Condition Annotations.md @@ -0,0 +1,12 @@ +### 46.3 条件注解 + +你几乎总是需要在自己的自动配置类里添加一个或更多的`@Conditional`注解。`@ConditionalOnMissingBean`注解是一个常见的示例,开发者可以用它覆盖自动配置类提供的默认行为。 + +Spring Boot包含很多`@Conditional`注解,你可以在自己的代码中通过注解`@Configuration`类或单独的`@Bean`方法来重用它们。这些注解包括: + +- [46.3.1 Class条件](https://docs.spring.io/spring-boot/docs/2.0.0.RELEASE/reference/htmlsingle/#boot-features-class-conditions) +- [46.3.2 Bean条件](https://docs.spring.io/spring-boot/docs/2.0.0.RELEASE/reference/htmlsingle/#boot-features-bean-conditions) +- [46.3.3 Property条件](https://docs.spring.io/spring-boot/docs/2.0.0.RELEASE/reference/htmlsingle/#boot-features-property-conditions) +- [46.3.4 Resource条件](https://docs.spring.io/spring-boot/docs/2.0.0.RELEASE/reference/htmlsingle/#boot-features-resource-conditions) +- [46.3.5 Web Application条件](https://docs.spring.io/spring-boot/docs/2.0.0.RELEASE/reference/htmlsingle/#boot-features-web-application-conditions) +- [46.3.6 SpEL表达式条件](https://docs.spring.io/spring-boot/docs/2.0.0.RELEASE/reference/htmlsingle/#boot-features-spel-conditions) From 4adda987833b8f42f3b2ef0852a902817b8d6313 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E7=83=AD=E5=BF=83=E5=B8=82=E6=B0=91=E9=92=9F=E5=B0=8F?= =?UTF-8?q?=E5=BC=BA?= Date: Sun, 7 Jul 2019 16:06:39 +0800 Subject: [PATCH 434/865] Update SUMMARY.md --- SUMMARY.md | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/SUMMARY.md b/SUMMARY.md index d8f83937..d0e28016 100644 --- a/SUMMARY.md +++ b/SUMMARY.md @@ -290,12 +290,12 @@ * [46.1 理解自动配置的bean](IV. Spring Boot features/46.1 Understanding Auto-configured Beans.md) * [46.2 定位自动配置候选者](IV. Spring Boot features/46.2 Locating Auto-configuration Candidates.md) * [46.3 条件注解](IV. Spring Boot features/46.3 Condition Annotations.md) - * [46.3.1 Class条件](IV. Spring Boot features/46.3.1 Class conditions.md) - * [46.3.2 Bean条件](IV. Spring Boot features/46.3.2 Bean conditions.md) - * [46.3.3 Property条件](IV. Spring Boot features/46.3.3 Property conditions.md) - * [46.3.4 Resource条件](IV. Spring Boot features/46.3.4 Resource conditions.md) + * [46.3.1 Class条件](IV. Spring Boot features/46.3.1 Class Conditions.md) + * [46.3.2 Bean条件](IV. Spring Boot features/46.3.2 Bean Conditions.md) + * [46.3.3 Property条件](IV. Spring Boot features/46.3.3 Property Conditions.md) + * [46.3.4 Resource条件](IV. Spring Boot features/46.3.4 Resource Conditions.md) * [46.3.5 Web Application条件](IV. Spring Boot features/46.3.5 Web Application Conditions.md) - * [46.3.6 SpEL表达式条件](IV. Spring Boot features/46.3.6 SpEL expression conditions.md) + * [46.3.6 SpEL表达式条件](IV. Spring Boot features/46.3.6 SpEL Expression Conditions.md) * [46.4 创建自己的starter](IV. Spring Boot features/46.4 Creating your own starter.md) * [46.4.1 命名](IV. Spring Boot features/46.4.1 Naming.md) * [46.4.2 自动配置模块](IV. Spring Boot features/46.4.2 Autoconfigure module.md) From d6578f1c78dfea73400cb222b3cc062c31d5b276 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E7=83=AD=E5=BF=83=E5=B8=82=E6=B0=91=E9=92=9F=E5=B0=8F?= =?UTF-8?q?=E5=BC=BA?= Date: Sun, 7 Jul 2019 16:09:50 +0800 Subject: [PATCH 435/865] Update and rename 45.3.1 Class conditions.md to 46.3.1 Class Conditions.md --- ...{45.3.1 Class conditions.md => 46.3.1 Class Conditions.md} | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) rename IV. Spring Boot features/{45.3.1 Class conditions.md => 46.3.1 Class Conditions.md} (75%) diff --git a/IV. Spring Boot features/45.3.1 Class conditions.md b/IV. Spring Boot features/46.3.1 Class Conditions.md similarity index 75% rename from IV. Spring Boot features/45.3.1 Class conditions.md rename to IV. Spring Boot features/46.3.1 Class Conditions.md index 11352520..42e1af88 100644 --- a/IV. Spring Boot features/45.3.1 Class conditions.md +++ b/IV. Spring Boot features/46.3.1 Class Conditions.md @@ -1,5 +1,5 @@ -### 45.3.1 Class条件 +### 46.3.1 Class条件 -`@ConditionalOnClass`和`@ConditionalOnMissingClass`注解可以根据特定类是否出现来决定配置的包含,由于注解元数据是使用[ASM](http://asm.ow2.org/)来解析的,所以你可以使用`value`属性来引用真正的类,即使该类没有出现在运行应用的classpath下,也可以使用`name`属性如果你倾向于使用字符串作为类名。 +`@ConditionalOnClass`和`@ConditionalOnMissingClass`注解可以根据特定类是否出现来决定配置的包含。由于注解元数据是使用[ASM](http://asm.ow2.org/)来解析的,所以你可以使用`value`属性来引用真正的类。即使该类没有出现在运行应用的classpath下,也可以使用`name`属性如果你倾向于使用字符串作为类名。 **提示** 如果你正在使用`@ConditionalOnClass`或者`@ConditionalOnMissingClass`,作为元注解的一部分来构成你自己的注解,你必须使用`name`。因为在这种情况下指向class没有被处理。 From bc96a3508dd24930f4fa4eb44ceabdbb60474b40 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E7=83=AD=E5=BF=83=E5=B8=82=E6=B0=91=E9=92=9F=E5=B0=8F?= =?UTF-8?q?=E5=BC=BA?= Date: Sun, 7 Jul 2019 16:13:36 +0800 Subject: [PATCH 436/865] Update and rename 45.3.2 Bean conditions.md to 46.3.2 Bean Conditions.md --- .../{45.3.2 Bean conditions.md => 46.3.2 Bean Conditions.md} | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) rename IV. Spring Boot features/{45.3.2 Bean conditions.md => 46.3.2 Bean Conditions.md} (96%) diff --git a/IV. Spring Boot features/45.3.2 Bean conditions.md b/IV. Spring Boot features/46.3.2 Bean Conditions.md similarity index 96% rename from IV. Spring Boot features/45.3.2 Bean conditions.md rename to IV. Spring Boot features/46.3.2 Bean Conditions.md index b5d8c3d9..60f76469 100644 --- a/IV. Spring Boot features/45.3.2 Bean conditions.md +++ b/IV. Spring Boot features/46.3.2 Bean Conditions.md @@ -1,4 +1,4 @@ -### 45.3.2 Bean条件 +### 46.3.2 Bean条件 `@ConditionalOnBean`和`@ConditionalOnMissingBean`注解可以根据特定类是否存在决定bean的包含,你可以使用`value`属性指定beans(by type),也可以使用`name`定义beans(by name),`search`属性用于限制搜索beans时需要考虑的`ApplicationContext`层次。 From cbe79e225ab44f32b82576371241e6f4aac1b8ac Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E7=83=AD=E5=BF=83=E5=B8=82=E6=B0=91=E9=92=9F=E5=B0=8F?= =?UTF-8?q?=E5=BC=BA?= Date: Sun, 7 Jul 2019 16:18:05 +0800 Subject: [PATCH 437/865] Update and rename 45.3.3 Property conditions.md to 46.3.3 Property Conditions.md --- ....3 Property conditions.md => 46.3.3 Property Conditions.md} | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) rename IV. Spring Boot features/{45.3.3 Property conditions.md => 46.3.3 Property Conditions.md} (91%) diff --git a/IV. Spring Boot features/45.3.3 Property conditions.md b/IV. Spring Boot features/46.3.3 Property Conditions.md similarity index 91% rename from IV. Spring Boot features/45.3.3 Property conditions.md rename to IV. Spring Boot features/46.3.3 Property Conditions.md index c5f3b23a..2da008a0 100644 --- a/IV. Spring Boot features/45.3.3 Property conditions.md +++ b/IV. Spring Boot features/46.3.3 Property Conditions.md @@ -1,2 +1,3 @@ -###45.3.3 Property条件 +### 46.3.3 Property条件 + `@ConditionalOnProperty`注解可以根据一个Spring `Environment`属性来决定是否包含配置,使用`prefix`和`name`属性指定要检查的配置。默认情况下,任何存在的只要不是`false`的属性都会匹配,你也可以使用`havingValue`和`matchIfMissing`属性创建更高级的检测。 From f8f82d43a128d4fa6070c0b00cf46e9e49c43bcd Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E7=83=AD=E5=BF=83=E5=B8=82=E6=B0=91=E9=92=9F=E5=B0=8F?= =?UTF-8?q?=E5=BC=BA?= Date: Sun, 7 Jul 2019 16:20:57 +0800 Subject: [PATCH 438/865] Update and rename 45.3.4 Resource conditions.md to 46.3.4 Resource Conditions.md --- ....4 Resource conditions.md => 46.3.4 Resource Conditions.md} | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) rename IV. Spring Boot features/{45.3.4 Resource conditions.md => 46.3.4 Resource Conditions.md} (84%) diff --git a/IV. Spring Boot features/45.3.4 Resource conditions.md b/IV. Spring Boot features/46.3.4 Resource Conditions.md similarity index 84% rename from IV. Spring Boot features/45.3.4 Resource conditions.md rename to IV. Spring Boot features/46.3.4 Resource Conditions.md index e73bdd98..901b3a3a 100644 --- a/IV. Spring Boot features/45.3.4 Resource conditions.md +++ b/IV. Spring Boot features/46.3.4 Resource Conditions.md @@ -1,2 +1,3 @@ -###45.3.4 Resource条件 +### 46.3.4 Resource条件 + `@ConditionalOnResource`注解只在特定资源出现时才会包含配置,可以使用常见的Spring约定命名资源,例如`file:/home/user/test.dat`。 From dc7e5e60c3f64a266ab15a9d7407fdeb31ea6e06 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E7=83=AD=E5=BF=83=E5=B8=82=E6=B0=91=E9=92=9F=E5=B0=8F?= =?UTF-8?q?=E5=BC=BA?= Date: Sun, 7 Jul 2019 16:23:21 +0800 Subject: [PATCH 439/865] Update and rename 45.3.5 Web Application Conditions.md to 46.3.5 Web Application Conditions.md --- IV. Spring Boot features/45.3.5 Web Application Conditions.md | 2 -- IV. Spring Boot features/46.3.5 Web Application Conditions.md | 3 +++ 2 files changed, 3 insertions(+), 2 deletions(-) delete mode 100644 IV. Spring Boot features/45.3.5 Web Application Conditions.md create mode 100644 IV. Spring Boot features/46.3.5 Web Application Conditions.md diff --git a/IV. Spring Boot features/45.3.5 Web Application Conditions.md b/IV. Spring Boot features/45.3.5 Web Application Conditions.md deleted file mode 100644 index 1fd1e46f..00000000 --- a/IV. Spring Boot features/45.3.5 Web Application Conditions.md +++ /dev/null @@ -1,2 +0,0 @@ -###45.3.5 Web Application条件 -`@ConditionalOnWebApplication`和`@ConditionalOnNotWebApplication`注解可以根据应用是否为'web应用'来决定是否包含配置,web应用是任何使用Spring `WebApplicationContext`,定义一个`session`作用域,或有一个`StandardServletEnvironment`的应用。 diff --git a/IV. Spring Boot features/46.3.5 Web Application Conditions.md b/IV. Spring Boot features/46.3.5 Web Application Conditions.md new file mode 100644 index 00000000..656a9430 --- /dev/null +++ b/IV. Spring Boot features/46.3.5 Web Application Conditions.md @@ -0,0 +1,3 @@ +### 46.3.5 Web Application条件 + +`@ConditionalOnWebApplication`和`@ConditionalOnNotWebApplication`注解可以根据应用是否为“web应用”来决定是否包含配置。web应用是任何使用Spring `WebApplicationContext`,定义一个`session`作用域,或有一个`StandardServletEnvironment`的应用。 From 48a8cad3255d3bf48b98aa334d943863e466655a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E7=83=AD=E5=BF=83=E5=B8=82=E6=B0=91=E9=92=9F=E5=B0=8F?= =?UTF-8?q?=E5=BC=BA?= Date: Sun, 7 Jul 2019 16:25:50 +0800 Subject: [PATCH 440/865] Update and rename 45.3.6 SpEL expression conditions.md to 46.3.6 SpEL Expression Conditions.md --- ...on conditions.md => 46.3.6 SpEL Expression Conditions.md} | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) rename IV. Spring Boot features/{45.3.6 SpEL expression conditions.md => 46.3.6 SpEL Expression Conditions.md} (55%) diff --git a/IV. Spring Boot features/45.3.6 SpEL expression conditions.md b/IV. Spring Boot features/46.3.6 SpEL Expression Conditions.md similarity index 55% rename from IV. Spring Boot features/45.3.6 SpEL expression conditions.md rename to IV. Spring Boot features/46.3.6 SpEL Expression Conditions.md index c262cbad..18b23b3a 100644 --- a/IV. Spring Boot features/45.3.6 SpEL expression conditions.md +++ b/IV. Spring Boot features/46.3.6 SpEL Expression Conditions.md @@ -1,2 +1,3 @@ -###45.3.6 SpEL表达式条件 -`@ConditionalOnExpression`注解可以根据[SpEL表达式](https://docs.spring.io/spring/docs/5.0.4.RELEASE/spring-framework-reference/htmlsingle/#expressions)结果来决定是否包含配置。 +### 46.3.6 SpEL表达式条件 + +`@ConditionalOnExpression`注解可以根据[SpEL表达式](https://docs.spring.io/spring/docs/5.0.4.RELEASE/spring-framework-reference/core.html#expressions)结果来决定是否包含配置。 From a45ec6230fcb135776c065680b72d7ee21ca585a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E7=83=AD=E5=BF=83=E5=B8=82=E6=B0=91=E9=92=9F=E5=B0=8F?= =?UTF-8?q?=E5=BC=BA?= Date: Mon, 8 Jul 2019 23:11:23 +0800 Subject: [PATCH 441/865] Update SUMMARY.md --- SUMMARY.md | 3 +++ 1 file changed, 3 insertions(+) diff --git a/SUMMARY.md b/SUMMARY.md index d0e28016..49036dbb 100644 --- a/SUMMARY.md +++ b/SUMMARY.md @@ -296,6 +296,9 @@ * [46.3.4 Resource条件](IV. Spring Boot features/46.3.4 Resource Conditions.md) * [46.3.5 Web Application条件](IV. Spring Boot features/46.3.5 Web Application Conditions.md) * [46.3.6 SpEL表达式条件](IV. Spring Boot features/46.3.6 SpEL Expression Conditions.md) + * [46.4 测试你的自动配置](IV. Spring Boot features/46.4 Testing your Auto-configuration.md) + * [46.4.1 模拟网络上下文](IV. Spring Boot features/46.4.1 Simulating a Web Context.md) + * [46.4.2 覆盖类路径](IV. Spring Boot features/46.4.2 Overriding the Classpath.md) * [46.4 创建自己的starter](IV. Spring Boot features/46.4 Creating your own starter.md) * [46.4.1 命名](IV. Spring Boot features/46.4.1 Naming.md) * [46.4.2 自动配置模块](IV. Spring Boot features/46.4.2 Autoconfigure module.md) From c3de2bc539b3b006e2de2cd35f294d548bfe6426 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E7=83=AD=E5=BF=83=E5=B8=82=E6=B0=91=E9=92=9F=E5=B0=8F?= =?UTF-8?q?=E5=BC=BA?= Date: Mon, 8 Jul 2019 23:20:31 +0800 Subject: [PATCH 442/865] Create 46.4 Testing your Auto-configuration.md --- .../46.4 Testing your Auto-configuration.md | 45 +++++++++++++++++++ 1 file changed, 45 insertions(+) create mode 100644 IV. Spring Boot features/46.4 Testing your Auto-configuration.md diff --git a/IV. Spring Boot features/46.4 Testing your Auto-configuration.md b/IV. Spring Boot features/46.4 Testing your Auto-configuration.md new file mode 100644 index 00000000..3cb6f582 --- /dev/null +++ b/IV. Spring Boot features/46.4 Testing your Auto-configuration.md @@ -0,0 +1,45 @@ +### 46.4 测试你的自动配置 + +An auto-configuration can be affected by many factors: user configuration (`@Bean` definition and `Environment` customization), condition evaluation (presence of a particular library), and others. Concretely, each test should create a well defined `ApplicationContext` that represents a combination of those customizations. `ApplicationContextRunner` provides a great way to achieve that. + +`ApplicationContextRunner` is usually defined as a field of the test class to gather the base, common configuration. The following example makes sure that `UserServiceAutoConfiguration` is always invoked: +```java +private final ApplicationContextRunner contextRunner = new ApplicationContextRunner() + .withConfiguration(AutoConfigurations.of(UserServiceAutoConfiguration.class)); +``` + +**注** If multiple auto-configurations have to be defined, there is no need to order their declarations as they are invoked in the exact same order as when running the application. + +Each test can use the runner to represent a particular use case. For instance, the sample below invokes a user configuration (`UserConfiguration`) and checks that the auto-configuration backs off properly. Invoking `run` provides a callback context that can be used with `Assert4J`. +```java +@Test +public void defaultServiceBacksOff() { + this.contextRunner.withUserConfiguration(UserConfiguration.class) + .run((context) -> { + assertThat(context).hasSingleBean(UserService.class); + assertThat(context.getBean(UserService.class)).isSameAs( + context.getBean(UserConfiguration.class).myUserService()); + }); +} + +@Configuration +static class UserConfiguration { + + @Bean + public UserService myUserService() { + return new UserService("mine"); + } + +} +``` +It is also possible to easily customize the `Environment`, as shown in the following example: + +```java +@Test +public void serviceNameCanBeConfigured() { + this.contextRunner.withPropertyValues("user.name=test123").run((context) -> { + assertThat(context).hasSingleBean(UserService.class); + assertThat(context.getBean(UserService.class).getName()).isEqualTo("test123"); + }); +} +``` From 88f1d7a48b75c12d6e84597b9863f9fba6d9b14a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E7=83=AD=E5=BF=83=E5=B8=82=E6=B0=91=E9=92=9F=E5=B0=8F?= =?UTF-8?q?=E5=BC=BA?= Date: Mon, 8 Jul 2019 23:25:53 +0800 Subject: [PATCH 443/865] Create 46.4.1 Simulating a Web Context.md --- IV. Spring Boot features/46.4.1 Simulating a Web Context.md | 3 +++ 1 file changed, 3 insertions(+) create mode 100644 IV. Spring Boot features/46.4.1 Simulating a Web Context.md diff --git a/IV. Spring Boot features/46.4.1 Simulating a Web Context.md b/IV. Spring Boot features/46.4.1 Simulating a Web Context.md new file mode 100644 index 00000000..9ba58295 --- /dev/null +++ b/IV. Spring Boot features/46.4.1 Simulating a Web Context.md @@ -0,0 +1,3 @@ +### 46.4.1 模拟网络上下文 + +If you need to test an auto-configuration that only operates in a Servlet or Reactive web application context, use the `WebApplicationContextRunner` or `ReactiveWebApplicationContextRunner` respectively. From 2359bf70f9a447e798c885013eadcf7ad04aa4a1 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E7=83=AD=E5=BF=83=E5=B8=82=E6=B0=91=E9=92=9F=E5=B0=8F?= =?UTF-8?q?=E5=BC=BA?= Date: Mon, 8 Jul 2019 23:28:00 +0800 Subject: [PATCH 444/865] Create 46.4.2 Overriding the Classpath.md --- .../46.4.2 Overriding the Classpath.md | 10 ++++++++++ 1 file changed, 10 insertions(+) create mode 100644 IV. Spring Boot features/46.4.2 Overriding the Classpath.md diff --git a/IV. Spring Boot features/46.4.2 Overriding the Classpath.md b/IV. Spring Boot features/46.4.2 Overriding the Classpath.md new file mode 100644 index 00000000..06cd2419 --- /dev/null +++ b/IV. Spring Boot features/46.4.2 Overriding the Classpath.md @@ -0,0 +1,10 @@ +### 46.4.2 覆盖类路径 + +It is also possible to test what happens when a particular class and/or package is not present at runtime. Spring Boot ships with a `FilteredClassLoader` that can easily be used by the runner. In the following example, we assert that if `UserService` is not present, the auto-configuration is properly disabled: +```java +@Test +public void serviceIsIgnoredIfLibraryIsNotPresent() { + this.contextRunner.withClassLoader(new FilteredClassLoader(UserService.class)) + .run((context) -> assertThat(context).doesNotHaveBean("userService")); +} +``` From 226f4a03e4b4bfc864ae7e66be7a2a875afb455f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E7=83=AD=E5=BF=83=E5=B8=82=E6=B0=91=E9=92=9F=E5=B0=8F?= =?UTF-8?q?=E5=BC=BA?= Date: Tue, 9 Jul 2019 11:01:46 +0800 Subject: [PATCH 445/865] Update 46.4 Testing your Auto-configuration.md --- .../46.4 Testing your Auto-configuration.md | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/IV. Spring Boot features/46.4 Testing your Auto-configuration.md b/IV. Spring Boot features/46.4 Testing your Auto-configuration.md index 3cb6f582..08d31bdb 100644 --- a/IV. Spring Boot features/46.4 Testing your Auto-configuration.md +++ b/IV. Spring Boot features/46.4 Testing your Auto-configuration.md @@ -1,16 +1,16 @@ ### 46.4 测试你的自动配置 -An auto-configuration can be affected by many factors: user configuration (`@Bean` definition and `Environment` customization), condition evaluation (presence of a particular library), and others. Concretely, each test should create a well defined `ApplicationContext` that represents a combination of those customizations. `ApplicationContextRunner` provides a great way to achieve that. +自动配置会受很多因素影响:用户配置(`@Bean`定义与`Environment`自定义)、状况评估(存在特定库)等。具体地,每个测试应当创建一个定义良好的`ApplicationContext`。它代表了那些自定义的结合。`ApplicationContextRunner`提供了达成这种目标的好办法。 -`ApplicationContextRunner` is usually defined as a field of the test class to gather the base, common configuration. The following example makes sure that `UserServiceAutoConfiguration` is always invoked: +`ApplicationContextRunner`经常会定义成测试类的实例变量,用来收集基础的、普遍的配置。下面的例子确保了`UserServiceAutoConfiguration`总是会被调用: ```java private final ApplicationContextRunner contextRunner = new ApplicationContextRunner() .withConfiguration(AutoConfigurations.of(UserServiceAutoConfiguration.class)); ``` -**注** If multiple auto-configurations have to be defined, there is no need to order their declarations as they are invoked in the exact same order as when running the application. +**注** 如果不得不定义多个自动配置,不需要对它们的声明排序,因为会和应用运行时完全相同的顺序调用它们。 -Each test can use the runner to represent a particular use case. For instance, the sample below invokes a user configuration (`UserConfiguration`) and checks that the auto-configuration backs off properly. Invoking `run` provides a callback context that can be used with `Assert4J`. +每个测试可以使用runner代表一个特殊的使用案例。例如,下面的样本调用了一个用户配置(`UserConfiguration`),并且检查自动配置是否没有采用。调用`run`方法提供了一个回调上下文。它可以与`Assert4J`一起使用。 ```java @Test public void defaultServiceBacksOff() { @@ -32,8 +32,8 @@ static class UserConfiguration { } ``` -It is also possible to easily customize the `Environment`, as shown in the following example: +也可以很容易地自定义`Environment`。如下所示: ```java @Test public void serviceNameCanBeConfigured() { From da8ccec24e49662a6efe3faa746c8bc55cf6f9ac Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E7=83=AD=E5=BF=83=E5=B8=82=E6=B0=91=E9=92=9F=E5=B0=8F?= =?UTF-8?q?=E5=BC=BA?= Date: Tue, 9 Jul 2019 11:07:36 +0800 Subject: [PATCH 446/865] Update 46.4.1 Simulating a Web Context.md --- IV. Spring Boot features/46.4.1 Simulating a Web Context.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/IV. Spring Boot features/46.4.1 Simulating a Web Context.md b/IV. Spring Boot features/46.4.1 Simulating a Web Context.md index 9ba58295..204451ec 100644 --- a/IV. Spring Boot features/46.4.1 Simulating a Web Context.md +++ b/IV. Spring Boot features/46.4.1 Simulating a Web Context.md @@ -1,3 +1,3 @@ ### 46.4.1 模拟网络上下文 -If you need to test an auto-configuration that only operates in a Servlet or Reactive web application context, use the `WebApplicationContextRunner` or `ReactiveWebApplicationContextRunner` respectively. +如果你需要测试一个只在Servlet和Reactive网络应用上下文里操作的自动配置,分别使用`WebApplicationContextRunner`和`ReactiveWebApplicationContextRunner`。 From ad309064d4366ce574379fda11775d3b02746ed9 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E7=83=AD=E5=BF=83=E5=B8=82=E6=B0=91=E9=92=9F=E5=B0=8F?= =?UTF-8?q?=E5=BC=BA?= Date: Tue, 9 Jul 2019 11:20:53 +0800 Subject: [PATCH 447/865] Update 46.4.2 Overriding the Classpath.md --- IV. Spring Boot features/46.4.2 Overriding the Classpath.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/IV. Spring Boot features/46.4.2 Overriding the Classpath.md b/IV. Spring Boot features/46.4.2 Overriding the Classpath.md index 06cd2419..05690db4 100644 --- a/IV. Spring Boot features/46.4.2 Overriding the Classpath.md +++ b/IV. Spring Boot features/46.4.2 Overriding the Classpath.md @@ -1,6 +1,6 @@ ### 46.4.2 覆盖类路径 -It is also possible to test what happens when a particular class and/or package is not present at runtime. Spring Boot ships with a `FilteredClassLoader` that can easily be used by the runner. In the following example, we assert that if `UserService` is not present, the auto-configuration is properly disabled: +测试当一个特殊的类或者包在运行时不存在的时候会发生什么也是可能的。Spring Boot提供了`FilteredClassLoader`。runner可以容易的使用它。在下面的例子里,我们断言如果`UserService`不存在,自动配置会正确地禁用: ```java @Test public void serviceIsIgnoredIfLibraryIsNotPresent() { From 0c6056c6abf672ecf4b451f7a8889077a741a0be Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E7=83=AD=E5=BF=83=E5=B8=82=E6=B0=91=E9=92=9F=E5=B0=8F?= =?UTF-8?q?=E5=BC=BA?= Date: Tue, 9 Jul 2019 11:26:59 +0800 Subject: [PATCH 448/865] Update SUMMARY.md --- SUMMARY.md | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/SUMMARY.md b/SUMMARY.md index 49036dbb..4b15b16f 100644 --- a/SUMMARY.md +++ b/SUMMARY.md @@ -299,10 +299,10 @@ * [46.4 测试你的自动配置](IV. Spring Boot features/46.4 Testing your Auto-configuration.md) * [46.4.1 模拟网络上下文](IV. Spring Boot features/46.4.1 Simulating a Web Context.md) * [46.4.2 覆盖类路径](IV. Spring Boot features/46.4.2 Overriding the Classpath.md) - * [46.4 创建自己的starter](IV. Spring Boot features/46.4 Creating your own starter.md) - * [46.4.1 命名](IV. Spring Boot features/46.4.1 Naming.md) - * [46.4.2 自动配置模块](IV. Spring Boot features/46.4.2 Autoconfigure module.md) - * [46.4.3 Starter模块](IV. Spring Boot features/46.4.3 Starter module.md) + * [46.5 创建自己的starter](IV. Spring Boot features/46.5 Creating Your Own Starter.md) + * [46.5.1 命名](IV. Spring Boot features/46.5.1 Naming.md) + * [46.5.2 自动配置模块](IV. Spring Boot features/46.5.2 Autoconfigure Module.md) + * [46.5.3 Starter模块](IV. Spring Boot features/46.5.3 Starter Module.md) * [47. 接下来阅读什么](IV. Spring Boot features/47. What to read next.md) * [V. Spring Boot执行器: Production-ready特性](V. Spring Boot Actuator/README.md) * [47. 开启production-ready特性](V. Spring Boot Actuator/47. Enabling production-ready features.md) From bff160e0768d4614132c83941155b106a6b8fd90 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E7=83=AD=E5=BF=83=E5=B8=82=E6=B0=91=E9=92=9F=E5=B0=8F?= =?UTF-8?q?=E5=BC=BA?= Date: Tue, 9 Jul 2019 11:35:11 +0800 Subject: [PATCH 449/865] Update and rename 45.4 Creating your own starter.md to 46.5 Creating Your Own Starter.md --- ...g your own starter.md => 46.5 Creating Your Own Starter.md} | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) rename IV. Spring Boot features/{45.4 Creating your own starter.md => 46.5 Creating Your Own Starter.md} (92%) diff --git a/IV. Spring Boot features/45.4 Creating your own starter.md b/IV. Spring Boot features/46.5 Creating Your Own Starter.md similarity index 92% rename from IV. Spring Boot features/45.4 Creating your own starter.md rename to IV. Spring Boot features/46.5 Creating Your Own Starter.md index 421b3b9b..dc88d4dd 100644 --- a/IV. Spring Boot features/45.4 Creating your own starter.md +++ b/IV. Spring Boot features/46.5 Creating Your Own Starter.md @@ -1,4 +1,5 @@ -###45.4 创建自己的starter +### 46.5 创建自己的starter + 一个完整的Spring Boot starter可能包含以下组件: * `autoconfigure`模块,包含自动配置类的代码。 From f0dc19d18aca208f75395cfca74dd5002377ed59 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E7=83=AD=E5=BF=83=E5=B8=82=E6=B0=91=E9=92=9F=E5=B0=8F?= =?UTF-8?q?=E5=BC=BA?= Date: Tue, 9 Jul 2019 11:56:33 +0800 Subject: [PATCH 450/865] Update and rename 45.4.1 Naming.md to 46.5.1 Naming.md --- IV. Spring Boot features/45.4.1 Naming.md | 8 -------- IV. Spring Boot features/46.5.1 Naming.md | 9 +++++++++ 2 files changed, 9 insertions(+), 8 deletions(-) delete mode 100644 IV. Spring Boot features/45.4.1 Naming.md create mode 100644 IV. Spring Boot features/46.5.1 Naming.md diff --git a/IV. Spring Boot features/45.4.1 Naming.md b/IV. Spring Boot features/45.4.1 Naming.md deleted file mode 100644 index 7cf76829..00000000 --- a/IV. Spring Boot features/45.4.1 Naming.md +++ /dev/null @@ -1,8 +0,0 @@ -###45.4.1 命名 -确保为你的starter提供一个合适的命名空间(namespace),模块名不要以`spring-boot`作为开头,尽管使用一个不同的Maven groupId,未来我们可能会为你正在做的自动配置提供官方支持。 - -这里是经验之谈,假设你正在为“acme”创建一个starter,命名自动配置模块为`acme-spring-boot-autoconfigure`,命名starter为`acme-spring-boot-starter`,如果只有一个模块结合它们,通常会使用`acme-spring-boot-starter`。 - -此外,如果你的starter提供配置keys,需要为它们提供一个合适的命名空间,特别是不要使用Spring Boot的命名空间(比如,`server`,`management`,`spring`等),这些是属于Spring Boot的,我们可能会在将来以相同方式提高/修改它们,这可能会破坏你的东西。 - -确保[触发meta-data生成](http://docs.spring.io/spring-boot/docs/2.0.0.RELEASE/reference/htmlsingle/#configuration-metadata-annotation-processor),这样IDE辅助也就可以用于你的keys了,你可能想检查生成的元数据(`META-INF/spring-configuration-metadata.json`)以确保keys被正确的文档化。 diff --git a/IV. Spring Boot features/46.5.1 Naming.md b/IV. Spring Boot features/46.5.1 Naming.md new file mode 100644 index 00000000..91c643ce --- /dev/null +++ b/IV. Spring Boot features/46.5.1 Naming.md @@ -0,0 +1,9 @@ +### 46.5.1 命名 + +你应该确保为你的starter提供一个合适的命名空间。即使使用一个不同的Maven groupId,模块名也不要以`spring-boot`作为开头。未来我们可能会为你正在做的自动配置提供官方支持。 + +这里是经验之谈:你应该在starter之后命名一个组合模块。例如,假设你正在为“acme”创建一个starter,命名自动配置模块为`acme-spring-boot-autoconfigure`,命名starter为`acme-spring-boot-starter`。如果只有一个模块结合它们,通常会使用`acme-spring-boot-starter`。 + +此外,如果你的starter提供配置key,需要为它们提供一个唯一的命名空间,特别是不要使用Spring Boot的命名空间(比如,`server`、`management`、`spring`等)。我们可能会在将来修改它们。如果你使用相同的命名空间,这可能会破坏你的模块。 + +确保[触发meta-data生成](https://docs.spring.io/spring-boot/docs/2.0.0.RELEASE/reference/htmlsingle/#configuration-metadata-annotation-processor),这样IDE辅助也就可以用于你的key了。你可能想检查生成的元数据(`META-INF/spring-configuration-metadata.json`)以确保key被正确的文档化。 From fd367cca5aeb2d40685bc9b33bec6a140b7e32f3 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E7=83=AD=E5=BF=83=E5=B8=82=E6=B0=91=E9=92=9F=E5=B0=8F?= =?UTF-8?q?=E5=BC=BA?= Date: Tue, 9 Jul 2019 13:36:44 +0800 Subject: [PATCH 451/865] Update and rename 45.4.2 Autoconfigure module.md to 46.5.2 Autoconfigure Module.md --- ...utoconfigure module.md => 46.5.2 Autoconfigure Module.md} | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) rename IV. Spring Boot features/{45.4.2 Autoconfigure module.md => 46.5.2 Autoconfigure Module.md} (63%) diff --git a/IV. Spring Boot features/45.4.2 Autoconfigure module.md b/IV. Spring Boot features/46.5.2 Autoconfigure Module.md similarity index 63% rename from IV. Spring Boot features/45.4.2 Autoconfigure module.md rename to IV. Spring Boot features/46.5.2 Autoconfigure Module.md index de0ffcea..d5423cfd 100644 --- a/IV. Spring Boot features/45.4.2 Autoconfigure module.md +++ b/IV. Spring Boot features/46.5.2 Autoconfigure Module.md @@ -1,4 +1,5 @@ -###45.4.2 自动配置模块 -自动配置模块包含了使用该library需要的任何东西,它可能还包含配置的keys定义(`@ConfigurationProperties`)和用于定义组件如何初始化的回调接口。 +### 46.5.2 自动配置模块 + +自动配置模块包含了使用该library需要的任何东西,它可能还包含配置的key定义(例如`@ConfigurationProperties`)和用于定义组件如何初始化的回调接口。 **注** 你需要将对该library的依赖标记为可选的,这样在项目中添加该自动配置模块就更容易了。如果你这样做,该library将不会提供,Spring Boot会回退到默认设置。 From 890d22ef67971c9d68da2673bca0f676fb8631b4 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E7=83=AD=E5=BF=83=E5=B8=82=E6=B0=91=E9=92=9F=E5=B0=8F?= =?UTF-8?q?=E5=BC=BA?= Date: Tue, 9 Jul 2019 14:15:12 +0800 Subject: [PATCH 452/865] Update and rename 45.4.3 Starter module.md to 46.5.3 Starter Module.md --- IV. Spring Boot features/45.4.3 Starter module.md | 2 -- IV. Spring Boot features/46.5.3 Starter Module.md | 7 +++++++ 2 files changed, 7 insertions(+), 2 deletions(-) delete mode 100644 IV. Spring Boot features/45.4.3 Starter module.md create mode 100644 IV. Spring Boot features/46.5.3 Starter Module.md diff --git a/IV. Spring Boot features/45.4.3 Starter module.md b/IV. Spring Boot features/45.4.3 Starter module.md deleted file mode 100644 index 099b1e1b..00000000 --- a/IV. Spring Boot features/45.4.3 Starter module.md +++ /dev/null @@ -1,2 +0,0 @@ -###45.4.3 Starter模块 -starter模块实际是一个空jar,它的目的是提供使用该library所需的必要依赖。不要对添加你的starter的项目做任何假设,如果你正在自动配置的library需要其他starters,一定要提到它。提供一个合适的默认依赖集可能比较困难,特别是存在大量可选依赖时,你应该避免引入任何非必需的依赖。 diff --git a/IV. Spring Boot features/46.5.3 Starter Module.md b/IV. Spring Boot features/46.5.3 Starter Module.md new file mode 100644 index 00000000..f5865571 --- /dev/null +++ b/IV. Spring Boot features/46.5.3 Starter Module.md @@ -0,0 +1,7 @@ +### 46.5.3 Starter模块 + +starter模块实际是一个空jar。它的目的是提供使用该library所需的必要依赖。 + +不要对添加你的starter的项目做任何假设。如果你正在自动配置的library需要其他starter,一定要提到它。提供一个合适的默认依赖集可能比较困难,特别是存在大量可选依赖时,你应该避免引入任何非必需的依赖。换句话说,不应当包含可选的依赖。 + +**注** 无论哪种方式,你的starter必须直接或间接(如果你的starter依赖另外的starter,就不需要添加)地引用核心的Spring Boot starter(`spring-boot-starter`)。 如果一个项目只用你自定义的starter创建,Spring Boot的核心特性会因为核心starter的存在而启用。 From 10ca271f0bbed62efdec4e7766a9f16bc62c8b89 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E7=83=AD=E5=BF=83=E5=B8=82=E6=B0=91=E9=92=9F=E5=B0=8F?= =?UTF-8?q?=E5=BC=BA?= Date: Wed, 10 Jul 2019 11:54:31 +0800 Subject: [PATCH 453/865] Update SUMMARY.md --- SUMMARY.md | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) diff --git a/SUMMARY.md b/SUMMARY.md index 4b15b16f..7989233a 100644 --- a/SUMMARY.md +++ b/SUMMARY.md @@ -303,7 +303,19 @@ * [46.5.1 命名](IV. Spring Boot features/46.5.1 Naming.md) * [46.5.2 自动配置模块](IV. Spring Boot features/46.5.2 Autoconfigure Module.md) * [46.5.3 Starter模块](IV. Spring Boot features/46.5.3 Starter Module.md) - * [47. 接下来阅读什么](IV. Spring Boot features/47. What to read next.md) + * [47. Kotlin支持](IV. Spring Boot features/47. Kotlin support.md) + * [47.1 要求](IV. Spring Boot features/47.1 Requirements.md) + * [47.2 空安全](IV. Spring Boot features/47.2 Null-safety.md) + * 47.3 Kotlin API + * [47.3.1 runApplication](IV. Spring Boot features/47.3.1 runApplication.md) + * [47.3.2 扩展](IV. Spring Boot features/47.3.2 Extensions.md) + * [47.4 依赖管理](IV. Spring Boot features/47.4 Dependency management.md) + * [47.5 @ConfigurationProperties](IV. Spring Boot features/47.5 @ConfigurationProperties.md) + * [47.6 测试](IV. Spring Boot features/47.6 Testing.md) + * 47.7 资源 + * [47.7.1 延伸阅读](IV. Spring Boot features/47.7.1 Further reading.md) + * [47.7.2 示例](IV. Spring Boot features/47.7.2 Examples.md) + * [48. 接下来阅读什么](IV. Spring Boot features/48. What to Read Next.md) * [V. Spring Boot执行器: Production-ready特性](V. Spring Boot Actuator/README.md) * [47. 开启production-ready特性](V. Spring Boot Actuator/47. Enabling production-ready features.md) * [48. 端点](V. Spring Boot Actuator/48. Endpoints.md) From b0e00632ca53de3a36da4adaf72ba171e538fe3f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E7=83=AD=E5=BF=83=E5=B8=82=E6=B0=91=E9=92=9F=E5=B0=8F?= =?UTF-8?q?=E5=BC=BA?= Date: Thu, 11 Jul 2019 15:32:30 +0800 Subject: [PATCH 454/865] Create 47. Kotlin support.md --- IV. Spring Boot features/47. Kotlin support.md | 7 +++++++ 1 file changed, 7 insertions(+) create mode 100644 IV. Spring Boot features/47. Kotlin support.md diff --git a/IV. Spring Boot features/47. Kotlin support.md b/IV. Spring Boot features/47. Kotlin support.md new file mode 100644 index 00000000..edd7cfcb --- /dev/null +++ b/IV. Spring Boot features/47. Kotlin support.md @@ -0,0 +1,7 @@ +### 47. Kotlin支持 + +[Kotlin](https://kotlinlang.org/)是一种面向JVM(以及其它平台)的静态类型语言。它允许编写简洁优雅的代码,并且提供了与既存Java库的[互操作性](https://kotlinlang.org/docs/reference/java-interop.html)。 + +Spring Boot通过利用Spring Framework、Spring Data和Reactor等其它Spring项目中的支持来提供Kotlin支持。更多信息请查看[Spring框架Kotlin支持文档](https://docs.spring.io/spring/docs/5.0.4.RELEASE/spring-framework-reference/languages.html#kotlin)。 + +通过[start.spring.io](https://start.spring.io/#!language=kotlin)创建项目是开始使用Spring Boot与Kotlin的最简单方式。如果你需要帮助,欢迎加入[Kotlin Slack](http://slack.kotlinlang.org/)的#spring频道。或者在[Stack Overflow](https://stackoverflow.com/questions/tagged/spring+kotlin)上带上`spring`与`kotlin`标签问问题。 From f7f9f42a52c1a4667dcd7b7962d6af40259ad31b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E7=83=AD=E5=BF=83=E5=B8=82=E6=B0=91=E9=92=9F=E5=B0=8F?= =?UTF-8?q?=E5=BC=BA?= Date: Fri, 12 Jul 2019 10:08:18 +0800 Subject: [PATCH 455/865] Create 47.1 Requirements.md --- IV. Spring Boot features/47.1 Requirements.md | 9 +++++++++ 1 file changed, 9 insertions(+) create mode 100644 IV. Spring Boot features/47.1 Requirements.md diff --git a/IV. Spring Boot features/47.1 Requirements.md b/IV. Spring Boot features/47.1 Requirements.md new file mode 100644 index 00000000..1128c007 --- /dev/null +++ b/IV. Spring Boot features/47.1 Requirements.md @@ -0,0 +1,9 @@ +### 47.1 要求 + +Spring Boot支持Kotlin 1.2.x。要使用Kotlin的话,类路径上必须存在`org.jetbrains.kotlin:kotlin-stdlib`和`org.jetbrains.kotlin:kotlin-reflect`。也可以使用`kotlin-stdlib`的变体`kotlin-stdlib-jdk7`与`kotlin-stdlib-jdk8`。 + +由于[Kotlin类默认是final的](https://discuss.kotlinlang.org/t/classes-final-by-default/166),你可能想要配置[kotlin-spring](https://kotlinlang.org/docs/reference/compiler-plugins.html#spring-support)插件,好自动打开Spring注解的类。这样,它们就能被代理了。 + +在Kotlin里序列化/反序列化JSON数据需要[Jackson’s Kotlin模块](https://github.com/FasterXML/jackson-module-kotlin)。类路径上存在时,它会被自动注册。如果存在Jackson和Kotlin,却没有Jackson Kotlin模块,会打印出一条警告信息。 + +**注** 如果你使用[start.spring.io](https://start.spring.io/#!language=kotlin)开始你的Kotlin项目,默认会提供这些依赖和插件。 From a5d1ed156d270e8d48817936646462288021383b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E7=83=AD=E5=BF=83=E5=B8=82=E6=B0=91=E9=92=9F=E5=B0=8F?= =?UTF-8?q?=E5=BC=BA?= Date: Sat, 13 Jul 2019 10:39:50 +0800 Subject: [PATCH 456/865] Create 47.2 Null-safety.md --- IV. Spring Boot features/47.2 Null-safety.md | 9 +++++++++ 1 file changed, 9 insertions(+) create mode 100644 IV. Spring Boot features/47.2 Null-safety.md diff --git a/IV. Spring Boot features/47.2 Null-safety.md b/IV. Spring Boot features/47.2 Null-safety.md new file mode 100644 index 00000000..5e5dff6d --- /dev/null +++ b/IV. Spring Boot features/47.2 Null-safety.md @@ -0,0 +1,9 @@ +### 47.2 空安全 + +One of Kotlin’s key features is [null-safety](https://kotlinlang.org/docs/reference/null-safety.html). It deals with `null` values at compile time rather than deferring the problem to runtime and encountering a `NullPointerException`. This helps to eliminate a common source of bugs without paying the cost of wrappers like `Optional`. Kotlin also allows using functional constructs with nullable values as described in this [comprehensive guide to null-safety in Kotlin](http://www.baeldung.com/kotlin-null-safety). + +Although Java does not allow one to express null-safety in its type system, Spring Framework, Spring Data, and Reactor now provide null-safety of their API via tooling-friendly annotations. By default, types from Java APIs used in Kotlin are recognized as [platform types](https://kotlinlang.org/docs/reference/java-interop.html#null-safety-and-platform-types) for which null-checks are relaxed. [Kotlin’s support for JSR 305 annotations](https://kotlinlang.org/docs/reference/java-interop.html#jsr-305-support) combined with nullability annotations provide null-safety for the related Spring API in Kotlin. + +The JSR 305 checks can be configured by adding the `-Xjsr305` compiler flag with the following options: `-Xjsr305={strict|warn|ignore}`. The default behavior is the same as `-Xjsr305=warn`. The `strict` value is required to have null-safety taken in account in Kotlin types inferred from Spring API but should be used with the knowledge that Spring API nullability declaration could evolve even between minor releases and more checks may be added in the future). + +WARN: Generic type arguments, varargs and array elements nullability are not yet supported. See [SPR-15942](https://jira.spring.io/browse/SPR-15942) for up-to-date information. Also be aware that Spring Boot’s own API is [not yet annotated](https://github.com/spring-projects/spring-boot/issues/10712). From 34ca8bd09047e3ee827f87ffe60b0bebf23d28d4 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E7=83=AD=E5=BF=83=E5=B8=82=E6=B0=91=E9=92=9F=E5=B0=8F?= =?UTF-8?q?=E5=BC=BA?= Date: Sat, 13 Jul 2019 13:36:52 +0800 Subject: [PATCH 457/865] Update 47.2 Null-safety.md --- IV. Spring Boot features/47.2 Null-safety.md | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/IV. Spring Boot features/47.2 Null-safety.md b/IV. Spring Boot features/47.2 Null-safety.md index 5e5dff6d..1646a5f5 100644 --- a/IV. Spring Boot features/47.2 Null-safety.md +++ b/IV. Spring Boot features/47.2 Null-safety.md @@ -1,9 +1,9 @@ ### 47.2 空安全 -One of Kotlin’s key features is [null-safety](https://kotlinlang.org/docs/reference/null-safety.html). It deals with `null` values at compile time rather than deferring the problem to runtime and encountering a `NullPointerException`. This helps to eliminate a common source of bugs without paying the cost of wrappers like `Optional`. Kotlin also allows using functional constructs with nullable values as described in this [comprehensive guide to null-safety in Kotlin](http://www.baeldung.com/kotlin-null-safety). +[空安全](https://kotlinlang.org/docs/reference/null-safety.html)是Kotlin的关键特性之一。它会在编译时处理`null`值,而不是等到运行时才处理然后不幸遇到了`NullPointerException`。这有助于消除一个普遍的bug源头,并且不需要花费包装器的开销,比如`Optional`。Kotlin也允许使用带有可空值的函数式的构造器。就像[Kotlin里空安全的全面指南](http://www.baeldung.com/kotlin-null-safety)里描述的那样。 -Although Java does not allow one to express null-safety in its type system, Spring Framework, Spring Data, and Reactor now provide null-safety of their API via tooling-friendly annotations. By default, types from Java APIs used in Kotlin are recognized as [platform types](https://kotlinlang.org/docs/reference/java-interop.html#null-safety-and-platform-types) for which null-checks are relaxed. [Kotlin’s support for JSR 305 annotations](https://kotlinlang.org/docs/reference/java-interop.html#jsr-305-support) combined with nullability annotations provide null-safety for the related Spring API in Kotlin. +尽管Java不允许在它的类型系统里表达空安全,Spring框架、Spring Data和Reactor现在通过工具友好的注解,提供了它们API的空安全。默认的,Kotlin里使用的来自Java API的类型被认为是[平台类型](https://kotlinlang.org/docs/reference/java-interop.html#null-safety-and-platform-types)。平台类型的null检查是宽松的。[对JSR 305注解的Kotlin支持](https://kotlinlang.org/docs/reference/java-interop.html#jsr-305-support)连同为空性注解,提供了Kotlin里相关Spring API的空安全。 -The JSR 305 checks can be configured by adding the `-Xjsr305` compiler flag with the following options: `-Xjsr305={strict|warn|ignore}`. The default behavior is the same as `-Xjsr305=warn`. The `strict` value is required to have null-safety taken in account in Kotlin types inferred from Spring API but should be used with the knowledge that Spring API nullability declaration could evolve even between minor releases and more checks may be added in the future). +JSR 305检查可以通过添加`-Xjsr305`编译器标记配置。该标识可以是以下选项:`-Xjsr305={strict|warn|ignore}`。默认行为与`-Xjsr305=warn`相同。由Spring API推断来的Kotlin类型考虑空安全需要`strict`值。但是应当在具备以下认识的情况下使用:Spring API可空性声明甚至会在小版本发布之间进化,并且可能会在未来加入更多的检查。 -WARN: Generic type arguments, varargs and array elements nullability are not yet supported. See [SPR-15942](https://jira.spring.io/browse/SPR-15942) for up-to-date information. Also be aware that Spring Boot’s own API is [not yet annotated](https://github.com/spring-projects/spring-boot/issues/10712). +**警告** 泛型参数、可变参数和数组元素的可空性还不被支持。最新信息请查看[SPR-15942](https://jira.spring.io/browse/SPR-15942)。Spring Boot自己的API[也还没有被注解](https://github.com/spring-projects/spring-boot/issues/10712). From 34f28aeafbcadca858fc85f3fdc741ef21b23386 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E7=83=AD=E5=BF=83=E5=B8=82=E6=B0=91=E9=92=9F=E5=B0=8F?= =?UTF-8?q?=E5=BC=BA?= Date: Mon, 15 Jul 2019 10:28:32 +0800 Subject: [PATCH 458/865] Create 47.3.1 runApplication.md --- .../47.3.1 runApplication.md | 20 +++++++++++++++++++ 1 file changed, 20 insertions(+) create mode 100644 IV. Spring Boot features/47.3.1 runApplication.md diff --git a/IV. Spring Boot features/47.3.1 runApplication.md b/IV. Spring Boot features/47.3.1 runApplication.md new file mode 100644 index 00000000..ffc62b95 --- /dev/null +++ b/IV. Spring Boot features/47.3.1 runApplication.md @@ -0,0 +1,20 @@ +### 47.3.1 runApplication + +Spring Boot提供了用`runApplication(*args)`运行应用的惯用方式。如下所示: +```java +import org.springframework.boot.autoconfigure.SpringBootApplication +import org.springframework.boot.runApplication + +@SpringBootApplication +class FooApplication + +fun main(args: Array) { + runApplication(*args) +} +``` +这是`SpringApplication.run(FooApplication::class.java, *args)`的替代品。它也允许自定义应用。如下所示: +```java +runApplication(*args) { + setBannerMode(OFF) +} +``` From 0943f81213e50efb0302ff7b98e7fb7ad809e67c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E7=83=AD=E5=BF=83=E5=B8=82=E6=B0=91=E9=92=9F=E5=B0=8F?= =?UTF-8?q?=E5=BC=BA?= Date: Mon, 15 Jul 2019 16:14:19 +0800 Subject: [PATCH 459/865] Create 47.3.2 Extensions.md --- IV. Spring Boot features/47.3.2 Extensions.md | 5 +++++ 1 file changed, 5 insertions(+) create mode 100644 IV. Spring Boot features/47.3.2 Extensions.md diff --git a/IV. Spring Boot features/47.3.2 Extensions.md b/IV. Spring Boot features/47.3.2 Extensions.md new file mode 100644 index 00000000..9296f918 --- /dev/null +++ b/IV. Spring Boot features/47.3.2 Extensions.md @@ -0,0 +1,5 @@ +### 47.3.2 扩展 + +Kotlin[扩展](https://kotlinlang.org/docs/reference/extensions.html)提供了既存类扩展额外功能的能力。Spring Boot Kotlin API使用这些扩展给既存的API添加新的Kotlin特定的便利。 + +提供了`TestRestTemplate`扩展。它类似于Spring框架提供的`RestOperations`。此外,扩展能够发挥Kotlin具体化参数类型的优势。 From ac201ad6842c36bf0da4d88f0666c454a1e440e9 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E7=83=AD=E5=BF=83=E5=B8=82=E6=B0=91=E9=92=9F=E5=B0=8F?= =?UTF-8?q?=E5=BC=BA?= Date: Mon, 15 Jul 2019 17:07:08 +0800 Subject: [PATCH 460/865] Create 47.4 Dependency management.md --- .../47.4 Dependency management.md | 13 +++++++++++++ 1 file changed, 13 insertions(+) create mode 100644 IV. Spring Boot features/47.4 Dependency management.md diff --git a/IV. Spring Boot features/47.4 Dependency management.md b/IV. Spring Boot features/47.4 Dependency management.md new file mode 100644 index 00000000..909e4af7 --- /dev/null +++ b/IV. Spring Boot features/47.4 Dependency management.md @@ -0,0 +1,13 @@ +### 47.4 依赖管理 + +为了避免混淆类路径上Kotlin依赖的不同版本,Spring Boot提供了下列Kotlin依赖的依赖管理。 + +- `kotlin-reflect` +- `kotlin-runtime` +- `kotlin-stdlib` +- `kotlin-stdlib-jdk7` +- `kotlin-stdlib-jdk8` +- `kotlin-stdlib-jre7` +- `kotlin-stdlib-jre8` + +如果你用的是Maven,Kotlin版本可以通过`kotlin.version`属性自定义。并且,Maven为`kotlin-maven-plugin`提供了插件管理。如果你用的是Gradle,Spring Boot插件会自动把`kotlin.version`定义为Kotlin插件的版本。 From ccd94aa463945b9462320f5f8a420f92301bf0bf Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E7=83=AD=E5=BF=83=E5=B8=82=E6=B0=91=E9=92=9F=E5=B0=8F?= =?UTF-8?q?=E5=BC=BA?= Date: Tue, 16 Jul 2019 09:45:41 +0800 Subject: [PATCH 461/865] Create 47.5 @ConfigurationProperties.md --- .../47.5 @ConfigurationProperties.md | 23 +++++++++++++++++++ 1 file changed, 23 insertions(+) create mode 100644 IV. Spring Boot features/47.5 @ConfigurationProperties.md diff --git a/IV. Spring Boot features/47.5 @ConfigurationProperties.md b/IV. Spring Boot features/47.5 @ConfigurationProperties.md new file mode 100644 index 00000000..d1ce2e10 --- /dev/null +++ b/IV. Spring Boot features/47.5 @ConfigurationProperties.md @@ -0,0 +1,23 @@ +### 47.5 @ConfigurationProperties + +`@ConfigurationProperties`目前只对`lateinit`或者可为空的`var`属性(推荐前者)生效。由于不可变类由构造器初始化,所以[还不被支持](https://github.com/spring-projects/spring-boot/issues/8762)。 +```java +@ConfigurationProperties("example.kotlin") +class KotlinExampleProperties { + + lateinit var foo1: String + + lateinit var foo2: String + + lateinit val bar = Bar() + + class Bar { + + lateinit var bar1: String + + lateinit var bar2: String + + } + +} +``` From 0a51a6fb387a3f6a88aff9b90245af1bbbae13ec Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E7=83=AD=E5=BF=83=E5=B8=82=E6=B0=91=E9=92=9F=E5=B0=8F?= =?UTF-8?q?=E5=BC=BA?= Date: Tue, 16 Jul 2019 15:51:26 +0800 Subject: [PATCH 462/865] Create 47.6 Testing.md --- IV. Spring Boot features/47.6 Testing.md | 5 +++++ 1 file changed, 5 insertions(+) create mode 100644 IV. Spring Boot features/47.6 Testing.md diff --git a/IV. Spring Boot features/47.6 Testing.md b/IV. Spring Boot features/47.6 Testing.md new file mode 100644 index 00000000..f98cd191 --- /dev/null +++ b/IV. Spring Boot features/47.6 Testing.md @@ -0,0 +1,5 @@ +### 47.6 测试 + +虽然可以使用JUnit 4(`spring-boot-starter-test`提供的默认版本)测试Kotlin代码,但是推荐JUnit 5。JUnit 5使一个测试类可以被实例化,然后被这个类的所有测试重复使用。这使它可以在非静态方法上使用`@BeforeAll`和`@AfterAll`注解,非常适合Kotlin。 + +使用JUnit 5,需要从`spring-boot-starter-test`里排除`junit:junit`依赖,添加JUnit 5依赖,并且相应地配置Maven或者Gradle插件。更多详情请查看[JUnit 5文档](https://junit.org/junit5/docs/current/user-guide/#dependency-metadata-junit-jupiter-samples)。你也需要[将测试实例的生命周期切换到“每个类”](https://junit.org/junit5/docs/current/user-guide/#writing-tests-test-instance-lifecycle-changing-default)。 From 5bc17f0e8dc362f2e2c942487586ddbc0a5c6612 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E7=83=AD=E5=BF=83=E5=B8=82=E6=B0=91=E9=92=9F=E5=B0=8F?= =?UTF-8?q?=E5=BC=BA?= Date: Thu, 18 Jul 2019 09:48:59 +0800 Subject: [PATCH 463/865] Create 47.7.1 Further reading.md --- IV. Spring Boot features/47.7.1 Further reading.md | 12 ++++++++++++ 1 file changed, 12 insertions(+) create mode 100644 IV. Spring Boot features/47.7.1 Further reading.md diff --git a/IV. Spring Boot features/47.7.1 Further reading.md b/IV. Spring Boot features/47.7.1 Further reading.md new file mode 100644 index 00000000..0a4134fe --- /dev/null +++ b/IV. Spring Boot features/47.7.1 Further reading.md @@ -0,0 +1,12 @@ +### 47.7.1 延伸阅读 + +- [Kotlin语言参考](https://kotlinlang.org/docs/reference/) +- [Kotlin Slack](http://slack.kotlinlang.org/)(专用的#spring频道) +- [Stackoverflow,带上`spring`与`kotlin`标签](https://stackoverflow.com/questions/tagged/spring+kotlin) +- [在你的浏览器里尝试Kotlin](https://try.kotlinlang.org/) +- [Kotlin博客](https://blog.jetbrains.com/kotlin/) +- [牛逼的Kotlin](https://kotlin.link/) +- [用Kotlin开发Spring Boot应用](https://spring.io/blog/2016/02/15/developing-spring-boot-applications-with-kotlin) +- [用Kotlin、Spring Boot和PostgreSQL开发地理空间信使](https://spring.io/blog/2016/03/20/a-geospatial-messenger-with-kotlin-spring-boot-and-postgresql) +- [介绍Spring框架5.0里的Kotlin支持](https://spring.io/blog/2017/01/04/introducing-kotlin-support-in-spring-framework-5-0) +- [Spring Framework 5 Kotlin API,函数式方式](https://spring.io/blog/2017/08/01/spring-framework-5-kotlin-apis-the-functional-way) From 7b8f828ac372b4c948d399c23efc9d9a031c6f05 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E7=83=AD=E5=BF=83=E5=B8=82=E6=B0=91=E9=92=9F=E5=B0=8F?= =?UTF-8?q?=E5=BC=BA?= Date: Thu, 18 Jul 2019 10:05:22 +0800 Subject: [PATCH 464/865] Create 47.7.2 Examples.md --- IV. Spring Boot features/47.7.2 Examples.md | 7 +++++++ 1 file changed, 7 insertions(+) create mode 100644 IV. Spring Boot features/47.7.2 Examples.md diff --git a/IV. Spring Boot features/47.7.2 Examples.md b/IV. Spring Boot features/47.7.2 Examples.md new file mode 100644 index 00000000..b8eb5957 --- /dev/null +++ b/IV. Spring Boot features/47.7.2 Examples.md @@ -0,0 +1,7 @@ +### 47.7.2 示例 + +- [spring-boot-kotlin-demo](https://github.com/sdeleuze/spring-boot-kotlin-demo):常规的Spring Boot + Spring Data JPA项目 +- [mixit](https://github.com/mixitconf/mixit):Spring Boot 2 + WebFlux + Reactive Spring Data MongoDB +- [spring-kotlin-fullstack](https://github.com/sdeleuze/spring-kotlin-fullstack):WebFlux Kotlin全栈示例,前端使用Kotlin2js代替JavaScript或者TypeScript +- [spring-petclinic-kotlin](https://github.com/spring-petclinic/spring-petclinic-kotlin):Kotlin版本的Spring PetClinic示例应用 +- [spring-kotlin-deepdive](https://github.com/sdeleuze/spring-kotlin-deepdive):从Boot 1.0 + Java逐步迁移到Boot 2.0 + Kotlin From 64f94a5e84d6efb95bcbabb811f9b62d06646195 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E7=83=AD=E5=BF=83=E5=B8=82=E6=B0=91=E9=92=9F=E5=B0=8F?= =?UTF-8?q?=E5=BC=BA?= Date: Thu, 18 Jul 2019 10:19:29 +0800 Subject: [PATCH 465/865] Update and rename 46. What to read next.md to 48. What to Read Next.md --- IV. Spring Boot features/46. What to read next.md | 4 ---- IV. Spring Boot features/48. What to Read Next.md | 5 +++++ 2 files changed, 5 insertions(+), 4 deletions(-) delete mode 100644 IV. Spring Boot features/46. What to read next.md create mode 100644 IV. Spring Boot features/48. What to Read Next.md diff --git a/IV. Spring Boot features/46. What to read next.md b/IV. Spring Boot features/46. What to read next.md deleted file mode 100644 index b4bd7873..00000000 --- a/IV. Spring Boot features/46. What to read next.md +++ /dev/null @@ -1,4 +0,0 @@ -### 46. 接下来阅读什么 -如果想了解本章节讨论类的更多内容,你可以查看[Spring Boot API文档](http://docs.spring.io/spring-boot/docs/2.0.0.RELEASE/api),或直接浏览[源码](https://github.com/spring-projects/spring-boot/tree/v2.0.0.RELEASE)。如果有特别问题,可以参考[how-to](http://docs.spring.io/spring-boot/docs/2.0.0.RELEASE/reference/htmlsingle/#howto)章节。 - -如果已熟悉Spring Boot的核心特性,你可以继续并查看[production-ready特性](http://docs.spring.io/spring-boot/docs/2.0.0.RELEASE/reference/htmlsingle/#production-ready)。 diff --git a/IV. Spring Boot features/48. What to Read Next.md b/IV. Spring Boot features/48. What to Read Next.md new file mode 100644 index 00000000..8e870b16 --- /dev/null +++ b/IV. Spring Boot features/48. What to Read Next.md @@ -0,0 +1,5 @@ +### 48. 接下来阅读什么 + +如果想了解本章节讨论类的更多内容,你可以查看[Spring Boot API文档](https://docs.spring.io/spring-boot/docs/2.0.0.RELEASE/api),或直接浏览[源码](https://github.com/spring-projects/spring-boot/tree/v2.0.0.RELEASE)。如果有特别问题,可以参考[how-to](https://docs.spring.io/spring-boot/docs/2.0.0.RELEASE/reference/htmlsingle/#howto)章节。 + +如果已熟悉Spring Boot的核心特性,你可以继续并查看[production-ready特性](https://docs.spring.io/spring-boot/docs/2.0.0.RELEASE/reference/htmlsingle/#production-ready)。 From fbe9e4fd5e88c9669e896122eb4e244ba4cda876 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E7=83=AD=E5=BF=83=E5=B8=82=E6=B0=91=E9=92=9F=E5=B0=8F?= =?UTF-8?q?=E5=BC=BA?= Date: Fri, 19 Jul 2019 10:26:33 +0800 Subject: [PATCH 466/865] Update README.md --- V. Spring Boot Actuator/README.md | 2 -- 1 file changed, 2 deletions(-) diff --git a/V. Spring Boot Actuator/README.md b/V. Spring Boot Actuator/README.md index dd29eb85..e762854e 100644 --- a/V. Spring Boot Actuator/README.md +++ b/V. Spring Boot Actuator/README.md @@ -1,5 +1,3 @@ ### Spring Boot执行器:Production-ready特性 Spring Boot包含很多其他特性,可用来帮你监控和管理发布到生产环境的应用。你可以选择使用HTTP端点,或者JMX来管理和监控应用。审计(Auditing),健康(health)和数据采集(metrics gathering)会自动应用到你的应用。 - -Actuator HTTP端点只能用在基于Spring MVC的应用,特别地,它不能跟Jersey一块使用,除非你也[启用Spring MVC](https://docs.spring.io/spring-boot/docs/2.0.0.RELEASE/reference/htmlsingle/#howto-use-actuator-with-jersey)。 \ No newline at end of file From 8ca16c1793fd7a810e2b702247a0d6216417c08b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E7=83=AD=E5=BF=83=E5=B8=82=E6=B0=91=E9=92=9F=E5=B0=8F?= =?UTF-8?q?=E5=BC=BA?= Date: Fri, 19 Jul 2019 10:28:47 +0800 Subject: [PATCH 467/865] Update and rename 47. Enabling production-ready features.md to 49. Enabling Production-ready Features.md --- ...features.md => 49. Enabling Production-ready Features.md} | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) rename V. Spring Boot Actuator/{47. Enabling production-ready features.md => 49. Enabling Production-ready Features.md} (62%) diff --git a/V. Spring Boot Actuator/47. Enabling production-ready features.md b/V. Spring Boot Actuator/49. Enabling Production-ready Features.md similarity index 62% rename from V. Spring Boot Actuator/47. Enabling production-ready features.md rename to V. Spring Boot Actuator/49. Enabling Production-ready Features.md index b6242ce2..46f07668 100644 --- a/V. Spring Boot Actuator/47. Enabling production-ready features.md +++ b/V. Spring Boot Actuator/49. Enabling Production-ready Features.md @@ -1,5 +1,6 @@ -### 47. 开启production-ready特性 -[spring-boot-actuator](http://github.com/spring-projects/spring-boot/tree/master/spring-boot-actuator)模块提供Spring Boot所有的production-ready特性,启用该特性的最简单方式是添加`spring-boot-starter-actuator` ‘Starter’依赖。 +### 49. 开启production-ready特性 + +[spring-boot-actuator](https://github.com/spring-projects/spring-boot/tree/v2.0.0.RELEASE/spring-boot-project/spring-boot-actuator)模块提供Spring Boot所有的production-ready特性,启用该特性的最简单方式是添加`spring-boot-starter-actuator` ‘Starter’依赖。 **执行器(Actuator)的定义**:执行器是一个制造业术语,指的是用于移动或控制东西的一个机械装置,一个很小的改变就能让执行器产生大量的运动。 From cf33ba6390edbc84d060b34066eb6d5a862dd331 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E7=83=AD=E5=BF=83=E5=B8=82=E6=B0=91=E9=92=9F=E5=B0=8F?= =?UTF-8?q?=E5=BC=BA?= Date: Fri, 19 Jul 2019 10:45:26 +0800 Subject: [PATCH 468/865] Update SUMMARY.md --- SUMMARY.md | 116 ++++++++++++++++++++++++++--------------------------- 1 file changed, 58 insertions(+), 58 deletions(-) diff --git a/SUMMARY.md b/SUMMARY.md index 7989233a..c57f132f 100644 --- a/SUMMARY.md +++ b/SUMMARY.md @@ -317,64 +317,64 @@ * [47.7.2 示例](IV. Spring Boot features/47.7.2 Examples.md) * [48. 接下来阅读什么](IV. Spring Boot features/48. What to Read Next.md) * [V. Spring Boot执行器: Production-ready特性](V. Spring Boot Actuator/README.md) - * [47. 开启production-ready特性](V. Spring Boot Actuator/47. Enabling production-ready features.md) - * [48. 端点](V. Spring Boot Actuator/48. Endpoints.md) - * [48.1 自定义端点](V. Spring Boot Actuator/48.1 Customizing endpoints.md) - * [48.2 执行器MVC端点的超媒体支持](V. Spring Boot Actuator/48.2 Hypermedia for actuator MVC endpoints.md) - * [48.3 CORS支持](V. Spring Boot Actuator/48.3 CORS support.md) - * [48.4 添加自定义端点](V. Spring Boot Actuator/48.4 Adding custom endpoints.md) - * [48.5 健康信息](V. Spring Boot Actuator/48.5 Health information.md) - * [48.6 安全与HealthIndicators](V. Spring Boot Actuator/48.6 Security with HealthIndicators.md) - * [48.6.1 自动配置的HealthIndicators](V. Spring Boot Actuator/48.6.1 Auto-configured-HealthIndicators.md) - * [48.6.2 编写自定义HealthIndicators](V. Spring Boot Actuator/48.6.2 Writing custom HealthIndicators.md) - * [48.7 应用信息](V. Spring Boot Actuator/48.7 Application information.md) - * [48.7.1 自动配置的InfoContributors](V. Spring Boot Actuator/48.7.1 Auto-configured InfoContributors.md) - * [48.7.2 自定义应用info信息](V. Spring Boot Actuator/48.7.2 Custom application info information.md) - * [48.7.3 Git提交信息](V. Spring Boot Actuator/48.7.3 Git commit information.md) - * [48.7.4 构建信息](V. Spring Boot Actuator/48.7.4 Build information.md) - * [48.7.5 编写自定义的InfoContributors](V. Spring Boot Actuator/48.7.5 Writing custom InfoContributors.md) - * [49. 基于HTTP的监控和管理](V. Spring Boot Actuator/49. Monitoring and management over HTTP.md) - * [49.1 访问敏感端点](V. Spring Boot Actuator/49.1 Accessing sensitive endpoints.md) - * [49.2 自定义管理端点路径](V. Spring Boot Actuator/49.2 Customizing the management endpoint paths.md) - * [49.3 自定义管理服务器端口](V. Spring Boot Actuator/49.3 Customizing the management server port.md) - * [49.4 配置管理相关的SSL](V. Spring Boot Actuator/49.4 Configuring management-specific SSL.md) - * [49.5 自定义管理服务器地址](V. Spring Boot Actuator/49.5 Customizing the management server address.md) - * [49.6 禁用HTTP端点](V. Spring Boot Actuator/49.6 Disabling HTTP endpoints.md) - * [49.7 HTTP health端点访问限制](V. Spring Boot Actuator/49.7 HTTP Health endpoint access restrictions.md) - * [50. 基于JMX的监控和管理](V. Spring Boot Actuator/50. Monitoring and management over JMX.md) - * [50.1 自定义MBean名称](V. Spring Boot Actuator/50.1 Customizing MBean names.md) - * [50.2 禁用JMX端点](V. Spring Boot Actuator/50.2 Disabling JMX endpoints.md) - * [50.3 使用Jolokia通过HTTP实现JMX远程管理](V. Spring Boot Actuator/50.3 Using Jolokia for JMX over HTTP.md) - * [50.3.1 自定义Jolokia](V. Spring Boot Actuator/50.3.1 Customizing Jolokia.md) - * [50.3.2 禁用Jolokia](V. Spring Boot Actuator/50.3.2 Disabling Jolokia.md) - * [51. 记录器](V. Spring Boot Actuator/51. Loggers.md) - * [51.1 配置记录器](V. Spring Boot Actuator/51.1 Configure a Logger.md) - * [52. 度量指标](V. Spring Boot Actuator/52. Metrics.md) - * [52.1 系统指标](V. Spring Boot Actuator/52.1 System metrics.md) - * [52.2 数据源指标](V. Spring Boot Actuator/52.2 DataSource metrics.md) - * [52.3 缓存指标](V. Spring Boot Actuator/52.3 Cache metrics.md) - * [52.4 Tomcat session指标](V. Spring Boot Actuator/52.4 Tomcat session metrics.md) - * [52.5 记录自己的指标](V. Spring Boot Actuator/52.5 Recording your own metrics.md) - * [52.6 添加自己的公共指标](V. Spring Boot Actuator/52.6 Adding your own public metrics.md) - * [52.7 指标写入,导出和聚合](V. Spring Boot Actuator/52.7 Metric writers, exporters and aggregation.md) - * [52.7.1 示例: 导出到Redis](V. Spring Boot Actuator/52.7.1 Export to Redis.md) - * [52.7.2 示例: 导出到Open TSDB](V. Spring Boot Actuator/52.7.2 Export to Open TSDB.md) - * [52.7.3 示例: 导出到Statsd](V. Spring Boot Actuator/52.7.3 Export to Statsd.md) - * [52.7.4 示例: 导出到JMX](V. Spring Boot Actuator/52.7.4 Export to JMX.md) - * [52.8 聚合多个来源的指标](V. Spring Boot Actuator/52.8 Aggregating metrics from multiple sources.md) - * [52.9 Dropwizard指标](V. Spring Boot Actuator/52.9 Dropwizard Metrics.md) - * [52.10 消息渠道集成](V. Spring Boot Actuator/52.10 Message channel integration.md) - * [53. 审计](V. Spring Boot Actuator/53. Auditing.md) - * [54. 追踪](V. Spring Boot Actuator/54. Tracing.md) - * [54.1 自定义追踪](V. Spring Boot Actuator/54.1 Custom tracing.md) - * [55. 进程监控](V. Spring Boot Actuator/55. Process monitoring.md) - * [55.1 扩展配置](V. Spring Boot Actuator/55.1 Extend configuration.md) - * [55.2 以编程方式](V. Spring Boot Actuator/55.2 Programmatically.md) - * [56. Cloud Foundry支持](V. Spring Boot Actuator/56. Cloud Foundry support.md) - * [56.1 禁用扩展的Cloud Foundry执行器支持](V. Spring Boot Actuator/56.1 Disabling extended Cloud Foundry actuator support.md) - * [56.2 Cloud Foundry自签名证书](V. Spring Boot Actuator/56.2 Cloud Foundry self signed certificates.md) - * [56.3 自定义安全配置](V. Spring Boot Actuator/56.3 Custom security configuration.md) - * [57. 接下来阅读什么](V. Spring Boot Actuator/57. What to read next.md) + * [49. 开启production-ready特性](V. Spring Boot Actuator/49. Enabling Production-ready Features.md) + * [50. 端点](V. Spring Boot Actuator/50. Endpoints.md) + * [50.1 自定义端点](V. Spring Boot Actuator/50.1 Customizing Endpoints.md) + * [50.2 执行器MVC端点的超媒体支持](V. Spring Boot Actuator/50.2 Hypermedia for Actuator MVC Endpoints.md) + * [50.3 CORS支持](V. Spring Boot Actuator/50.3 CORS Support.md) + * [50.4 添加自定义端点](V. Spring Boot Actuator/50.4 Adding Custom Endpoints.md) + * [50.5 健康信息](V. Spring Boot Actuator/50.5 Health Information.md) + * [50.6 安全与HealthIndicators](V. Spring Boot Actuator/50.6 Security with HealthIndicators.md) + * [50.6.1 自动配置的HealthIndicators](V. Spring Boot Actuator/50.6.1 Auto-configured-HealthIndicators.md) + * [50.6.2 编写自定义HealthIndicators](V. Spring Boot Actuator/50.6.2 Writing Custom HealthIndicators.md) + * [50.7 应用信息](V. Spring Boot Actuator/50.7 Application Information.md) + * [50.7.1 自动配置的InfoContributors](V. Spring Boot Actuator/50.7.1 Auto-configured InfoContributors.md) + * [50.7.2 自定义应用info信息](V. Spring Boot Actuator/50.7.2 Custom Application Info Information.md) + * [50.7.3 Git提交信息](V. Spring Boot Actuator/50.7.3 Git Commit Information.md) + * [50.7.4 构建信息](V. Spring Boot Actuator/50.7.4 Build Information.md) + * [50.7.5 编写自定义的InfoContributors](V. Spring Boot Actuator/50.7.5 Writing Custom InfoContributors.md) + * [51. 基于HTTP的监控和管理](V. Spring Boot Actuator/51. Monitoring and Management over HTTP.md) + * [51.1 访问敏感端点](V. Spring Boot Actuator/51.1 Accessing Sensitive Endpoints.md) + * [51.2 自定义管理端点路径](V. Spring Boot Actuator/51.2 Customizing the Management Endpoint Paths.md) + * [51.3 自定义管理服务器端口](V. Spring Boot Actuator/51.3 Customizing the Management Server Port.md) + * [51.4 配置管理相关的SSL](V. Spring Boot Actuator/51.4 Configuring Management-specific SSL.md) + * [51.5 自定义管理服务器地址](V. Spring Boot Actuator/51.5 Customizing the Management Server Address.md) + * [51.6 禁用HTTP端点](V. Spring Boot Actuator/51.6 Disabling HTTP Endpoints.md) + * [51.7 HTTP health端点访问限制](V. Spring Boot Actuator/51.7 HTTP Health Endpoint Access Restrictions.md) + * [52. 基于JMX的监控和管理](V. Spring Boot Actuator/52. Monitoring and Management over JMX.md) + * [52.1 自定义MBean名称](V. Spring Boot Actuator/52.1 Customizing MBean Names.md) + * [52.2 禁用JMX端点](V. Spring Boot Actuator/52.2 Disabling JMX Endpoints.md) + * [52.3 使用Jolokia通过HTTP实现JMX远程管理](V. Spring Boot Actuator/52.3 Using Jolokia for JMX over HTTP.md) + * [52.3.1 自定义Jolokia](V. Spring Boot Actuator/52.3.1 Customizing Jolokia.md) + * [52.3.2 禁用Jolokia](V. Spring Boot Actuator/52.3.2 Disabling Jolokia.md) + * [53. 记录器](V. Spring Boot Actuator/53. Loggers.md) + * [53.1 配置记录器](V. Spring Boot Actuator/53.1 Configure a Logger.md) + * [54. 度量指标](V. Spring Boot Actuator/54. Metrics.md) + * [54.1 系统指标](V. Spring Boot Actuator/54.1 System Metrics.md) + * [54.2 数据源指标](V. Spring Boot Actuator/54.2 DataSource Metrics.md) + * [54.3 缓存指标](V. Spring Boot Actuator/54.3 Cache Metrics.md) + * [54.4 Tomcat session指标](V. Spring Boot Actuator/54.4 Tomcat Session Metrics.md) + * [54.5 记录自己的指标](V. Spring Boot Actuator/54.5 Recording your own Metrics.md) + * [54.6 添加自己的公共指标](V. Spring Boot Actuator/54.6 Adding your own public Metrics.md) + * [54.7 指标写入,导出和聚合](V. Spring Boot Actuator/54.7 Metric writers, exporters and aggregation.md) + * [54.7.1 示例: 导出到Redis](V. Spring Boot Actuator/54.7.1 Export to Redis.md) + * [54.7.2 示例: 导出到Open TSDB](V. Spring Boot Actuator/54.7.2 Export to Open TSDB.md) + * [54.7.3 示例: 导出到Statsd](V. Spring Boot Actuator/54.7.3 Export to Statsd.md) + * [54.7.4 示例: 导出到JMX](V. Spring Boot Actuator/54.7.4 Export to JMX.md) + * [54.8 聚合多个来源的指标](V. Spring Boot Actuator/54.8 Aggregating Metrics from Multiple Sources.md) + * [54.9 Dropwizard指标](V. Spring Boot Actuator/54.9 Dropwizard Metrics.md) + * [54.10 消息渠道集成](V. Spring Boot Actuator/54.10 Message Channel Integration.md) + * [55. 审计](V. Spring Boot Actuator/55. Auditing.md) + * [56. 追踪](V. Spring Boot Actuator/56. Tracing.md) + * [56.1 自定义追踪](V. Spring Boot Actuator/56.1 Custom Tracing.md) + * [57. 进程监控](V. Spring Boot Actuator/57. Process Monitoring.md) + * [57.1 扩展配置](V. Spring Boot Actuator/57.1 Extend Configuration.md) + * [57.2 以编程方式](V. Spring Boot Actuator/57.2 Programmatically.md) + * [58. Cloud Foundry支持](V. Spring Boot Actuator/58. Cloud Foundry Support.md) + * [58.1 禁用扩展的Cloud Foundry执行器支持](V. Spring Boot Actuator/58.1 Disabling extended Cloud Foundry Actuator Support.md) + * [58.2 Cloud Foundry自签名证书](V. Spring Boot Actuator/58.2 Cloud Foundry self signed Certificates.md) + * [58.3 自定义安全配置](V. Spring Boot Actuator/58.3 Custom Security Configuration.md) + * [59. 接下来阅读什么](V. Spring Boot Actuator/59. What to Read Next.md) * [VI. 部署到云端](VI. Deploying Spring Boot applications/README.md) * [58. 部署到云端](VI. Deploying Spring Boot applications/58. Deploying to the cloud.md) * [58.1 Cloud Foundry](VI. Deploying Spring Boot applications/58.1 Cloud Foundry.md) From 9294cc43f84a8851305c9ea4d0b69a7d827e0237 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E7=83=AD=E5=BF=83=E5=B8=82=E6=B0=91=E9=92=9F=E5=B0=8F?= =?UTF-8?q?=E5=BC=BA?= Date: Sat, 20 Jul 2019 17:29:05 +0800 Subject: [PATCH 469/865] Update and rename 48. Endpoints.md to 50. Endpoints.md --- V. Spring Boot Actuator/48. Endpoints.md | 35 ---------------------- V. Spring Boot Actuator/50. Endpoints.md | 37 ++++++++++++++++++++++++ 2 files changed, 37 insertions(+), 35 deletions(-) delete mode 100644 V. Spring Boot Actuator/48. Endpoints.md create mode 100644 V. Spring Boot Actuator/50. Endpoints.md diff --git a/V. Spring Boot Actuator/48. Endpoints.md b/V. Spring Boot Actuator/48. Endpoints.md deleted file mode 100644 index 865d793e..00000000 --- a/V. Spring Boot Actuator/48. Endpoints.md +++ /dev/null @@ -1,35 +0,0 @@ -### 48. 端点 -执行器端点(endpoints)可用于监控应用及与应用进行交互,Spring Boot包含很多内置的端点,你也可以添加自己的。例如,`health`端点提供了应用的基本健康信息。 -端点暴露的方式取决于你采用的技术类型,大部分应用选择HTTP监控,端点的ID连同前缀`/application`映射到一个URL。例如,`health`端点默认映射到`/application/health`。 - -下面的端点都是可用的: - -| ID | 描述 |是否敏感| -| ---- | :----- | :----- | -|`actuator`|为其他端点提供基于超文本的导航页面,需要添加Spring HATEOAS依赖|true| -|`auditevents`|为当前应用暴露审计事件的信息|true| -|`autoconfig`|显示一个自动配置类的报告,该报告展示所有自动配置候选者及它们被应用或未被应用的原因|true| -|`beans`|显示一个应用中所有Spring Beans的完整列表|true| -|`configprops`|显示一个所有`@ConfigurationProperties`的集合列表|true| -|`dump`|执行一个线程转储|true| -|`env`|暴露来自Spring `ConfigurableEnvironment`的属性|true| -|`flyway`|显示数据库迁移路径,如果有的话|true| -|`health`|展示应用的健康信息(当使用一个未认证连接访问时显示一个简单的'status',使用认证连接访问则显示全部信息详情)|false| -|`info`|显示任意的应用信息|false| -|`loggers`|显示和修改应用中的记录器的配置|true| -|`liquibase`|展示任何Liquibase数据库迁移路径,如果有的话|true| -|`metrics`|展示当前应用的'metrics'信息|true| -|`mappings`|显示一个所有`@RequestMapping`路径的集合列表|true| -|`shutdown`|允许应用以优雅的方式关闭(默认情况下不启用)|true| -|`trace`|显示trace信息(默认为最新的100条HTTP请求)|true| - -如果使用Spring MVC,你还可以使用以下端点: - -| ID | 描述 |是否敏感| -| ---- | :----- | :----- | -|`docs`|展示Actuator的文档,包括示例请求和响应,需添加`spring-boot-actuator-docs`依赖|false| -|`heapdump`|返回一个GZip压缩的`hprof`堆转储文件|true| -|`jolokia`|通过HTTP暴露JMX beans(依赖Jolokia)|true| -|`logfile`|返回日志文件内容(如果设置`logging.file`或`logging.path`属性),支持使用HTTP `Range`头接收日志文件内容的部分信息|| - -**注**:根据端点暴露的方式,`sensitive`属性可用做安全提示,例如,在使用HTTP访问敏感(sensitive)端点时需要提供用户名/密码(如果没有启用web安全,可能会简化为禁止访问该端点)。 diff --git a/V. Spring Boot Actuator/50. Endpoints.md b/V. Spring Boot Actuator/50. Endpoints.md new file mode 100644 index 00000000..94620600 --- /dev/null +++ b/V. Spring Boot Actuator/50. Endpoints.md @@ -0,0 +1,37 @@ +### 50. 端点 + +执行器端点(endpoints)可用于监控应用及与应用进行交互,Spring Boot包含很多内置的端点,你也可以添加自己的。例如,`health`端点提供了应用的基本健康信息。 +可以单独[启用或禁用](https://docs.spring.io/spring-boot/docs/2.0.0.RELEASE/reference/htmlsingle/#production-ready-endpoints-enabling-endpoints)每个端点。这决定了端点是否已经创建并且在应用上下文里存在它的bean。[通过JMX或者HTTP暴露的](https://docs.spring.io/spring-boot/docs/2.0.0.RELEASE/reference/htmlsingle/#production-ready-endpoints-enabling-endpoints)端点可以被远程访问。大部分应用选择HTTP监控,端点的ID连同前缀`/actuator`映射到一个URL。例如,`health`端点默认映射到`/actuator/health`。 + +下面的端点都是可用的: + +| ID | 描述 |是否默认启用| +| ---- | :----- | :----- | +|`auditevents`|为当前应用暴露审计事件的信息|Yes| +|`beans`|显示一个应用中所有Spring Bean的完整列表|Yes| +|`conditions`|展示依据配置和自动配置类评估的条件,以及它们匹配或者不匹配的原因|Yes| +|`configprops`|显示一个所有`@ConfigurationProperties`的集合列表|Yes| +|`env`|暴露来自Spring `ConfigurableEnvironment`的属性|Yes| +|`flyway`|显示数据库迁移路径,如果有的话|Yes| +|`health`|展示应用健康信息|Yes| +|`httptrace`|显示HTTP跟踪信息(默认的,最后的100个HTTP请求-响应交换)|Yes| +|`info`|显示任意的应用信息|Yes| +|`loggers`|显示和修改应用中的记录器的配置|Yes| +|`liquibase`|展示任何Liquibase数据库迁移路径,如果有的话|Yes| +|`metrics`|展示当前应用的'metrics'信息|Yes| +|`mappings`|显示一个所有`@RequestMapping`路径的集合列表|Yes| +|`scheduledtasks`|显示应用里的计划任务|Yes| +|`sessions`|允许从Spring Session的会话存储,检索和删除用户会话。当为响应式网络应用使用Spring Session支持时,不可用|Yes| +|`shutdown`|允许应用以优雅的方式关闭|No| +|`threaddump`|执行线程转储|Yes| + +如果你的应用是一个网络应用(Spring MVC、Spring WebFlux或者Jersey),你可以使用以下额外的端点: + +| ID | 描述 |是否默认启用| +| ---- | :----- | :----- | +|`heapdump`|返回一个GZip压缩的`hprof`堆转储文件|Yes| +|`jolokia`|通过HTTP暴露JMX bean(当Jolokia在类路径上,对WebFlux不可用)|Yes| +|`logfile`|返回日志文件内容(如果设置了`logging.file`或`logging.path`属性),支持使用HTTP `Range`头接收日志文件内容的部分信息|Yes| +|`prometheus`|用一种可以被Prometheus服务器下载的格式暴露度量指标|Yes| + +请参考单独的API文档([HTML](https://docs.spring.io/spring-boot/docs/2.0.0.RELEASE/actuator-api//html)或者[PDF](https://docs.spring.io/spring-boot/docs/2.0.0.RELEASE/actuator-api//pdf/spring-boot-actuator-web-api.pdf)),学习更多有关执行器端点和它们的请求与响应的格式。 From 546918564e277aa1bcff521034acf0cad7b004ae Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E7=83=AD=E5=BF=83=E5=B8=82=E6=B0=91=E9=92=9F=E5=B0=8F?= =?UTF-8?q?=E5=BC=BA?= Date: Mon, 22 Jul 2019 11:08:08 +0800 Subject: [PATCH 470/865] Update SUMMARY.md --- SUMMARY.md | 1 + 1 file changed, 1 insertion(+) diff --git a/SUMMARY.md b/SUMMARY.md index c57f132f..282d9c82 100644 --- a/SUMMARY.md +++ b/SUMMARY.md @@ -319,6 +319,7 @@ * [V. Spring Boot执行器: Production-ready特性](V. Spring Boot Actuator/README.md) * [49. 开启production-ready特性](V. Spring Boot Actuator/49. Enabling Production-ready Features.md) * [50. 端点](V. Spring Boot Actuator/50. Endpoints.md) + * [50.1 启用端点](V. Spring Boot Actuator/50.1 Enabling Endpoints.md) * [50.1 自定义端点](V. Spring Boot Actuator/50.1 Customizing Endpoints.md) * [50.2 执行器MVC端点的超媒体支持](V. Spring Boot Actuator/50.2 Hypermedia for Actuator MVC Endpoints.md) * [50.3 CORS支持](V. Spring Boot Actuator/50.3 CORS Support.md) From d8ddd03984a6cba0e4112207aaff1f6587382bd1 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E7=83=AD=E5=BF=83=E5=B8=82=E6=B0=91=E9=92=9F=E5=B0=8F?= =?UTF-8?q?=E5=BC=BA?= Date: Mon, 22 Jul 2019 11:14:28 +0800 Subject: [PATCH 471/865] Create 50.1 Enabling Endpoints.md --- V. Spring Boot Actuator/50.1 Enabling Endpoints.md | 12 ++++++++++++ 1 file changed, 12 insertions(+) create mode 100644 V. Spring Boot Actuator/50.1 Enabling Endpoints.md diff --git a/V. Spring Boot Actuator/50.1 Enabling Endpoints.md b/V. Spring Boot Actuator/50.1 Enabling Endpoints.md new file mode 100644 index 00000000..a88cbcb5 --- /dev/null +++ b/V. Spring Boot Actuator/50.1 Enabling Endpoints.md @@ -0,0 +1,12 @@ +### 50.1 启用端点 + +By default, all endpoints except for `shutdown` are enabled. To configure the enablement of an endpoint, use its `management.endpoint..enabled` property. The following example enables the `shutdown` endpoint: +```java +management.endpoint.shutdown.enabled=true +``` +If you prefer endpoint enablement to be opt-in rather than opt-out, set the `management.endpoints.enabled-by-default` property to `false` and use individual endpoint `enabled` properties to opt back in. The following example enables the `info` endpoint and disables all other endpoints: +```java +management.endpoints.enabled-by-default=false +management.endpoint.info.enabled=true +``` +**注** Disabled endpoints are removed entirely from the application context. If you want to change only the technologies over which an endpoint is exposed, use the [`include` and `exclude` properties](https://docs.spring.io/spring-boot/docs/2.0.0.RELEASE/reference/htmlsingle/#production-ready-endpoints-exposing-endpoints) instead. From ef4fb2f9f94af426f4833a1aa70f319038ef05d3 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E7=83=AD=E5=BF=83=E5=B8=82=E6=B0=91=E9=92=9F=E5=B0=8F?= =?UTF-8?q?=E5=BC=BA?= Date: Mon, 22 Jul 2019 11:57:34 +0800 Subject: [PATCH 472/865] Update 50.1 Enabling Endpoints.md --- V. Spring Boot Actuator/50.1 Enabling Endpoints.md | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/V. Spring Boot Actuator/50.1 Enabling Endpoints.md b/V. Spring Boot Actuator/50.1 Enabling Endpoints.md index a88cbcb5..298528ef 100644 --- a/V. Spring Boot Actuator/50.1 Enabling Endpoints.md +++ b/V. Spring Boot Actuator/50.1 Enabling Endpoints.md @@ -1,12 +1,12 @@ ### 50.1 启用端点 -By default, all endpoints except for `shutdown` are enabled. To configure the enablement of an endpoint, use its `management.endpoint..enabled` property. The following example enables the `shutdown` endpoint: +默认的,除了`shutdown`,所有端点都是启用的。使用`management.endpoint..enabled`属性,启用端点。下面的示例启用了`shutdown`端点: ```java management.endpoint.shutdown.enabled=true ``` -If you prefer endpoint enablement to be opt-in rather than opt-out, set the `management.endpoints.enabled-by-default` property to `false` and use individual endpoint `enabled` properties to opt back in. The following example enables the `info` endpoint and disables all other endpoints: +如果相比选择性退出,你更喜欢选择性加入端点启用,将`management.endpoints.enabled-by-default`属性设置为`false`,并使用独立的端点`enabled`属性。下面的示例启用了`info`端点,禁用了所有其它端点: ```java management.endpoints.enabled-by-default=false management.endpoint.info.enabled=true ``` -**注** Disabled endpoints are removed entirely from the application context. If you want to change only the technologies over which an endpoint is exposed, use the [`include` and `exclude` properties](https://docs.spring.io/spring-boot/docs/2.0.0.RELEASE/reference/htmlsingle/#production-ready-endpoints-exposing-endpoints) instead. +**注** 禁用的端点会完全从应用上下文中移除。如果你想改变端点暴露的技术,使用[`include`与`exclude`属性](https://docs.spring.io/spring-boot/docs/2.0.0.RELEASE/reference/htmlsingle/#production-ready-endpoints-exposing-endpoints)代替。 From 51be5c1180f2ffb61dd7650cce50f95434c47acb Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E7=83=AD=E5=BF=83=E5=B8=82=E6=B0=91=E9=92=9F=E5=B0=8F?= =?UTF-8?q?=E5=BC=BA?= Date: Mon, 22 Jul 2019 16:18:23 +0800 Subject: [PATCH 473/865] Update SUMMARY.md --- SUMMARY.md | 1 + 1 file changed, 1 insertion(+) diff --git a/SUMMARY.md b/SUMMARY.md index 282d9c82..2ff773f8 100644 --- a/SUMMARY.md +++ b/SUMMARY.md @@ -320,6 +320,7 @@ * [49. 开启production-ready特性](V. Spring Boot Actuator/49. Enabling Production-ready Features.md) * [50. 端点](V. Spring Boot Actuator/50. Endpoints.md) * [50.1 启用端点](V. Spring Boot Actuator/50.1 Enabling Endpoints.md) + * [50.2 暴露端点](V. Spring Boot Actuator/50.2 Exposing Endpoints.md) * [50.1 自定义端点](V. Spring Boot Actuator/50.1 Customizing Endpoints.md) * [50.2 执行器MVC端点的超媒体支持](V. Spring Boot Actuator/50.2 Hypermedia for Actuator MVC Endpoints.md) * [50.3 CORS支持](V. Spring Boot Actuator/50.3 CORS Support.md) From 1d15ce23ec55fc42420ca8aa1d9550a39e1a397b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E7=83=AD=E5=BF=83=E5=B8=82=E6=B0=91=E9=92=9F=E5=B0=8F?= =?UTF-8?q?=E5=BC=BA?= Date: Mon, 22 Jul 2019 16:35:45 +0800 Subject: [PATCH 474/865] Create 50.2 Exposing Endpoints.md --- .../50.2 Exposing Endpoints.md | 52 +++++++++++++++++++ 1 file changed, 52 insertions(+) create mode 100644 V. Spring Boot Actuator/50.2 Exposing Endpoints.md diff --git a/V. Spring Boot Actuator/50.2 Exposing Endpoints.md b/V. Spring Boot Actuator/50.2 Exposing Endpoints.md new file mode 100644 index 00000000..75ab1120 --- /dev/null +++ b/V. Spring Boot Actuator/50.2 Exposing Endpoints.md @@ -0,0 +1,52 @@ +### 50.2 暴露端点 + +Since Endpoints may contain sensitive information, careful consideration should be given about when to expose them. The following table shows the default exposure for the built-in endpoints: + +| ID | JMX |Web| +| ---- | :----- | :----- | +|`auditevents`|Yes|No| +|`beans`|Yes|No| +|`conditions`|Yes|No| +|`configprops`|Yes|No| +|`env`|Yes|No| +|`flyway`|Yes|No| +|`health`|Yes|Yes| +|`heapdump`|N/A|No| +|`httptrace`|Yes|No| +|`info`|Yes|Yes| +|`jolokia`|N/A|No| +|`logfile`|N/A|No| +|`loggers`|Yes|No| +|`liquibase`|Yes|No| +|`metrics`|Yes|No| +|`mappings`|Yes|No| +|`prometheus`|N/A|No| +|`scheduledtasks`|Yes|No| +|`sessions`|Yes|No| +|`shutdown`|Yes|No| +|`threaddump`|Yes|No| + +To change which endpoints are exposed, use the following technology-specific `include` and `exclude` properties: + +| Property | Default | +| ---- | :----- | +|`management.endpoints.jmx.exposure.exclude`|| +|`management.endpoints.jmx.exposure.include`|`*`| +|`management.endpoints.web.exposure.exclude`|| +|`management.endpoints.web.exposure.include`|`info, health`| + +The `include` property lists the IDs of the endpoints that are exposed. The `exclude` property lists the IDs of the endpoints that should not be exposed. The `exclude` property takes precedence over the `include` property. Both `include` and `exclude` properties can be configured with a list of endpoint IDs. + +For example, to stop exposing all endpoints over JMX and only expose the `health` and `info` endpoints, use the following property: +```properties +management.endpoints.jmx.exposure.include=health,info +``` +`*` can be used to select all endpoints. For example, to expose everything over HTTP except the `env` and `beans` endpoints, use the following properties: +```properties +management.endpoints.web.exposure.include=* +management.endpoints.web.exposure.exclude=env,beans +``` + +**注** If your application is exposed publicly, we strongly recommend that you also [secure your endpoints](https://docs.spring.io/spring-boot/docs/2.0.0.RELEASE/reference/htmlsingle/#production-ready-endpoints-security). + +**注** If you want to implement your own strategy for when endpoints are exposed, you can register an `EndpointFilter` bean. From 5f5e4e9142a1a9a993ccad522659321d8583bd2f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E7=83=AD=E5=BF=83=E5=B8=82=E6=B0=91=E9=92=9F=E5=B0=8F?= =?UTF-8?q?=E5=BC=BA?= Date: Tue, 23 Jul 2019 10:34:59 +0800 Subject: [PATCH 475/865] Update 50.2 Exposing Endpoints.md --- .../50.2 Exposing Endpoints.md | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/V. Spring Boot Actuator/50.2 Exposing Endpoints.md b/V. Spring Boot Actuator/50.2 Exposing Endpoints.md index 75ab1120..fbe29033 100644 --- a/V. Spring Boot Actuator/50.2 Exposing Endpoints.md +++ b/V. Spring Boot Actuator/50.2 Exposing Endpoints.md @@ -1,6 +1,6 @@ ### 50.2 暴露端点 -Since Endpoints may contain sensitive information, careful consideration should be given about when to expose them. The following table shows the default exposure for the built-in endpoints: +由于端点可能包含敏感信息,暴露它们要慎重。下面的表格展示了内建端点默认是否展示的情况: | ID | JMX |Web| | ---- | :----- | :----- | @@ -26,27 +26,27 @@ Since Endpoints may contain sensitive information, careful consideration should |`shutdown`|Yes|No| |`threaddump`|Yes|No| -To change which endpoints are exposed, use the following technology-specific `include` and `exclude` properties: +使用下面技术特定的`include`和`exclude`属性,改变端点的暴露状况: -| Property | Default | +| 属性 | 默认 | | ---- | :----- | |`management.endpoints.jmx.exposure.exclude`|| |`management.endpoints.jmx.exposure.include`|`*`| |`management.endpoints.web.exposure.exclude`|| |`management.endpoints.web.exposure.include`|`info, health`| -The `include` property lists the IDs of the endpoints that are exposed. The `exclude` property lists the IDs of the endpoints that should not be exposed. The `exclude` property takes precedence over the `include` property. Both `include` and `exclude` properties can be configured with a list of endpoint IDs. +`include`属性列出了暴露的端点ID。`exclude`属性列出了不应当暴露的端点ID。`exclude`属性优先于`include`属性。`include`和`exclude`属性都可以使用端点ID列表配置。 -For example, to stop exposing all endpoints over JMX and only expose the `health` and `info` endpoints, use the following property: +例如,为了停止暴露所有JMX端点,只暴露`health`和`info`端点,使用下面的属性: ```properties management.endpoints.jmx.exposure.include=health,info ``` -`*` can be used to select all endpoints. For example, to expose everything over HTTP except the `env` and `beans` endpoints, use the following properties: +`*`可以用于选择所有端点。例如,为了暴露所有HTTP端点,但是不暴露`env`和`beans`端点,使用下面的属性: ```properties management.endpoints.web.exposure.include=* management.endpoints.web.exposure.exclude=env,beans ``` -**注** If your application is exposed publicly, we strongly recommend that you also [secure your endpoints](https://docs.spring.io/spring-boot/docs/2.0.0.RELEASE/reference/htmlsingle/#production-ready-endpoints-security). +**注** 如果你的应用公开暴露,我们强烈推荐你[加密端点](https://docs.spring.io/spring-boot/docs/2.0.0.RELEASE/reference/htmlsingle/#production-ready-endpoints-security). -**注** If you want to implement your own strategy for when endpoints are exposed, you can register an `EndpointFilter` bean. +**注** 如果你想实现自己的何时暴露端点的策略,你可以注册一个`EndpointFilter` bean。 From 2e930c2f586404817c0760644dc3edfa780c0cba Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E7=83=AD=E5=BF=83=E5=B8=82=E6=B0=91=E9=92=9F=E5=B0=8F?= =?UTF-8?q?=E5=BC=BA?= Date: Tue, 23 Jul 2019 10:40:20 +0800 Subject: [PATCH 476/865] Update SUMMARY.md --- SUMMARY.md | 1 + 1 file changed, 1 insertion(+) diff --git a/SUMMARY.md b/SUMMARY.md index 2ff773f8..596fbe4a 100644 --- a/SUMMARY.md +++ b/SUMMARY.md @@ -321,6 +321,7 @@ * [50. 端点](V. Spring Boot Actuator/50. Endpoints.md) * [50.1 启用端点](V. Spring Boot Actuator/50.1 Enabling Endpoints.md) * [50.2 暴露端点](V. Spring Boot Actuator/50.2 Exposing Endpoints.md) + * [50.3 加密HTTP端点](V. Spring Boot Actuator/50.3 Securing HTTP Endpoints.md) * [50.1 自定义端点](V. Spring Boot Actuator/50.1 Customizing Endpoints.md) * [50.2 执行器MVC端点的超媒体支持](V. Spring Boot Actuator/50.2 Hypermedia for Actuator MVC Endpoints.md) * [50.3 CORS支持](V. Spring Boot Actuator/50.3 CORS Support.md) From 6b56f890191a5c169d43de946c950565e0e44e04 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E7=83=AD=E5=BF=83=E5=B8=82=E6=B0=91=E9=92=9F=E5=B0=8F?= =?UTF-8?q?=E5=BC=BA?= Date: Tue, 23 Jul 2019 10:48:53 +0800 Subject: [PATCH 477/865] Create 50.3 Securing HTTP Endpoints.md --- .../50.3 Securing HTTP Endpoints.md | 40 +++++++++++++++++++ 1 file changed, 40 insertions(+) create mode 100644 V. Spring Boot Actuator/50.3 Securing HTTP Endpoints.md diff --git a/V. Spring Boot Actuator/50.3 Securing HTTP Endpoints.md b/V. Spring Boot Actuator/50.3 Securing HTTP Endpoints.md new file mode 100644 index 00000000..437fbff3 --- /dev/null +++ b/V. Spring Boot Actuator/50.3 Securing HTTP Endpoints.md @@ -0,0 +1,40 @@ +### 50.3 加密HTTP端点 + +You should take care to secure HTTP endpoints in the same way that you would any other sensitive URL. If Spring Security is present, endpoints are secured by default using Spring Security’s content-negotiation strategy. If you wish to configure custom security for HTTP endpoints, for example, only allow users with a certain role to access them, Spring Boot provides some convenient `RequestMatcher` objects that can be used in combination with Spring Security. + +A typical Spring Security configuration might look something like the following example: +```java +@Configuration +public class ActuatorSecurity extends WebSecurityConfigurerAdapter { + + @Override + protected void configure(HttpSecurity http) throws Exception { + http.requestMatcher(EndpointRequest.toAnyEndpoint()).authorizeRequests() + .anyRequest().hasRole("ENDPOINT_ADMIN") + .and() + .httpBasic(); + } + +} +``` +The preceding example uses `EndpointRequest.toAnyEndpoint()` to match a request to any endpoint and then ensures that all have the `ENDPOINT_ADMIN` role. Several other matcher methods are also available on `EndpointRequest`. See the API documentation ([HTML](https://docs.spring.io/spring-boot/docs/2.0.0.RELEASE/actuator-api//html) or [PDF](https://docs.spring.io/spring-boot/docs/2.0.0.RELEASE/actuator-api//pdf/spring-boot-actuator-web-api.pdf)) for details. + +If you deploy applications behind a firewall, you may prefer that all your actuator endpoints can be accessed without requiring authentication. You can do so by changing the `management.endpoints.web.exposure.include` property, as follows: + +**application.properties. ** +```properties +management.endpoints.web.exposure.include=* +``` +Additionally, if Spring Security is present, you would need to add custom security configuration that allows unauthenticated access to the endpoints as shown in the following example: +```java +@Configuration +public class ActuatorSecurity extends WebSecurityConfigurerAdapter { + + @Override + protected void configure(HttpSecurity http) throws Exception { + http.requestMatcher(EndpointRequest.toAnyEndpoint()).authorizeRequests() + .anyRequest().permitAll() + } + +} +``` From 0586a5fe89c501fc75322fd61f733846cc100bb8 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E7=83=AD=E5=BF=83=E5=B8=82=E6=B0=91=E9=92=9F=E5=B0=8F?= =?UTF-8?q?=E5=BC=BA?= Date: Wed, 24 Jul 2019 16:08:37 +0800 Subject: [PATCH 478/865] Update 50.3 Securing HTTP Endpoints.md --- .../50.3 Securing HTTP Endpoints.md | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/V. Spring Boot Actuator/50.3 Securing HTTP Endpoints.md b/V. Spring Boot Actuator/50.3 Securing HTTP Endpoints.md index 437fbff3..572102b5 100644 --- a/V. Spring Boot Actuator/50.3 Securing HTTP Endpoints.md +++ b/V. Spring Boot Actuator/50.3 Securing HTTP Endpoints.md @@ -1,8 +1,8 @@ ### 50.3 加密HTTP端点 -You should take care to secure HTTP endpoints in the same way that you would any other sensitive URL. If Spring Security is present, endpoints are secured by default using Spring Security’s content-negotiation strategy. If you wish to configure custom security for HTTP endpoints, for example, only allow users with a certain role to access them, Spring Boot provides some convenient `RequestMatcher` objects that can be used in combination with Spring Security. +你应当采取与处理其它敏感的URL相同的方式,加密HTTP端点。如果存在Spring Security,端点会默认用Spring Security的内容协商策略加密。如果你要为HTTP端点配置自定义的安全,例如,只允许某一角色的用户访问它们,Spring Boot提供了一些方便的`RequestMatcher`对象。它们可以与Spring Security结合使用。 -A typical Spring Security configuration might look something like the following example: +典型的Spring Security配置可能类似于下面的例子: ```java @Configuration public class ActuatorSecurity extends WebSecurityConfigurerAdapter { @@ -17,15 +17,15 @@ public class ActuatorSecurity extends WebSecurityConfigurerAdapter { } ``` -The preceding example uses `EndpointRequest.toAnyEndpoint()` to match a request to any endpoint and then ensures that all have the `ENDPOINT_ADMIN` role. Several other matcher methods are also available on `EndpointRequest`. See the API documentation ([HTML](https://docs.spring.io/spring-boot/docs/2.0.0.RELEASE/actuator-api//html) or [PDF](https://docs.spring.io/spring-boot/docs/2.0.0.RELEASE/actuator-api//pdf/spring-boot-actuator-web-api.pdf)) for details. +之前的例子使用`EndpointRequest.toAnyEndpoint()`将请求匹配端点,然后确保所有请求都有`ENDPOINT_ADMIN`角色。另外几个匹配器方法也可以用于`EndpointRequest`。详情请查看API文档([HTML](https://docs.spring.io/spring-boot/docs/2.0.0.RELEASE/actuator-api//html)或者[PDF](https://docs.spring.io/spring-boot/docs/2.0.0.RELEASE/actuator-api//pdf/spring-boot-actuator-web-api.pdf))。 -If you deploy applications behind a firewall, you may prefer that all your actuator endpoints can be accessed without requiring authentication. You can do so by changing the `management.endpoints.web.exposure.include` property, as follows: +如果你在防火墙后面部署应用,你可能更喜欢不需要验证,你所有的执行器端点就能被访问。你可以改变`management.endpoints.web.exposure.include`属性,达到这种效果。如下所示: -**application.properties. ** +**application.properties.** ```properties management.endpoints.web.exposure.include=* ``` -Additionally, if Spring Security is present, you would need to add custom security configuration that allows unauthenticated access to the endpoints as shown in the following example: +另外,如果Spring Security存在,你需要添加自定义的安全配置,来允许未验证的访问。如下所示: ```java @Configuration public class ActuatorSecurity extends WebSecurityConfigurerAdapter { From c42b28ad9c853c394c527b6f81bb83805eda9dfa Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E7=83=AD=E5=BF=83=E5=B8=82=E6=B0=91=E9=92=9F=E5=B0=8F?= =?UTF-8?q?=E5=BC=BA?= Date: Wed, 24 Jul 2019 16:25:53 +0800 Subject: [PATCH 479/865] Update SUMMARY.md --- SUMMARY.md | 28 ++++++++++++++-------------- 1 file changed, 14 insertions(+), 14 deletions(-) diff --git a/SUMMARY.md b/SUMMARY.md index 596fbe4a..65c6ba3e 100644 --- a/SUMMARY.md +++ b/SUMMARY.md @@ -322,20 +322,20 @@ * [50.1 启用端点](V. Spring Boot Actuator/50.1 Enabling Endpoints.md) * [50.2 暴露端点](V. Spring Boot Actuator/50.2 Exposing Endpoints.md) * [50.3 加密HTTP端点](V. Spring Boot Actuator/50.3 Securing HTTP Endpoints.md) - * [50.1 自定义端点](V. Spring Boot Actuator/50.1 Customizing Endpoints.md) - * [50.2 执行器MVC端点的超媒体支持](V. Spring Boot Actuator/50.2 Hypermedia for Actuator MVC Endpoints.md) - * [50.3 CORS支持](V. Spring Boot Actuator/50.3 CORS Support.md) - * [50.4 添加自定义端点](V. Spring Boot Actuator/50.4 Adding Custom Endpoints.md) - * [50.5 健康信息](V. Spring Boot Actuator/50.5 Health Information.md) - * [50.6 安全与HealthIndicators](V. Spring Boot Actuator/50.6 Security with HealthIndicators.md) - * [50.6.1 自动配置的HealthIndicators](V. Spring Boot Actuator/50.6.1 Auto-configured-HealthIndicators.md) - * [50.6.2 编写自定义HealthIndicators](V. Spring Boot Actuator/50.6.2 Writing Custom HealthIndicators.md) - * [50.7 应用信息](V. Spring Boot Actuator/50.7 Application Information.md) - * [50.7.1 自动配置的InfoContributors](V. Spring Boot Actuator/50.7.1 Auto-configured InfoContributors.md) - * [50.7.2 自定义应用info信息](V. Spring Boot Actuator/50.7.2 Custom Application Info Information.md) - * [50.7.3 Git提交信息](V. Spring Boot Actuator/50.7.3 Git Commit Information.md) - * [50.7.4 构建信息](V. Spring Boot Actuator/50.7.4 Build Information.md) - * [50.7.5 编写自定义的InfoContributors](V. Spring Boot Actuator/50.7.5 Writing Custom InfoContributors.md) + * [50.4 配置端点](V. Spring Boot Actuator/50.4 Configuring Endpoints.md) + * [50.5 执行器MVC端点的超媒体支持](V. Spring Boot Actuator/50.5 Hypermedia for Actuator MVC Endpoints.md) + * [50.6 CORS支持](V. Spring Boot Actuator/50.6 CORS Support.md) + * [50.7 添加自定义端点](V. Spring Boot Actuator/50.7 Adding Custom Endpoints.md) + * [50.8 健康信息](V. Spring Boot Actuator/50.8 Health Information.md) + * [50.9 安全与HealthIndicators](V. Spring Boot Actuator/50.9 Security with HealthIndicators.md) + * [50.9.1 自动配置的HealthIndicators](V. Spring Boot Actuator/50.9.1 Auto-configured-HealthIndicators.md) + * [50.9.2 编写自定义HealthIndicators](V. Spring Boot Actuator/50.9.2 Writing Custom HealthIndicators.md) + * [50.10 应用信息](V. Spring Boot Actuator/50.10 Application Information.md) + * [50.10.1 自动配置的InfoContributors](V. Spring Boot Actuator/50.10.1 Auto-configured InfoContributors.md) + * [50.10.2 自定义应用info信息](V. Spring Boot Actuator/50.10.2 Custom Application Info Information.md) + * [50.10.3 Git提交信息](V. Spring Boot Actuator/50.10.3 Git Commit Information.md) + * [50.10.4 构建信息](V. Spring Boot Actuator/50.10.4 Build Information.md) + * [50.10.5 编写自定义的InfoContributors](V. Spring Boot Actuator/50.10.5 Writing Custom InfoContributors.md) * [51. 基于HTTP的监控和管理](V. Spring Boot Actuator/51. Monitoring and Management over HTTP.md) * [51.1 访问敏感端点](V. Spring Boot Actuator/51.1 Accessing Sensitive Endpoints.md) * [51.2 自定义管理端点路径](V. Spring Boot Actuator/51.2 Customizing the Management Endpoint Paths.md) From f58e591b11746db2a0b77b63c49be5c6d2982ba8 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E7=83=AD=E5=BF=83=E5=B8=82=E6=B0=91=E9=92=9F=E5=B0=8F?= =?UTF-8?q?=E5=BC=BA?= Date: Wed, 24 Jul 2019 16:31:45 +0800 Subject: [PATCH 480/865] Update and rename 48.1 Customizing endpoints.md to 50.4 Configuring Endpoints.md --- .../48.1 Customizing endpoints.md | 19 ------------------- .../50.4 Configuring Endpoints.md | 12 ++++++++++++ 2 files changed, 12 insertions(+), 19 deletions(-) delete mode 100644 V. Spring Boot Actuator/48.1 Customizing endpoints.md create mode 100644 V. Spring Boot Actuator/50.4 Configuring Endpoints.md diff --git a/V. Spring Boot Actuator/48.1 Customizing endpoints.md b/V. Spring Boot Actuator/48.1 Customizing endpoints.md deleted file mode 100644 index fafa72f2..00000000 --- a/V. Spring Boot Actuator/48.1 Customizing endpoints.md +++ /dev/null @@ -1,19 +0,0 @@ -### 48.1 自定义端点 -使用Spring属性可以自定义端点,你可以设置端点是否开启(`enabled`),是否敏感(`sensitive`),甚至改变它的`id`。例如,下面的`application.properties`改变`beans`端点的敏感性及id,并启用`shutdown`: -```java -endpoints.beans.id=springbeans -endpoints.beans.sensitive=false -endpoints.shutdown.enabled=true -``` -**注**:前缀`endpoints + . + name`用于被配置端点的唯一标识。 - -默认情况,所有端点除了`shutdown`以外都是开启的,你可以使用`endpoints.enabled`属性指定可选端点是否启用。例如,所有端点除`info`外都被禁用: -```java -endpoints.enabled=false -endpoints.info.enabled=true -``` -同样地,你可以全局范围内设置所有端点的`sensitive`标记,敏感标记默认取决于端点类型(查看上面表格)。例如,所有端点除`info`外都标记为敏感: -```java -endpoints.sensitive=true -endpoints.info.sensitive=false -``` diff --git a/V. Spring Boot Actuator/50.4 Configuring Endpoints.md b/V. Spring Boot Actuator/50.4 Configuring Endpoints.md new file mode 100644 index 00000000..531457c8 --- /dev/null +++ b/V. Spring Boot Actuator/50.4 Configuring Endpoints.md @@ -0,0 +1,12 @@ +### 50.4 配置端点 + +Endpoints automatically cache responses to read operations that do not take any parameters. To configure the amount of time for which an endpoint will cache a response, use its `cache.time-to-live` property. The following example sets the time-to-live of the `beans` endpoint’s cache to 10 seconds: + +**application.properties.** +```properties +management.endpoint.beans.cache.time-to-live=10s +``` + +**注** The prefix management.endpoint. is used to uniquely identify the endpoint that is being configured. + +**注** When making an authenticated HTTP request, the Principal is considered as input to the endpoint and, therefore, the response will not be cached. From dae5208d18c9cd90222128bdf057b157c0add8e8 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E7=83=AD=E5=BF=83=E5=B8=82=E6=B0=91=E9=92=9F=E5=B0=8F?= =?UTF-8?q?=E5=BC=BA?= Date: Thu, 25 Jul 2019 10:47:10 +0800 Subject: [PATCH 481/865] Update 50.4 Configuring Endpoints.md --- V. Spring Boot Actuator/50.4 Configuring Endpoints.md | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/V. Spring Boot Actuator/50.4 Configuring Endpoints.md b/V. Spring Boot Actuator/50.4 Configuring Endpoints.md index 531457c8..d045ffec 100644 --- a/V. Spring Boot Actuator/50.4 Configuring Endpoints.md +++ b/V. Spring Boot Actuator/50.4 Configuring Endpoints.md @@ -1,12 +1,12 @@ ### 50.4 配置端点 -Endpoints automatically cache responses to read operations that do not take any parameters. To configure the amount of time for which an endpoint will cache a response, use its `cache.time-to-live` property. The following example sets the time-to-live of the `beans` endpoint’s cache to 10 seconds: +端点自动缓存不带任何参数的读取操作的响应。使用`cache.time-to-live`属性,配置端点缓存响应的时间。下面的例子将`beans`端点的缓存的存活时间设置为10秒: **application.properties.** ```properties management.endpoint.beans.cache.time-to-live=10s ``` -**注** The prefix management.endpoint. is used to uniquely identify the endpoint that is being configured. +**注** 前缀`management.endpoint.`用于唯一确定一个端点。 -**注** When making an authenticated HTTP request, the Principal is considered as input to the endpoint and, therefore, the response will not be cached. +**注** 当发送一个经过验证的HTTP请求时,`Principal`会被当做端点的输入,因此,响应不会被缓存。 From 4db9b383db909d011edfcbf69d69a5478ee0f607 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E7=83=AD=E5=BF=83=E5=B8=82=E6=B0=91=E9=92=9F=E5=B0=8F?= =?UTF-8?q?=E5=BC=BA?= Date: Thu, 25 Jul 2019 11:14:42 +0800 Subject: [PATCH 482/865] Update and rename 48.2 Hypermedia for actuator MVC endpoints.md to 50.5 Hypermedia for Actuator Web Endpoints.md --- .../48.2 Hypermedia for actuator MVC endpoints.md | 6 ------ .../50.5 Hypermedia for Actuator Web Endpoints.md | 5 +++++ 2 files changed, 5 insertions(+), 6 deletions(-) delete mode 100644 V. Spring Boot Actuator/48.2 Hypermedia for actuator MVC endpoints.md create mode 100644 V. Spring Boot Actuator/50.5 Hypermedia for Actuator Web Endpoints.md diff --git a/V. Spring Boot Actuator/48.2 Hypermedia for actuator MVC endpoints.md b/V. Spring Boot Actuator/48.2 Hypermedia for actuator MVC endpoints.md deleted file mode 100644 index bad667a1..00000000 --- a/V. Spring Boot Actuator/48.2 Hypermedia for actuator MVC endpoints.md +++ /dev/null @@ -1,6 +0,0 @@ -###48.2 执行器MVC端点的超媒体支持 -如果`endpoints.hypermedia.enabled`设置为true,同时classpath下存在[Spring HATEOAS](http://projects.spring.io/spring-hateoas)库(比如,通过`spring-boot-starter-hateoas`或使用[Spring Data REST](http://projects.spring.io/spring-data-rest)),来自执行器(Actuator)的HTTP端点将使用超媒体链接进行增强(hypermedia links),也就是使用一个“导航页”汇总所有端点链接,该页面默认路径为`/application`。该实现也是一个端点,可以通过属性配置它的路径(`endpoints.actuator.path`)及是否开启(`endpoints.actuator.enabled`)。 - -当指定了一个自定义管理上下文路径时,“导航页”路径自动从`/application`迁移到管理上下文根目录。例如,如果管理上下文路径为`/management`,那就可以通过`/management`访问“导航页”。 - -如果classpath下存在[HAL Browser](https://github.com/mikekelly/hal-browser)(通过webjar:`org.webjars:hal-browser`,或`spring-data-rest-hal-browser`),Spring Boot将提供一个以HAL Browser格式的HTML“导航页”。 diff --git a/V. Spring Boot Actuator/50.5 Hypermedia for Actuator Web Endpoints.md b/V. Spring Boot Actuator/50.5 Hypermedia for Actuator Web Endpoints.md new file mode 100644 index 00000000..5517f1c6 --- /dev/null +++ b/V. Spring Boot Actuator/50.5 Hypermedia for Actuator Web Endpoints.md @@ -0,0 +1,5 @@ +### 50.5 执行器网络端点的超媒体支持 + +一个“发现页”会带着链接加到所有端点。该页面默认可用,路径为`/actuator`。 + +当指定了一个自定义管理上下文路径时,“发现页”路径自动从`/actuator`迁移到管理上下文根目录。例如,如果管理上下文路径为`/management`,那就可以通过`/management`访问“导航页”。当管理上下文路径设置为`/`时,为了防止和其它映射发生冲突,发现页会被禁用。 From 7e1a7037e2d8cc46b1abb31f76694078c93b8763 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E7=83=AD=E5=BF=83=E5=B8=82=E6=B0=91=E9=92=9F=E5=B0=8F?= =?UTF-8?q?=E5=BC=BA?= Date: Thu, 25 Jul 2019 11:19:43 +0800 Subject: [PATCH 483/865] Update SUMMARY.md --- SUMMARY.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/SUMMARY.md b/SUMMARY.md index 65c6ba3e..67b7692b 100644 --- a/SUMMARY.md +++ b/SUMMARY.md @@ -323,7 +323,7 @@ * [50.2 暴露端点](V. Spring Boot Actuator/50.2 Exposing Endpoints.md) * [50.3 加密HTTP端点](V. Spring Boot Actuator/50.3 Securing HTTP Endpoints.md) * [50.4 配置端点](V. Spring Boot Actuator/50.4 Configuring Endpoints.md) - * [50.5 执行器MVC端点的超媒体支持](V. Spring Boot Actuator/50.5 Hypermedia for Actuator MVC Endpoints.md) + * [50.5 执行器网络端点的超媒体支持](V. Spring Boot Actuator/50.5 Hypermedia for Actuator Web Endpoints.md) * [50.6 CORS支持](V. Spring Boot Actuator/50.6 CORS Support.md) * [50.7 添加自定义端点](V. Spring Boot Actuator/50.7 Adding Custom Endpoints.md) * [50.8 健康信息](V. Spring Boot Actuator/50.8 Health Information.md) From f71c269007b8c4c27b577a7f69de6f8ecb6f6892 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E7=83=AD=E5=BF=83=E5=B8=82=E6=B0=91=E9=92=9F=E5=B0=8F?= =?UTF-8?q?=E5=BC=BA?= Date: Thu, 25 Jul 2019 11:39:02 +0800 Subject: [PATCH 484/865] Update 50.5 Hypermedia for Actuator Web Endpoints.md --- .../50.5 Hypermedia for Actuator Web Endpoints.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/V. Spring Boot Actuator/50.5 Hypermedia for Actuator Web Endpoints.md b/V. Spring Boot Actuator/50.5 Hypermedia for Actuator Web Endpoints.md index 5517f1c6..d98f3857 100644 --- a/V. Spring Boot Actuator/50.5 Hypermedia for Actuator Web Endpoints.md +++ b/V. Spring Boot Actuator/50.5 Hypermedia for Actuator Web Endpoints.md @@ -2,4 +2,4 @@ 一个“发现页”会带着链接加到所有端点。该页面默认可用,路径为`/actuator`。 -当指定了一个自定义管理上下文路径时,“发现页”路径自动从`/actuator`迁移到管理上下文根目录。例如,如果管理上下文路径为`/management`,那就可以通过`/management`访问“导航页”。当管理上下文路径设置为`/`时,为了防止和其它映射发生冲突,发现页会被禁用。 +当指定了一个自定义管理上下文路径时,“发现页”路径自动从`/actuator`迁移到管理上下文根目录。例如,如果管理上下文路径为`/management`,那就可以通过`/management`访问“发现页”。当管理上下文路径设置为`/`时,为了防止和其它映射发生冲突,发现页会被禁用。 From bca5e471fd3360481b11e0427d541f68894ec05b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E7=83=AD=E5=BF=83=E5=B8=82=E6=B0=91=E9=92=9F=E5=B0=8F?= =?UTF-8?q?=E5=BC=BA?= Date: Thu, 25 Jul 2019 14:14:25 +0800 Subject: [PATCH 485/865] Update SUMMARY.md --- SUMMARY.md | 25 +++++++++++++------------ 1 file changed, 13 insertions(+), 12 deletions(-) diff --git a/SUMMARY.md b/SUMMARY.md index 67b7692b..9f7ca0aa 100644 --- a/SUMMARY.md +++ b/SUMMARY.md @@ -324,18 +324,19 @@ * [50.3 加密HTTP端点](V. Spring Boot Actuator/50.3 Securing HTTP Endpoints.md) * [50.4 配置端点](V. Spring Boot Actuator/50.4 Configuring Endpoints.md) * [50.5 执行器网络端点的超媒体支持](V. Spring Boot Actuator/50.5 Hypermedia for Actuator Web Endpoints.md) - * [50.6 CORS支持](V. Spring Boot Actuator/50.6 CORS Support.md) - * [50.7 添加自定义端点](V. Spring Boot Actuator/50.7 Adding Custom Endpoints.md) - * [50.8 健康信息](V. Spring Boot Actuator/50.8 Health Information.md) - * [50.9 安全与HealthIndicators](V. Spring Boot Actuator/50.9 Security with HealthIndicators.md) - * [50.9.1 自动配置的HealthIndicators](V. Spring Boot Actuator/50.9.1 Auto-configured-HealthIndicators.md) - * [50.9.2 编写自定义HealthIndicators](V. Spring Boot Actuator/50.9.2 Writing Custom HealthIndicators.md) - * [50.10 应用信息](V. Spring Boot Actuator/50.10 Application Information.md) - * [50.10.1 自动配置的InfoContributors](V. Spring Boot Actuator/50.10.1 Auto-configured InfoContributors.md) - * [50.10.2 自定义应用info信息](V. Spring Boot Actuator/50.10.2 Custom Application Info Information.md) - * [50.10.3 Git提交信息](V. Spring Boot Actuator/50.10.3 Git Commit Information.md) - * [50.10.4 构建信息](V. Spring Boot Actuator/50.10.4 Build Information.md) - * [50.10.5 编写自定义的InfoContributors](V. Spring Boot Actuator/50.10.5 Writing Custom InfoContributors.md) + * [50.6 执行器网络端点路径](V. Spring Boot Actuator/50.6 Actuator Web Endpoint Paths.md) + * [50.7 CORS支持](V. Spring Boot Actuator/50.7 CORS Support.md) + * [50.8 添加自定义端点](V. Spring Boot Actuator/50.8 Adding Custom Endpoints.md) + * [50.9 健康信息](V. Spring Boot Actuator/50.9 Health Information.md) + * [50.10 安全与HealthIndicators](V. Spring Boot Actuator/50.10 Security with HealthIndicators.md) + * [50.10.1 自动配置的HealthIndicators](V. Spring Boot Actuator/50.10.1 Auto-configured-HealthIndicators.md) + * [50.10.2 编写自定义HealthIndicators](V. Spring Boot Actuator/50.10.2 Writing Custom HealthIndicators.md) + * [50.11 应用信息](V. Spring Boot Actuator/50.11 Application Information.md) + * [50.11.1 自动配置的InfoContributors](V. Spring Boot Actuator/50.11.1 Auto-configured InfoContributors.md) + * [50.11.2 自定义应用info信息](V. Spring Boot Actuator/50.11.2 Custom Application Info Information.md) + * [50.11.3 Git提交信息](V. Spring Boot Actuator/50.11.3 Git Commit Information.md) + * [50.11.4 构建信息](V. Spring Boot Actuator/50.11.4 Build Information.md) + * [50.11.5 编写自定义的InfoContributors](V. Spring Boot Actuator/50.11.5 Writing Custom InfoContributors.md) * [51. 基于HTTP的监控和管理](V. Spring Boot Actuator/51. Monitoring and Management over HTTP.md) * [51.1 访问敏感端点](V. Spring Boot Actuator/51.1 Accessing Sensitive Endpoints.md) * [51.2 自定义管理端点路径](V. Spring Boot Actuator/51.2 Customizing the Management Endpoint Paths.md) From 62ddaf4829601aba2315e87acb9e0a3b7f25c7a2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E7=83=AD=E5=BF=83=E5=B8=82=E6=B0=91=E9=92=9F=E5=B0=8F?= =?UTF-8?q?=E5=BC=BA?= Date: Thu, 25 Jul 2019 14:32:21 +0800 Subject: [PATCH 486/865] Create 50.6 Actuator Web Endpoint Paths.md --- .../50.6 Actuator Web Endpoint Paths.md | 11 +++++++++++ 1 file changed, 11 insertions(+) create mode 100644 V. Spring Boot Actuator/50.6 Actuator Web Endpoint Paths.md diff --git a/V. Spring Boot Actuator/50.6 Actuator Web Endpoint Paths.md b/V. Spring Boot Actuator/50.6 Actuator Web Endpoint Paths.md new file mode 100644 index 00000000..881bb41d --- /dev/null +++ b/V. Spring Boot Actuator/50.6 Actuator Web Endpoint Paths.md @@ -0,0 +1,11 @@ +### 50.6 执行器网络端点路径 + +默认的,端点使用其ID,通过HTTP暴露在`/actuator`下。例如,`beans`端点暴露在`/actuator/beans`下面。如果你想要将端点映射到不同的路径,你可以使用`management.endpoints.web.path-mapping`属性。同样的,如果你需要修改基础路径,你可以使用`management.endpoints.web.base-path`。 + +下面的例子将`/actuator/health`重映射为`/healthcheck`: + +**application.properties.** +```properties +management.endpoints.web.base-path=/ +management.endpoints.web.path-mapping.health=healthcheck +``` From 166d086f28f7fba6d4f5fc39b3874a831bb5360c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E7=83=AD=E5=BF=83=E5=B8=82=E6=B0=91=E9=92=9F=E5=B0=8F?= =?UTF-8?q?=E5=BC=BA?= Date: Fri, 26 Jul 2019 16:19:31 +0800 Subject: [PATCH 487/865] Update and rename 48.3 CORS support.md to 50.7 CORS Support.md --- V. Spring Boot Actuator/48.3 CORS support.md | 10 ---------- V. Spring Boot Actuator/50.7 CORS Support.md | 11 +++++++++++ 2 files changed, 11 insertions(+), 10 deletions(-) delete mode 100644 V. Spring Boot Actuator/48.3 CORS support.md create mode 100644 V. Spring Boot Actuator/50.7 CORS Support.md diff --git a/V. Spring Boot Actuator/48.3 CORS support.md b/V. Spring Boot Actuator/48.3 CORS support.md deleted file mode 100644 index 87d98ae5..00000000 --- a/V. Spring Boot Actuator/48.3 CORS support.md +++ /dev/null @@ -1,10 +0,0 @@ -###48.3 CORS支持 -[跨域资源共享](http://en.wikipedia.org/wiki/Cross-origin_resource_sharing)(CORS)是一个[W3C规范](http://www.w3.org/TR/cors/),用于以灵活的方式指定跨域请求的认证类型,执行器的MVC端点也可以配置成支持该场景。 - -CORS支持默认是禁用的,只有在`endpoints.cors.allowed-origins`属性设置时才启用。以下配置允许来自`example.com`域的`GET`和`POST`调用: -```properties -endpoints.cors.allowed-origins=http://example.com -endpoints.cors.allowed-methods=GET,POST -``` - -**注** 查看[EndpointCorsProperties](https://github.com/spring-projects/spring-boot/tree/v2.0.0.RELEASE/spring-boot-actuator/src/main/java/org/springframework/boot/actuate/autoconfigure/EndpointCorsProperties.java)获取完整的配置选项列表。 diff --git a/V. Spring Boot Actuator/50.7 CORS Support.md b/V. Spring Boot Actuator/50.7 CORS Support.md new file mode 100644 index 00000000..7c0b1c02 --- /dev/null +++ b/V. Spring Boot Actuator/50.7 CORS Support.md @@ -0,0 +1,11 @@ +### 50.7 CORS支持 + +[跨域资源共享](https://en.wikipedia.org/wiki/Cross-origin_resource_sharing)(CORS)是一个[W3C规范](https://www.w3.org/TR/cors/),用于以灵活的方式指定跨域请求的认证类型。如果你使用Spring MVC或者Spring WebFlux,执行器的网络端点也可以配置成支持该场景。 + +CORS支持默认是禁用的,只有在`management.endpoints.web.cors.allowed-origins`属性设置时才启用。以下配置允许来自`example.com`域的`GET`和`POST`调用: +```properties +management.endpoints.web.cors.allowed-origins=http://example.com +management.endpoints.web.cors.allowed-methods=GET,POST +``` + +**注** 查看[CorsEndpointProperties](https://github.com/spring-projects/spring-boot/tree/v2.0.0.RELEASE/spring-boot-project/spring-boot-actuator-autoconfigure/src/main/java/org/springframework/boot/actuate/autoconfigure/endpoint/web/CorsEndpointProperties.java)获取完整的配置选项列表。 From f34e01b29509ba0326eb2741e5571434fb5dae03 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E7=83=AD=E5=BF=83=E5=B8=82=E6=B0=91=E9=92=9F=E5=B0=8F?= =?UTF-8?q?=E5=BC=BA?= Date: Tue, 30 Jul 2019 10:39:23 +0800 Subject: [PATCH 488/865] Update SUMMARY.md --- SUMMARY.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/SUMMARY.md b/SUMMARY.md index 9f7ca0aa..aa4668bb 100644 --- a/SUMMARY.md +++ b/SUMMARY.md @@ -326,7 +326,7 @@ * [50.5 执行器网络端点的超媒体支持](V. Spring Boot Actuator/50.5 Hypermedia for Actuator Web Endpoints.md) * [50.6 执行器网络端点路径](V. Spring Boot Actuator/50.6 Actuator Web Endpoint Paths.md) * [50.7 CORS支持](V. Spring Boot Actuator/50.7 CORS Support.md) - * [50.8 添加自定义端点](V. Spring Boot Actuator/50.8 Adding Custom Endpoints.md) + * [50.8 实现自定义端点](V. Spring Boot Actuator/50.8 Implementing Custom Endpoints.md) * [50.9 健康信息](V. Spring Boot Actuator/50.9 Health Information.md) * [50.10 安全与HealthIndicators](V. Spring Boot Actuator/50.10 Security with HealthIndicators.md) * [50.10.1 自动配置的HealthIndicators](V. Spring Boot Actuator/50.10.1 Auto-configured-HealthIndicators.md) From 948ccd44337b55319a93c70c3e76fc31cd8e3e79 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E7=83=AD=E5=BF=83=E5=B8=82=E6=B0=91=E9=92=9F=E5=B0=8F?= =?UTF-8?q?=E5=BC=BA?= Date: Tue, 30 Jul 2019 11:29:21 +0800 Subject: [PATCH 489/865] Update and rename 48.4 Adding custom endpoints.md to 50.8 Implementing Custom Endpoints.md --- .../48.4 Adding custom endpoints.md | 4 ---- .../50.8 Implementing Custom Endpoints.md | 11 +++++++++++ 2 files changed, 11 insertions(+), 4 deletions(-) delete mode 100644 V. Spring Boot Actuator/48.4 Adding custom endpoints.md create mode 100644 V. Spring Boot Actuator/50.8 Implementing Custom Endpoints.md diff --git a/V. Spring Boot Actuator/48.4 Adding custom endpoints.md b/V. Spring Boot Actuator/48.4 Adding custom endpoints.md deleted file mode 100644 index fa69d852..00000000 --- a/V. Spring Boot Actuator/48.4 Adding custom endpoints.md +++ /dev/null @@ -1,4 +0,0 @@ -###48.4 添加自定义端点 -如果添加一个`Endpoint`类型的`@Bean`,Spring Boot会自动通过JMX和HTTP(如果有可用服务器)将该端点暴露出去。通过创建`MvcEndpoint`类型的bean可进一步定义HTTP端点,虽然该bean不是`@Controller`,但仍能使用`@RequestMapping`(和`@Managed*`)暴露资源。 - -**注** 如果你的用户需要一个单独的管理端口或地址,你可以将注解`@ManagementContextConfiguration`的配置类添加到`/META-INF/spring.factories`中,且key为`org.springframework.boot.actuate.autoconfigure.ManagementContextConfiguration`,这样该端点将跟其他MVC端点一样移动到一个子上下文中,通过`WebConfigurerAdapter`可以为管理端点添加静态资源。 diff --git a/V. Spring Boot Actuator/50.8 Implementing Custom Endpoints.md b/V. Spring Boot Actuator/50.8 Implementing Custom Endpoints.md new file mode 100644 index 00000000..a2934865 --- /dev/null +++ b/V. Spring Boot Actuator/50.8 Implementing Custom Endpoints.md @@ -0,0 +1,11 @@ +### 50.8 实现自定义端点 + +如果你添加一个用`@Endpoint`标注的`@Bean`,任何用`@ReadOperation`、`@WriteOperation`或者`@DeleteOperation`标注的方法都会自动通过JMX暴露,在网络应用里则会通过HTTP暴露。使用Jersey、Spring MVC或者Spring WebFlux时,端点会通过HTTP暴露。 + +你也可以使用`@JmxEndpoint`或者`@WebEndpoint`,编写技术特定的端点。这些端点受到对应技术的限制。比如,`@WebEndpoint`只能通过HTTP暴露,不能通过JMX暴露。 + +你可以使用`@EndpointWebExtension`或者`@EndpointJmxExtension`编写技术特定的扩展。这些注解让你提供技术特定的操作,来声明一个既存的端点。 + +最后,如果你需要访问网络框架特定的功能,你可以实现Servlet或者Spring `@Controller`和`@RestController`端点。但是,它们将不能通过JMX暴露,也不能用于另外的网络框架。 + +**注** 如果你添加端点作为一个库特性,考虑将一个用`@ManagementContextConfiguration`标注的配置类添加到`/META-INF/spring.factories`中,且key为`org.springframework.boot.actuate.autoconfigure.web.ManagementContextConfiguration`。这样,如果你的用户要求一个独立的管理端口或地址,端点将跟其它网络端点一样移动到一个子上下文中。 From 7baff6a8892437a1f0becfa9482db95acd320396 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E7=83=AD=E5=BF=83=E5=B8=82=E6=B0=91=E9=92=9F=E5=B0=8F?= =?UTF-8?q?=E5=BC=BA?= Date: Wed, 31 Jul 2019 09:22:25 +0800 Subject: [PATCH 490/865] Update SUMMARY.md --- SUMMARY.md | 1 + 1 file changed, 1 insertion(+) diff --git a/SUMMARY.md b/SUMMARY.md index aa4668bb..e0d256de 100644 --- a/SUMMARY.md +++ b/SUMMARY.md @@ -327,6 +327,7 @@ * [50.6 执行器网络端点路径](V. Spring Boot Actuator/50.6 Actuator Web Endpoint Paths.md) * [50.7 CORS支持](V. Spring Boot Actuator/50.7 CORS Support.md) * [50.8 实现自定义端点](V. Spring Boot Actuator/50.8 Implementing Custom Endpoints.md) + * [50.8.1 接收输入](IV. Spring Boot features/50.8.1 Receiving Input.md) * [50.9 健康信息](V. Spring Boot Actuator/50.9 Health Information.md) * [50.10 安全与HealthIndicators](V. Spring Boot Actuator/50.10 Security with HealthIndicators.md) * [50.10.1 自动配置的HealthIndicators](V. Spring Boot Actuator/50.10.1 Auto-configured-HealthIndicators.md) From 6748a377029e3658b22a754709d6d91d1d94ff41 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E7=83=AD=E5=BF=83=E5=B8=82=E6=B0=91=E9=92=9F=E5=B0=8F?= =?UTF-8?q?=E5=BC=BA?= Date: Wed, 31 Jul 2019 09:42:25 +0800 Subject: [PATCH 491/865] Create 50.8.1 Receiving Input.md --- V. Spring Boot Actuator/50.8.1 Receiving Input.md | 8 ++++++++ 1 file changed, 8 insertions(+) create mode 100644 V. Spring Boot Actuator/50.8.1 Receiving Input.md diff --git a/V. Spring Boot Actuator/50.8.1 Receiving Input.md b/V. Spring Boot Actuator/50.8.1 Receiving Input.md new file mode 100644 index 00000000..3f3f2fd7 --- /dev/null +++ b/V. Spring Boot Actuator/50.8.1 Receiving Input.md @@ -0,0 +1,8 @@ +### 50.8.1 接收输入 + +Operations on an endpoint receive input via their parameters. When exposed via the web, the values for these parameters are taken from the URL’s query parameters and from the JSON request body. When exposed via JMX, the parameters are mapped to the parameters of the MBean’s operations. Parameters are required by default. They can be made optional by annotating them with `@org.springframework.lang.Nullable`. + +**注** To allow the input to be mapped to the operation method’s parameters, code implementing an endpoint should be compiled with `-parameters`. This will happen automatically if you are using Spring Boot’s Gradle plugin or if you are using Maven and `spring-boot-starter-parent`. + +**Input type conversion** +The parameters passed to endpoint operation methods are, if necessary, automatically converted to the required type. Before calling an operation method, the input received via JMX or an HTTP request is converted to the required types using an instance of `ApplicationConversionService`. From bae3ab7fa8ea4d1701c831e2af96ae5b930f1f9f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E7=83=AD=E5=BF=83=E5=B8=82=E6=B0=91=E9=92=9F=E5=B0=8F?= =?UTF-8?q?=E5=BC=BA?= Date: Wed, 31 Jul 2019 10:06:29 +0800 Subject: [PATCH 492/865] Update 50.8.1 Receiving Input.md --- V. Spring Boot Actuator/50.8.1 Receiving Input.md | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/V. Spring Boot Actuator/50.8.1 Receiving Input.md b/V. Spring Boot Actuator/50.8.1 Receiving Input.md index 3f3f2fd7..08b81e68 100644 --- a/V. Spring Boot Actuator/50.8.1 Receiving Input.md +++ b/V. Spring Boot Actuator/50.8.1 Receiving Input.md @@ -1,8 +1,9 @@ ### 50.8.1 接收输入 -Operations on an endpoint receive input via their parameters. When exposed via the web, the values for these parameters are taken from the URL’s query parameters and from the JSON request body. When exposed via JMX, the parameters are mapped to the parameters of the MBean’s operations. Parameters are required by default. They can be made optional by annotating them with `@org.springframework.lang.Nullable`. +在一个端点上的操作会通过它们的参数接收数据。当该端点通过网络暴露的时候,这些参数的值取自URL查询参数和JSON请求体。当该端点通过JMX暴露的时候,这些参数会映射到MBean操作的参数上。参数默认必需。但是,它们可以通过标注`@org.springframework.lang.Nullable`成为可选项。 -**注** To allow the input to be mapped to the operation method’s parameters, code implementing an endpoint should be compiled with `-parameters`. This will happen automatically if you are using Spring Boot’s Gradle plugin or if you are using Maven and `spring-boot-starter-parent`. +**注** 为了允许输入映射到操作方法的参数上,实现端点的代码应该带上`-parameters`编译。如果你正在使用Spring Boot的Gradle插件,或是Maven和`spring-boot-starter-parent`,这会自动发生。 -**Input type conversion** -The parameters passed to endpoint operation methods are, if necessary, automatically converted to the required type. Before calling an operation method, the input received via JMX or an HTTP request is converted to the required types using an instance of `ApplicationConversionService`. +**输入类型转换** + +如果需要,传递到端点操作方法的参数会自动转换到需要的类型。在调用操作方法之前,通过JMX或者HTTP请求接收的输入会使用`ApplicationConversionService`的实例转换到需要的类型。 From 39f857a1fe33f4f66b91f7bbccb18a2de21aabd9 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E7=83=AD=E5=BF=83=E5=B8=82=E6=B0=91=E9=92=9F=E5=B0=8F?= =?UTF-8?q?=E5=BC=BA?= Date: Wed, 31 Jul 2019 13:50:53 +0800 Subject: [PATCH 493/865] Update SUMMARY.md --- SUMMARY.md | 1 + 1 file changed, 1 insertion(+) diff --git a/SUMMARY.md b/SUMMARY.md index e0d256de..88330ba8 100644 --- a/SUMMARY.md +++ b/SUMMARY.md @@ -328,6 +328,7 @@ * [50.7 CORS支持](V. Spring Boot Actuator/50.7 CORS Support.md) * [50.8 实现自定义端点](V. Spring Boot Actuator/50.8 Implementing Custom Endpoints.md) * [50.8.1 接收输入](IV. Spring Boot features/50.8.1 Receiving Input.md) + * [50.8.2 自定义网络端点](IV. Spring Boot features/50.8.2 Custom Web Endpoints.md) * [50.9 健康信息](V. Spring Boot Actuator/50.9 Health Information.md) * [50.10 安全与HealthIndicators](V. Spring Boot Actuator/50.10 Security with HealthIndicators.md) * [50.10.1 自动配置的HealthIndicators](V. Spring Boot Actuator/50.10.1 Auto-configured-HealthIndicators.md) From 7df4d00df9d3fcb767ea7260a2b1856661ba6850 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E7=83=AD=E5=BF=83=E5=B8=82=E6=B0=91=E9=92=9F=E5=B0=8F?= =?UTF-8?q?=E5=BC=BA?= Date: Wed, 31 Jul 2019 14:03:18 +0800 Subject: [PATCH 494/865] Create 50.8.2 Custom Web Endpoints.md --- .../50.8.2 Custom Web Endpoints.md | 54 +++++++++++++++++++ 1 file changed, 54 insertions(+) create mode 100644 V. Spring Boot Actuator/50.8.2 Custom Web Endpoints.md diff --git a/V. Spring Boot Actuator/50.8.2 Custom Web Endpoints.md b/V. Spring Boot Actuator/50.8.2 Custom Web Endpoints.md new file mode 100644 index 00000000..f6ae7d78 --- /dev/null +++ b/V. Spring Boot Actuator/50.8.2 Custom Web Endpoints.md @@ -0,0 +1,54 @@ +### 50.8.2 自定义网络端点 + +Operations on a `@Endpoint`, `@WebEndpoint`, or `@WebEndpointExtension` are automatically exposed over HTTP using Jersey, Spring MVC, or Spring WebFlux. + +**Web Endpoint Request Predicates** + +A request predicate is automatically generated for each operation on a web-exposed endpoint. + +**Path** + +The path of the predicate is determined by the ID of the endpoint and the base path of web-exposed endpoints. The default base path is `/actuator`. For example, an endpoint with the ID `sessions` will use `/actuator/sessions` as its path in the predicate. + +The path can be further customized by annotating one or more parameters of the operation method with `@Selector`. Such a parameter is added to the path predicate as a path variable. The variable’s value is passed into the operation method when the endpoint operation is invoked. + +**HTTP method** + +The HTTP method of the predicate is determined by the operation type, as shown in the following table: + +| Operation | HTTP method | +| ---- | :----- | +|`@ReadOperation`|`GET`| +|`@WriteOperation`|`POST`| +|`@DeleteOperation`|`DELETE`| + +**Consumes** + +For a `@WriteOperation` (HTTP `POST`) that uses the request body, the consumes clause of the predicate is `application/vnd.spring-boot.actuator.v2+json, application/json`. For all other operations the consumes clause is empty. + +**Produces** + +The produces clause of the predicate can be determined by the `produces` attribute of the `@DeleteOperation`, `@ReadOperation`, and `@WriteOperation` annotations. The attribute is optional. If it is not used, the produces clause is determined automatically. + +If the operation method returns `void` or `Void` the produces clause is empty. If the operation method returns a `org.springframework.core.io.Resource`, the produces clause is `application/octet-stream`. For all other operations the produces clause is `application/vnd.spring-boot.actuator.v2+json, application/json`. + +**Web Endpoint Response Status** + +The default response status for an endpoint operation depends on the operation type (read, write, or delete) and what, if anything, the operation returns. + +A `@ReadOperation` returns a value, the response status will be 200 (OK). If it does not return a value, the response status will be 404 (Not Found). + +If a `@WriteOperation` or `@DeleteOperation` returns a value, the response status will be 200 (OK). If it does not return a value the response status will be 204 (No Content). + +If an operation is invoked without a required parameter, or with a parameter that cannot be converted to the required type, the operation method will not be called and the response status will be 400 (Bad Request). + +**Web Endpoint Range Requests** + +An HTTP range request can be used to request part of an HTTP resource. When using Spring MVC or Spring Web Flux, operations that return a `org.springframework.core.io.Resource` automatically support range requests. + +[Note] +Range requests are not supported when using Jersey. + +**Web Endpoint Security** + +An operation on a web endpoint or a web-specific endpoint extension can receive the `urrent java.security.Principal` or `org.springframework.boot.actuate.endpoint.SecurityContext` as a method parameter. The former is typically used in conjuction with `@Nullable` to provide different behaviour for authenticated and unauthenticated users. The latter is typically used to perform authorization checks using its `isUserInRole(String)` method. From c5fa36cc407056cf3a106b8eaae9f8f1b14467b0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E7=83=AD=E5=BF=83=E5=B8=82=E6=B0=91=E9=92=9F=E5=B0=8F?= =?UTF-8?q?=E5=BC=BA?= Date: Wed, 31 Jul 2019 14:08:24 +0800 Subject: [PATCH 495/865] Update SUMMARY.md --- SUMMARY.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/SUMMARY.md b/SUMMARY.md index 88330ba8..c11666e0 100644 --- a/SUMMARY.md +++ b/SUMMARY.md @@ -327,8 +327,8 @@ * [50.6 执行器网络端点路径](V. Spring Boot Actuator/50.6 Actuator Web Endpoint Paths.md) * [50.7 CORS支持](V. Spring Boot Actuator/50.7 CORS Support.md) * [50.8 实现自定义端点](V. Spring Boot Actuator/50.8 Implementing Custom Endpoints.md) - * [50.8.1 接收输入](IV. Spring Boot features/50.8.1 Receiving Input.md) - * [50.8.2 自定义网络端点](IV. Spring Boot features/50.8.2 Custom Web Endpoints.md) + * [50.8.1 接收输入](V. Spring Boot Actuator/50.8.1 Receiving Input.md) + * [50.8.2 自定义网络端点](V. Spring Boot Actuator/50.8.2 Custom Web Endpoints.md) * [50.9 健康信息](V. Spring Boot Actuator/50.9 Health Information.md) * [50.10 安全与HealthIndicators](V. Spring Boot Actuator/50.10 Security with HealthIndicators.md) * [50.10.1 自动配置的HealthIndicators](V. Spring Boot Actuator/50.10.1 Auto-configured-HealthIndicators.md) From 03ef64672a0597f9ecd94631bec826c464d4a252 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E7=83=AD=E5=BF=83=E5=B8=82=E6=B0=91=E9=92=9F=E5=B0=8F?= =?UTF-8?q?=E5=BC=BA?= Date: Wed, 31 Jul 2019 14:53:58 +0800 Subject: [PATCH 496/865] Update SUMMARY.md --- SUMMARY.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/SUMMARY.md b/SUMMARY.md index c11666e0..c69291b7 100644 --- a/SUMMARY.md +++ b/SUMMARY.md @@ -316,8 +316,8 @@ * [47.7.1 延伸阅读](IV. Spring Boot features/47.7.1 Further reading.md) * [47.7.2 示例](IV. Spring Boot features/47.7.2 Examples.md) * [48. 接下来阅读什么](IV. Spring Boot features/48. What to Read Next.md) -* [V. Spring Boot执行器: Production-ready特性](V. Spring Boot Actuator/README.md) - * [49. 开启production-ready特性](V. Spring Boot Actuator/49. Enabling Production-ready Features.md) +* [V. Spring Boot执行器:用于生产环境的特性](V. Spring Boot Actuator/README.md) + * [49. 开启用于生产环境的特性](V. Spring Boot Actuator/49. Enabling Production-ready Features.md) * [50. 端点](V. Spring Boot Actuator/50. Endpoints.md) * [50.1 启用端点](V. Spring Boot Actuator/50.1 Enabling Endpoints.md) * [50.2 暴露端点](V. Spring Boot Actuator/50.2 Exposing Endpoints.md) From 95b63a259394d09f65c0cc76e10ca60972da63fc Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E7=83=AD=E5=BF=83=E5=B8=82=E6=B0=91=E9=92=9F=E5=B0=8F?= =?UTF-8?q?=E5=BC=BA?= Date: Wed, 31 Jul 2019 14:55:10 +0800 Subject: [PATCH 497/865] Update README.md --- V. Spring Boot Actuator/README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/V. Spring Boot Actuator/README.md b/V. Spring Boot Actuator/README.md index e762854e..29f790f0 100644 --- a/V. Spring Boot Actuator/README.md +++ b/V. Spring Boot Actuator/README.md @@ -1,3 +1,3 @@ -### Spring Boot执行器:Production-ready特性 +### Spring Boot执行器:用于生产环境的特性 Spring Boot包含很多其他特性,可用来帮你监控和管理发布到生产环境的应用。你可以选择使用HTTP端点,或者JMX来管理和监控应用。审计(Auditing),健康(health)和数据采集(metrics gathering)会自动应用到你的应用。 From fe4e59a8a926becac8c8cc6ac6ec332e668ea63c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E7=83=AD=E5=BF=83=E5=B8=82=E6=B0=91=E9=92=9F=E5=B0=8F?= =?UTF-8?q?=E5=BC=BA?= Date: Wed, 31 Jul 2019 14:56:45 +0800 Subject: [PATCH 498/865] Update 49. Enabling Production-ready Features.md --- .../49. Enabling Production-ready Features.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/V. Spring Boot Actuator/49. Enabling Production-ready Features.md b/V. Spring Boot Actuator/49. Enabling Production-ready Features.md index 46f07668..1df28896 100644 --- a/V. Spring Boot Actuator/49. Enabling Production-ready Features.md +++ b/V. Spring Boot Actuator/49. Enabling Production-ready Features.md @@ -1,6 +1,6 @@ -### 49. 开启production-ready特性 +### 49. 开启用于生产环境的特性 -[spring-boot-actuator](https://github.com/spring-projects/spring-boot/tree/v2.0.0.RELEASE/spring-boot-project/spring-boot-actuator)模块提供Spring Boot所有的production-ready特性,启用该特性的最简单方式是添加`spring-boot-starter-actuator` ‘Starter’依赖。 +[spring-boot-actuator](https://github.com/spring-projects/spring-boot/tree/v2.0.0.RELEASE/spring-boot-project/spring-boot-actuator)模块提供Spring Boot所有的用于生产环境的特性,启用该特性的最简单方式是添加`spring-boot-starter-actuator`“Starter依赖。 **执行器(Actuator)的定义**:执行器是一个制造业术语,指的是用于移动或控制东西的一个机械装置,一个很小的改变就能让执行器产生大量的运动。 From c520d01a79ff5079236d4863d6ed180468360b52 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E7=83=AD=E5=BF=83=E5=B8=82=E6=B0=91=E9=92=9F=E5=B0=8F?= =?UTF-8?q?=E5=BC=BA?= Date: Fri, 2 Aug 2019 14:56:42 +0800 Subject: [PATCH 499/865] Update 50.8.2 Custom Web Endpoints.md --- .../50.8.2 Custom Web Endpoints.md | 45 +++++++++---------- 1 file changed, 22 insertions(+), 23 deletions(-) diff --git a/V. Spring Boot Actuator/50.8.2 Custom Web Endpoints.md b/V. Spring Boot Actuator/50.8.2 Custom Web Endpoints.md index f6ae7d78..c906a888 100644 --- a/V. Spring Boot Actuator/50.8.2 Custom Web Endpoints.md +++ b/V. Spring Boot Actuator/50.8.2 Custom Web Endpoints.md @@ -1,22 +1,22 @@ ### 50.8.2 自定义网络端点 -Operations on a `@Endpoint`, `@WebEndpoint`, or `@WebEndpointExtension` are automatically exposed over HTTP using Jersey, Spring MVC, or Spring WebFlux. +在`@Endpoint`、`@WebEndpoint`或者`@WebEndpointExtension`上的操作会自动使用Jersey、Spring MVC或者Spring WebFlux通过HTTP暴露。 -**Web Endpoint Request Predicates** +**网络端点请求谓语** -A request predicate is automatically generated for each operation on a web-exposed endpoint. +请求谓语会在网络暴露的端点上,为每一个操作自动产生。 -**Path** +**路径** -The path of the predicate is determined by the ID of the endpoint and the base path of web-exposed endpoints. The default base path is `/actuator`. For example, an endpoint with the ID `sessions` will use `/actuator/sessions` as its path in the predicate. +谓语的路径由端点的ID以及网络暴露的基础路径所决定。默认的基础路径是`/actuator`。比如,ID为`sessions`的端点会使用`/actuator/sessions`,作为它在谓语里的路径。 -The path can be further customized by annotating one or more parameters of the operation method with `@Selector`. Such a parameter is added to the path predicate as a path variable. The variable’s value is passed into the operation method when the endpoint operation is invoked. +路径可以通过使用`@Selector`标注一个或者更多的操作方法参数,进一步自定义。这样的一个参数会添加进路径谓语,作为一个路径变量。当端点操作被调用时,变量值会传入操作方法。 -**HTTP method** +**HTTP方法** -The HTTP method of the predicate is determined by the operation type, as shown in the following table: +谓语的HTTP方法由操作类型所决定。如下所示: -| Operation | HTTP method | +| 操作 | HTTP方法 | | ---- | :----- | |`@ReadOperation`|`GET`| |`@WriteOperation`|`POST`| @@ -24,31 +24,30 @@ The HTTP method of the predicate is determined by the operation type, as shown i **Consumes** -For a `@WriteOperation` (HTTP `POST`) that uses the request body, the consumes clause of the predicate is `application/vnd.spring-boot.actuator.v2+json, application/json`. For all other operations the consumes clause is empty. +对于使用请求体的`@WriteOperation`(HTTP `POST`),谓语的consumes子句是`application/vnd.spring-boot.actuator.v2+json, application/json`。对于其它所有的操作,consumes子句是空的。 **Produces** -The produces clause of the predicate can be determined by the `produces` attribute of the `@DeleteOperation`, `@ReadOperation`, and `@WriteOperation` annotations. The attribute is optional. If it is not used, the produces clause is determined automatically. +谓语的produces子句由`@DeleteOperation`、`@ReadOperation`和`@WriteOperation`注解的`produces`属性所决定。这个属性是可选的。如果它没被使用,produces子句会被自动决定。 -If the operation method returns `void` or `Void` the produces clause is empty. If the operation method returns a `org.springframework.core.io.Resource`, the produces clause is `application/octet-stream`. For all other operations the produces clause is `application/vnd.spring-boot.actuator.v2+json, application/json`. +如果操作方法返回`void`或者`Void`,produces子句是空的。如果操作方法返回`org.springframework.core.io.Resource`,produces子句`application/octet-stream`。对于其它所有的操作,produces子句是`application/vnd.spring-boot.actuator.v2+json, application/json`。 -**Web Endpoint Response Status** +**网络端点响应状态** -The default response status for an endpoint operation depends on the operation type (read, write, or delete) and what, if anything, the operation returns. +端点操作的默认响应状态取决于操作类型(读取、写入或者删除)。 -A `@ReadOperation` returns a value, the response status will be 200 (OK). If it does not return a value, the response status will be 404 (Not Found). +`@ReadOperation`返回一个值,响应状态将会是200(OK)。如果没有返回一个值,响应状态将会是404(没有找到)。 -If a `@WriteOperation` or `@DeleteOperation` returns a value, the response status will be 200 (OK). If it does not return a value the response status will be 204 (No Content). +如果`@WriteOperation`或者`@DeleteOperation`返回一个值,响应状态将会是200(OK)。如果没有返回一个值,响应状态将会是204(没有内容)。 -If an operation is invoked without a required parameter, or with a parameter that cannot be converted to the required type, the operation method will not be called and the response status will be 400 (Bad Request). +如果一个操作被调用了,但是没有需要的参数,或者参数无法转换成需要的类型,操作方法将不会被调用,响应状态将会是400(错误请求)。 -**Web Endpoint Range Requests** +**网络端点范围请求** -An HTTP range request can be used to request part of an HTTP resource. When using Spring MVC or Spring Web Flux, operations that return a `org.springframework.core.io.Resource` automatically support range requests. +HTTP范围请求可以用于请求HTTP资源的一部分。当使用Spring MVC或者Spring Web Flux时,返回`org.springframework.core.io.Resource`的操作自动支持范围请求。 -[Note] -Range requests are not supported when using Jersey. +**注** 使用Jersey时,范围请求不被支持。 -**Web Endpoint Security** +**网络端点安全** -An operation on a web endpoint or a web-specific endpoint extension can receive the `urrent java.security.Principal` or `org.springframework.boot.actuate.endpoint.SecurityContext` as a method parameter. The former is typically used in conjuction with `@Nullable` to provide different behaviour for authenticated and unauthenticated users. The latter is typically used to perform authorization checks using its `isUserInRole(String)` method. +在网络端点或是网络特定端点扩展上的操作会收到`urrent java.security.Principal`或者`org.springframework.boot.actuate.endpoint.SecurityContext`,作为一个方法参数。前者典型地和`@Nullable`结合使用,来为认证用户和未认证用户提供不同的行为。后者使用它的`isUserInRole(String)`方法,典型地用于执行权限检查。 From ab14e93bcad54ae7f38b1ababf67f6cb8682b6fa Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E7=83=AD=E5=BF=83=E5=B8=82=E6=B0=91=E9=92=9F=E5=B0=8F?= =?UTF-8?q?=E5=BC=BA?= Date: Fri, 2 Aug 2019 18:11:28 +0800 Subject: [PATCH 500/865] Update SUMMARY.md --- SUMMARY.md | 2 ++ 1 file changed, 2 insertions(+) diff --git a/SUMMARY.md b/SUMMARY.md index c69291b7..5c4ab534 100644 --- a/SUMMARY.md +++ b/SUMMARY.md @@ -329,6 +329,8 @@ * [50.8 实现自定义端点](V. Spring Boot Actuator/50.8 Implementing Custom Endpoints.md) * [50.8.1 接收输入](V. Spring Boot Actuator/50.8.1 Receiving Input.md) * [50.8.2 自定义网络端点](V. Spring Boot Actuator/50.8.2 Custom Web Endpoints.md) + * [50.8.3 Servlet端点](V. Spring Boot Actuator/50.8.3 Servlet endpoints.md) + * [50.8.4 Controller端点](V. Spring Boot Actuator/50.8.4 Controller endpoints.md) * [50.9 健康信息](V. Spring Boot Actuator/50.9 Health Information.md) * [50.10 安全与HealthIndicators](V. Spring Boot Actuator/50.10 Security with HealthIndicators.md) * [50.10.1 自动配置的HealthIndicators](V. Spring Boot Actuator/50.10.1 Auto-configured-HealthIndicators.md) From 7c51c15b3df8f64d306ea23087f112efdda3f1f3 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E7=83=AD=E5=BF=83=E5=B8=82=E6=B0=91=E9=92=9F=E5=B0=8F?= =?UTF-8?q?=E5=BC=BA?= Date: Fri, 2 Aug 2019 18:16:11 +0800 Subject: [PATCH 501/865] Create 50.8.3 Servlet endpoints.md --- V. Spring Boot Actuator/50.8.3 Servlet endpoints.md | 3 +++ 1 file changed, 3 insertions(+) create mode 100644 V. Spring Boot Actuator/50.8.3 Servlet endpoints.md diff --git a/V. Spring Boot Actuator/50.8.3 Servlet endpoints.md b/V. Spring Boot Actuator/50.8.3 Servlet endpoints.md new file mode 100644 index 00000000..7f96ad7c --- /dev/null +++ b/V. Spring Boot Actuator/50.8.3 Servlet endpoints.md @@ -0,0 +1,3 @@ +### 50.8.3 Servlet端点 + +A `Servlet` can be exposed as an endpoint by implementing a class annotated with `@ServletEndpoint` that also implements `Supplier`. Servlet endpoints provide deeper integration with the Servlet container but at the expose of portability. They are intended to be used to expose an existing `Servlet` as an endpoint. For new endpoints, the `@Endpoint` and `@WebEndpoint` annotations should be preferred whenever possible. From 9115d7d6dde72282be52784051774c3df7ed722c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E7=83=AD=E5=BF=83=E5=B8=82=E6=B0=91=E9=92=9F=E5=B0=8F?= =?UTF-8?q?=E5=BC=BA?= Date: Mon, 5 Aug 2019 15:25:31 +0800 Subject: [PATCH 502/865] Update 50.8.3 Servlet endpoints.md --- V. Spring Boot Actuator/50.8.3 Servlet endpoints.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/V. Spring Boot Actuator/50.8.3 Servlet endpoints.md b/V. Spring Boot Actuator/50.8.3 Servlet endpoints.md index 7f96ad7c..e6f05c32 100644 --- a/V. Spring Boot Actuator/50.8.3 Servlet endpoints.md +++ b/V. Spring Boot Actuator/50.8.3 Servlet endpoints.md @@ -1,3 +1,3 @@ ### 50.8.3 Servlet端点 -A `Servlet` can be exposed as an endpoint by implementing a class annotated with `@ServletEndpoint` that also implements `Supplier`. Servlet endpoints provide deeper integration with the Servlet container but at the expose of portability. They are intended to be used to expose an existing `Servlet` as an endpoint. For new endpoints, the `@Endpoint` and `@WebEndpoint` annotations should be preferred whenever possible. +通过实现一个用`@ServletEndpoint`注解的类,`Servlet`可以暴露为一个端点。该类还实现了`Supplier`。Servlet端点提供了与Servlet容器更深层次的集成,但是暴露了可移植性。它们用于将现有`Servlet`暴露为端点。对于新的端点,只要可能,就应该首选`@Endpoint`和`@WebEndpoint`注解。 From 3d8e4072d19935fcd4a3651e708e4a43c7a602f6 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E7=83=AD=E5=BF=83=E5=B8=82=E6=B0=91=E9=92=9F=E5=B0=8F?= =?UTF-8?q?=E5=BC=BA?= Date: Mon, 5 Aug 2019 15:31:24 +0800 Subject: [PATCH 503/865] Create 50.8.4 Controller endpoints.md --- V. Spring Boot Actuator/50.8.4 Controller endpoints.md | 3 +++ 1 file changed, 3 insertions(+) create mode 100644 V. Spring Boot Actuator/50.8.4 Controller endpoints.md diff --git a/V. Spring Boot Actuator/50.8.4 Controller endpoints.md b/V. Spring Boot Actuator/50.8.4 Controller endpoints.md new file mode 100644 index 00000000..315b2eed --- /dev/null +++ b/V. Spring Boot Actuator/50.8.4 Controller endpoints.md @@ -0,0 +1,3 @@ +### 50.8.4 Controller端点 + +`@ControllerEndpoint` and `@RestControllerEndpoint` can be used to implement an endpoint that is only exposed by Spring MVC or Spring WebFlux. Methods are mapped using the standard annotations Spring MVC and Spring WevFlux annotations such as `@RequestMapping` and `@GetMapping`, with the endpoint’s ID being used as a prefix for the path. Controller endpoints provide deeper integration with Spring’s web frameworks but at the expense of portability. The `@Endpoint` and `@WebEndpoint` annotations should be preferred whenever possible. From ba7020f6d976c73dfdf31135cbbe64ec8b3e9feb Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E7=83=AD=E5=BF=83=E5=B8=82=E6=B0=91=E9=92=9F=E5=B0=8F?= =?UTF-8?q?=E5=BC=BA?= Date: Tue, 6 Aug 2019 10:43:29 +0800 Subject: [PATCH 504/865] Update 50.8.4 Controller endpoints.md --- V. Spring Boot Actuator/50.8.4 Controller endpoints.md | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/V. Spring Boot Actuator/50.8.4 Controller endpoints.md b/V. Spring Boot Actuator/50.8.4 Controller endpoints.md index 315b2eed..94ab68d3 100644 --- a/V. Spring Boot Actuator/50.8.4 Controller endpoints.md +++ b/V. Spring Boot Actuator/50.8.4 Controller endpoints.md @@ -1,3 +1,5 @@ ### 50.8.4 Controller端点 -`@ControllerEndpoint` and `@RestControllerEndpoint` can be used to implement an endpoint that is only exposed by Spring MVC or Spring WebFlux. Methods are mapped using the standard annotations Spring MVC and Spring WevFlux annotations such as `@RequestMapping` and `@GetMapping`, with the endpoint’s ID being used as a prefix for the path. Controller endpoints provide deeper integration with Spring’s web frameworks but at the expense of portability. The `@Endpoint` and `@WebEndpoint` annotations should be preferred whenever possible. +Methods are mapped using the standard annotations Spring MVC and Spring WevFlux annotations such as `@RequestMapping` and `@GetMapping`, with the endpoint’s ID being used as a prefix for the path. Controller endpoints provide deeper integration with Spring’s web frameworks but at the expense of portability. The `@Endpoint` and `@WebEndpoint` annotations should be preferred whenever possible. + +`@ControllerEndpoint`和`@RestControllerEndpoint`可用于实现仅由Spring MVC或Spring WebFlux暴露的端点。方法使用标准注解Spring MVC和Spring WevFlux注解(如`@RequestMapping`和`@GetMapping`)进行映射,端点的ID用作路径的前缀。Controller端点提供了与Spring的web框架更深入的集成,但这是以可移植性为代价的。只要可能,应该首选`@Endpoint`和`@WebEndpoint`注解。 From 5f3cc561c21e6ff33c705b43bd3c9cfbe8c636c0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E7=83=AD=E5=BF=83=E5=B8=82=E6=B0=91=E9=92=9F=E5=B0=8F?= =?UTF-8?q?=E5=BC=BA?= Date: Tue, 6 Aug 2019 10:43:46 +0800 Subject: [PATCH 505/865] Update 50.8.4 Controller endpoints.md --- V. Spring Boot Actuator/50.8.4 Controller endpoints.md | 2 -- 1 file changed, 2 deletions(-) diff --git a/V. Spring Boot Actuator/50.8.4 Controller endpoints.md b/V. Spring Boot Actuator/50.8.4 Controller endpoints.md index 94ab68d3..7b36cce2 100644 --- a/V. Spring Boot Actuator/50.8.4 Controller endpoints.md +++ b/V. Spring Boot Actuator/50.8.4 Controller endpoints.md @@ -1,5 +1,3 @@ ### 50.8.4 Controller端点 -Methods are mapped using the standard annotations Spring MVC and Spring WevFlux annotations such as `@RequestMapping` and `@GetMapping`, with the endpoint’s ID being used as a prefix for the path. Controller endpoints provide deeper integration with Spring’s web frameworks but at the expense of portability. The `@Endpoint` and `@WebEndpoint` annotations should be preferred whenever possible. - `@ControllerEndpoint`和`@RestControllerEndpoint`可用于实现仅由Spring MVC或Spring WebFlux暴露的端点。方法使用标准注解Spring MVC和Spring WevFlux注解(如`@RequestMapping`和`@GetMapping`)进行映射,端点的ID用作路径的前缀。Controller端点提供了与Spring的web框架更深入的集成,但这是以可移植性为代价的。只要可能,应该首选`@Endpoint`和`@WebEndpoint`注解。 From 101a3f36ab76f08845506abd0cbb366de7cc3fb3 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E7=83=AD=E5=BF=83=E5=B8=82=E6=B0=91=E9=92=9F=E5=B0=8F?= =?UTF-8?q?=E5=BC=BA?= Date: Wed, 7 Aug 2019 16:55:54 +0800 Subject: [PATCH 506/865] Update and rename 48.5 Health information.md to 50.9 Health Information.md --- .../48.5 Health information.md | 4 ---- .../50.9 Health Information.md | 15 +++++++++++++++ 2 files changed, 15 insertions(+), 4 deletions(-) delete mode 100644 V. Spring Boot Actuator/48.5 Health information.md create mode 100644 V. Spring Boot Actuator/50.9 Health Information.md diff --git a/V. Spring Boot Actuator/48.5 Health information.md b/V. Spring Boot Actuator/48.5 Health information.md deleted file mode 100644 index a31bcdb1..00000000 --- a/V. Spring Boot Actuator/48.5 Health information.md +++ /dev/null @@ -1,4 +0,0 @@ -### 48.5 健康信息 -健康信息可以检查应用的运行状态,它经常被监控软件用来提醒人们生产环境是否存在问题。`health`端点暴露的默认信息取决于端点是如何被访问的。对于一个非安全,未认证的连接只返回一个简单的'status'信息。对于一个安全或认证过的连接其他详细信息也会展示(具体参考[章节49.7, “HTTP健康端点形式和访问限制” ](49.7. HTTP health endpoint format and access restrictions.md))。 - -健康信息是从你的`ApplicationContext`中定义的所有[HealthIndicator](http://github.com/spring-projects/spring-boot/tree/master/spring-boot-actuator/src/main/java/org/springframework/boot/actuate/health/HealthIndicator.java) beans收集过来的。Spring Boot包含很多自动配置的`HealthIndicators`,你也可以写自己的。 diff --git a/V. Spring Boot Actuator/50.9 Health Information.md b/V. Spring Boot Actuator/50.9 Health Information.md new file mode 100644 index 00000000..00cbe295 --- /dev/null +++ b/V. Spring Boot Actuator/50.9 Health Information.md @@ -0,0 +1,15 @@ +### 50.9 健康信息 + +你可以使用健康信息来检查应用的运行状态。它经常被监控软件用来提醒人们生产环境是否存在问题。`health`端点暴露的信息取决于`management.endpoint.health.show-details`属性。该属性可以使用下列值配置: + +| 名称 | 描述 | +| ---- | :----- | +|`never`|不展示细节| +|`when-authorized`|只对授权用户展示细节。可以使用`management.endpoint.health.roles`配置授权用户| +|`always`|对所有用户展示细节| + +默认值是`never`。当用户有一到多个端点角色时,就认为用户已经授权。如果端点没有配置角色(默认),就认为所有验证用户已经授权。可以使用`management.endpoint.health.roles`属性配置角色。 + +**注** 如果你已经加密了你的应用,并且想要使用`always`,你的加密配置必须允许所有用户访问健康端点。 + +健康信息是从你的`ApplicationContext`中定义的所有[HealthIndicator](https://github.com/spring-projects/spring-boot/tree/v2.0.0.RELEASE/spring-boot-project/spring-boot-actuator/src/main/java/org/springframework/boot/actuate/health/HealthIndicator.java) beans收集过来的。Spring Boot包含很多自动配置的`HealthIndicators`,你也可以写自己的。默认的,最终的系统状态来自于`HealthAggregator`。它会基于一个状态的有序列表,排序来自每一个`HealthIndicator`的状态。有序列表里的头一个状态会用作全体的健康状态。如果`HealthIndicator`返回的状态都无法被`HealthAggregator`识别, 则会使用`UNKNOWN`状态。 From 229d20452db321beece6e300f1ad7591f61a3b80 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E7=83=AD=E5=BF=83=E5=B8=82=E6=B0=91=E9=92=9F=E5=B0=8F?= =?UTF-8?q?=E5=BC=BA?= Date: Thu, 8 Aug 2019 09:24:03 +0800 Subject: [PATCH 507/865] Update SUMMARY.md --- SUMMARY.md | 17 ++++++++--------- 1 file changed, 8 insertions(+), 9 deletions(-) diff --git a/SUMMARY.md b/SUMMARY.md index 5c4ab534..06f45826 100644 --- a/SUMMARY.md +++ b/SUMMARY.md @@ -332,15 +332,14 @@ * [50.8.3 Servlet端点](V. Spring Boot Actuator/50.8.3 Servlet endpoints.md) * [50.8.4 Controller端点](V. Spring Boot Actuator/50.8.4 Controller endpoints.md) * [50.9 健康信息](V. Spring Boot Actuator/50.9 Health Information.md) - * [50.10 安全与HealthIndicators](V. Spring Boot Actuator/50.10 Security with HealthIndicators.md) - * [50.10.1 自动配置的HealthIndicators](V. Spring Boot Actuator/50.10.1 Auto-configured-HealthIndicators.md) - * [50.10.2 编写自定义HealthIndicators](V. Spring Boot Actuator/50.10.2 Writing Custom HealthIndicators.md) - * [50.11 应用信息](V. Spring Boot Actuator/50.11 Application Information.md) - * [50.11.1 自动配置的InfoContributors](V. Spring Boot Actuator/50.11.1 Auto-configured InfoContributors.md) - * [50.11.2 自定义应用info信息](V. Spring Boot Actuator/50.11.2 Custom Application Info Information.md) - * [50.11.3 Git提交信息](V. Spring Boot Actuator/50.11.3 Git Commit Information.md) - * [50.11.4 构建信息](V. Spring Boot Actuator/50.11.4 Build Information.md) - * [50.11.5 编写自定义的InfoContributors](V. Spring Boot Actuator/50.11.5 Writing Custom InfoContributors.md) + * [50.9.1 自动配置的HealthIndicator](V. Spring Boot Actuator/50.9.1 Auto-configured HealthIndicators.md) + * [50.9.2 编写自定义HealthIndicator](V. Spring Boot Actuator/50.9.2 Writing Custom HealthIndicators.md) + * [50.10 应用信息](V. Spring Boot Actuator/50.10 Application Information.md) + * [50.10.1 自动配置的InfoContributors](V. Spring Boot Actuator/50.10.1 Auto-configured InfoContributors.md) + * [50.10.2 自定义应用info信息](V. Spring Boot Actuator/50.10.2 Custom Application Info Information.md) + * [50.10.3 Git提交信息](V. Spring Boot Actuator/50.10.3 Git Commit Information.md) + * [50.10.4 构建信息](V. Spring Boot Actuator/50.10.4 Build Information.md) + * [50.10.5 编写自定义的InfoContributors](V. Spring Boot Actuator/50.10.5 Writing Custom InfoContributors.md) * [51. 基于HTTP的监控和管理](V. Spring Boot Actuator/51. Monitoring and Management over HTTP.md) * [51.1 访问敏感端点](V. Spring Boot Actuator/51.1 Accessing Sensitive Endpoints.md) * [51.2 自定义管理端点路径](V. Spring Boot Actuator/51.2 Customizing the Management Endpoint Paths.md) From 20775df084bdf61c872a96c0316c0349c1aec91b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E7=83=AD=E5=BF=83=E5=B8=82=E6=B0=91=E9=92=9F=E5=B0=8F?= =?UTF-8?q?=E5=BC=BA?= Date: Thu, 8 Aug 2019 09:36:51 +0800 Subject: [PATCH 508/865] Update 48.6.1 Auto-configured-HealthIndicators.md --- ...48.6.1 Auto-configured-HealthIndicators.md | 22 ++++++++++--------- 1 file changed, 12 insertions(+), 10 deletions(-) diff --git a/V. Spring Boot Actuator/48.6.1 Auto-configured-HealthIndicators.md b/V. Spring Boot Actuator/48.6.1 Auto-configured-HealthIndicators.md index 52d7388c..e53a4969 100644 --- a/V. Spring Boot Actuator/48.6.1 Auto-configured-HealthIndicators.md +++ b/V. Spring Boot Actuator/48.6.1 Auto-configured-HealthIndicators.md @@ -4,15 +4,17 @@ Spring Boot在合适的时候会自动配置以下`HealthIndicators`: |名称|描述| |----|:-----| -|[`CassandraHealthIndicator`](https://github.com/spring-projects/spring-boot/tree/v2.0.0.RELEASE/spring-boot-actuator/src/main/java/org/springframework/boot/actuate/health/CassandraHealthIndicator.java)|检查Cassandra数据库状况| -|[`DiskSpaceHealthIndicator`](https://github.com/spring-projects/spring-boot/tree/v2.0.0.RELEASE/spring-boot-actuator/src/main/java/org/springframework/boot/actuate/health/DiskSpaceHealthIndicator.java)|低磁盘空间检查| -|[`DataSourceHealthIndicator`](https://github.com/spring-projects/spring-boot/tree/v2.0.0.RELEASE/spring-boot-actuator/src/main/java/org/springframework/boot/actuate/health/DataSourceHealthIndicator.java)|检查是否能从`DataSource`获取连接| -|[`ElasticsearchHealthIndicator`](https://github.com/spring-projects/spring-boot/tree/v2.0.0.RELEASE/spring-boot-actuator/src/main/java/org/springframework/boot/actuate/health/ElasticsearchHealthIndicator.java)|检查Elasticsearch集群状况| -|[`JmsHealthIndicator`](https://github.com/spring-projects/spring-boot/tree/v2.0.0.RELEASE/spring-boot-actuator/src/main/java/org/springframework/boot/actuate/health/JmsHealthIndicator.java)|检查JMS消息代理状况| -|[`MailHealthIndicator`](https://github.com/spring-projects/spring-boot/tree/v2.0.0.RELEASE/spring-boot-actuator/src/main/java/org/springframework/boot/actuate/health/MailHealthIndicator.java)|检查邮件服务器状况| -|[`MongoHealthIndicator`](https://github.com/spring-projects/spring-boot/tree/v2.0.0.RELEASE/spring-boot-actuator/src/main/java/org/springframework/boot/actuate/health/MongoHealthIndicator.java)|检查Mongo数据库状况| -|[`RabbitHealthIndicator`](https://github.com/spring-projects/spring-boot/tree/v2.0.0.RELEASE/spring-boot-actuator/src/main/java/org/springframework/boot/actuate/health/MongoHealthIndicator.java)|检查Rabbit服务器状况| -|[`RedisHealthIndicator`](https://github.com/spring-projects/spring-boot/tree/v2.0.0.RELEASE/spring-boot-actuator/src/main/java/org/springframework/boot/actuate/health/RedisHealthIndicator.java)|检查Redis服务器状况| -|[`SolrHealthIndicator`](https://github.com/spring-projects/spring-boot/tree/v2.0.0.RELEASE/spring-boot-actuator/src/main/java/org/springframework/boot/actuate/health/SolrHealthIndicator.java)|检查Solr服务器状况| +|[`CassandraHealthIndicator`](https://github.com/spring-projects/spring-boot/tree/v2.0.0.RELEASE/spring-boot-project/spring-boot-actuator/src/main/java/org/springframework/boot/actuate/cassandra/CassandraHealthIndicator.java)|检查Cassandra数据库状况| +|[`DiskSpaceHealthIndicator`](https://github.com/spring-projects/spring-boot/tree/v2.0.0.RELEASE/spring-boot-project/spring-boot-actuator/src/main/java/org/springframework/boot/actuate/system/DiskSpaceHealthIndicator.java)|低磁盘空间检查| +|[`DataSourceHealthIndicator`](https://github.com/spring-projects/spring-boot/tree/v2.0.0.RELEASE/spring-boot-project/spring-boot-actuator/src/main/java/org/springframework/boot/actuate/jdbc/DataSourceHealthIndicator.java)|检查是否能从`DataSource`获取连接| +|[`ElasticsearchHealthIndicator`](https://github.com/spring-projects/spring-boot/tree/v2.0.0.RELEASE/spring-boot-project/spring-boot-actuator/src/main/java/org/springframework/boot/actuate/elasticsearch/ElasticsearchHealthIndicator.java)|检查Elasticsearch集群状况| +|[`InfluxDbHealthIndicator`](https://github.com/spring-projects/spring-boot/tree/v2.0.0.RELEASE/spring-boot-project/spring-boot-actuator/src/main/java/org/springframework/boot/actuate/influx/InfluxDbHealthIndicator.java)|检查InfluxDB服务器状况| +|[`JmsHealthIndicator`](https://github.com/spring-projects/spring-boot/tree/v2.0.0.RELEASE/spring-boot-project/spring-boot-actuator/src/main/java/org/springframework/boot/actuate/jms/JmsHealthIndicator.java)|检查JMS消息代理状况| +|[`MailHealthIndicator`](https://github.com/spring-projects/spring-boot/tree/v2.0.0.RELEASE/spring-boot-project/spring-boot-actuator/src/main/java/org/springframework/boot/actuate/mail/MailHealthIndicator.java)|检查邮件服务器状况| +|[`MongoHealthIndicator`](https://github.com/spring-projects/spring-boot/tree/v2.0.0.RELEASE/spring-boot-project/spring-boot-actuator/src/main/java/org/springframework/boot/actuate/mongo/MongoHealthIndicator.java)|检查Mongo数据库状况| +|[`Neo4jHealthIndicator`](https://github.com/spring-projects/spring-boot/tree/v2.0.0.RELEASE/spring-boot-project/spring-boot-actuator/src/main/java/org/springframework/boot/actuate/neo4j/Neo4jHealthIndicator.java)|检查Neo4j服务器状况| +|[`RabbitHealthIndicator`](https://github.com/spring-projects/spring-boot/tree/v2.0.0.RELEASE/spring-boot-project/spring-boot-actuator/src/main/java/org/springframework/boot/actuate/amqp/RabbitHealthIndicator.java)|检查Rabbit服务器状况| +|[`RedisHealthIndicator`](https://github.com/spring-projects/spring-boot/tree/v2.0.0.RELEASE/spring-boot-project/spring-boot-actuator/src/main/java/org/springframework/boot/actuate/redis/RedisHealthIndicator.java)|检查Redis服务器状况| +|[`SolrHealthIndicator`](https://github.com/spring-projects/spring-boot/tree/v2.0.0.RELEASE/spring-boot-project/spring-boot-actuator/src/main/java/org/springframework/boot/actuate/solr/SolrHealthIndicator.java)|检查Solr服务器状况| **注** 使用`management.health.defaults.enabled`属性可以禁用以上全部`HealthIndicators`。 From f50ddb0955cdc2c99b7b0f4c559cb978b9a8abfb Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E7=83=AD=E5=BF=83=E5=B8=82=E6=B0=91=E9=92=9F=E5=B0=8F?= =?UTF-8?q?=E5=BC=BA?= Date: Thu, 8 Aug 2019 09:37:42 +0800 Subject: [PATCH 509/865] Update and rename 48.6.1 Auto-configured-HealthIndicators.md to 50.9.1 Auto-configured HealthIndicators.md --- ...Indicators.md => 50.9.1 Auto-configured HealthIndicators.md} | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) rename V. Spring Boot Actuator/{48.6.1 Auto-configured-HealthIndicators.md => 50.9.1 Auto-configured HealthIndicators.md} (98%) diff --git a/V. Spring Boot Actuator/48.6.1 Auto-configured-HealthIndicators.md b/V. Spring Boot Actuator/50.9.1 Auto-configured HealthIndicators.md similarity index 98% rename from V. Spring Boot Actuator/48.6.1 Auto-configured-HealthIndicators.md rename to V. Spring Boot Actuator/50.9.1 Auto-configured HealthIndicators.md index e53a4969..b6bd2a6d 100644 --- a/V. Spring Boot Actuator/48.6.1 Auto-configured-HealthIndicators.md +++ b/V. Spring Boot Actuator/50.9.1 Auto-configured HealthIndicators.md @@ -1,4 +1,4 @@ -### 48.6.1 自动配置的HealthIndicators +### 50.9.1 自动配置的HealthIndicator Spring Boot在合适的时候会自动配置以下`HealthIndicators`: From 45b47eabc1090a84afaa68ac3436b686049bd2f5 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E7=83=AD=E5=BF=83=E5=B8=82=E6=B0=91=E9=92=9F=E5=B0=8F?= =?UTF-8?q?=E5=BC=BA?= Date: Thu, 8 Aug 2019 10:25:32 +0800 Subject: [PATCH 510/865] Delete 48.6 Security with HealthIndicators.md --- .../48.6 Security with HealthIndicators.md | 4 ---- 1 file changed, 4 deletions(-) delete mode 100644 V. Spring Boot Actuator/48.6 Security with HealthIndicators.md diff --git a/V. Spring Boot Actuator/48.6 Security with HealthIndicators.md b/V. Spring Boot Actuator/48.6 Security with HealthIndicators.md deleted file mode 100644 index 38187328..00000000 --- a/V. Spring Boot Actuator/48.6 Security with HealthIndicators.md +++ /dev/null @@ -1,4 +0,0 @@ -### 48.6 安全与HealthIndicators -`HealthIndicators`返回的信息通常有点敏感,例如,你可能不想将数据库服务器的详情发布到外面。因此,在使用一个未认证的HTTP连接时,默认只会暴露健康状态(health status)。如果想将所有的健康信息暴露出去,你可以把`endpoints.health.sensitive`设置为`false`。 - -为防止'拒绝服务'攻击,Health响应会被缓存,你可以使用`endpoints.health.time-to-live`属性改变默认的缓存时间(1000毫秒)。 From a59647cdc78ebef87c98aabde68fb190ecb26f30 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E7=83=AD=E5=BF=83=E5=B8=82=E6=B0=91=E9=92=9F=E5=B0=8F?= =?UTF-8?q?=E5=BC=BA?= Date: Sat, 10 Aug 2019 21:09:07 +0800 Subject: [PATCH 511/865] Update and rename 48.6.2 Writing custom HealthIndicators.md to 50.9.2 Writing Custom HealthIndicators.md --- .../48.6.2 Writing custom HealthIndicators.md | 33 -------------- .../50.9.2 Writing Custom HealthIndicators.md | 44 +++++++++++++++++++ 2 files changed, 44 insertions(+), 33 deletions(-) delete mode 100644 V. Spring Boot Actuator/48.6.2 Writing custom HealthIndicators.md create mode 100644 V. Spring Boot Actuator/50.9.2 Writing Custom HealthIndicators.md diff --git a/V. Spring Boot Actuator/48.6.2 Writing custom HealthIndicators.md b/V. Spring Boot Actuator/48.6.2 Writing custom HealthIndicators.md deleted file mode 100644 index 811a2aea..00000000 --- a/V. Spring Boot Actuator/48.6.2 Writing custom HealthIndicators.md +++ /dev/null @@ -1,33 +0,0 @@ -### 48.6.2 编写自定义HealthIndicators -你可以注册实现[HealthIndicator](https://github.com/spring-projects/spring-boot/tree/v2.0.0.RELEASE/spring-boot-actuator/src/main/java/org/springframework/boot/actuate/health/HealthIndicator.java)接口的Spring beans来提供自定义健康信息。你需要实现`health()`方法,并返回一个`Health`响应,该响应需要包含一个`status`和其他用于展示的详情。 -```java -import org.springframework.boot.actuate.health.HealthIndicator; -import org.springframework.stereotype.Component; - -@Component -public class MyHealth implements HealthIndicator { - - @Override - public Health health() { - int errorCode = check(); // perform some specific health check - if (errorCode != 0) { - return Health.down().withDetail("Error Code", errorCode).build(); - } - return Health.up().build(); - } - -} -``` -**注** 对于给定`HealthIndicator`的标识是bean name去掉`HealthIndicator`后缀剩下的部分。在以上示例中,可以在`my`的实体中获取健康信息。 - -除Spring Boot预定义的[`Status`](http://github.com/spring-projects/spring-boot/tree/master/spring-boot-actuator/src/main/java/org/springframework/boot/actuate/health/Status.java)类型,`Health`也可以返回一个代表新的系统状态的自定义`Status`。在这种情况下,你需要提供一个[`HealthAggregator`](http://github.com/spring-projects/spring-boot/tree/master/spring-boot-actuator/src/main/java/org/springframework/boot/actuate/health/HealthAggregator.java)接口的自定义实现,或使用`management.health.status.order`属性配置默认实现。 - -例如,假设一个新的,代码为`FATAL`的`Status`被用于你的一个`HealthIndicator`实现中。为了配置严重性级别,你需要将以下配置添加到application属性文件中: -```properties -management.health.status.order=FATAL, DOWN, OUT_OF_SERVICE, UNKNOWN, UP -``` -在回应中的HTTP状态码反映了全体的健康状况(例如,`UP`映射到200,`OUT_OF_SERVICE`或者`DOWN`映射到503)。如果使用HTTP访问health端点,你可能想要注册自定义的status,并使用`HealthMvcEndpoint`进行映射。例如,你可以将`FATAL`映射为`HttpStatus.SERVICE_UNAVAILABLE`。 -例如,如下将`FATAL`映射到`HttpStatus.SERVICE_UNAVAILABLE`: -```properties -endpoints.health.mapping.FATAL=503 -``` diff --git a/V. Spring Boot Actuator/50.9.2 Writing Custom HealthIndicators.md b/V. Spring Boot Actuator/50.9.2 Writing Custom HealthIndicators.md new file mode 100644 index 00000000..332cdb5c --- /dev/null +++ b/V. Spring Boot Actuator/50.9.2 Writing Custom HealthIndicators.md @@ -0,0 +1,44 @@ +### 50.9.2 编写自定义HealthIndicator + +你可以注册实现[HealthIndicator](https://github.com/spring-projects/spring-boot/tree/v2.0.0.RELEASE/spring-boot-project/spring-boot-actuator/src/main/java/org/springframework/boot/actuate/health/HealthIndicator.java)接口的Spring beans来提供自定义健康信息。你需要实现`health()`方法,并返回一个`Health`响应,该响应需要包含一个`status`和其他用于展示的详情。下面的代码展示了一个`HealthIndicator`实现类的例子: +```java +import org.springframework.boot.actuate.health.HealthIndicator; +import org.springframework.stereotype.Component; + +@Component +public class MyHealth implements HealthIndicator { + + @Override + public Health health() { + int errorCode = check(); // perform some specific health check + if (errorCode != 0) { + return Health.down().withDetail("Error Code", errorCode).build(); + } + return Health.up().build(); + } + +} +``` +**注** 对于给定`HealthIndicator`的标识是bean name去掉`HealthIndicator`后缀剩下的部分。在以上示例中,可以在`my`的实体中获取健康信息。 + +除Spring Boot预定义的[`Status`](https://github.com/spring-projects/spring-boot/tree/v2.0.0.RELEASE/spring-boot-project/spring-boot-actuator/src/main/java/org/springframework/boot/actuate/health/Status.java)类型,`Health`也可以返回一个代表新的系统状态的自定义`Status`。在这种情况下,你需要提供一个[`HealthAggregator`](https://github.com/spring-projects/spring-boot/tree/v2.0.0.RELEASE/spring-boot-project/spring-boot-actuator/src/main/java/org/springframework/boot/actuate/health/HealthAggregator.java)接口的自定义实现,或使用`management.health.status.order`属性配置默认实现。 + +例如,假设一个新的,代码为`FATAL`的`Status`被用于你的一个`HealthIndicator`实现中。为了配置严重性级别,你需要将以下配置添加到application属性文件中: +```properties +management.health.status.order=FATAL, DOWN, OUT_OF_SERVICE, UNKNOWN, UP +``` +在回应中的HTTP状态码反映了全体的健康状况(例如,`UP`映射到200,`OUT_OF_SERVICE`和`DOWN`映射到503)。如果使用HTTP访问health端点,你可能想要注册自定义的status。例如,你可以将`FATAL`映射为503(服务不可用)。 +```properties +management.health.status.http-mapping.FATAL=503 +``` + +**注** 如果你需要更多的控制,你可以定义你自己的`HealthStatusHttpMapper`bean。 + +下面的表格展示了内建状态的默认状态映射: + +|状态|映射| +|----|:-----| +|DOWN|SERVICE_UNAVAILABLE (503)| +|OUT_OF_SERVICE|SERVICE_UNAVAILABLE (503)| +|UP|默认无映射,所以http状态是200| +|UNKNOWN|默认无映射,所以http状态是200| From e19890c64f3a44a6fb97d5ea698601b333b3b61a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E7=83=AD=E5=BF=83=E5=B8=82=E6=B0=91=E9=92=9F=E5=B0=8F?= =?UTF-8?q?=E5=BC=BA?= Date: Sat, 10 Aug 2019 21:19:47 +0800 Subject: [PATCH 512/865] Update SUMMARY.md --- SUMMARY.md | 2 ++ 1 file changed, 2 insertions(+) diff --git a/SUMMARY.md b/SUMMARY.md index 06f45826..aaedb4ed 100644 --- a/SUMMARY.md +++ b/SUMMARY.md @@ -334,6 +334,8 @@ * [50.9 健康信息](V. Spring Boot Actuator/50.9 Health Information.md) * [50.9.1 自动配置的HealthIndicator](V. Spring Boot Actuator/50.9.1 Auto-configured HealthIndicators.md) * [50.9.2 编写自定义HealthIndicator](V. Spring Boot Actuator/50.9.2 Writing Custom HealthIndicators.md) + * [50.9.3 响应式的健康指示器](V. Spring Boot Actuator/50.9.3 Reactive Health Indicators.md) + * [50.9.4 自动配置的ReactiveHealthIndicators](V. Spring Boot Actuator/50.9.4 Auto-configured ReactiveHealthIndicators.md) * [50.10 应用信息](V. Spring Boot Actuator/50.10 Application Information.md) * [50.10.1 自动配置的InfoContributors](V. Spring Boot Actuator/50.10.1 Auto-configured InfoContributors.md) * [50.10.2 自定义应用info信息](V. Spring Boot Actuator/50.10.2 Custom Application Info Information.md) From 0fed8884b74d3159e357c092f13c309f1c6494ef Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E7=83=AD=E5=BF=83=E5=B8=82=E6=B0=91=E9=92=9F=E5=B0=8F?= =?UTF-8?q?=E5=BC=BA?= Date: Sat, 10 Aug 2019 21:43:32 +0800 Subject: [PATCH 513/865] Create 50.9.3 Reactive Health Indicators.md --- .../50.9.3 Reactive Health Indicators.md | 20 +++++++++++++++++++ 1 file changed, 20 insertions(+) create mode 100644 V. Spring Boot Actuator/50.9.3 Reactive Health Indicators.md diff --git a/V. Spring Boot Actuator/50.9.3 Reactive Health Indicators.md b/V. Spring Boot Actuator/50.9.3 Reactive Health Indicators.md new file mode 100644 index 00000000..cac27bc9 --- /dev/null +++ b/V. Spring Boot Actuator/50.9.3 Reactive Health Indicators.md @@ -0,0 +1,20 @@ +### 50.9.3 响应式的健康指示器 + +For reactive applications, such as those using Spring WebFlux, `ReactiveHealthIndicator` provides a non-blocking contract for getting application health. Similar to a traditional `HealthIndicator`, health information is collected from all [`ReactiveHealthIndicator`](https://github.com/spring-projects/spring-boot/tree/v2.0.0.RELEASE/spring-boot-project/spring-boot-actuator/src/main/java/org/springframework/boot/actuate/health/ReactiveHealthIndicator.java) beans defined in your `ApplicationContext`. Regular `HealthIndicator` beans that do not check against a reactive API are included and executed on the elastic scheduler. + +To provide custom health information from a reactive API, you can register Spring beans that implement the [`ReactiveHealthIndicator`](https://github.com/spring-projects/spring-boot/tree/v2.0.0.RELEASE/spring-boot-project/spring-boot-actuator/src/main/java/org/springframework/boot/actuate/health/ReactiveHealthIndicator.java) interface. The following code shows a sample `ReactiveHealthIndicator` implementation: + +``` +@Component +public class MyReactiveHealthIndicator implements ReactiveHealthIndicator { + + @Override + public Mono health() { + return doHealthCheck() //perform some specific health check that returns a Mono + .onErrorResume(ex -> Mono.just(new Health.Builder().down(ex).build()))); + } + +} +``` + +**注** To handle the error automatically, consider extending from `AbstractReactiveHealthIndicator`. From ec7777f5743ddafd51bc8763feff0ce408b54dc5 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E7=83=AD=E5=BF=83=E5=B8=82=E6=B0=91=E9=92=9F=E5=B0=8F?= =?UTF-8?q?=E5=BC=BA?= Date: Sun, 11 Aug 2019 22:13:26 +0800 Subject: [PATCH 514/865] Update 50.9.3 Reactive Health Indicators.md --- .../50.9.3 Reactive Health Indicators.md | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/V. Spring Boot Actuator/50.9.3 Reactive Health Indicators.md b/V. Spring Boot Actuator/50.9.3 Reactive Health Indicators.md index cac27bc9..5c988fc7 100644 --- a/V. Spring Boot Actuator/50.9.3 Reactive Health Indicators.md +++ b/V. Spring Boot Actuator/50.9.3 Reactive Health Indicators.md @@ -1,9 +1,8 @@ ### 50.9.3 响应式的健康指示器 -For reactive applications, such as those using Spring WebFlux, `ReactiveHealthIndicator` provides a non-blocking contract for getting application health. Similar to a traditional `HealthIndicator`, health information is collected from all [`ReactiveHealthIndicator`](https://github.com/spring-projects/spring-boot/tree/v2.0.0.RELEASE/spring-boot-project/spring-boot-actuator/src/main/java/org/springframework/boot/actuate/health/ReactiveHealthIndicator.java) beans defined in your `ApplicationContext`. Regular `HealthIndicator` beans that do not check against a reactive API are included and executed on the elastic scheduler. - -To provide custom health information from a reactive API, you can register Spring beans that implement the [`ReactiveHealthIndicator`](https://github.com/spring-projects/spring-boot/tree/v2.0.0.RELEASE/spring-boot-project/spring-boot-actuator/src/main/java/org/springframework/boot/actuate/health/ReactiveHealthIndicator.java) interface. The following code shows a sample `ReactiveHealthIndicator` implementation: +对于响应式应用程序,例如那些使用Spring WebFlux的应用程序,`ReactiveHealthIndicator`提供了一个非阻塞契约来获得应用程序的健康状态。与传统的`HealthIndicator`类似,健康信息收集自`ApplicationContext`中定义的所有[`ReactiveHealthIndicator`](https://github.com/spring-projects/spring-boot/tree/v2.0.0.RELEASE/spring-boot-project/spring-boot-actuator/src/main/java/org/springframework/boot/actuate/health/ReactiveHealthIndicator.java) bean。不检查响应式API的常规`HealthIndicator`bean包含在弹性调度器中并在其上执行。 +要从响应式API提供自定义健康信息,你可以注册实现[`ReactiveHealthIndicator`](https://github.com/spring-projects/spring-boot/tree/v2.0.0.RELEASE/spring-boot-project/spring-boot-actuator/src/main/java/org/springframework/boot/actuate/health/ReactiveHealthIndicator.java)接口的Spring bean。下面的代码显示了一个示例`ReactiveHealthIndicator`实现: ``` @Component public class MyReactiveHealthIndicator implements ReactiveHealthIndicator { @@ -17,4 +16,4 @@ public class MyReactiveHealthIndicator implements ReactiveHealthIndicator { } ``` -**注** To handle the error automatically, consider extending from `AbstractReactiveHealthIndicator`. +**注** 要自动处理错误,可以考虑从`AbstractReactiveHealthIndicator`扩展。 From 034913fc108d93dcac290b9576de84e3d48560af Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E7=83=AD=E5=BF=83=E5=B8=82=E6=B0=91=E9=92=9F=E5=B0=8F?= =?UTF-8?q?=E5=BC=BA?= Date: Sun, 11 Aug 2019 22:26:17 +0800 Subject: [PATCH 515/865] Create 50.9.4 Auto-configured ReactiveHealthIndicators.md --- .../50.9.4 Auto-configured ReactiveHealthIndicators.md | 10 ++++++++++ 1 file changed, 10 insertions(+) create mode 100644 V. Spring Boot Actuator/50.9.4 Auto-configured ReactiveHealthIndicators.md diff --git a/V. Spring Boot Actuator/50.9.4 Auto-configured ReactiveHealthIndicators.md b/V. Spring Boot Actuator/50.9.4 Auto-configured ReactiveHealthIndicators.md new file mode 100644 index 00000000..f9582f14 --- /dev/null +++ b/V. Spring Boot Actuator/50.9.4 Auto-configured ReactiveHealthIndicators.md @@ -0,0 +1,10 @@ +### 50.9.4 自动配置的ReactiveHealthIndicator + +以下`ReactiveHealthIndicator`是由Spring Boot在适当的时候自动配置的: + +|名称|描述| +|----|:-----| +|[`MongoReactiveHealthIndicator`](https://github.com/spring-projects/spring-boot/tree/v2.0.0.RELEASE/spring-boot-project/spring-boot-actuator/src/main/java/org/springframework/boot/actuate/mongo/MongoReactiveHealthIndicator.java)|检查Mongo数据库是否已启动| +|[`RedisReactiveHealthIndicator`](https://github.com/spring-projects/spring-boot/tree/v2.0.0.RELEASE/spring-boot-project/spring-boot-actuator/src/main/java/org/springframework/boot/actuate/redis/RedisReactiveHealthIndicator.java)|检查Redis服务器是否已启动| + +**注** 如有必要,响应式指标会取代常规指标。此外,任何未显式处理的`HealthIndicator`都会自动包装。 From fd39965adf33ef5748cd3207bc9b31f7c4984c4a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E7=83=AD=E5=BF=83=E5=B8=82=E6=B0=91=E9=92=9F=E5=B0=8F?= =?UTF-8?q?=E5=BC=BA?= Date: Mon, 12 Aug 2019 09:24:16 +0800 Subject: [PATCH 516/865] Update and rename 48.7 Application information.md to 50.10 Application Information.md --- V. Spring Boot Actuator/48.7 Application information.md | 2 -- V. Spring Boot Actuator/50.10 Application Information.md | 3 +++ 2 files changed, 3 insertions(+), 2 deletions(-) delete mode 100644 V. Spring Boot Actuator/48.7 Application information.md create mode 100644 V. Spring Boot Actuator/50.10 Application Information.md diff --git a/V. Spring Boot Actuator/48.7 Application information.md b/V. Spring Boot Actuator/48.7 Application information.md deleted file mode 100644 index 9f93b41b..00000000 --- a/V. Spring Boot Actuator/48.7 Application information.md +++ /dev/null @@ -1,2 +0,0 @@ -###48.7 应用信息 -应用信息会暴露所有[`InfoContributor`](https://github.com/spring-projects/spring-boot/tree/v2.0.0.RELEASE/spring-boot-actuator/src/main/java/org/springframework/boot/actuate/info/InfoContributor.java) beans收集的各种信息,Spring Boot包含很多自动配置的`InfoContributors`,你也可以编写自己的实现。 diff --git a/V. Spring Boot Actuator/50.10 Application Information.md b/V. Spring Boot Actuator/50.10 Application Information.md new file mode 100644 index 00000000..a64c0524 --- /dev/null +++ b/V. Spring Boot Actuator/50.10 Application Information.md @@ -0,0 +1,3 @@ +### 50.10 应用信息 + +应用信息会暴露所有[`InfoContributor`](https://github.com/spring-projects/spring-boot/tree/v2.0.0.RELEASE/spring-boot-project/spring-boot-actuator/src/main/java/org/springframework/boot/actuate/info/InfoContributor.java) bean收集的各种信息。Spring Boot包含很多自动配置的`InfoContributor` bean,你也可以编写自己的实现。 From 0e12131be54b71a5618c40119d56df133bfc23a6 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E7=83=AD=E5=BF=83=E5=B8=82=E6=B0=91=E9=92=9F=E5=B0=8F?= =?UTF-8?q?=E5=BC=BA?= Date: Mon, 12 Aug 2019 09:30:39 +0800 Subject: [PATCH 517/865] Update and rename 48.7.1 Auto-configured InfoContributors.md to 50.10.1 Auto-configured InfoContributors.md --- .../48.7.1 Auto-configured InfoContributors.md | 10 ---------- .../50.10.1 Auto-configured InfoContributors.md | 11 +++++++++++ 2 files changed, 11 insertions(+), 10 deletions(-) delete mode 100644 V. Spring Boot Actuator/48.7.1 Auto-configured InfoContributors.md create mode 100644 V. Spring Boot Actuator/50.10.1 Auto-configured InfoContributors.md diff --git a/V. Spring Boot Actuator/48.7.1 Auto-configured InfoContributors.md b/V. Spring Boot Actuator/48.7.1 Auto-configured InfoContributors.md deleted file mode 100644 index 964e1738..00000000 --- a/V. Spring Boot Actuator/48.7.1 Auto-configured InfoContributors.md +++ /dev/null @@ -1,10 +0,0 @@ -###48.7.1 自动配置的InfoContributors -Spring Boot会在合适的时候自动配置以下`InfoContributors`: - -|名称|描述| -|:----|:----| -|[`EnvironmentInfoContributor`](https://github.com/spring-projects/spring-boot/tree/v2.0.0.RELEASE/spring-boot-actuator/src/main/java/org/springframework/boot/actuate/info/EnvironmentInfoContributor.java)|暴露`Environment`中key为`info`的所有key| -|[`GitInfoContributor`](https://github.com/spring-projects/spring-boot/tree/v2.0.0.RELEASE/spring-boot-actuator/src/main/java/org/springframework/boot/actuate/info/GitInfoContributor.java)|暴露git信息,如果存在`git.properties`文件| -|[`BuildInfoContributor`](https://github.com/spring-projects/spring-boot/tree/v2.0.0.RELEASE/spring-boot-actuator/src/main/java/org/springframework/boot/actuate/info/BuildInfoContributor.java)|暴露构建信息,如果存在`META-INF/build-info.properties`文件| - -**注** 使用`management.info.defaults.enabled`属性可禁用以上所有`InfoContributors`。 diff --git a/V. Spring Boot Actuator/50.10.1 Auto-configured InfoContributors.md b/V. Spring Boot Actuator/50.10.1 Auto-configured InfoContributors.md new file mode 100644 index 00000000..5da1205b --- /dev/null +++ b/V. Spring Boot Actuator/50.10.1 Auto-configured InfoContributors.md @@ -0,0 +1,11 @@ +### 50.10.1 自动配置的InfoContributor + +Spring Boot会在合适的时候自动配置以下`InfoContributor` bean: + +|名称|描述| +|:----|:----| +|[`EnvironmentInfoContributor`](https://github.com/spring-projects/spring-boot/tree/v2.0.0.RELEASE/spring-boot-project/spring-boot-actuator/src/main/java/org/springframework/boot/actuate/info/EnvironmentInfoContributor.java)|暴露`Environment`中key为`info`的所有key| +|[`GitInfoContributor`](https://github.com/spring-projects/spring-boot/tree/v2.0.0.RELEASE/spring-boot-project/spring-boot-actuator/src/main/java/org/springframework/boot/actuate/info/GitInfoContributor.java)|暴露git信息,如果存在`git.properties`文件| +|[`BuildInfoContributor`](https://github.com/spring-projects/spring-boot/tree/v2.0.0.RELEASE/spring-boot-project/spring-boot-actuator/src/main/java/org/springframework/boot/actuate/info/BuildInfoContributor.java)|暴露构建信息,如果存在`META-INF/build-info.properties`文件| + +**注** 使用`management.info.defaults.enabled`属性可禁用以上所有`InfoContributor` bean。 From 5f588335f72a26123308858bda2f0b762cb85650 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E7=83=AD=E5=BF=83=E5=B8=82=E6=B0=91=E9=92=9F=E5=B0=8F?= =?UTF-8?q?=E5=BC=BA?= Date: Mon, 12 Aug 2019 09:37:32 +0800 Subject: [PATCH 518/865] Update and rename 48.7.2 Custom application info information.md to 50.10.2 Custom Application Information.md --- ...formation.md => 50.10.2 Custom Application Information.md} | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) rename V. Spring Boot Actuator/{48.7.2 Custom application info information.md => 50.10.2 Custom Application Information.md} (80%) diff --git a/V. Spring Boot Actuator/48.7.2 Custom application info information.md b/V. Spring Boot Actuator/50.10.2 Custom Application Information.md similarity index 80% rename from V. Spring Boot Actuator/48.7.2 Custom application info information.md rename to V. Spring Boot Actuator/50.10.2 Custom Application Information.md index e4914e77..b11eefd3 100644 --- a/V. Spring Boot Actuator/48.7.2 Custom application info information.md +++ b/V. Spring Boot Actuator/50.10.2 Custom Application Information.md @@ -1,6 +1,6 @@ -### 48.7.2 自定义应用info信息 +### 50.10.2 自定义应用信息 -通过设置Spring属性`info.*`,你可以定义`info`端点暴露的数据。所有在`info`关键字下的`Environment`属性都将被自动暴露,例如,你可以将以下配置添加到`application.properties`: +通过设置Spring属性`info.*`,你可以定义`info`端点暴露的数据。所有在`info`关键字下的`Environment`属性都将被自动暴露。例如,你可以将以下配置添加到`application.properties`文件: ```properties info.app.encoding=UTF-8 info.app.java.source=1.8 From e2ab029cfc4ef61e33696ab83fc51836c29ee866 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E7=83=AD=E5=BF=83=E5=B8=82=E6=B0=91=E9=92=9F=E5=B0=8F?= =?UTF-8?q?=E5=BC=BA?= Date: Mon, 12 Aug 2019 09:41:50 +0800 Subject: [PATCH 519/865] Update and rename 48.7.3 Git commit information.md to 50.10.3 Git Commit Information.md --- ...commit information.md => 50.10.3 Git Commit Information.md} | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) rename V. Spring Boot Actuator/{48.7.3 Git commit information.md => 50.10.3 Git Commit Information.md} (94%) diff --git a/V. Spring Boot Actuator/48.7.3 Git commit information.md b/V. Spring Boot Actuator/50.10.3 Git Commit Information.md similarity index 94% rename from V. Spring Boot Actuator/48.7.3 Git commit information.md rename to V. Spring Boot Actuator/50.10.3 Git Commit Information.md index 22d4c508..b344f38d 100644 --- a/V. Spring Boot Actuator/48.7.3 Git commit information.md +++ b/V. Spring Boot Actuator/50.10.3 Git Commit Information.md @@ -1,4 +1,5 @@ -### 48.7.3 Git提交信息 +### 50.10.3 Git提交信息 + `info`端点的另一个有用特性是,在项目构建完成后发布`git`源码仓库的状态信息。如果`GitProperties` bean可用,Spring Boot将暴露`git.branch`,`git.commit.id`和`git.commit.time`属性。 **注** 如果classpath根目录存在`git.properties`文件,Spring Boot将自动配置`GitProperties` bean。查看[Generate git information](https://docs.spring.io/spring-boot/docs/2.0.0.RELEASE/reference/htmlsingle/#howto-git-info)获取更多详细信息。 From 2a0a756aee1db9f69e73a15c78168f7f7330a6ae Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E7=83=AD=E5=BF=83=E5=B8=82=E6=B0=91=E9=92=9F=E5=B0=8F?= =?UTF-8?q?=E5=BC=BA?= Date: Mon, 12 Aug 2019 09:44:32 +0800 Subject: [PATCH 520/865] Update and rename 48.7.4 Build information.md to 50.10.4 Build Information.md --- ...8.7.4 Build information.md => 50.10.4 Build Information.md} | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) rename V. Spring Boot Actuator/{48.7.4 Build information.md => 50.10.4 Build Information.md} (93%) diff --git a/V. Spring Boot Actuator/48.7.4 Build information.md b/V. Spring Boot Actuator/50.10.4 Build Information.md similarity index 93% rename from V. Spring Boot Actuator/48.7.4 Build information.md rename to V. Spring Boot Actuator/50.10.4 Build Information.md index b9c615a9..46bbe3a2 100644 --- a/V. Spring Boot Actuator/48.7.4 Build information.md +++ b/V. Spring Boot Actuator/50.10.4 Build Information.md @@ -1,4 +1,5 @@ -###48.7.4 构建信息 +### 50.10.4 构建信息 + 如果`BuildProperties` bean存在,`info`端点也会发布你的构建信息。 **注** 如果classpath下存在`META-INF/build-info.properties`文件,Spring Boot将自动构建`BuildProperties` bean。Maven和Gradle都能产生该文件,具体查看[Generate build information](https://docs.spring.io/spring-boot/docs/2.0.0.RELEASE/reference/htmlsingle/#howto-build-info)。 From d55ac44ea481a63222588a56b81b5b613e95f145 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E7=83=AD=E5=BF=83=E5=B8=82=E6=B0=91=E9=92=9F=E5=B0=8F?= =?UTF-8?q?=E5=BC=BA?= Date: Mon, 12 Aug 2019 09:50:27 +0800 Subject: [PATCH 521/865] Update and rename 48.7.5 Writing custom InfoContributors.md to 50.10.5 Writing Custom InfoContributors.md --- ...utors.md => 50.10.5 Writing Custom InfoContributors.md} | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) rename V. Spring Boot Actuator/{48.7.5 Writing custom InfoContributors.md => 50.10.5 Writing Custom InfoContributors.md} (60%) diff --git a/V. Spring Boot Actuator/48.7.5 Writing custom InfoContributors.md b/V. Spring Boot Actuator/50.10.5 Writing Custom InfoContributors.md similarity index 60% rename from V. Spring Boot Actuator/48.7.5 Writing custom InfoContributors.md rename to V. Spring Boot Actuator/50.10.5 Writing Custom InfoContributors.md index dfb42e05..1b4e7f26 100644 --- a/V. Spring Boot Actuator/48.7.5 Writing custom InfoContributors.md +++ b/V. Spring Boot Actuator/50.10.5 Writing Custom InfoContributors.md @@ -1,5 +1,6 @@ -###48.7.5 编写自定义的InfoContributors -你可以注册实现了[`InfoContributor`](https://github.com/spring-projects/spring-boot/tree/v2.0.0.RELEASE/spring-boot-actuator/src/main/java/org/springframework/boot/actuate/info/InfoContributor.java)接口的Spring beans来提供自定义应用信息。以下示例暴露一个只有单个值的`example`实体: +### 50.10.5 编写自定义的InfoContributor + +你可以注册实现了[`InfoContributor`](https://github.com/spring-projects/spring-boot/tree/v2.0.0.RELEASE/spring-boot-project/spring-boot-actuator/src/main/java/org/springframework/boot/actuate/info/InfoContributor.java)接口的Spring bean,来提供自定义应用信息。以下示例暴露一个只有单个值的`example`实体: ```java import java.util.Collections; @@ -18,7 +19,7 @@ public class ExampleInfoContributor implements InfoContributor { } ``` -如果点击`info`端点,你应该可以看到包含以下实体的响应: +如果到达`info`端点,你应该可以看到包含以下实体的响应: ```json { "example": { From 68d040be9a05494e82ffbbc0e93452a50d11f374 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E7=83=AD=E5=BF=83=E5=B8=82=E6=B0=91=E9=92=9F=E5=B0=8F?= =?UTF-8?q?=E5=BC=BA?= Date: Mon, 12 Aug 2019 10:04:28 +0800 Subject: [PATCH 522/865] Update SUMMARY.md --- SUMMARY.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/SUMMARY.md b/SUMMARY.md index aaedb4ed..82754498 100644 --- a/SUMMARY.md +++ b/SUMMARY.md @@ -338,10 +338,10 @@ * [50.9.4 自动配置的ReactiveHealthIndicators](V. Spring Boot Actuator/50.9.4 Auto-configured ReactiveHealthIndicators.md) * [50.10 应用信息](V. Spring Boot Actuator/50.10 Application Information.md) * [50.10.1 自动配置的InfoContributors](V. Spring Boot Actuator/50.10.1 Auto-configured InfoContributors.md) - * [50.10.2 自定义应用info信息](V. Spring Boot Actuator/50.10.2 Custom Application Info Information.md) + * [50.10.2 自定义应用信息](V. Spring Boot Actuator/50.10.2 Custom Application Information.md) * [50.10.3 Git提交信息](V. Spring Boot Actuator/50.10.3 Git Commit Information.md) * [50.10.4 构建信息](V. Spring Boot Actuator/50.10.4 Build Information.md) - * [50.10.5 编写自定义的InfoContributors](V. Spring Boot Actuator/50.10.5 Writing Custom InfoContributors.md) + * [50.10.5 编写自定义的InfoContributor](V. Spring Boot Actuator/50.10.5 Writing Custom InfoContributors.md) * [51. 基于HTTP的监控和管理](V. Spring Boot Actuator/51. Monitoring and Management over HTTP.md) * [51.1 访问敏感端点](V. Spring Boot Actuator/51.1 Accessing Sensitive Endpoints.md) * [51.2 自定义管理端点路径](V. Spring Boot Actuator/51.2 Customizing the Management Endpoint Paths.md) From abd6a8c3d207553cbbe739e3e0587055383eec9d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E7=83=AD=E5=BF=83=E5=B8=82=E6=B0=91=E9=92=9F=E5=B0=8F?= =?UTF-8?q?=E5=BC=BA?= Date: Sat, 17 Aug 2019 21:52:33 +0800 Subject: [PATCH 523/865] Update and rename 49. Monitoring and management over HTTP.md to 51. Monitoring and Management over HTTP.md --- .../49. Monitoring and management over HTTP.md | 3 --- .../51. Monitoring and Management over HTTP.md | 5 +++++ 2 files changed, 5 insertions(+), 3 deletions(-) delete mode 100644 V. Spring Boot Actuator/49. Monitoring and management over HTTP.md create mode 100644 V. Spring Boot Actuator/51. Monitoring and Management over HTTP.md diff --git a/V. Spring Boot Actuator/49. Monitoring and management over HTTP.md b/V. Spring Boot Actuator/49. Monitoring and management over HTTP.md deleted file mode 100644 index 568b1e01..00000000 --- a/V. Spring Boot Actuator/49. Monitoring and management over HTTP.md +++ /dev/null @@ -1,3 +0,0 @@ -### 49. 基于HTTP的监控和管理 - -如果你正在开发一个Spring MVC应用,Spring Boot执行器自动将所有启用的端点通过HTTP暴露出去。默认约定使用端点的`id`加上前缀`/application`作为URL路径,例如,`health`暴露为`/application/health`。 diff --git a/V. Spring Boot Actuator/51. Monitoring and Management over HTTP.md b/V. Spring Boot Actuator/51. Monitoring and Management over HTTP.md new file mode 100644 index 00000000..48a10a89 --- /dev/null +++ b/V. Spring Boot Actuator/51. Monitoring and Management over HTTP.md @@ -0,0 +1,5 @@ +### 51. 基于HTTP的监控和管理 + +如果你正在开发一个网络应用,Spring Boot执行器自动将所有启用的端点通过HTTP暴露出去。默认约定使用端点的`id`加上前缀`/actuator`作为URL路径。例如,`health`暴露为`/actuator/health`。 + +**注** Spring MVC、Spring WebFlux和Jersey对执行器提供了原生支持。 From 061f2352250c0721448d449aa9ed473c3b6d1a17 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E7=83=AD=E5=BF=83=E5=B8=82=E6=B0=91=E9=92=9F=E5=B0=8F?= =?UTF-8?q?=E5=BC=BA?= Date: Sat, 17 Aug 2019 21:55:14 +0800 Subject: [PATCH 524/865] Update SUMMARY.md --- SUMMARY.md | 13 ++++++------- 1 file changed, 6 insertions(+), 7 deletions(-) diff --git a/SUMMARY.md b/SUMMARY.md index 82754498..10b896b6 100644 --- a/SUMMARY.md +++ b/SUMMARY.md @@ -343,13 +343,12 @@ * [50.10.4 构建信息](V. Spring Boot Actuator/50.10.4 Build Information.md) * [50.10.5 编写自定义的InfoContributor](V. Spring Boot Actuator/50.10.5 Writing Custom InfoContributors.md) * [51. 基于HTTP的监控和管理](V. Spring Boot Actuator/51. Monitoring and Management over HTTP.md) - * [51.1 访问敏感端点](V. Spring Boot Actuator/51.1 Accessing Sensitive Endpoints.md) - * [51.2 自定义管理端点路径](V. Spring Boot Actuator/51.2 Customizing the Management Endpoint Paths.md) - * [51.3 自定义管理服务器端口](V. Spring Boot Actuator/51.3 Customizing the Management Server Port.md) - * [51.4 配置管理相关的SSL](V. Spring Boot Actuator/51.4 Configuring Management-specific SSL.md) - * [51.5 自定义管理服务器地址](V. Spring Boot Actuator/51.5 Customizing the Management Server Address.md) - * [51.6 禁用HTTP端点](V. Spring Boot Actuator/51.6 Disabling HTTP Endpoints.md) - * [51.7 HTTP health端点访问限制](V. Spring Boot Actuator/51.7 HTTP Health Endpoint Access Restrictions.md) + * [51.1 自定义管理端点路径](V. Spring Boot Actuator/51.1 Customizing the Management Endpoint Paths.md) + * [51.2 自定义管理服务器端口](V. Spring Boot Actuator/51.2 Customizing the Management Server Port.md) + * [51.3 配置管理相关的SSL](V. Spring Boot Actuator/51.3 Configuring Management-specific SSL.md) + * [51.4 自定义管理服务器地址](V. Spring Boot Actuator/51.4 Customizing the Management Server Address.md) + * [51.5 禁用HTTP端点](V. Spring Boot Actuator/51.5 Disabling HTTP Endpoints.md) + * [51.6 HTTP health端点访问限制](V. Spring Boot Actuator/51.6 HTTP Health Endpoint Access Restrictions.md) * [52. 基于JMX的监控和管理](V. Spring Boot Actuator/52. Monitoring and Management over JMX.md) * [52.1 自定义MBean名称](V. Spring Boot Actuator/52.1 Customizing MBean Names.md) * [52.2 禁用JMX端点](V. Spring Boot Actuator/52.2 Disabling JMX Endpoints.md) From d18a2e68766c3031c22329535c93a766f73fba7f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E7=83=AD=E5=BF=83=E5=B8=82=E6=B0=91=E9=92=9F=E5=B0=8F?= =?UTF-8?q?=E5=BC=BA?= Date: Sat, 17 Aug 2019 22:00:57 +0800 Subject: [PATCH 525/865] Delete 49.1 Accessing sensitive endpoints.md --- .../49.1 Accessing sensitive endpoints.md | 29 ------------------- 1 file changed, 29 deletions(-) delete mode 100644 V. Spring Boot Actuator/49.1 Accessing sensitive endpoints.md diff --git a/V. Spring Boot Actuator/49.1 Accessing sensitive endpoints.md b/V. Spring Boot Actuator/49.1 Accessing sensitive endpoints.md deleted file mode 100644 index 554b5099..00000000 --- a/V. Spring Boot Actuator/49.1 Accessing sensitive endpoints.md +++ /dev/null @@ -1,29 +0,0 @@ -### 49.1 访问敏感端点 - -默认地,所有敏感的HTTP端点受到保护,只有角色为`ACTUATOR`的用户可以访问它们。通过使用标准的`HttpServletRequest.isUserInRole`方法确保了安全。 - -**提示** 如果想要与`ACTUATOR`不同,使用`management.security.roles`属性 - -如果你正在防火墙后面部署应用,你可能更喜欢所有的执行器端点不需要验证就可以访问。你可以通过改变`management.security.enabled`属性来实现: - -**application.properties.** -```properties -management.security.enabled=false -``` -**注** 默认地,执行器端点暴露在同一个服务常规HTTP传输的端口之下。如果你改变了`management.security.enabled`属性,小心不要意外暴露了敏感信息。 - -如果你正在公开地部署应用,你可能会想加上‘Spring Security’来处理用户认证。当你加上了‘Spring Security’, 默认情况下会使用用户名为`user`的基本认证(basic authentication),产生的密码会在应用启动时打印到控制台上。 - -**注** 在应用启动时会记录生成的密码,具体搜索`Using default security password`。 - -你可以使用Spring属性改变用户名,密码和访问端点需要的安全角色。例如,你可以将以下配置添加到`application.properties`中: -```java -security.user.name=admin -security.user.password=secret -management.security.role=SUPERUSER -``` -如果你的应用有自定义的安全配置,而且你想要所有的执行器端点不需要验证就可以访问,你需要明确地在你的安全配置中配置。除此之外,你需要将`management.security.enabled`属性改为`false`。 - -如果你自定义的安全配置保护了你的执行器端点,你也需要确认验证过的用户拥有`management.security.roles`下指定的角色。 - -**注** 如果你没有一种使用情况要将基本的健康信息暴露给未经身份验证的用户,而且你已经通过自定义安全保护了执行器端点,你可以将`management.security.enabled`设置为`false`。这将会通知Spring Boot跳过另外的角色检查。 From f2813a3fcdf8126c5627b7adb800bce448b19b30 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E7=83=AD=E5=BF=83=E5=B8=82=E6=B0=91=E9=92=9F=E5=B0=8F?= =?UTF-8?q?=E5=BC=BA?= Date: Sat, 17 Aug 2019 22:16:25 +0800 Subject: [PATCH 526/865] Update and rename 49.2 Customizing the management endpoint paths.md to 51.1 Customizing the Management Endpoint Paths.md --- ...49.2 Customizing the management endpoint paths.md | 12 ------------ ...51.1 Customizing the Management Endpoint Paths.md | 9 +++++++++ 2 files changed, 9 insertions(+), 12 deletions(-) delete mode 100644 V. Spring Boot Actuator/49.2 Customizing the management endpoint paths.md create mode 100644 V. Spring Boot Actuator/51.1 Customizing the Management Endpoint Paths.md diff --git a/V. Spring Boot Actuator/49.2 Customizing the management endpoint paths.md b/V. Spring Boot Actuator/49.2 Customizing the management endpoint paths.md deleted file mode 100644 index 7a62e74a..00000000 --- a/V. Spring Boot Actuator/49.2 Customizing the management endpoint paths.md +++ /dev/null @@ -1,12 +0,0 @@ -### 49.2 自定义管理端点路径 -有时给管理端点自定义前缀是有用的。例如,`/application`可能已被应用占用,你可以用`management.context-path`属性来改变管理端点的前缀: -```java -management.context-path=/manage -``` -以上的`application.properties`示例将把端点从`/application/{id}`改为`/manage/{id}`(比如`/manage/info`)。 - -你也可以改变端点的`path`(使用`endpoints.{name}.path`)来改变MVC端点的默认资源路径。Spring Boot不会校验这些值(所以你可以使用URL中任何合法的字符)。例如,想要改变`/health`端点路径为`/ping/me`,你可以设置`endpoints.health.path=/ping/me`。 - -**注** 即使端点路径是分开配置的,仍旧与`management.context-path`相关。 - -**提醒** 如果你提供一个自定义`MvcEndpoint`,记得包含一个可设置的`path`属性,并像标准MVC端点那样将该属性默认设置为`/{id}`(具体可参考`HealthMvcEndpoint`)。如果你的自定义端点是一个`Endpoint`(不是`MvcEndpoint`),Spring Boot将会为你分配路径。 diff --git a/V. Spring Boot Actuator/51.1 Customizing the Management Endpoint Paths.md b/V. Spring Boot Actuator/51.1 Customizing the Management Endpoint Paths.md new file mode 100644 index 00000000..d50d50ad --- /dev/null +++ b/V. Spring Boot Actuator/51.1 Customizing the Management Endpoint Paths.md @@ -0,0 +1,9 @@ +### 51.1 自定义管理端点路径 + +有时给管理端点自定义前缀是有用的。例如,`/actuator`可能已被应用占用,你可以用`management.endpoints.web.base-path`属性来改变管理端点的前缀。如下所示: +```java +management.endpoints.web.base-path=/manage +``` +以上的`application.properties`示例将把端点从`/actuator/{id}`改为`/manage/{id}`(比如,`/manage/info`)。 + +**注** `management.endpoints.web.base-path`相对于`server.servlet.context-path`,除非管理端口已经配置为[使用不同的HTTP端口暴露端点](https://docs.spring.io/spring-boot/docs/2.0.0.RELEASE/reference/htmlsingle/#production-ready-customizing-management-server-port)。如果已经配置了`management.server.port`,`management.endpoints.web.base-path`相对于`management.server.servlet.context-path`有关。 From 551f9d428d732cb66a1cf7c405a3ffddc72cbb26 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E7=83=AD=E5=BF=83=E5=B8=82=E6=B0=91=E9=92=9F=E5=B0=8F?= =?UTF-8?q?=E5=BC=BA?= Date: Mon, 19 Aug 2019 09:02:19 +0800 Subject: [PATCH 527/865] Update 51.1 Customizing the Management Endpoint Paths.md --- .../51.1 Customizing the Management Endpoint Paths.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/V. Spring Boot Actuator/51.1 Customizing the Management Endpoint Paths.md b/V. Spring Boot Actuator/51.1 Customizing the Management Endpoint Paths.md index d50d50ad..987315e9 100644 --- a/V. Spring Boot Actuator/51.1 Customizing the Management Endpoint Paths.md +++ b/V. Spring Boot Actuator/51.1 Customizing the Management Endpoint Paths.md @@ -6,4 +6,4 @@ management.endpoints.web.base-path=/manage ``` 以上的`application.properties`示例将把端点从`/actuator/{id}`改为`/manage/{id}`(比如,`/manage/info`)。 -**注** `management.endpoints.web.base-path`相对于`server.servlet.context-path`,除非管理端口已经配置为[使用不同的HTTP端口暴露端点](https://docs.spring.io/spring-boot/docs/2.0.0.RELEASE/reference/htmlsingle/#production-ready-customizing-management-server-port)。如果已经配置了`management.server.port`,`management.endpoints.web.base-path`相对于`management.server.servlet.context-path`有关。 +**注** `management.endpoints.web.base-path`相对于`server.servlet.context-path`,除非管理端口已经配置为[使用不同的HTTP端口暴露端点](https://docs.spring.io/spring-boot/docs/2.0.0.RELEASE/reference/htmlsingle/#production-ready-customizing-management-server-port)。如果已经配置了`management.server.port`,`management.endpoints.web.base-path`相对于`management.server.servlet.context-path`。 From 4f6c6ef70afa399c3a93cf2d8183f41273180bed Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E7=83=AD=E5=BF=83=E5=B8=82=E6=B0=91=E9=92=9F=E5=B0=8F?= =?UTF-8?q?=E5=BC=BA?= Date: Mon, 19 Aug 2019 09:09:52 +0800 Subject: [PATCH 528/865] Update and rename 49.3 Customizing the management server port.md to 51.2. Customizing the Management Server Port.md --- .../49.3 Customizing the management server port.md | 10 ---------- .../51.2. Customizing the Management Server Port.md | 8 ++++++++ 2 files changed, 8 insertions(+), 10 deletions(-) delete mode 100644 V. Spring Boot Actuator/49.3 Customizing the management server port.md create mode 100644 V. Spring Boot Actuator/51.2. Customizing the Management Server Port.md diff --git a/V. Spring Boot Actuator/49.3 Customizing the management server port.md b/V. Spring Boot Actuator/49.3 Customizing the management server port.md deleted file mode 100644 index d3a018a3..00000000 --- a/V. Spring Boot Actuator/49.3 Customizing the management server port.md +++ /dev/null @@ -1,10 +0,0 @@ -### 49.3 自定义管理服务器端口 -对于基于云的部署,使用默认的HTTP端口暴露管理端点(endpoints)是明智的选择。然而,如果你的应用是在自己的数据中心运行,那你可能倾向于使用一个不同的HTTP端口来暴露端点。`management.port`属性可以用来改变HTTP端口: -```java -management.port=8081 -``` -由于你的管理端口经常被防火墙保护,不对外暴露也就不需要保护管理端点,即使你的主应用是受保护的。在这种情况下,classpath下会存在Spring Security库,你可以设置以下属性来禁用安全管理策略(management security): -```java -management.security.enabled=false -``` -(如果classpath下不存在Spring Security,那也就不需要显式的以这种方式来禁用安全管理策略,它甚至可能会破坏应用程序。) diff --git a/V. Spring Boot Actuator/51.2. Customizing the Management Server Port.md b/V. Spring Boot Actuator/51.2. Customizing the Management Server Port.md new file mode 100644 index 00000000..68e9d8df --- /dev/null +++ b/V. Spring Boot Actuator/51.2. Customizing the Management Server Port.md @@ -0,0 +1,8 @@ +### 51.2 自定义管理服务器端口 + +对于基于云的部署,使用默认的HTTP端口暴露管理端点(endpoints)是明智的选择。然而,如果你的应用是在自己的数据中心运行,那你可能倾向于使用一个不同的HTTP端口来暴露端点。 + +你可以设置`management.server.port`属性,来改变HTTP端口。如下所示: +```java +management.server.port=8081 +``` From 585e494184e156437e3fbd6d6bb313fb3ee0968a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E7=83=AD=E5=BF=83=E5=B8=82=E6=B0=91=E9=92=9F=E5=B0=8F?= =?UTF-8?q?=E5=BC=BA?= Date: Mon, 19 Aug 2019 09:18:55 +0800 Subject: [PATCH 529/865] Update and rename 49.4 Configuring management-specific SSL.md to 51.3 Configuring Management-specific SSL.md --- ...9.4 Configuring management-specific SSL.md | 21 ----------------- ...1.3 Configuring Management-specific SSL.md | 23 +++++++++++++++++++ 2 files changed, 23 insertions(+), 21 deletions(-) delete mode 100644 V. Spring Boot Actuator/49.4 Configuring management-specific SSL.md create mode 100644 V. Spring Boot Actuator/51.3 Configuring Management-specific SSL.md diff --git a/V. Spring Boot Actuator/49.4 Configuring management-specific SSL.md b/V. Spring Boot Actuator/49.4 Configuring management-specific SSL.md deleted file mode 100644 index 9998cb35..00000000 --- a/V. Spring Boot Actuator/49.4 Configuring management-specific SSL.md +++ /dev/null @@ -1,21 +0,0 @@ -###49.4 配置管理相关的SSL -当配置使用一个自定义端口时,管理服务器可以通过各种`management.ssl.*`属性配置自己的SSL。例如,以下配置允许通过HTTP访问管理服务器,通过HTTPS访问主应用: -```properties -server.port=8443 -server.ssl.enabled=true -server.ssl.key-store=classpath:store.jks -server.ssl.key-password=secret -management.port=8080 -management.ssl.enabled=false -``` -或者,主应用服务器和管理服务器都使用SSL,但key stores不一样: -```properties -server.port=8443 -server.ssl.enabled=true -server.ssl.key-store=classpath:main.jks -server.ssl.key-password=secret -management.port=8080 -management.ssl.enabled=true -management.ssl.key-store=classpath:management.jks -management.ssl.key-password=secret -``` diff --git a/V. Spring Boot Actuator/51.3 Configuring Management-specific SSL.md b/V. Spring Boot Actuator/51.3 Configuring Management-specific SSL.md new file mode 100644 index 00000000..96adaeba --- /dev/null +++ b/V. Spring Boot Actuator/51.3 Configuring Management-specific SSL.md @@ -0,0 +1,23 @@ +### 51.3 配置管理相关的SSL + +当配置使用一个自定义端口时,管理服务器可以通过各种`management.server.ssl.*`属性配置自己的SSL。例如,以下配置允许通过HTTP访问管理服务器,通过HTTPS访问主应用: +```properties +server.port=8443 +server.ssl.enabled=true +server.ssl.key-store=classpath:store.jks +server.ssl.key-password=secret +management.server.port=8080 +management.server.ssl.enabled=false +``` + +或者,主应用服务器和管理服务器都使用SSL,但key stores不一样: +```properties +server.port=8443 +server.ssl.enabled=true +server.ssl.key-store=classpath:main.jks +server.ssl.key-password=secret +management.server.port=8080 +management.server.ssl.enabled=true +management.server.ssl.key-store=classpath:management.jks +management.server.ssl.key-password=secret +``` From 79d1f1e63a78546c07611997710a9762841ab589 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E7=83=AD=E5=BF=83=E5=B8=82=E6=B0=91=E9=92=9F=E5=B0=8F?= =?UTF-8?q?=E5=BC=BA?= Date: Tue, 20 Aug 2019 09:36:10 +0800 Subject: [PATCH 530/865] Update and rename 49.5 Customizing the management server address.md to 51.4 Customizing the Management Server Address.md --- .../49.5 Customizing the management server address.md | 10 ---------- .../51.4 Customizing the Management Server Address.md | 11 +++++++++++ 2 files changed, 11 insertions(+), 10 deletions(-) delete mode 100644 V. Spring Boot Actuator/49.5 Customizing the management server address.md create mode 100644 V. Spring Boot Actuator/51.4 Customizing the Management Server Address.md diff --git a/V. Spring Boot Actuator/49.5 Customizing the management server address.md b/V. Spring Boot Actuator/49.5 Customizing the management server address.md deleted file mode 100644 index b39ab192..00000000 --- a/V. Spring Boot Actuator/49.5 Customizing the management server address.md +++ /dev/null @@ -1,10 +0,0 @@ -### 49.5 自定义管理服务器地址 -你可以通过设置`management.address`属性来定义管理端点使用的地址,这在你只想监听内部或面向生产环境的网络,或只监听来自`localhost`的连接时非常有用。 - -**注** 如果端口跟主应用服务器不一样,你只能监听一个不同的地址。 - -下面的application.properties示例不允许远程访问管理服务器: -```java -management.port=8081 -management.address=127.0.0.1 -``` diff --git a/V. Spring Boot Actuator/51.4 Customizing the Management Server Address.md b/V. Spring Boot Actuator/51.4 Customizing the Management Server Address.md new file mode 100644 index 00000000..852d7a83 --- /dev/null +++ b/V. Spring Boot Actuator/51.4 Customizing the Management Server Address.md @@ -0,0 +1,11 @@ +### 51.4 自定义管理服务器地址 + +你可以通过设置`management.server.address`属性来定义管理端点使用的地址,这在你只想监听内部或面向生产环境的网络,或只监听来自`localhost`的连接时非常有用。 + +**注** 当端口跟主应用服务器不一样时,你只能监听一个不同的地址。 + +下面的application.properties示例不允许远程访问管理服务器: +```java +management.server.port=8081 +management.server.address=127.0.0.1 +``` From 8649d8bf5266abff8b56e7e86e04d349ecb62388 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E7=83=AD=E5=BF=83=E5=B8=82=E6=B0=91=E9=92=9F=E5=B0=8F?= =?UTF-8?q?=E5=BC=BA?= Date: Tue, 20 Aug 2019 11:12:38 +0800 Subject: [PATCH 531/865] Rename 51.2. Customizing the Management Server Port.md to 51.2 Customizing the Management Server Port.md --- ...ver Port.md => 51.2 Customizing the Management Server Port.md} | 0 1 file changed, 0 insertions(+), 0 deletions(-) rename V. Spring Boot Actuator/{51.2. Customizing the Management Server Port.md => 51.2 Customizing the Management Server Port.md} (100%) diff --git a/V. Spring Boot Actuator/51.2. Customizing the Management Server Port.md b/V. Spring Boot Actuator/51.2 Customizing the Management Server Port.md similarity index 100% rename from V. Spring Boot Actuator/51.2. Customizing the Management Server Port.md rename to V. Spring Boot Actuator/51.2 Customizing the Management Server Port.md From 390935b5f4338b214cb1d0953f5660b858ce7a30 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E7=83=AD=E5=BF=83=E5=B8=82=E6=B0=91=E9=92=9F=E5=B0=8F?= =?UTF-8?q?=E5=BC=BA?= Date: Tue, 20 Aug 2019 11:16:53 +0800 Subject: [PATCH 532/865] Update and rename 49.6 Disabling HTTP endpoints.md to 51.5 Disabling HTTP Endpoints.md --- V. Spring Boot Actuator/49.6 Disabling HTTP endpoints.md | 4 ---- V. Spring Boot Actuator/51.5 Disabling HTTP Endpoints.md | 6 ++++++ 2 files changed, 6 insertions(+), 4 deletions(-) delete mode 100644 V. Spring Boot Actuator/49.6 Disabling HTTP endpoints.md create mode 100644 V. Spring Boot Actuator/51.5 Disabling HTTP Endpoints.md diff --git a/V. Spring Boot Actuator/49.6 Disabling HTTP endpoints.md b/V. Spring Boot Actuator/49.6 Disabling HTTP endpoints.md deleted file mode 100644 index 2eec811f..00000000 --- a/V. Spring Boot Actuator/49.6 Disabling HTTP endpoints.md +++ /dev/null @@ -1,4 +0,0 @@ -### 49.6 禁用HTTP端点 - -如果不想通过HTTP暴露端点,你可以将管理端口设置为-1: -`management.port=-1` diff --git a/V. Spring Boot Actuator/51.5 Disabling HTTP Endpoints.md b/V. Spring Boot Actuator/51.5 Disabling HTTP Endpoints.md new file mode 100644 index 00000000..8e42f2ab --- /dev/null +++ b/V. Spring Boot Actuator/51.5 Disabling HTTP Endpoints.md @@ -0,0 +1,6 @@ +### 51.5 禁用HTTP端点 + +如果不想通过HTTP暴露端点,你可以将管理端口设置为`-1`。如下所示: +``` +management.server.port=-1 +``` From 98871ce8d9deb9e56485875e077465f1777e5266 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E7=83=AD=E5=BF=83=E5=B8=82=E6=B0=91=E9=92=9F=E5=B0=8F?= =?UTF-8?q?=E5=BC=BA?= Date: Tue, 20 Aug 2019 11:18:01 +0800 Subject: [PATCH 533/865] Update SUMMARY.md --- SUMMARY.md | 1 - 1 file changed, 1 deletion(-) diff --git a/SUMMARY.md b/SUMMARY.md index 10b896b6..846c8bf3 100644 --- a/SUMMARY.md +++ b/SUMMARY.md @@ -348,7 +348,6 @@ * [51.3 配置管理相关的SSL](V. Spring Boot Actuator/51.3 Configuring Management-specific SSL.md) * [51.4 自定义管理服务器地址](V. Spring Boot Actuator/51.4 Customizing the Management Server Address.md) * [51.5 禁用HTTP端点](V. Spring Boot Actuator/51.5 Disabling HTTP Endpoints.md) - * [51.6 HTTP health端点访问限制](V. Spring Boot Actuator/51.6 HTTP Health Endpoint Access Restrictions.md) * [52. 基于JMX的监控和管理](V. Spring Boot Actuator/52. Monitoring and Management over JMX.md) * [52.1 自定义MBean名称](V. Spring Boot Actuator/52.1 Customizing MBean Names.md) * [52.2 禁用JMX端点](V. Spring Boot Actuator/52.2 Disabling JMX Endpoints.md) From 3f8e332212a0a0b9d64994479d9c7446decebf2a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E7=83=AD=E5=BF=83=E5=B8=82=E6=B0=91=E9=92=9F=E5=B0=8F?= =?UTF-8?q?=E5=BC=BA?= Date: Tue, 20 Aug 2019 11:19:16 +0800 Subject: [PATCH 534/865] Delete 49.7 HTTP Health endpoint access restrictions.md --- ...TTP Health endpoint access restrictions.md | 54 ------------------- 1 file changed, 54 deletions(-) delete mode 100644 V. Spring Boot Actuator/49.7 HTTP Health endpoint access restrictions.md diff --git a/V. Spring Boot Actuator/49.7 HTTP Health endpoint access restrictions.md b/V. Spring Boot Actuator/49.7 HTTP Health endpoint access restrictions.md deleted file mode 100644 index 9fa4b2e7..00000000 --- a/V. Spring Boot Actuator/49.7 HTTP Health endpoint access restrictions.md +++ /dev/null @@ -1,54 +0,0 @@ -### 49.7 HTTP health端点访问限制 -`health`端点暴露的信息依赖于是否为匿名访问,应用是否受保护。默认情况下,当匿名访问一个受保护的应用时,任何有关服务器的健康详情都被隐藏了,该端点只简单的展示服务器运行状况(up或down)。此外,响应会被缓存一个可配置的时间段以防止端点被用于'拒绝服务'攻击,你可以通过`endpoints.health.time-to-live`属性设置缓存时间(单位为毫秒),默认为1000毫秒,也就是1秒。 - -概括了HTTP请求的样本(默认对于匿名请求): -```shell -$ curl -i localhost:8080/health -HTTP/1.1 200 -X-Application-Context: application -Content-Type: application/vnd.spring-boot.actuator.v2+json;charset=UTF-8 -Content-Length: 15 - -{"status":"UP"} -``` -概括了对于状态“DOWN”的HTTP请求的样本(注意状态码503): -```shell -$ curl -i localhost:8080/health -HTTP/1.1 503 -X-Application-Context: application -Content-Type: application/vnd.spring-boot.actuator.v2+json;charset=UTF-8 -Content-Length: 17 - -{"status":"DOWN"} -``` -详细的HTTP请求样本: -```shell -$ curl -i localhost:8080/health -HTTP/1.1 200 OK -X-Application-Context: application -Content-Type: application/vnd.spring-boot.actuator.v2+json;charset=UTF-8 -Content-Length: 221 - -{ - "status" : "UP", - "diskSpace" : { - "status" : "UP", - "total" : 63251804160, - "free" : 31316164608, - "threshold" : 10485760 - }, - "db" : { - "status" : "UP", - "database" : "H2", - "hello" : 1 - } -} -``` -你可以增强上述限制,从而只允许认证用户完全访问一个受保护应用的`health`端点,将`endpoints.health.sensitive`设为`true`可以实现该效果,具体可查看以下总结(`sensitive`标识值为"false"的默认加粗): - -|`management.security.enabled`|`endpoints.health.sensitive`|未认证|认证(有正确的角色)| -|:----|:----|:----|:-----| -|false|*|全部内容|全部内容| -|true|**false**|只能查看Status|全部内容| -|true|true|不能查看任何内容|全部内容| - From d658e3f505a2def5692eaa4928e92635ed966996 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E7=83=AD=E5=BF=83=E5=B8=82=E6=B0=91=E9=92=9F=E5=B0=8F?= =?UTF-8?q?=E5=BC=BA?= Date: Mon, 26 Aug 2019 12:45:50 +0800 Subject: [PATCH 535/865] Update and rename 50. Monitoring and management over JMX.md to 52. Monitoring and Management over JMX.md --- ... over JMX.md => 52. Monitoring and Management over JMX.md} | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) rename V. Spring Boot Actuator/{50. Monitoring and management over JMX.md => 52. Monitoring and Management over JMX.md} (57%) diff --git a/V. Spring Boot Actuator/50. Monitoring and management over JMX.md b/V. Spring Boot Actuator/52. Monitoring and Management over JMX.md similarity index 57% rename from V. Spring Boot Actuator/50. Monitoring and management over JMX.md rename to V. Spring Boot Actuator/52. Monitoring and Management over JMX.md index 1dd2c5bb..9eb293da 100644 --- a/V. Spring Boot Actuator/50. Monitoring and management over JMX.md +++ b/V. Spring Boot Actuator/52. Monitoring and Management over JMX.md @@ -1,3 +1,3 @@ -### 50. 基于JMX的监控和管理 +### 52. 基于JMX的监控和管理 -Java管理扩展(JMX)提供了一种标准的监控和管理应用的机制。默认情况下,Spring Boot在`org.springframework.boot`域下将管理端点暴露为JMX MBeans。 +Java管理扩展(JMX)提供了一种标准的监控和管理应用的机制。默认情况下,Spring Boot在`org.springframework.boot`域下将管理端点暴露为JMX MBean。 From 277816f246382f4533f0f9ee65b321671f2534d9 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E7=83=AD=E5=BF=83=E5=B8=82=E6=B0=91=E9=92=9F=E5=B0=8F?= =?UTF-8?q?=E5=BC=BA?= Date: Mon, 26 Aug 2019 12:51:32 +0800 Subject: [PATCH 536/865] Update and rename 50.1 Customizing MBean names.md to 52.1 Customizing MBean Names.md --- .../50.1 Customizing MBean names.md | 9 --------- .../52.1 Customizing MBean Names.md | 11 +++++++++++ 2 files changed, 11 insertions(+), 9 deletions(-) delete mode 100644 V. Spring Boot Actuator/50.1 Customizing MBean names.md create mode 100644 V. Spring Boot Actuator/52.1 Customizing MBean Names.md diff --git a/V. Spring Boot Actuator/50.1 Customizing MBean names.md b/V. Spring Boot Actuator/50.1 Customizing MBean names.md deleted file mode 100644 index 23658f72..00000000 --- a/V. Spring Boot Actuator/50.1 Customizing MBean names.md +++ /dev/null @@ -1,9 +0,0 @@ -### 50.1 自定义MBean名称 -MBean的名称通常产生于端点的id,例如,`health`端点被暴露为`org.springframework.boot/Endpoint/healthEndpoint`。 - -如果应用包含多个Spring `ApplicationContext`,你会发现存在名称冲突。为了解决这个问题,你可以将`endpoints.jmx.uniqueNames`设置为`true`,这样MBean的名称总是唯一的。 - -你也可以自定义端点暴露的JMX域,具体可参考以下`application.properties`示例: -```properties -endpoints.jmx.domain=myapp -endpoints.jmx.uniqueNames=true diff --git a/V. Spring Boot Actuator/52.1 Customizing MBean Names.md b/V. Spring Boot Actuator/52.1 Customizing MBean Names.md new file mode 100644 index 00000000..f7c61a4e --- /dev/null +++ b/V. Spring Boot Actuator/52.1 Customizing MBean Names.md @@ -0,0 +1,11 @@ +### 52.1 自定义MBean名称 + +MBean的名称通常产生于端点的`id`。例如,`health`端点被暴露为`org.springframework.boot:type=Endpoint,name=Health`。 + +如果应用包含多个Spring `ApplicationContext`,你会发现存在名称冲突。为了解决这个问题,你可以将`management.endpoints.jmx.unique-names`设置为`true`,这样MBean的名称总是唯一的。 + +你也可以自定义端点暴露的JMX域,具体可参考以下`application.properties`示例: +```properties +management.endpoints.jmx.domain=com.example.myapp +management.endpoints.jmx.unique-names=true +``` From a3245f0a5b55c5837610b2a5f98dc8d445db956a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E7=83=AD=E5=BF=83=E5=B8=82=E6=B0=91=E9=92=9F=E5=B0=8F?= =?UTF-8?q?=E5=BC=BA?= Date: Mon, 26 Aug 2019 12:55:00 +0800 Subject: [PATCH 537/865] Update and rename 50.2 Disabling JMX endpoints.md to 52.2 Disabling JMX Endpoints.md --- V. Spring Boot Actuator/50.2 Disabling JMX endpoints.md | 5 ----- V. Spring Boot Actuator/52.2 Disabling JMX Endpoints.md | 6 ++++++ 2 files changed, 6 insertions(+), 5 deletions(-) delete mode 100644 V. Spring Boot Actuator/50.2 Disabling JMX endpoints.md create mode 100644 V. Spring Boot Actuator/52.2 Disabling JMX Endpoints.md diff --git a/V. Spring Boot Actuator/50.2 Disabling JMX endpoints.md b/V. Spring Boot Actuator/50.2 Disabling JMX endpoints.md deleted file mode 100644 index 640fa722..00000000 --- a/V. Spring Boot Actuator/50.2 Disabling JMX endpoints.md +++ /dev/null @@ -1,5 +0,0 @@ -### 50.2 禁用JMX端点 -如果不想通过JMX暴露端点,你可以将`endpoints.jmx.enabled`属性设置为`false`: -```java -endpoints.jmx.enabled=false -``` diff --git a/V. Spring Boot Actuator/52.2 Disabling JMX Endpoints.md b/V. Spring Boot Actuator/52.2 Disabling JMX Endpoints.md new file mode 100644 index 00000000..c23b344b --- /dev/null +++ b/V. Spring Boot Actuator/52.2 Disabling JMX Endpoints.md @@ -0,0 +1,6 @@ +### 52.2 禁用JMX端点 + +如果不想通过JMX暴露端点,你可以将`management.endpoints.jmx.exposure.exclude`属性设置为`*`: +```properties +management.endpoints.jmx.exposure.exclude=* +``` From 94e69e680bb36cd2f0f8199fc90263891e489ad5 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E7=83=AD=E5=BF=83=E5=B8=82=E6=B0=91=E9=92=9F=E5=B0=8F?= =?UTF-8?q?=E5=BC=BA?= Date: Tue, 27 Aug 2019 11:55:09 +0800 Subject: [PATCH 538/865] Update and rename 50.3 Using Jolokia for JMX over HTTP.md to 52.3 Using Jolokia for JMX over HTTP.md --- .../50.3 Using Jolokia for JMX over HTTP.md | 9 --------- .../52.3 Using Jolokia for JMX over HTTP.md | 11 +++++++++++ 2 files changed, 11 insertions(+), 9 deletions(-) delete mode 100644 V. Spring Boot Actuator/50.3 Using Jolokia for JMX over HTTP.md create mode 100644 V. Spring Boot Actuator/52.3 Using Jolokia for JMX over HTTP.md diff --git a/V. Spring Boot Actuator/50.3 Using Jolokia for JMX over HTTP.md b/V. Spring Boot Actuator/50.3 Using Jolokia for JMX over HTTP.md deleted file mode 100644 index 1c63c730..00000000 --- a/V. Spring Boot Actuator/50.3 Using Jolokia for JMX over HTTP.md +++ /dev/null @@ -1,9 +0,0 @@ -### 50.3 使用Jolokia通过HTTP实现JMX远程管理 -Jolokia是一个JMX-HTTP桥,它提供了一种访问JMX beans的替代方法。想要使用Jolokia,只需添加`org.jolokia:jolokia-core`的依赖。例如,使用Maven需要添加以下配置: -```xml - - org.jolokia - jolokia-core - -``` -然后在你的管理HTTP服务器上可以通过`/jolokia`访问Jolokia。 diff --git a/V. Spring Boot Actuator/52.3 Using Jolokia for JMX over HTTP.md b/V. Spring Boot Actuator/52.3 Using Jolokia for JMX over HTTP.md new file mode 100644 index 00000000..4d14c99b --- /dev/null +++ b/V. Spring Boot Actuator/52.3 Using Jolokia for JMX over HTTP.md @@ -0,0 +1,11 @@ +### 52.3 使用Jolokia通过HTTP实现JMX远程管理 + +Jolokia是一个JMX-HTTP桥。它提供了一种访问JMX bean的替代方法。想要使用Jolokia,只需添加`org.jolokia:jolokia-core`的依赖。例如,使用Maven需要添加以下配置: +```xml + + org.jolokia + jolokia-core + +``` + +之后,通过将`jolokia`或者`*`添加到`management.endpoints.web.exposure.include`属性,暴露Jolokia端点。然后,在你的管理HTTP服务器上可以使用`/actuator/jolokia`访问Jolokia。 From 4264f5b17e3e1a387a3af136b69d7a9714df75b4 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E7=83=AD=E5=BF=83=E5=B8=82=E6=B0=91=E9=92=9F=E5=B0=8F?= =?UTF-8?q?=E5=BC=BA?= Date: Tue, 27 Aug 2019 11:58:45 +0800 Subject: [PATCH 539/865] Update and rename 50.3.1 Customizing Jolokia.md to 52.3.1 Customizing Jolokia.md --- V. Spring Boot Actuator/50.3.1 Customizing Jolokia.md | 5 ----- V. Spring Boot Actuator/52.3.1 Customizing Jolokia.md | 6 ++++++ 2 files changed, 6 insertions(+), 5 deletions(-) delete mode 100644 V. Spring Boot Actuator/50.3.1 Customizing Jolokia.md create mode 100644 V. Spring Boot Actuator/52.3.1 Customizing Jolokia.md diff --git a/V. Spring Boot Actuator/50.3.1 Customizing Jolokia.md b/V. Spring Boot Actuator/50.3.1 Customizing Jolokia.md deleted file mode 100644 index 8a94a6b7..00000000 --- a/V. Spring Boot Actuator/50.3.1 Customizing Jolokia.md +++ /dev/null @@ -1,5 +0,0 @@ -### 50.3.1 自定义Jolokia -Jolokia有很多配置,通常使用servlet参数进行设置,跟Spring Boot一块使用时可以在`application.properties`中添加`jolokia.config.`前缀的属性进行配置: -```java -jolokia.config.debug=true -``` diff --git a/V. Spring Boot Actuator/52.3.1 Customizing Jolokia.md b/V. Spring Boot Actuator/52.3.1 Customizing Jolokia.md new file mode 100644 index 00000000..113b73d8 --- /dev/null +++ b/V. Spring Boot Actuator/52.3.1 Customizing Jolokia.md @@ -0,0 +1,6 @@ +### 52.3.1 自定义Jolokia + +Jolokia有很多配置,通常使用servlet参数进行设置。跟Spring Boot一块使用时可以在`application.properties`文件中添加`management.endpoint.jolokia.config.`前缀的属性进行配置: +```properties +management.endpoint.jolokia.config.debug=true +``` From f8d7f1a719b042eb97ec6646ca2464f57957f1db Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E7=83=AD=E5=BF=83=E5=B8=82=E6=B0=91=E9=92=9F=E5=B0=8F?= =?UTF-8?q?=E5=BC=BA?= Date: Tue, 27 Aug 2019 12:03:55 +0800 Subject: [PATCH 540/865] Update and rename 50.3.2 Disabling Jolokia.md to 52.3.2 Disabling Jolokia.md --- V. Spring Boot Actuator/50.3.2 Disabling Jolokia.md | 5 ----- V. Spring Boot Actuator/52.3.2 Disabling Jolokia.md | 6 ++++++ 2 files changed, 6 insertions(+), 5 deletions(-) delete mode 100644 V. Spring Boot Actuator/50.3.2 Disabling Jolokia.md create mode 100644 V. Spring Boot Actuator/52.3.2 Disabling Jolokia.md diff --git a/V. Spring Boot Actuator/50.3.2 Disabling Jolokia.md b/V. Spring Boot Actuator/50.3.2 Disabling Jolokia.md deleted file mode 100644 index f69a190e..00000000 --- a/V. Spring Boot Actuator/50.3.2 Disabling Jolokia.md +++ /dev/null @@ -1,5 +0,0 @@ -### 50.3.2 禁用Jolokia -如果正在使用Jolokia,又不想让Spring Boot配置它,你只需要简单的将`endpoints.jolokia.enabled`属性设置为`false`: -```java -endpoints.jolokia.enabled=false -``` diff --git a/V. Spring Boot Actuator/52.3.2 Disabling Jolokia.md b/V. Spring Boot Actuator/52.3.2 Disabling Jolokia.md new file mode 100644 index 00000000..c2abe34b --- /dev/null +++ b/V. Spring Boot Actuator/52.3.2 Disabling Jolokia.md @@ -0,0 +1,6 @@ +### 52.3.2 禁用Jolokia + +如果正在使用Jolokia,又不想让Spring Boot配置它,你只需要简单的将`management.endpoint.jolokia.enabled`属性设置为`false`: +```properties +management.endpoint.jolokia.enabled=false +``` From a4ef9399f805673741ad8361fa52605713be5380 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E7=83=AD=E5=BF=83=E5=B8=82=E6=B0=91=E9=92=9F=E5=B0=8F?= =?UTF-8?q?=E5=BC=BA?= Date: Wed, 28 Aug 2019 14:07:40 +0800 Subject: [PATCH 541/865] Update and rename 51. Loggers.md to 53. Loggers.md --- V. Spring Boot Actuator/{51. Loggers.md => 53. Loggers.md} | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) rename V. Spring Boot Actuator/{51. Loggers.md => 53. Loggers.md} (83%) diff --git a/V. Spring Boot Actuator/51. Loggers.md b/V. Spring Boot Actuator/53. Loggers.md similarity index 83% rename from V. Spring Boot Actuator/51. Loggers.md rename to V. Spring Boot Actuator/53. Loggers.md index 38c3651f..04f362d3 100644 --- a/V. Spring Boot Actuator/51. Loggers.md +++ b/V. Spring Boot Actuator/53. Loggers.md @@ -1,4 +1,4 @@ -### 51. 记录器 +### 53. 记录器 Spring Boot执行器可以在运行时查看和配置你的应用的记录器级别。你可以查看整个的列表或者单个的记录器配置。单个的记录器配置由明确配置的日志级别和日志框架提供的有效日志级别组成。这些级别是: @@ -11,4 +11,4 @@ Spring Boot执行器可以在运行时查看和配置你的应用的记录器级 * `OFF` * `null` -`null`表明没有明确的配置。 \ No newline at end of file +`null`表明没有明确的配置。 From ce7dc1a61182f8e4df45819b7d07d265f3f6fa5d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E7=83=AD=E5=BF=83=E5=B8=82=E6=B0=91=E9=92=9F=E5=B0=8F?= =?UTF-8?q?=E5=BC=BA?= Date: Wed, 28 Aug 2019 14:11:18 +0800 Subject: [PATCH 542/865] Update and rename 51.1 Configure a Logger.md to 53.1 Configure a Logger.md --- .../{51.1 Configure a Logger.md => 53.1 Configure a Logger.md} | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) rename V. Spring Boot Actuator/{51.1 Configure a Logger.md => 53.1 Configure a Logger.md} (88%) diff --git a/V. Spring Boot Actuator/51.1 Configure a Logger.md b/V. Spring Boot Actuator/53.1 Configure a Logger.md similarity index 88% rename from V. Spring Boot Actuator/51.1 Configure a Logger.md rename to V. Spring Boot Actuator/53.1 Configure a Logger.md index 47028efd..33a581ce 100644 --- a/V. Spring Boot Actuator/51.1 Configure a Logger.md +++ b/V. Spring Boot Actuator/53.1 Configure a Logger.md @@ -1,4 +1,4 @@ -### 51.1 配置记录器 +### 53.1 配置记录器 为了配置一个特定的记录器,你向资源的URI`POST`一个部分的实体: ```properties From dca3d5f81b900644239560bde77062b71d2b599c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E7=83=AD=E5=BF=83=E5=B8=82=E6=B0=91=E9=92=9F=E5=B0=8F?= =?UTF-8?q?=E5=BC=BA?= Date: Thu, 29 Aug 2019 14:45:57 +0800 Subject: [PATCH 543/865] Update and rename 52. Metrics.md to 54. Metrics.md --- V. Spring Boot Actuator/52. Metrics.md | 38 -------------------------- V. Spring Boot Actuator/54. Metrics.md | 18 ++++++++++++ 2 files changed, 18 insertions(+), 38 deletions(-) delete mode 100644 V. Spring Boot Actuator/52. Metrics.md create mode 100644 V. Spring Boot Actuator/54. Metrics.md diff --git a/V. Spring Boot Actuator/52. Metrics.md b/V. Spring Boot Actuator/52. Metrics.md deleted file mode 100644 index ec1b8c2a..00000000 --- a/V. Spring Boot Actuator/52. Metrics.md +++ /dev/null @@ -1,38 +0,0 @@ - -### 52. 度量指标(Metrics) -Spring Boot执行器包含一个支持'gauge'和'counter'级别的度量指标服务,'gauge'记录一个单一值,'counter'记录一个增量(增加或减少)。同时,Spring Boot提供一个[PublicMetrics](https://github.com/spring-projects/spring-boot/tree/v2.0.0.RELEASE/spring-boot-actuator/src/main/java/org/springframework/boot/actuate/endpoint/PublicMetrics.java)接口,你可以实现它,从而暴露以上两种机制不能记录的指标,具体参考[SystemPublicMetrics](https://github.com/spring-projects/spring-boot/tree/v2.0.0.RELEASE/spring-boot-actuator/src/main/java/org/springframework/boot/actuate/endpoint/SystemPublicMetrics.java)。 - -所有HTTP请求的指标都被自动记录,所以如果点击`metrics`端点,你可能会看到类似以下的响应: -```javascript -{ - "counter.status.200.root": 20, - "counter.status.200.metrics": 3, - "counter.status.200.star-star": 5, - "counter.status.401.root": 4, - "gauge.response.star-star": 6, - "gauge.response.root": 2, - "gauge.response.metrics": 3, - "classes": 5808, - "classes.loaded": 5808, - "classes.unloaded": 0, - "heap": 3728384, - "heap.committed": 986624, - "heap.init": 262144, - "heap.used": 52765, - "mem": 986624, - "mem.free": 933858, - "processors": 8, - "threads": 15, - "threads.daemon": 11, - "threads.peak": 15, - "uptime": 494836, - "instance.uptime": 489782, - "datasource.primary.active": 5, - "datasource.primary.usage": 0.25 -} -``` -此处,我们可以看到基本的`memory`,`heap`,`class loading`,`processor`和`thread pool`信息,连同一些HTTP指标。在该实例中,`root`('/'),`/metrics` URLs分别返回`20`次,`3`次`HTTP 200`响应,同时可以看到`root` URL返回了`4`次`HTTP 401`(unauthorized)响应。双星号(`star-star`)来自于被Spring MVC `/**`匹配到的请求(通常为静态资源)。 - -`gauge`展示了一个请求的最后响应时间,所以`root`的最后请求响应耗时`2毫秒`,`/metrics`耗时`3毫秒`。 - -**注** 在该示例中,我们实际是通过HTTP的`/metrics`路径访问该端点的,这也就是响应中出现`metrics`的原因。 diff --git a/V. Spring Boot Actuator/54. Metrics.md b/V. Spring Boot Actuator/54. Metrics.md new file mode 100644 index 00000000..a458a2cb --- /dev/null +++ b/V. Spring Boot Actuator/54. Metrics.md @@ -0,0 +1,18 @@ +### 54. 度量指标(Metrics) + +Spring Boot执行器为[Micrometer](https://micrometer.io/)提供了依赖管理和自动配置。Micrometer是一种应用度量外观。它支持许多的监控系统,包括: + +- [Atlas](https://docs.spring.io/spring-boot/docs/2.0.0.RELEASE/reference/htmlsingle/#production-ready-metrics-export-atlas) +- [Datadog](https://docs.spring.io/spring-boot/docs/2.0.0.RELEASE/reference/htmlsingle/#production-ready-metrics-export-datadog) +- [Ganglia](https://docs.spring.io/spring-boot/docs/2.0.0.RELEASE/reference/htmlsingle/#production-ready-metrics-export-ganglia) +- [Graphite](https://docs.spring.io/spring-boot/docs/2.0.0.RELEASE/reference/htmlsingle/#production-ready-metrics-export-graphite) +- [Influx](https://docs.spring.io/spring-boot/docs/2.0.0.RELEASE/reference/htmlsingle/#production-ready-metrics-export-influx) +- [JMX](https://docs.spring.io/spring-boot/docs/2.0.0.RELEASE/reference/htmlsingle/#production-ready-metrics-export-jmx) +- [New Relic](https://docs.spring.io/spring-boot/docs/2.0.0.RELEASE/reference/htmlsingle/#production-ready-metrics-export-newrelic) +- [Prometheus](https://docs.spring.io/spring-boot/docs/2.0.0.RELEASE/reference/htmlsingle/#production-ready-metrics-export-prometheus) +- [SignalFx](https://docs.spring.io/spring-boot/docs/2.0.0.RELEASE/reference/htmlsingle/#production-ready-metrics-export-signalfx) +- [Simple (in-memory)](https://docs.spring.io/spring-boot/docs/2.0.0.RELEASE/reference/htmlsingle/#production-ready-metrics-export-simple) +- [StatsD](https://docs.spring.io/spring-boot/docs/2.0.0.RELEASE/reference/htmlsingle/#production-ready-metrics-export-statsd) +- [Wavefront](https://docs.spring.io/spring-boot/docs/2.0.0.RELEASE/reference/htmlsingle/#production-ready-metrics-export-wavefront) + +**注** 请参考[文档](https://micrometer.io/docs),学习更多的Micrometer功能,特别是[概念章节](https://micrometer.io/docs/concepts)。 From 8cf083eaa59c945253069a03957bc45dfb90ac87 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E7=83=AD=E5=BF=83=E5=B8=82=E6=B0=91=E9=92=9F=E5=B0=8F?= =?UTF-8?q?=E5=BC=BA?= Date: Fri, 30 Aug 2019 14:18:22 +0800 Subject: [PATCH 544/865] Update SUMMARY.md --- SUMMARY.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/SUMMARY.md b/SUMMARY.md index 846c8bf3..5d84f946 100644 --- a/SUMMARY.md +++ b/SUMMARY.md @@ -357,7 +357,7 @@ * [53. 记录器](V. Spring Boot Actuator/53. Loggers.md) * [53.1 配置记录器](V. Spring Boot Actuator/53.1 Configure a Logger.md) * [54. 度量指标](V. Spring Boot Actuator/54. Metrics.md) - * [54.1 系统指标](V. Spring Boot Actuator/54.1 System Metrics.md) + * [54.1 入门指南](V. Spring Boot Actuator/54.1 Getting started.md) * [54.2 数据源指标](V. Spring Boot Actuator/54.2 DataSource Metrics.md) * [54.3 缓存指标](V. Spring Boot Actuator/54.3 Cache Metrics.md) * [54.4 Tomcat session指标](V. Spring Boot Actuator/54.4 Tomcat Session Metrics.md) From 10e154a44ecc80d2d4218a001e506fd1754031d6 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E7=83=AD=E5=BF=83=E5=B8=82=E6=B0=91=E9=92=9F=E5=B0=8F?= =?UTF-8?q?=E5=BC=BA?= Date: Fri, 30 Aug 2019 14:24:47 +0800 Subject: [PATCH 545/865] Update and rename 52.1 System metrics.md to 54.1 Getting started.md --- .../52.1 System metrics.md | 12 ----- .../54.1 Getting started.md | 49 +++++++++++++++++++ 2 files changed, 49 insertions(+), 12 deletions(-) delete mode 100644 V. Spring Boot Actuator/52.1 System metrics.md create mode 100644 V. Spring Boot Actuator/54.1 Getting started.md diff --git a/V. Spring Boot Actuator/52.1 System metrics.md b/V. Spring Boot Actuator/52.1 System metrics.md deleted file mode 100644 index 4192f45b..00000000 --- a/V. Spring Boot Actuator/52.1 System metrics.md +++ /dev/null @@ -1,12 +0,0 @@ -### 52.1 系统指标 -Spring Boot会暴露以下系统指标: -- 系统内存总量(`mem`),单位:KB -- 空闲内存数量(`mem.free`),单位:KB -- 处理器数量(`processors`) -- 系统正常运行时间(`uptime`),单位:毫秒 -- 应用上下文(应用实例)正常运行时间(`instance.uptime`),单位:毫秒 -- 系统平均负载(`systemload.average`) -- 堆信息(`heap`,`heap.committed`,`heap.init`,`heap.used`),单位:KB -- 线程信息(`threads`,`thread.peak`,`thead.daemon`) -- 类加载信息(`classes`,`classes.loaded`,`classes.unloaded`) -- 垃圾收集信息(`gc.xxx.count`, `gc.xxx.time`) diff --git a/V. Spring Boot Actuator/54.1 Getting started.md b/V. Spring Boot Actuator/54.1 Getting started.md new file mode 100644 index 00000000..266f6222 --- /dev/null +++ b/V. Spring Boot Actuator/54.1 Getting started.md @@ -0,0 +1,49 @@ +### 54.1 入门指南 + +Spring Boot auto-configures a composite `MeterRegistry` and adds a registry to the composite for each of the supported implementations that it finds on the classpath. Having a dependency on `micrometer-registry-{system}` in your runtime classpath is enough for Spring Boot to configure the registry. + +Most registries share common features. For instance, you can disable a particular registry even if the Micrometer registry implementation is on the classpath. For instance, to disable Datadog: +```properties +management.metrics.export.datadog.enabled=false +``` + +Spring Boot will also add any auto-configured registries to the global static composite registry on the `Metrics` class unless you explicitly tell it not to: +```properties +management.metrics.use-global-registry=false +``` + +You can register any number of `MeterRegistryCustomizer` beans to further configure the registry, such as applying common tags, before any meters are registered with the registry: +```java +@Bean +MeterRegistryCustomizer metricsCommonTags() { + return registry -> registry.config().commonTags("region", "us-east-1"); +} +``` + +You can apply customizations to particular registry implementations by being more specific about the generic type: +```java +@Bean +MeterRegistryCustomizer graphiteMetricsNamingConvention() { + return registry -> registry.config().namingConvention(MY_CUSTOM_CONVENTION); +} +``` +With that setup in place you can inject `MeterRegistry` in your components and register metrics: +```java +@Component +public class SampleBean { + + private final Counter counter; + + public SampleBean(MeterRegistry registry) { + this.counter = registry.counter("received.messages"); + } + + public void handleMessage(String message) { + this.counter.increment(); + // handle message implementation + } + +} +``` + +Spring Boot also [configures built-in instrumentation](https://docs.spring.io/spring-boot/docs/2.0.0.RELEASE/reference/htmlsingle/#production-ready-metrics-meter) (i.e. `MeterBinder` implementations) that you can control via configuration or dedicated annotation markers. From 3b47310fe904b6cf5747a2a4b95afac560122c23 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E7=83=AD=E5=BF=83=E5=B8=82=E6=B0=91=E9=92=9F=E5=B0=8F?= =?UTF-8?q?=E5=BC=BA?= Date: Fri, 30 Aug 2019 14:46:44 +0800 Subject: [PATCH 546/865] Update 54.1 Getting started.md --- V. Spring Boot Actuator/54.1 Getting started.md | 15 ++++++++------- 1 file changed, 8 insertions(+), 7 deletions(-) diff --git a/V. Spring Boot Actuator/54.1 Getting started.md b/V. Spring Boot Actuator/54.1 Getting started.md index 266f6222..8d285296 100644 --- a/V. Spring Boot Actuator/54.1 Getting started.md +++ b/V. Spring Boot Actuator/54.1 Getting started.md @@ -1,18 +1,18 @@ ### 54.1 入门指南 -Spring Boot auto-configures a composite `MeterRegistry` and adds a registry to the composite for each of the supported implementations that it finds on the classpath. Having a dependency on `micrometer-registry-{system}` in your runtime classpath is enough for Spring Boot to configure the registry. +Spring Boot会自动配置一个复合`MeterRegistry`,并为它在类路径上找到的每个受支持的实现向复合添加注册。在运行时类路径中依赖于`micrometer-registry-{system}`就足以让Spring Boot配置注册表。 -Most registries share common features. For instance, you can disable a particular registry even if the Micrometer registry implementation is on the classpath. For instance, to disable Datadog: +大多数注册表都具有相同的特性。例如,即使Micrometer注册表实现位于类路径上,也可以禁用特定的注册表。例如,要禁用Datadog: ```properties management.metrics.export.datadog.enabled=false ``` -Spring Boot will also add any auto-configured registries to the global static composite registry on the `Metrics` class unless you explicitly tell it not to: +Spring Boot还会在`Metrics`类的全局静态复合注册表中添加任何自动配置的注册表,除非您明确告诉它不要: ```properties management.metrics.use-global-registry=false ``` -You can register any number of `MeterRegistryCustomizer` beans to further configure the registry, such as applying common tags, before any meters are registered with the registry: +你可以注册任何数量的`MeterRegistryCustomizer` bean来进一步配置注册表。例如在注册表注册任何meter之前应用通用标签: ```java @Bean MeterRegistryCustomizer metricsCommonTags() { @@ -20,14 +20,15 @@ MeterRegistryCustomizer metricsCommonTags() { } ``` -You can apply customizations to particular registry implementations by being more specific about the generic type: +您可以通过更具体的泛型类型将定制应用到特定的注册表实现: ```java @Bean MeterRegistryCustomizer graphiteMetricsNamingConvention() { return registry -> registry.config().namingConvention(MY_CUSTOM_CONVENTION); } ``` -With that setup in place you can inject `MeterRegistry` in your components and register metrics: + +有了这样的设置,你可以注入`MeterRegistry`在你的组件和注册指标: ```java @Component public class SampleBean { @@ -46,4 +47,4 @@ public class SampleBean { } ``` -Spring Boot also [configures built-in instrumentation](https://docs.spring.io/spring-boot/docs/2.0.0.RELEASE/reference/htmlsingle/#production-ready-metrics-meter) (i.e. `MeterBinder` implementations) that you can control via configuration or dedicated annotation markers. +Spring Boot还[配置了内置的工具](https://docs.spring.io/spring-boot/docs/2.0.0.RELEASE/reference/htmlsingle/#production-ready-metrics-meter)(即`MeterBinder`实现),你可以通过配置或专用的注释标记来控制这些工具。 From 6b7e3c4f258ed3d4d81bbda6fc30e40267c2a4e4 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E7=83=AD=E5=BF=83=E5=B8=82=E6=B0=91=E9=92=9F=E5=B0=8F?= =?UTF-8?q?=E5=BC=BA?= Date: Mon, 2 Sep 2019 21:27:17 +0800 Subject: [PATCH 547/865] Update SUMMARY.md --- SUMMARY.md | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) diff --git a/SUMMARY.md b/SUMMARY.md index 5d84f946..b6630c28 100644 --- a/SUMMARY.md +++ b/SUMMARY.md @@ -358,9 +358,21 @@ * [53.1 配置记录器](V. Spring Boot Actuator/53.1 Configure a Logger.md) * [54. 度量指标](V. Spring Boot Actuator/54. Metrics.md) * [54.1 入门指南](V. Spring Boot Actuator/54.1 Getting started.md) + * 54.2 支持的监控系统 + * [54.2.1 Atlas](V. Spring Boot Actuator/54.2.1 Atlas.md) + * [54.2.2 Datadog](V. Spring Boot Actuator/54.2.2 Datadog.md) + * [54.2.3 Ganglia](V. Spring Boot Actuator/54.2.3 Ganglia.md) + * [54.2.4 Graphite](V. Spring Boot Actuator/54.2.4 Graphite.md) + * [54.2.5 Influx](V. Spring Boot Actuator/54.2.5 Influx.md) + * [54.2.6 JMX](V. Spring Boot Actuator/54.2.6 JMX.md) + * [54.2.7 New Relic](V. Spring Boot Actuator/54.2.7 New Relic.md) + * [54.2.8 Prometheus](V. Spring Boot Actuator/54.2.8 Prometheus.md) + * [54.2.9 SignalFx](V. Spring Boot Actuator/54.2.9 SignalFx.md) + * [54.2.10 Simple](V. Spring Boot Actuator/54.2.10 Simple.md) + * [54.2.11 StatsD](V. Spring Boot Actuator/54.2.11 StatsD.md) + * [54.2.12 Wavefront](V. Spring Boot Actuator/54.2.12 Wavefront.md) * [54.2 数据源指标](V. Spring Boot Actuator/54.2 DataSource Metrics.md) * [54.3 缓存指标](V. Spring Boot Actuator/54.3 Cache Metrics.md) - * [54.4 Tomcat session指标](V. Spring Boot Actuator/54.4 Tomcat Session Metrics.md) * [54.5 记录自己的指标](V. Spring Boot Actuator/54.5 Recording your own Metrics.md) * [54.6 添加自己的公共指标](V. Spring Boot Actuator/54.6 Adding your own public Metrics.md) * [54.7 指标写入,导出和聚合](V. Spring Boot Actuator/54.7 Metric writers, exporters and aggregation.md) From 8e01b8f533ab525991554f845434550710154273 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E7=83=AD=E5=BF=83=E5=B8=82=E6=B0=91=E9=92=9F=E5=B0=8F?= =?UTF-8?q?=E5=BC=BA?= Date: Mon, 2 Sep 2019 21:34:23 +0800 Subject: [PATCH 548/865] Update and rename 52.4 Tomcat session metrics.md to 54.2.1 Atlas.md --- V. Spring Boot Actuator/52.4 Tomcat session metrics.md | 3 --- V. Spring Boot Actuator/54.2.1 Atlas.md | 6 ++++++ 2 files changed, 6 insertions(+), 3 deletions(-) delete mode 100644 V. Spring Boot Actuator/52.4 Tomcat session metrics.md create mode 100644 V. Spring Boot Actuator/54.2.1 Atlas.md diff --git a/V. Spring Boot Actuator/52.4 Tomcat session metrics.md b/V. Spring Boot Actuator/52.4 Tomcat session metrics.md deleted file mode 100644 index 9fc36770..00000000 --- a/V. Spring Boot Actuator/52.4 Tomcat session metrics.md +++ /dev/null @@ -1,3 +0,0 @@ -### 52.4 Tomcat session指标 -如果你使用Tomcat作为内嵌的servlet容器,Spring Boot将自动暴露session指标, -`httpsessions.active`和`httpsessions.max`分别提供活动的和最大的session数量。 diff --git a/V. Spring Boot Actuator/54.2.1 Atlas.md b/V. Spring Boot Actuator/54.2.1 Atlas.md new file mode 100644 index 00000000..5b4b0fa1 --- /dev/null +++ b/V. Spring Boot Actuator/54.2.1 Atlas.md @@ -0,0 +1,6 @@ +### 54.2.1 Atlas + +默认情况下,指标被导出到运行在本地机器上的[Atlas](http://micrometer.io/docs/registry/atlas)。可用以下方法提供要使用的[Atlas服务器](https://github.com/Netflix/atlas)的位置: +```properties +management.metrics.export.atlas.uri=http://atlas.example.com:7101/api/v1/publish +``` From 3beac1597b9c4abda405b1bc291fc318f3f540d3 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E7=83=AD=E5=BF=83=E5=B8=82=E6=B0=91=E9=92=9F=E5=B0=8F?= =?UTF-8?q?=E5=BC=BA?= Date: Fri, 13 Sep 2019 14:00:41 +0800 Subject: [PATCH 549/865] Update and rename 52.5 Recording your own metrics.md to 54.2.2 Datadog.md --- .../52.5 Recording your own metrics.md | 27 ------------------- V. Spring Boot Actuator/54.2.2 Datadog.md | 12 +++++++++ 2 files changed, 12 insertions(+), 27 deletions(-) delete mode 100644 V. Spring Boot Actuator/52.5 Recording your own metrics.md create mode 100644 V. Spring Boot Actuator/54.2.2 Datadog.md diff --git a/V. Spring Boot Actuator/52.5 Recording your own metrics.md b/V. Spring Boot Actuator/52.5 Recording your own metrics.md deleted file mode 100644 index 50939d07..00000000 --- a/V. Spring Boot Actuator/52.5 Recording your own metrics.md +++ /dev/null @@ -1,27 +0,0 @@ - -### 52.5 记录自己的指标 -将[CounterService](https://github.com/spring-projects/spring-boot/blob/master/spring-boot-actuator/src/main/java/org/springframework/boot/actuate/metrics/CounterService.java)或[GaugeService](http://github.com/spring-projects/spring-boot/tree/master/spring-boot-actuator/src/main/java/org/springframework/boot/actuate/metrics/GaugeService.java)注入到你的bean中可以记录自己的度量指标:`CounterService`暴露`increment`,`decrement`和`reset`方法;`GaugeService`提供一个`submit`方法。 - -下面是一个简单的示例,它记录了方法调用的次数: -```java -import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.boot.actuate.metrics.CounterService; -import org.springframework.stereotype.Service; - -@Service -public class MyService { - - private final CounterService counterService; - - @Autowired - public MyService(CounterService counterService) { - this.counterService = counterService; - } - - public void exampleMethod() { - this.counterService.increment("services.system.myservice.invoked"); - } - -} -``` -**注** 你可以将任何字符串用作度量指标的名称,但最好遵循所选存储/图形技术的指南,[Matt Aimonetti’s Blog](http://matt.aimonetti.net/posts/2013/06/26/practical-guide-to-graphite-monitoring/)中有一些好的关于Graphite的指南。 diff --git a/V. Spring Boot Actuator/54.2.2 Datadog.md b/V. Spring Boot Actuator/54.2.2 Datadog.md new file mode 100644 index 00000000..9a597451 --- /dev/null +++ b/V. Spring Boot Actuator/54.2.2 Datadog.md @@ -0,0 +1,12 @@ + +### 54.2.2 Datadog + +Datadog注册表定期将度量数据推送到[datadoghq](https://www.datadoghq.com/)。要将指标导出到[Datadog](http://micrometer.io/docs/registry/datadog),必须提供API密钥: +```properties +management.metrics.export.datadog.api-key=YOUR_KEY +``` + +你还可以更改将度量发送到Datadog的时间间隔: +```properties +management.metrics.export.datadog.steps=30s +``` From 01f4c4cacb2f04c27370bb34a89fafb0a1a6a188 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E7=83=AD=E5=BF=83=E5=B8=82=E6=B0=91=E9=92=9F=E5=B0=8F?= =?UTF-8?q?=E5=BC=BA?= Date: Fri, 13 Sep 2019 14:04:49 +0800 Subject: [PATCH 550/865] Update SUMMARY.md --- SUMMARY.md | 1 - 1 file changed, 1 deletion(-) diff --git a/SUMMARY.md b/SUMMARY.md index b6630c28..9c409598 100644 --- a/SUMMARY.md +++ b/SUMMARY.md @@ -373,7 +373,6 @@ * [54.2.12 Wavefront](V. Spring Boot Actuator/54.2.12 Wavefront.md) * [54.2 数据源指标](V. Spring Boot Actuator/54.2 DataSource Metrics.md) * [54.3 缓存指标](V. Spring Boot Actuator/54.3 Cache Metrics.md) - * [54.5 记录自己的指标](V. Spring Boot Actuator/54.5 Recording your own Metrics.md) * [54.6 添加自己的公共指标](V. Spring Boot Actuator/54.6 Adding your own public Metrics.md) * [54.7 指标写入,导出和聚合](V. Spring Boot Actuator/54.7 Metric writers, exporters and aggregation.md) * [54.7.1 示例: 导出到Redis](V. Spring Boot Actuator/54.7.1 Export to Redis.md) From de0e6dff40e67f6bdda3e172885a8316dc1c90bd Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E7=83=AD=E5=BF=83=E5=B8=82=E6=B0=91=E9=92=9F=E5=B0=8F?= =?UTF-8?q?=E5=BC=BA?= Date: Fri, 13 Sep 2019 18:29:22 +0800 Subject: [PATCH 551/865] Update and rename 52.6 Adding your own public metrics.md to 54.2.3 Ganglia.md --- .../52.6 Adding your own public metrics.md | 2 -- V. Spring Boot Actuator/54.2.3 Ganglia.md | 7 +++++++ 2 files changed, 7 insertions(+), 2 deletions(-) delete mode 100644 V. Spring Boot Actuator/52.6 Adding your own public metrics.md create mode 100644 V. Spring Boot Actuator/54.2.3 Ganglia.md diff --git a/V. Spring Boot Actuator/52.6 Adding your own public metrics.md b/V. Spring Boot Actuator/52.6 Adding your own public metrics.md deleted file mode 100644 index 9c8b0c7e..00000000 --- a/V. Spring Boot Actuator/52.6 Adding your own public metrics.md +++ /dev/null @@ -1,2 +0,0 @@ -### 52.6 添加自己的公共指标 -只要注册其他的`PublicMetrics`实现beans,你就可以添加其他的度量指标,比如计算metrics端点每次调用的次数。默认情况下,端点会聚合所有这样的beans,通过定义自己的`MetricsEndpoint`可以轻易改变这种情况。 diff --git a/V. Spring Boot Actuator/54.2.3 Ganglia.md b/V. Spring Boot Actuator/54.2.3 Ganglia.md new file mode 100644 index 00000000..0bbb6574 --- /dev/null +++ b/V. Spring Boot Actuator/54.2.3 Ganglia.md @@ -0,0 +1,7 @@ +### 54.2.3 Ganglia + +默认情况下,指标被导出到运行在本地机器上的[Ganglia](http://micrometer.io/docs/registry/ganglia)。[Ganglia服务器](http://ganglia.sourceforge.net/)主机和端口可以通过以下方式提供: +```properties +management.metrics.export.ganglia.host=ganglia.example.com +management.metrics.export.ganglia.post=9649 +``` From 9c74a48409de1f49531095d0a32765dd4316befd Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E7=83=AD=E5=BF=83=E5=B8=82=E6=B0=91=E9=92=9F=E5=B0=8F?= =?UTF-8?q?=E5=BC=BA?= Date: Fri, 13 Sep 2019 18:47:19 +0800 Subject: [PATCH 552/865] Update and rename 52.7 Metric writers, exporters and aggregation.md to 54.2.4 Graphite.md --- .../52.7 Metric writers, exporters and aggregation.md | 10 ---------- V. Spring Boot Actuator/54.2.4 Graphite.md | 7 +++++++ 2 files changed, 7 insertions(+), 10 deletions(-) delete mode 100644 V. Spring Boot Actuator/52.7 Metric writers, exporters and aggregation.md create mode 100644 V. Spring Boot Actuator/54.2.4 Graphite.md diff --git a/V. Spring Boot Actuator/52.7 Metric writers, exporters and aggregation.md b/V. Spring Boot Actuator/52.7 Metric writers, exporters and aggregation.md deleted file mode 100644 index d34c2aa9..00000000 --- a/V. Spring Boot Actuator/52.7 Metric writers, exporters and aggregation.md +++ /dev/null @@ -1,10 +0,0 @@ -###52.7 指标写入,导出和聚合 -Spring Boot提供几个标记接口`Exporter`的实现,可用于将从内存buffers读取的指标复制到一个分析和展示它们的地方。实际上,如果提供一个实现`MetricWriter`接口(或`GaugeWriter`用于简单场景)且注解`@ExportMetricWriter`的`@Bean`,它将自动挂钩一个`Exporter`并每5秒反馈下指标更新(通过`spring.metrics.export.delay-millis`配置)。此外,你定义的所有注解`@ExportMetricReader`的`MetricReader`,它们的值将被默认exporter导出。 - -**注** 这个特性会在你的应用中启用调度(`@EnableScheduling`)。如果你正在运行综合测试,这就会成为一个问题。因为你自己安排好的任务将会开始进行。你可以通过设置`spring.metrics.export.enabled`为`false`来禁用这个行为。 - -默认exporter是一个`MetricCopyExporter`,它会优化自己不去复制那些从上次调用以来没有变化的值(设置`spring.metrics.export.send-latest`标识可以关闭该优化)。注意Dropwizard `MetricRegistry`不支持时间戳,所以如果你使用Dropwizard指标服务,该优化是不起作用的(每次都会复制全部指标)。 - -通过`spring.metrics.export.*`属性可以设置导出的触发器(`delay-millis`,`includes`,`excludes`和`send-latest`),特殊`MetricWriters`的值可以通过`spring.metrics.export.triggers..*`设置,此处``是bean的名称(或匹配bean名称的表达式)。 - -**警告⚠️** 如果关闭默认的`MetricRepository`(比如使用Dropwizard指标服务),指标的自动导出将禁用。你可以通过声明自定义类型的`MetricReader`并注解`@ExportMetricReader`来获取相同功能。 diff --git a/V. Spring Boot Actuator/54.2.4 Graphite.md b/V. Spring Boot Actuator/54.2.4 Graphite.md new file mode 100644 index 00000000..f5f913ab --- /dev/null +++ b/V. Spring Boot Actuator/54.2.4 Graphite.md @@ -0,0 +1,7 @@ +### 54.2.4 Graphite + +默认情况下,指标被导出到运行在本地机器上的[Graphite](http://micrometer.io/docs/registry/graphite)。[Graphite服务器](https://graphiteapp.org/)主机和端口可以通过以下方式提供: +```properties +management.metrics.export.graphite.host=graphite.example.com +management.metrics.export.graphite.post=9004 +``` From 8de358fb18e3d41dc9db027dba5d8b771b2621ba Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E7=83=AD=E5=BF=83=E5=B8=82=E6=B0=91=E9=92=9F=E5=B0=8F?= =?UTF-8?q?=E5=BC=BA?= Date: Fri, 13 Sep 2019 18:48:07 +0800 Subject: [PATCH 553/865] Update SUMMARY.md --- SUMMARY.md | 2 -- 1 file changed, 2 deletions(-) diff --git a/SUMMARY.md b/SUMMARY.md index 9c409598..f7d712e0 100644 --- a/SUMMARY.md +++ b/SUMMARY.md @@ -373,8 +373,6 @@ * [54.2.12 Wavefront](V. Spring Boot Actuator/54.2.12 Wavefront.md) * [54.2 数据源指标](V. Spring Boot Actuator/54.2 DataSource Metrics.md) * [54.3 缓存指标](V. Spring Boot Actuator/54.3 Cache Metrics.md) - * [54.6 添加自己的公共指标](V. Spring Boot Actuator/54.6 Adding your own public Metrics.md) - * [54.7 指标写入,导出和聚合](V. Spring Boot Actuator/54.7 Metric writers, exporters and aggregation.md) * [54.7.1 示例: 导出到Redis](V. Spring Boot Actuator/54.7.1 Export to Redis.md) * [54.7.2 示例: 导出到Open TSDB](V. Spring Boot Actuator/54.7.2 Export to Open TSDB.md) * [54.7.3 示例: 导出到Statsd](V. Spring Boot Actuator/54.7.3 Export to Statsd.md) From fa6674bddcd5bcc049d4e52dbf3dded6fad8e328 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E7=83=AD=E5=BF=83=E5=B8=82=E6=B0=91=E9=92=9F=E5=B0=8F?= =?UTF-8?q?=E5=BC=BA?= Date: Fri, 13 Sep 2019 18:52:37 +0800 Subject: [PATCH 554/865] Update and rename 52.7.1 Export to Redis.md to 54.2.5 Influx.md --- .../52.7.1 Export to Redis.md | 23 ------------------- V. Spring Boot Actuator/54.2.5 Influx.md | 6 +++++ 2 files changed, 6 insertions(+), 23 deletions(-) delete mode 100644 V. Spring Boot Actuator/52.7.1 Export to Redis.md create mode 100644 V. Spring Boot Actuator/54.2.5 Influx.md diff --git a/V. Spring Boot Actuator/52.7.1 Export to Redis.md b/V. Spring Boot Actuator/52.7.1 Export to Redis.md deleted file mode 100644 index 18f94d0c..00000000 --- a/V. Spring Boot Actuator/52.7.1 Export to Redis.md +++ /dev/null @@ -1,23 +0,0 @@ -### 52.7.1 示例: 导出到Redis - -如果提供一个`RedisMetricRepository`类型的`@Bean`并注解`@ExportMetricWriter`,指标将导出到Redis缓存完成聚合。`RedisMetricRepository`有两个重要参数用于配置实现这样的目的:`prefix`和`key`(传递给构造器)。最好使用应用实例唯一的前缀(比如,使用一个随机值及应用的逻辑name,这样可以关联相同应用的其他实例)。“key”用来保持所有指标name的全局索引,所以它应该全局唯一,不管这对于你的应用意味着什么(比如,相同系统的两个实例可以共享一个Redis缓存,如果它们有不同的keys)。 - -示例: -```java -@Bean -@ExportMetricWriter -MetricWriter metricWriter(MetricExportProperties export) { - return new RedisMetricRepository(connectionFactory, - export.getRedis().getPrefix(), export.getRedis().getKey()); -} -``` -**application.properties.** -```properties -spring.metrics.export.redis.prefix: metrics.mysystem.${spring.application.name:application}.${random.value:0000} -spring.metrics.export.redis.key: keys.metrics.mysystem -``` -前缀最后由应用名和id组成,所以它可以用来标识具有相同逻辑名的processes分组。 - -**注** 设置`key`和`prefix`都是非常重要的。key用于所有的仓库操作,并可以被多个仓库共享。如果多个仓库共享一个key(比如你需要聚合它们的时候),你通常有一个只读“master”仓库,它有一个简短的但可辨识的前缀(比如`metrics.mysystem`),还有很多只写的仓库,这些仓库以master前缀开头(比如以上示例中为`metrics.mysystem.*`)。这样从一个"master"仓库读取所有keys是相当高效的,但使用较长的前缀读取一个子集就比较低效了(比如使用一个写仓库)。 - -**注** 以上示例使用`MetricExportProperties`去注入和提取key和前缀,这是Spring Boot提供的便利设施,用于配置合适的默认值,你也可以自己设值。 diff --git a/V. Spring Boot Actuator/54.2.5 Influx.md b/V. Spring Boot Actuator/54.2.5 Influx.md new file mode 100644 index 00000000..edfa8478 --- /dev/null +++ b/V. Spring Boot Actuator/54.2.5 Influx.md @@ -0,0 +1,6 @@ +### 54.2.5 Influx + +默认情况下,指标被导出到运行在本地机器上的[Influx](http://micrometer.io/docs/registry/influx)。可以使用以下方法提供要使用的[Influx服务器](https://www.influxdata.com/)的位置: +```properties +management.metrics.export.influx.uri=http://influx.example.com:8086 +``` From 9366432dada5fa2e6adb81b253d68d94b929acdf Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E7=83=AD=E5=BF=83=E5=B8=82=E6=B0=91=E9=92=9F=E5=B0=8F?= =?UTF-8?q?=E5=BC=BA?= Date: Fri, 13 Sep 2019 18:53:49 +0800 Subject: [PATCH 555/865] Update SUMMARY.md --- SUMMARY.md | 1 - 1 file changed, 1 deletion(-) diff --git a/SUMMARY.md b/SUMMARY.md index f7d712e0..9d48be64 100644 --- a/SUMMARY.md +++ b/SUMMARY.md @@ -373,7 +373,6 @@ * [54.2.12 Wavefront](V. Spring Boot Actuator/54.2.12 Wavefront.md) * [54.2 数据源指标](V. Spring Boot Actuator/54.2 DataSource Metrics.md) * [54.3 缓存指标](V. Spring Boot Actuator/54.3 Cache Metrics.md) - * [54.7.1 示例: 导出到Redis](V. Spring Boot Actuator/54.7.1 Export to Redis.md) * [54.7.2 示例: 导出到Open TSDB](V. Spring Boot Actuator/54.7.2 Export to Open TSDB.md) * [54.7.3 示例: 导出到Statsd](V. Spring Boot Actuator/54.7.3 Export to Statsd.md) * [54.7.4 示例: 导出到JMX](V. Spring Boot Actuator/54.7.4 Export to JMX.md) From cb8aeff10ee2a9beef9eeda0213ddc622bd84781 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E7=83=AD=E5=BF=83=E5=B8=82=E6=B0=91=E9=92=9F=E5=B0=8F?= =?UTF-8?q?=E5=BC=BA?= Date: Thu, 19 Sep 2019 14:19:28 +0800 Subject: [PATCH 556/865] Update and rename 52.7.2 Export to Open TSDB.md to 54.2.6 JMX.md --- .../52.7.2 Export to Open TSDB.md | 21 ------------------- V. Spring Boot Actuator/54.2.6 JMX.md | 5 +++++ 2 files changed, 5 insertions(+), 21 deletions(-) delete mode 100644 V. Spring Boot Actuator/52.7.2 Export to Open TSDB.md create mode 100644 V. Spring Boot Actuator/54.2.6 JMX.md diff --git a/V. Spring Boot Actuator/52.7.2 Export to Open TSDB.md b/V. Spring Boot Actuator/52.7.2 Export to Open TSDB.md deleted file mode 100644 index 88af2cc3..00000000 --- a/V. Spring Boot Actuator/52.7.2 Export to Open TSDB.md +++ /dev/null @@ -1,21 +0,0 @@ -###52.7.2 示例: 导出到Open TSDB -如果提供一个`OpenTsdbGaugeWriter`类型的`@Bean`并注解`@ExportMetricWriter`,指标将导出到[Open TSDB ](http://opentsdb.net/)完成聚合。`OpenTsdbGaugeWriter`有一个`url`属性,你需要将它设置为Open TSDB的“/put”端点,比如`localhost:4242/api/put`。它还有个`namingStrategy`,你可以自定义或配置以使指标匹配服务器上你需要的数据结构。默认它只传递指标名作为Open TSDB指标名,添加`domain`标签(值为`org.springframework.metrics`)和`process`(值为命名策略的对象hash值)。因此,在运行应用并产生一些指标后,你可以在TSD UI查看这些指标(默认路径为`localhost:4242`)。 - -示例: -```shell -curl localhost:4242/api/query?start=1h-ago&m=max:counter.status.200.root -[ - { - "metric": "counter.status.200.root", - "tags": { - "domain": "org.springframework.metrics", - "process": "b968a76" - }, - "aggregateTags": [], - "dps": { - "1430492872": 2, - "1430492875": 6 - } - } -] -``` diff --git a/V. Spring Boot Actuator/54.2.6 JMX.md b/V. Spring Boot Actuator/54.2.6 JMX.md new file mode 100644 index 00000000..c800bd4f --- /dev/null +++ b/V. Spring Boot Actuator/54.2.6 JMX.md @@ -0,0 +1,5 @@ +### 54.2.6 JMX + +Micrometer提供了到[JMX](http://micrometer.io/docs/registry/jmx)的层次映射,主要是作为一种廉价且可移植的方法来查看本地指标。Spring Boot提供了一个默认的`HierarchicalNameMapper`。它用于管理维度表id如何映射到平面分级名称。 + +**注** 要控制这种行为,请定义你自己的`HierarchicalNameMapper` bean。 From 3616752f2180c96e1fa63d6a86e91150b7f5bee2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E7=83=AD=E5=BF=83=E5=B8=82=E6=B0=91=E9=92=9F=E5=B0=8F?= =?UTF-8?q?=E5=BC=BA?= Date: Thu, 19 Sep 2019 14:30:12 +0800 Subject: [PATCH 557/865] Update and rename 52.7.3 Export to Statsd.md to 54.2.7 New Relic.md --- V. Spring Boot Actuator/52.7.3 Export to Statsd.md | 13 ------------- V. Spring Boot Actuator/54.2.7 New Relic.md | 11 +++++++++++ 2 files changed, 11 insertions(+), 13 deletions(-) delete mode 100644 V. Spring Boot Actuator/52.7.3 Export to Statsd.md create mode 100644 V. Spring Boot Actuator/54.2.7 New Relic.md diff --git a/V. Spring Boot Actuator/52.7.3 Export to Statsd.md b/V. Spring Boot Actuator/52.7.3 Export to Statsd.md deleted file mode 100644 index ee093fb6..00000000 --- a/V. Spring Boot Actuator/52.7.3 Export to Statsd.md +++ /dev/null @@ -1,13 +0,0 @@ -###52.7.3 示例: 导出到Statsd - -想要将指标导出到Statsd,首先你需要确定添加了`com.timgroup:java-statsd-client`依赖(Spring Boot为它提供了依赖管理),然后将`spring.metrics.export.statsd.host`属性添加到`application.properties`文件中,连接将在`8125`端口建立,除非设置`spring.metrics.export.statsd.port`对默认值进行覆盖。使用`spring.metrics.export.statsd.prefix`可以设置自定义前缀,此外,你可以提供一个`StatsdMetricWriter`类型的`@Bean`并注解`@ExportMetricWriter`: -```java -@Value("${spring.application.name:application}.${random.value:0000}") -private String prefix = "metrics"; - -@Bean -@ExportMetricWriter -MetricWriter metricWriter() { - return new StatsdMetricWriter(prefix, "localhost", 8125); -} -``` diff --git a/V. Spring Boot Actuator/54.2.7 New Relic.md b/V. Spring Boot Actuator/54.2.7 New Relic.md new file mode 100644 index 00000000..eb054857 --- /dev/null +++ b/V. Spring Boot Actuator/54.2.7 New Relic.md @@ -0,0 +1,11 @@ +### 54.2.7 New Relic + +New Relic注册表定期将度量数据推送到[New Relic](http://micrometer.io/docs/registry/new-relic)。要将指标导出到[New Relic](https://newrelic.com/),必须提供API密钥和帐户id: +```properties +management.metrics.export.newrelic.api-key=YOUR_KEY +management.metrics.export.newrelic.account-id=YOUR_ACCOUNT_ID +``` +你还可以更改将度量数据发送到New Relic的时间间隔: +```properties +management.metrics.export.newrelic.steps=30s +``` From 37480d79b530b1a1c2c0c486d958364741c606e9 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E7=83=AD=E5=BF=83=E5=B8=82=E6=B0=91=E9=92=9F=E5=B0=8F?= =?UTF-8?q?=E5=BC=BA?= Date: Thu, 19 Sep 2019 14:32:39 +0800 Subject: [PATCH 558/865] Update SUMMARY.md --- SUMMARY.md | 2 -- 1 file changed, 2 deletions(-) diff --git a/SUMMARY.md b/SUMMARY.md index 9d48be64..027692c6 100644 --- a/SUMMARY.md +++ b/SUMMARY.md @@ -373,8 +373,6 @@ * [54.2.12 Wavefront](V. Spring Boot Actuator/54.2.12 Wavefront.md) * [54.2 数据源指标](V. Spring Boot Actuator/54.2 DataSource Metrics.md) * [54.3 缓存指标](V. Spring Boot Actuator/54.3 Cache Metrics.md) - * [54.7.2 示例: 导出到Open TSDB](V. Spring Boot Actuator/54.7.2 Export to Open TSDB.md) - * [54.7.3 示例: 导出到Statsd](V. Spring Boot Actuator/54.7.3 Export to Statsd.md) * [54.7.4 示例: 导出到JMX](V. Spring Boot Actuator/54.7.4 Export to JMX.md) * [54.8 聚合多个来源的指标](V. Spring Boot Actuator/54.8 Aggregating Metrics from Multiple Sources.md) * [54.9 Dropwizard指标](V. Spring Boot Actuator/54.9 Dropwizard Metrics.md) From f10ca2210ed0dd862df7f28511f95f4521593537 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E7=83=AD=E5=BF=83=E5=B8=82=E6=B0=91=E9=92=9F=E5=B0=8F?= =?UTF-8?q?=E5=BC=BA?= Date: Fri, 20 Sep 2019 14:05:49 +0800 Subject: [PATCH 559/865] Update and rename 52.7.4 Export to JMX.md to 54.2.8 Prometheus.md --- V. Spring Boot Actuator/52.7.4 Export to JMX.md | 12 ------------ V. Spring Boot Actuator/54.2.8 Prometheus.md | 15 +++++++++++++++ 2 files changed, 15 insertions(+), 12 deletions(-) delete mode 100644 V. Spring Boot Actuator/52.7.4 Export to JMX.md create mode 100644 V. Spring Boot Actuator/54.2.8 Prometheus.md diff --git a/V. Spring Boot Actuator/52.7.4 Export to JMX.md b/V. Spring Boot Actuator/52.7.4 Export to JMX.md deleted file mode 100644 index a9c82e52..00000000 --- a/V. Spring Boot Actuator/52.7.4 Export to JMX.md +++ /dev/null @@ -1,12 +0,0 @@ -###52.7.4 示例: 导出到JMX -如果提供一个`JmxMetricWriter`类型并注解`@ExportMetricWriter`的`@Bean`,指标将作为MBeans暴露到本地服务器(只要开启,Spring Boot JMX自动配置会提供`MBeanExporter`)。 - -示例: -```java -@Bean -@ExportMetricWriter -MetricWriter metricWriter(MBeanExporter exporter) { - return new JmxMetricWriter(exporter); -} -``` -每个指标都暴露为单独的MBean,你可以将`ObjectNamingStrategy`注入`JmxMetricWriter`来指定`ObjectNames`的格式。 diff --git a/V. Spring Boot Actuator/54.2.8 Prometheus.md b/V. Spring Boot Actuator/54.2.8 Prometheus.md new file mode 100644 index 00000000..65018298 --- /dev/null +++ b/V. Spring Boot Actuator/54.2.8 Prometheus.md @@ -0,0 +1,15 @@ +### 54.2.8 Prometheus + +[Prometheus](http://micrometer.io/docs/registry/prometheus)希望通过抓取或轮询单个应用程序实例来获得指标。Spring Boot在`/actuator/prometheus`上提供了一个执行器端点,可以用适当的格式显示[Prometheus刮片](https://prometheus.io/)。 + +**注** 缺省情况下端点不可用,必须公开端点,请参阅公开端点以获得更多详细信息。 + +下面是一个要添加到`prometheus.yml`中的`scrape_config`示例: + +```yml +scrape_configs: + - job_name: 'spring' + metrics_path: '/actuator/prometheus' + static_configs: + - targets: ['HOST:PORT'] +``` From 1fc79dedca82dd78e85b76b30c0225589b3af01a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E7=83=AD=E5=BF=83=E5=B8=82=E6=B0=91=E9=92=9F=E5=B0=8F?= =?UTF-8?q?=E5=BC=BA?= Date: Fri, 20 Sep 2019 14:09:39 +0800 Subject: [PATCH 560/865] Update 54.2.8 Prometheus.md --- V. Spring Boot Actuator/54.2.8 Prometheus.md | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/V. Spring Boot Actuator/54.2.8 Prometheus.md b/V. Spring Boot Actuator/54.2.8 Prometheus.md index 65018298..5b436da6 100644 --- a/V. Spring Boot Actuator/54.2.8 Prometheus.md +++ b/V. Spring Boot Actuator/54.2.8 Prometheus.md @@ -9,7 +9,7 @@ ```yml scrape_configs: - job_name: 'spring' - metrics_path: '/actuator/prometheus' - static_configs: - - targets: ['HOST:PORT'] + metrics_path: '/actuator/prometheus' + static_configs: + - targets: ['HOST:PORT'] ``` From fd40c5e63d4c3869468a7b06b6cd2bd501d57f8c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E7=83=AD=E5=BF=83=E5=B8=82=E6=B0=91=E9=92=9F=E5=B0=8F?= =?UTF-8?q?=E5=BC=BA?= Date: Fri, 20 Sep 2019 14:20:44 +0800 Subject: [PATCH 561/865] Update 54.2.8 Prometheus.md --- V. Spring Boot Actuator/54.2.8 Prometheus.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/V. Spring Boot Actuator/54.2.8 Prometheus.md b/V. Spring Boot Actuator/54.2.8 Prometheus.md index 5b436da6..b57513c2 100644 --- a/V. Spring Boot Actuator/54.2.8 Prometheus.md +++ b/V. Spring Boot Actuator/54.2.8 Prometheus.md @@ -1,6 +1,6 @@ ### 54.2.8 Prometheus -[Prometheus](http://micrometer.io/docs/registry/prometheus)希望通过抓取或轮询单个应用程序实例来获得指标。Spring Boot在`/actuator/prometheus`上提供了一个执行器端点,可以用适当的格式显示[Prometheus刮片](https://prometheus.io/)。 +[Prometheus](http://micrometer.io/docs/registry/prometheus)希望通过抓取或轮询单个应用程序实例来获得度量数据。Spring Boot在`/actuator/prometheus`上提供了一个执行器端点,可以用适当的格式显示[Prometheus刮片](https://prometheus.io/)。 **注** 缺省情况下端点不可用,必须公开端点,请参阅公开端点以获得更多详细信息。 From f4902761a09000f91ac053f7ef4c98d340047c1f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E7=83=AD=E5=BF=83=E5=B8=82=E6=B0=91=E9=92=9F=E5=B0=8F?= =?UTF-8?q?=E5=BC=BA?= Date: Fri, 20 Sep 2019 14:27:38 +0800 Subject: [PATCH 562/865] Update and rename 52.8 Aggregating metrics from multiple sources.md to 54.2.9 SignalFx.md --- ...gregating metrics from multiple sources.md | 29 ------------------- V. Spring Boot Actuator/54.2.9 SignalFx.md | 10 +++++++ 2 files changed, 10 insertions(+), 29 deletions(-) delete mode 100644 V. Spring Boot Actuator/52.8 Aggregating metrics from multiple sources.md create mode 100644 V. Spring Boot Actuator/54.2.9 SignalFx.md diff --git a/V. Spring Boot Actuator/52.8 Aggregating metrics from multiple sources.md b/V. Spring Boot Actuator/52.8 Aggregating metrics from multiple sources.md deleted file mode 100644 index 13fa22a6..00000000 --- a/V. Spring Boot Actuator/52.8 Aggregating metrics from multiple sources.md +++ /dev/null @@ -1,29 +0,0 @@ -###52.8 聚合多个来源的指标 -Spring Boot提供一个`AggregateMetricReader`,用于合并来自不同物理来源的指标。具有相同逻辑指标的来源只需将指标加上以句号分隔的前缀发布出去,reader会聚合它们(通过截取指标名并丢掉前缀),计数器被求和,所有东西(比如gauges)都采用最近的值。 - -这非常有用,特别是当有多个应用实例反馈数据到中央仓库(比如Redis),并且你想展示结果。推荐将`MetricReaderPublicMetrics`结果连接到`/metrics`端点。 - -示例: -```java -@Autowired -private MetricExportProperties export; - -@Bean -public PublicMetrics metricsAggregate() { - return new MetricReaderPublicMetrics(aggregatesMetricReader()); -} - -private MetricReader globalMetricsForAggregation() { - return new RedisMetricRepository(this.connectionFactory, - this.export.getRedis().getAggregatePrefix(), this.export.getRedis().getKey()); -} - -private MetricReader aggregatesMetricReader() { - AggregateMetricReader repository = new AggregateMetricReader( - globalMetricsForAggregation()); - return repository; -} -``` -**注** 上面的示例使用`MetricExportProperties`注入和提取key和前缀,这是Spring Boot提供的便利设施,并且默认值是合适的,它们是在`MetricExportAutoConfiguration`中设置的。 - -**注** 上面的`MetricReaders`不是`@Beans`,也没注解`@ExportMetricReader`,因为它们只收集和分析来自其他仓库的数据,不需要暴露自己的值。 diff --git a/V. Spring Boot Actuator/54.2.9 SignalFx.md b/V. Spring Boot Actuator/54.2.9 SignalFx.md new file mode 100644 index 00000000..60eba558 --- /dev/null +++ b/V. Spring Boot Actuator/54.2.9 SignalFx.md @@ -0,0 +1,10 @@ +### 54.2.9 SignalFx + +SignalFx注册表定期将度量数据推送到[SignalFx](http://micrometer.io/docs/registry/signalfx)。要将度量数据导出到[SignalFx](https://signalfx.com/),必须提供您的访问令牌: +```properties +management.metrics.export.signalfx.access-token=YOUR_ACCESS_TOKEN +``` +你还可以更改度量数据发送到SignalFx的时间间隔: +```properties +management.metrics.export.signalfx.steps=30s +``` From 75ac28567a4d74f33185137d90bb364812b5eaa1 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E7=83=AD=E5=BF=83=E5=B8=82=E6=B0=91=E9=92=9F=E5=B0=8F?= =?UTF-8?q?=E5=BC=BA?= Date: Fri, 20 Sep 2019 14:40:49 +0800 Subject: [PATCH 563/865] Update and rename 52.9 Dropwizard Metrics.md to 54.2.10 Simple.md --- V. Spring Boot Actuator/52.9 Dropwizard Metrics.md | 4 ---- V. Spring Boot Actuator/54.2.10 Simple.md | 8 ++++++++ 2 files changed, 8 insertions(+), 4 deletions(-) delete mode 100644 V. Spring Boot Actuator/52.9 Dropwizard Metrics.md create mode 100644 V. Spring Boot Actuator/54.2.10 Simple.md diff --git a/V. Spring Boot Actuator/52.9 Dropwizard Metrics.md b/V. Spring Boot Actuator/52.9 Dropwizard Metrics.md deleted file mode 100644 index a7fb93a1..00000000 --- a/V. Spring Boot Actuator/52.9 Dropwizard Metrics.md +++ /dev/null @@ -1,4 +0,0 @@ -### 52.9 Dropwizard指标 -当你声明对`io.dropwizard.metrics:metrics-core`的依赖时,Spring Boot会创建一个默认的`MetricRegistry` bean。如果需要自定义,你可以注册自己的`@Bean`实例。使用[Dropwizard ‘Metrics’ library](https://dropwizard.github.io/metrics/)的用户会发现Spring Boot指标自动发布到`com.codahale.metrics.MetricRegistry`,来自`MetricRegistry`的指标也自动暴露到`/metrics`端点。 - -使用Dropwizard指标时,默认的`CounterService`和`GaugeService`被`DropwizardMetricServices`替换,它是一个`MetricRegistry`的包装器(所以你可以`@Autowired`其中任意services,并像平常那么使用它)。通过使用恰当的前缀类型标记你的指标名可以创建特殊的Dropwizard指标服务(比如,gauges使用`timer.*`,`histogram.*`,counters使用`meter.*`)。 diff --git a/V. Spring Boot Actuator/54.2.10 Simple.md b/V. Spring Boot Actuator/54.2.10 Simple.md new file mode 100644 index 00000000..b80b0b30 --- /dev/null +++ b/V. Spring Boot Actuator/54.2.10 Simple.md @@ -0,0 +1,8 @@ +### 54.2.10 Simple + +Micrometer附带一个简单的内存后端。如果没有配置其它注册表,该后端将自动用作回退。这允许你查看[度量端点](https://docs.spring.io/spring-boot/docs/2.0.0.RELEASE/reference/htmlsingle/#production-ready-metrics-endpoint)中收集了哪些度量数据。 + +只要使用任何其它可用后端,内存中的后端就会禁用自己。你也可以显式禁用它: +```properties +management.metrics.export.simple.enabled=false +``` From 5ba5b98882349f2cb90ee8b0a6f16ea020e2f457 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E7=83=AD=E5=BF=83=E5=B8=82=E6=B0=91=E9=92=9F=E5=B0=8F?= =?UTF-8?q?=E5=BC=BA?= Date: Fri, 20 Sep 2019 14:42:30 +0800 Subject: [PATCH 564/865] Update SUMMARY.md --- SUMMARY.md | 3 --- 1 file changed, 3 deletions(-) diff --git a/SUMMARY.md b/SUMMARY.md index 027692c6..7e9ef890 100644 --- a/SUMMARY.md +++ b/SUMMARY.md @@ -373,9 +373,6 @@ * [54.2.12 Wavefront](V. Spring Boot Actuator/54.2.12 Wavefront.md) * [54.2 数据源指标](V. Spring Boot Actuator/54.2 DataSource Metrics.md) * [54.3 缓存指标](V. Spring Boot Actuator/54.3 Cache Metrics.md) - * [54.7.4 示例: 导出到JMX](V. Spring Boot Actuator/54.7.4 Export to JMX.md) - * [54.8 聚合多个来源的指标](V. Spring Boot Actuator/54.8 Aggregating Metrics from Multiple Sources.md) - * [54.9 Dropwizard指标](V. Spring Boot Actuator/54.9 Dropwizard Metrics.md) * [54.10 消息渠道集成](V. Spring Boot Actuator/54.10 Message Channel Integration.md) * [55. 审计](V. Spring Boot Actuator/55. Auditing.md) * [56. 追踪](V. Spring Boot Actuator/56. Tracing.md) From 9507635bcfd39cfb966f59fe268c036e4a49a679 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E7=83=AD=E5=BF=83=E5=B8=82=E6=B0=91=E9=92=9F=E5=B0=8F?= =?UTF-8?q?=E5=BC=BA?= Date: Tue, 1 Oct 2019 16:29:45 +0800 Subject: [PATCH 565/865] Update and rename 52.10 Message channel integration.md to 54.2.11 StatsD.md --- .../52.10 Message channel integration.md | 2 -- V. Spring Boot Actuator/54.2.11 StatsD.md | 11 +++++++++++ 2 files changed, 11 insertions(+), 2 deletions(-) delete mode 100644 V. Spring Boot Actuator/52.10 Message channel integration.md create mode 100644 V. Spring Boot Actuator/54.2.11 StatsD.md diff --git a/V. Spring Boot Actuator/52.10 Message channel integration.md b/V. Spring Boot Actuator/52.10 Message channel integration.md deleted file mode 100644 index 7f987720..00000000 --- a/V. Spring Boot Actuator/52.10 Message channel integration.md +++ /dev/null @@ -1,2 +0,0 @@ -### 52.10 消息渠道集成 -如果存在名为`metricsChannel`的`MessageChannel` bean,Spring Boot将创建一个`MetricWriter`将指标写入该渠道(channel)。每一条传送到这个渠道的信息将会包含一个[Delta](https://docs.spring.io/spring-boot/docs/2.0.0.RELEASE/api/org/springframework/boot/actuate/metrics/writer/Delta.html)或者[Metric](https://docs.spring.io/spring-boot/docs/2.0.0.RELEASE/api/org/springframework/boot/actuate/metrics/Metric.html),同时有一个`metricName`标头。writer自动挂钩一个exporter,所以全部指标值都会出现在渠道上, 订阅者就可以进行其他分析或动作(提供渠道和订阅者取决于你)。 diff --git a/V. Spring Boot Actuator/54.2.11 StatsD.md b/V. Spring Boot Actuator/54.2.11 StatsD.md new file mode 100644 index 00000000..74899526 --- /dev/null +++ b/V. Spring Boot Actuator/54.2.11 StatsD.md @@ -0,0 +1,11 @@ +### 54.2.11 StatsD + +StatsD注册表急切地将度量数据从UDP推送到StatsD代理。默认情况下,度量数据被导出到运行在本地机器上的[StatsD](http://micrometer.io/docs/registry/statsd)代理。可以使用以下方法提供StatsD代理主机和端口: +```properties +management.metrics.export.statsd.host=statsd.example.com +management.metrics.export.statsd.port=9125 +``` +你也可以改变StatsD行协议来使用(默认为Datadog): +```properties +management.metrics.export.statsd.flavor=etsy +``` From e1a40c018ac57a4e7e09a3d01ae071fa1ced0f2e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E7=83=AD=E5=BF=83=E5=B8=82=E6=B0=91=E9=92=9F=E5=B0=8F?= =?UTF-8?q?=E5=BC=BA?= Date: Tue, 1 Oct 2019 16:34:14 +0800 Subject: [PATCH 566/865] Update SUMMARY.md --- SUMMARY.md | 1 - 1 file changed, 1 deletion(-) diff --git a/SUMMARY.md b/SUMMARY.md index 7e9ef890..6fc3e5c6 100644 --- a/SUMMARY.md +++ b/SUMMARY.md @@ -373,7 +373,6 @@ * [54.2.12 Wavefront](V. Spring Boot Actuator/54.2.12 Wavefront.md) * [54.2 数据源指标](V. Spring Boot Actuator/54.2 DataSource Metrics.md) * [54.3 缓存指标](V. Spring Boot Actuator/54.3 Cache Metrics.md) - * [54.10 消息渠道集成](V. Spring Boot Actuator/54.10 Message Channel Integration.md) * [55. 审计](V. Spring Boot Actuator/55. Auditing.md) * [56. 追踪](V. Spring Boot Actuator/56. Tracing.md) * [56.1 自定义追踪](V. Spring Boot Actuator/56.1 Custom Tracing.md) From 2fdd44052ad6881ed80e8827b6c794ebb5171350 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E7=83=AD=E5=BF=83=E5=B8=82=E6=B0=91=E9=92=9F=E5=B0=8F?= =?UTF-8?q?=E5=BC=BA?= Date: Tue, 1 Oct 2019 16:57:19 +0800 Subject: [PATCH 567/865] Create 54.2.12 Wavefront.md --- V. Spring Boot Actuator/54.2.12 Wavefront.md | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) create mode 100644 V. Spring Boot Actuator/54.2.12 Wavefront.md diff --git a/V. Spring Boot Actuator/54.2.12 Wavefront.md b/V. Spring Boot Actuator/54.2.12 Wavefront.md new file mode 100644 index 00000000..4019c647 --- /dev/null +++ b/V. Spring Boot Actuator/54.2.12 Wavefront.md @@ -0,0 +1,17 @@ +### 54.2.12 Wavefront + +Wavefront注册表周期性地将度量数据推送到[Wavefront](http://micrometer.io/docs/registry/wavefront)。如果你直接将度量数据导出到[Wavefront](https://www.wavefront.com/),你的API令牌必须提供: +```properties +management.metrics.export.wavefront.api-token=YOUR_API_TOKEN +``` +或者,你可以使用一个Wavefront sidecar或在你的环境中设置的内部代理,将度量数据转发到WavefrontAPI主机: +```properties +management.metrics.export.uri=proxy://localhost:7828 +``` + +**注** 如果将度量数据发布到一个Wavefront代理(如[文档](https://docs.wavefront.com/proxies_installing.html)中所述),主机必须采用`proxy://HOST:PORT`格式。 + +你也可以改变数据发送到Wavefront的时间间隔: +```properties +management.metrics.export.wavefront.steps=30s +``` From db30a15b770d81e5b08fb3d63cd42ff3231d955d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E7=83=AD=E5=BF=83=E5=B8=82=E6=B0=91=E9=92=9F=E5=B0=8F?= =?UTF-8?q?=E5=BC=BA?= Date: Wed, 2 Oct 2019 12:35:16 +0800 Subject: [PATCH 568/865] Update SUMMARY.md --- SUMMARY.md | 2 ++ 1 file changed, 2 insertions(+) diff --git a/SUMMARY.md b/SUMMARY.md index 6fc3e5c6..edcd3cbc 100644 --- a/SUMMARY.md +++ b/SUMMARY.md @@ -371,6 +371,8 @@ * [54.2.10 Simple](V. Spring Boot Actuator/54.2.10 Simple.md) * [54.2.11 StatsD](V. Spring Boot Actuator/54.2.11 StatsD.md) * [54.2.12 Wavefront](V. Spring Boot Actuator/54.2.12 Wavefront.md) + * [54.3 支持的指标](V. Spring Boot Actuator/54.3 Supported Metrics.md) + * [54.3.1 Spring MVC指标](V. Spring Boot Actuator/54.3.1 Spring MVC Metrics.md) * [54.2 数据源指标](V. Spring Boot Actuator/54.2 DataSource Metrics.md) * [54.3 缓存指标](V. Spring Boot Actuator/54.3 Cache Metrics.md) * [55. 审计](V. Spring Boot Actuator/55. Auditing.md) From 8a41de55fb3eee69804a50f5132ac583f42c6515 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E7=83=AD=E5=BF=83=E5=B8=82=E6=B0=91=E9=92=9F=E5=B0=8F?= =?UTF-8?q?=E5=BC=BA?= Date: Wed, 2 Oct 2019 16:49:42 +0800 Subject: [PATCH 569/865] Create 54.3 Supported Metrics.md --- V. Spring Boot Actuator/54.3 Supported Metrics.md | 13 +++++++++++++ 1 file changed, 13 insertions(+) create mode 100644 V. Spring Boot Actuator/54.3 Supported Metrics.md diff --git a/V. Spring Boot Actuator/54.3 Supported Metrics.md b/V. Spring Boot Actuator/54.3 Supported Metrics.md new file mode 100644 index 00000000..bc570059 --- /dev/null +++ b/V. Spring Boot Actuator/54.3 Supported Metrics.md @@ -0,0 +1,13 @@ +### 54.3 支持的指标 + +Spring Boot在适用时注册以下核心指标: +- JVM指标,报告利用率: + - 各种内存和缓冲池 + - 与垃圾收集相关的统计信息 + - 线程的利用率 + - 加载/卸载的类的数量 +- CPU指标 +- 文件描述符指标 +- Logback指标:记录每个级别登录到Logback的事件数量 +- 正常运行时间指标:报告正常运行时间的指标和表示应用程序绝对启动时间的固定指标 +- Tomcat指标 From 4c9c69ada3fd7a28911375fe9d899d181c2f5474 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E7=83=AD=E5=BF=83=E5=B8=82=E6=B0=91=E9=92=9F=E5=B0=8F?= =?UTF-8?q?=E5=BC=BA?= Date: Wed, 2 Oct 2019 17:14:03 +0800 Subject: [PATCH 570/865] Create 54.3.1 Spring MVC Metrics.md --- .../54.3.1 Spring MVC Metrics.md | 27 +++++++++++++++++++ 1 file changed, 27 insertions(+) create mode 100644 V. Spring Boot Actuator/54.3.1 Spring MVC Metrics.md diff --git a/V. Spring Boot Actuator/54.3.1 Spring MVC Metrics.md b/V. Spring Boot Actuator/54.3.1 Spring MVC Metrics.md new file mode 100644 index 00000000..7dd30640 --- /dev/null +++ b/V. Spring Boot Actuator/54.3.1 Spring MVC Metrics.md @@ -0,0 +1,27 @@ +### 54.3.1 Spring MVC指标 + +自动配置允许使用Spring MVC处理请求。当`management.metrics.web.server.auto-time-requests`为`true`,此检测用于所有请求。或者,当设置为`false`时,你可以通过向请求处理方法添加`@Timed`来启用: +```java +@RestController +@Timed 1 +public class MyController { + + @GetMapping("/api/people") + @Timed(extraTags = { "region", "us-east-1" }) 2 + @Timed(value = "all.people", longTask = true) 3 + public List listPeople() { ... } + +} +``` +1. 一个控制器类,用于对控制器中的每个请求处理程序启用计时。 +2. 为单个端点启用的方法。如果你在类中有计时器,则没有必要这样做,但是可以使用它进一步定制此特定端点的计时器。 +3. 具有`longTask = true`的方法,用于为该方法启用长任务计时器。长任务计时器需要一个单独的度量名称,可以使用短任务计时器进行堆叠。 + +默认情况下,使用`http.server.requests`来生成度量标准。可以通过设置`management.metrics.web.server.requests-metric-name`属性来定制名称。 + +默认情况下,与Spring MVC相关的指标用以下信息标记: +- `方法`,请求的方法(例如,`GET`或`POST`)。 +- `uri`,请求在变量替换之前的uri模板,如果可能的话(例如`/api/person/{id}`)。 +- `状态`,响应的HTTP状态码(例如,`200`或`500`)。 +- `异常`,处理请求时抛出的任何异常的简单类名。 +要自定义标记,请提供一个实现`WebMvcTagsProvider`的`@Bean`。 From 9a31b969709353a3fa3a2f8a34ad10cda629259a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E7=83=AD=E5=BF=83=E5=B8=82=E6=B0=91=E9=92=9F=E5=B0=8F?= =?UTF-8?q?=E5=BC=BA?= Date: Fri, 18 Oct 2019 13:57:16 +0800 Subject: [PATCH 571/865] Update SUMMARY.md --- SUMMARY.md | 3 +++ 1 file changed, 3 insertions(+) diff --git a/SUMMARY.md b/SUMMARY.md index edcd3cbc..6d53cc6d 100644 --- a/SUMMARY.md +++ b/SUMMARY.md @@ -373,6 +373,9 @@ * [54.2.12 Wavefront](V. Spring Boot Actuator/54.2.12 Wavefront.md) * [54.3 支持的指标](V. Spring Boot Actuator/54.3 Supported Metrics.md) * [54.3.1 Spring MVC指标](V. Spring Boot Actuator/54.3.1 Spring MVC Metrics.md) + * [54.3.2 Spring WebFlux指标](V. Spring Boot Actuator/54.3.2 Spring WebFlux Metrics.md) + * [54.3.3 RestTemplate指标](V. Spring Boot Actuator/54.3.3 RestTemplate Metrics.md) + * [54.3.4 Spring集成指标](V. Spring Boot Actuator/54.3.4 Spring Integration metrics.md) * [54.2 数据源指标](V. Spring Boot Actuator/54.2 DataSource Metrics.md) * [54.3 缓存指标](V. Spring Boot Actuator/54.3 Cache Metrics.md) * [55. 审计](V. Spring Boot Actuator/55. Auditing.md) From 76e3aaa61a1332249f1378c675d38fe892ec43dc Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E7=83=AD=E5=BF=83=E5=B8=82=E6=B0=91=E9=92=9F=E5=B0=8F?= =?UTF-8?q?=E5=BC=BA?= Date: Fri, 18 Oct 2019 14:14:19 +0800 Subject: [PATCH 572/865] Create 54.3.2 Spring WebFlux Metrics.md --- .../54.3.2 Spring WebFlux Metrics.md | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) create mode 100644 V. Spring Boot Actuator/54.3.2 Spring WebFlux Metrics.md diff --git a/V. Spring Boot Actuator/54.3.2 Spring WebFlux Metrics.md b/V. Spring Boot Actuator/54.3.2 Spring WebFlux Metrics.md new file mode 100644 index 00000000..21f53b50 --- /dev/null +++ b/V. Spring Boot Actuator/54.3.2 Spring WebFlux Metrics.md @@ -0,0 +1,19 @@ +### 54.3.2 Spring WebFlux指标 + +自动配置可以检测WebFlux控制器处理的所有请求。你还可以使用一个助手类`RouterFunctionMetrics`来检测使用WebFlux函数式编程模型的应用程序。 + +默认情况下,使用`http.server.requests`这个名称来生成度量标准。你可以通过设置`management.metrics.web.server.requests-metric-name`属性来自定义名称。 + +默认情况下,基于注解的编程模型的webflux相关指标会被标记上以下信息: +- `方法`,请求的方法(例如,`GET`或`POST`)。 +- `uri`,请求在变量替换之前的uri模板,如果可能的话(例如`/api/person/{id}`)。 +- `状态`,响应的HTTP状态码(例如,`200`或`500`)。 +- `异常`,处理请求时抛出的任何异常的简单类名。 +要自定义标签,请提供一个实现`WebFluxTagsProvider`的`@Bean`。 + +默认情况下,函数式编程模型的指标会被标记上以下信息: + +- `方法`,请求的方法(例如,`GET`或`POST`)。 +- `uri`,请求在变量替换之前的uri模板,如果可能的话(例如`/api/person/{id}`)。 +- `状态`,响应的HTTP状态码(例如,`200`或`500`)。 +要自定义标签,请在`RouterFunctionMetrics`实例上使用`defaultTags`方法。 From 0df2b1c0295816c7c28a9aad2d080dade6568913 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E7=83=AD=E5=BF=83=E5=B8=82=E6=B0=91=E9=92=9F=E5=B0=8F?= =?UTF-8?q?=E5=BC=BA?= Date: Fri, 18 Oct 2019 14:22:58 +0800 Subject: [PATCH 573/865] Create 54.3.3 RestTemplate Metrics.md --- .../54.3.3 RestTemplate Metrics.md | 13 +++++++++++++ 1 file changed, 13 insertions(+) create mode 100644 V. Spring Boot Actuator/54.3.3 RestTemplate Metrics.md diff --git a/V. Spring Boot Actuator/54.3.3 RestTemplate Metrics.md b/V. Spring Boot Actuator/54.3.3 RestTemplate Metrics.md new file mode 100644 index 00000000..95d2578f --- /dev/null +++ b/V. Spring Boot Actuator/54.3.3 RestTemplate Metrics.md @@ -0,0 +1,13 @@ +### 54.3.3 RestTemplate指标 + +使用自动配置的`RestTemplateBuilder`创建的任何`RestTemplate`工具都是启用的。也可以手动应用`MetricsRestTemplateCustomizer`。 + +默认情况下,使用名称`http.client.requests`生成度量标准。可以通过设置`management.metrics.web.client.requests-metric-name`属性来定制名称。 + +默认情况下,由装备的`RestTemplate`生成的指标用以下信息标记: + +- `方法`,请求的方法(例如,`GET`或`POST`)。 +- `uri`,请求在变量替换之前的uri模板,如果可能的话(例如`/api/person/{id}`)。 +- `状态`,响应的HTTP状态码(例如,`200`或`500`)。 +- `客户端名称`, URI的主机部分。 +要自定义标记,请提供一个实现`RestTemplateExchangeTagsProvider`的`@Bean`。在`RestTemplateExchangeTags`中有方便的静态函数。 From 3a6fb7d5c3563f2f55b0b9409b132f8b758a41d8 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E7=83=AD=E5=BF=83=E5=B8=82=E6=B0=91=E9=92=9F=E5=B0=8F?= =?UTF-8?q?=E5=BC=BA?= Date: Fri, 18 Oct 2019 14:26:56 +0800 Subject: [PATCH 574/865] Create 54.3.4 Spring Integration metrics.md --- V. Spring Boot Actuator/54.3.4 Spring Integration metrics.md | 3 +++ 1 file changed, 3 insertions(+) create mode 100644 V. Spring Boot Actuator/54.3.4 Spring Integration metrics.md diff --git a/V. Spring Boot Actuator/54.3.4 Spring Integration metrics.md b/V. Spring Boot Actuator/54.3.4 Spring Integration metrics.md new file mode 100644 index 00000000..a1acb441 --- /dev/null +++ b/V. Spring Boot Actuator/54.3.4 Spring Integration metrics.md @@ -0,0 +1,3 @@ +### 54.3.4 Spring集成指标 + +当Spring集成可用时,为每个`MessageHandler`和`MessageChannel`注册一个`计时器`和一个`错误计数器`。对于每个`MessageSource`,都注册了一个`计数器`。 From 20040905f04463be7c99f9aea69b65c2ff11bb2f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E7=83=AD=E5=BF=83=E5=B8=82=E6=B0=91=E9=92=9F=E5=B0=8F?= =?UTF-8?q?=E5=BC=BA?= Date: Fri, 18 Oct 2019 14:31:12 +0800 Subject: [PATCH 575/865] Update README.md --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index a18ce299..6ee195e6 100644 --- a/README.md +++ b/README.md @@ -1,6 +1,6 @@ # Spring-Boot-Reference-Guide -![LICENSE](https://img.shields.io/badge/license-MIT-blue.svg) [![LICENSE](https://img.shields.io/badge/license-Anti%20996-blue.svg)](https://github.com/996icu/996.ICU/blob/master/LICENSE) +![LICENSE](https://img.shields.io/badge/license-MIT-blue.svg) Spring Boot Reference Guide 2.0 中文翻译 -《Spring Boot参考指南》 From 5b60c2ca6f63c488e87967cfcacd806f40156a17 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E7=83=AD=E5=BF=83=E5=B8=82=E6=B0=91=E9=92=9F=E5=B0=8F?= =?UTF-8?q?=E5=BC=BA?= Date: Fri, 18 Oct 2019 14:31:33 +0800 Subject: [PATCH 576/865] Delete 996License --- 996License | 46 ---------------------------------------------- 1 file changed, 46 deletions(-) delete mode 100644 996License diff --git a/996License b/996License deleted file mode 100644 index 278e5594..00000000 --- a/996License +++ /dev/null @@ -1,46 +0,0 @@ -Copyright (c) <2017> - -996 License Version 1.0 (Draft) - -Permission is hereby granted to any individual or legal entity -obtaining a copy of this licensed work (including the source code, -documentation and/or related items, hereinafter collectively referred -to as the "licensed work"), free of charge, to deal with the licensed -work for any purpose, including without limitation, the rights to use, -reproduce, modify, prepare derivative works of, distribute, publish -and sublicense the licensed work, subject to the following conditions: - -1. The individual or the legal entity must conspicuously display, -without modification, this License and the notice on each redistributed -or derivative copy of the Licensed Work. - -2. The individual or the legal entity must strictly comply with all -applicable laws, regulations, rules and standards of the jurisdiction -relating to labor and employment where the individual is physically -located or where the individual was born or naturalized; or where the -legal entity is registered or is operating (whichever is stricter). In -case that the jurisdiction has no such laws, regulations, rules and -standards or its laws, regulations, rules and standards are -unenforceable, the individual or the legal entity are required to -comply with Core International Labor Standards. - -3. The individual or the legal entity shall not induce or force its -employee(s), whether full-time or part-time, or its independent -contractor(s), in any methods, to agree in oral or written form, to -directly or indirectly restrict, weaken or relinquish his or her -rights or remedies under such laws, regulations, rules and standards -relating to labor and employment as mentioned above, no matter whether -such written or oral agreement are enforceable under the laws of the -said jurisdiction, nor shall such individual or the legal entity -limit, in any methods, the rights of its employee(s) or independent -contractor(s) from reporting or complaining to the copyright holder or -relevant authorities monitoring the compliance of the license about -its violation(s) of the said license. - -THE LICENSED WORK IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, -EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF -MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. -IN NO EVENT SHALL THE COPYRIGHT HOLDER BE LIABLE FOR ANY CLAIM, -DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR -OTHERWISE, ARISING FROM, OUT OF OR IN ANY WAY CONNECTION WITH THE -LICENSED WORK OR THE USE OR OTHER DEALINGS IN THE LICENSED WORK. From 866dc78449b5379cc7aa679993041e9a8f050f97 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E7=83=AD=E5=BF=83=E5=B8=82=E6=B0=91=E9=92=9F=E5=B0=8F?= =?UTF-8?q?=E5=BC=BA?= Date: Fri, 18 Oct 2019 14:34:56 +0800 Subject: [PATCH 577/865] Update SUMMARY.md --- SUMMARY.md | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/SUMMARY.md b/SUMMARY.md index 6d53cc6d..57daf37a 100644 --- a/SUMMARY.md +++ b/SUMMARY.md @@ -376,8 +376,9 @@ * [54.3.2 Spring WebFlux指标](V. Spring Boot Actuator/54.3.2 Spring WebFlux Metrics.md) * [54.3.3 RestTemplate指标](V. Spring Boot Actuator/54.3.3 RestTemplate Metrics.md) * [54.3.4 Spring集成指标](V. Spring Boot Actuator/54.3.4 Spring Integration metrics.md) - * [54.2 数据源指标](V. Spring Boot Actuator/54.2 DataSource Metrics.md) - * [54.3 缓存指标](V. Spring Boot Actuator/54.3 Cache Metrics.md) + * [54.3.5 缓存指标](V. Spring Boot Actuator/54.3.5 Cache Metrics.md) + * [54.3.6 数据源指标](V. Spring Boot Actuator/54.3.6 DataSource Metrics.md) + * [54.3.7 RabbitMQ指标](V. Spring Boot Actuator/54.3.7 RabbitMQ Metrics.md) * [55. 审计](V. Spring Boot Actuator/55. Auditing.md) * [56. 追踪](V. Spring Boot Actuator/56. Tracing.md) * [56.1 自定义追踪](V. Spring Boot Actuator/56.1 Custom Tracing.md) From 63e3eeae45f59cd44332c39392179bc5321c36fc Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E7=83=AD=E5=BF=83=E5=B8=82=E6=B0=91=E9=92=9F=E5=B0=8F?= =?UTF-8?q?=E5=BC=BA?= Date: Fri, 18 Oct 2019 14:43:32 +0800 Subject: [PATCH 578/865] Update and rename 52.3 Cache metrics.md to 54.3.5 Cache Metrics.md --- V. Spring Boot Actuator/52.3 Cache metrics.md | 12 ------------ V. Spring Boot Actuator/54.3.5 Cache Metrics.md | 13 +++++++++++++ 2 files changed, 13 insertions(+), 12 deletions(-) delete mode 100644 V. Spring Boot Actuator/52.3 Cache metrics.md create mode 100644 V. Spring Boot Actuator/54.3.5 Cache Metrics.md diff --git a/V. Spring Boot Actuator/52.3 Cache metrics.md b/V. Spring Boot Actuator/52.3 Cache metrics.md deleted file mode 100644 index dca3ed5b..00000000 --- a/V. Spring Boot Actuator/52.3 Cache metrics.md +++ /dev/null @@ -1,12 +0,0 @@ -###52.3 缓存指标 -Spring Boot会为应用中定义的每个支持的缓存暴露以下指标: -- cache当前大小(`cache.xxx.size`) -- 命中率(`cache.xxx.hit.ratio`) -- 丢失率(`cache.xxx.miss.ratio`) - -**注** 缓存提供商没有以一致的方式暴露命中/丢失率,有些暴露的是聚合(aggregated)值(比如,自从统计清理后的命中率),而其他暴露的是时序(temporal)值 -(比如,最后一秒的命中率),具体查看缓存提供商的文档。 - -如果两个不同的缓存管理器恰巧定义了相同的缓存,缓存name将以`CacheManager` bean的name作为前缀。 - -注册自定义版本的`CachePublicMetrics`可以部分或全部覆盖这些默认值,Spring Boot默认为EhCache,Hazelcast,Infinispan,JCache和Caffeine提供统计。如果喜欢的缓存库没被支持,你可以添加其他`CacheStatisticsProvider` beans,具体可参考`CacheStatisticsAutoConfiguration`。 diff --git a/V. Spring Boot Actuator/54.3.5 Cache Metrics.md b/V. Spring Boot Actuator/54.3.5 Cache Metrics.md new file mode 100644 index 00000000..8f7120cd --- /dev/null +++ b/V. Spring Boot Actuator/54.3.5 Cache Metrics.md @@ -0,0 +1,13 @@ +### 54.3.5 缓存指标 + +自动配置允许在启动时对所有可用的`缓存`进行检测,其中的指标以`cache`为前缀。缓存检测是针对一组基本指标进行标准化的。另外,特定于缓存的度量也是可用的。 + +支持以下缓存库: +- Caffeine +- EhCache 2 +- Hazelcast +- 任何兼容的JCache(JSR-107)实现 + +根据缓存的名称和从bean名称派生的`CacheManager`的名称对指标进行标记。 + +**注** 只有在启动时可用的缓存才绑定到注册表。对于在启动阶段之后动态创建或以编程方式创建的缓存,需要显式注册。可以使用`CacheMetricsRegistrar` bean来简化这个过程。 From 4f95b6aca118b09f1e9e8d21b4d1b0540028db86 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E7=83=AD=E5=BF=83=E5=B8=82=E6=B0=91=E9=92=9F=E5=B0=8F?= =?UTF-8?q?=E5=BC=BA?= Date: Fri, 18 Oct 2019 14:52:26 +0800 Subject: [PATCH 579/865] Update and rename 52.2 DataSource metrics.md to 54.3.6 DataSource Metrics.md --- V. Spring Boot Actuator/52.2 DataSource metrics.md | 11 ----------- V. Spring Boot Actuator/54.3.6 DataSource Metrics.md | 7 +++++++ 2 files changed, 7 insertions(+), 11 deletions(-) delete mode 100644 V. Spring Boot Actuator/52.2 DataSource metrics.md create mode 100644 V. Spring Boot Actuator/54.3.6 DataSource Metrics.md diff --git a/V. Spring Boot Actuator/52.2 DataSource metrics.md b/V. Spring Boot Actuator/52.2 DataSource metrics.md deleted file mode 100644 index 5fe3c941..00000000 --- a/V. Spring Boot Actuator/52.2 DataSource metrics.md +++ /dev/null @@ -1,11 +0,0 @@ -### 52.2 数据源指标 -Spring Boot会为应用中定义的每个支持的`DataSource`暴露以下指标: -- 活动连接数(`datasource.xxx.active`) -- 连接池当前使用情况(`datasource.xxx.usage`) - -所有数据源指标共用`datasoure.`前缀,该前缀适用于每个数据源: -- 如果是主数据源(唯一可用的数据源或注解`@Primary`的数据源)前缀为`datasource.primary`。 -- 如果数据源bean名称以`DataSource`结尾,前缀就是bean的名称去掉`DataSource`的部分(比如,`batchDataSource`的前缀是`datasource.batch`)。 -- 其他情况使用bean的名称作为前缀。 - -通过注册自定义版本的`DataSourcePublicMetrics` bean,你可以覆盖部分或全部的默认行为。Spring Boot默认提供支持所有数据源的元数据,如果喜欢的数据源恰好不被支持,你可以添加其他的`DataSourcePoolMetadataProvider` beans,具体参考`DataSourcePoolMetadataProvidersConfiguration`。 diff --git a/V. Spring Boot Actuator/54.3.6 DataSource Metrics.md b/V. Spring Boot Actuator/54.3.6 DataSource Metrics.md new file mode 100644 index 00000000..ce5e2e35 --- /dev/null +++ b/V. Spring Boot Actuator/54.3.6 DataSource Metrics.md @@ -0,0 +1,7 @@ +### 54.3.6 数据源指标 + +自动配置允许使用一个名为`jdbc`的度量来检测所有可用的数据源对象。数据源插装产生的仪表表示当前池中活动的、允许的最大连接数和允许的最小连接数。每个量规都有一个由`jdbc`前缀的名称。 + +度量标准还根据基于bean名称计算的`数据源`名称进行标记。 + +此外,hikari特定的度量标准以`hikaricp`前缀公开。每个度量都使用池的名称进行标记(可以使用`spring.datasource.name`进行控制)。 From 8c1fe9919887e6b6910920d16753609a604515e9 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E7=83=AD=E5=BF=83=E5=B8=82=E6=B0=91=E9=92=9F=E5=B0=8F?= =?UTF-8?q?=E5=BC=BA?= Date: Fri, 18 Oct 2019 14:54:23 +0800 Subject: [PATCH 580/865] Create 54.3.7 RabbitMQ Metrics.md --- V. Spring Boot Actuator/54.3.7 RabbitMQ Metrics.md | 3 +++ 1 file changed, 3 insertions(+) create mode 100644 V. Spring Boot Actuator/54.3.7 RabbitMQ Metrics.md diff --git a/V. Spring Boot Actuator/54.3.7 RabbitMQ Metrics.md b/V. Spring Boot Actuator/54.3.7 RabbitMQ Metrics.md new file mode 100644 index 00000000..b1148073 --- /dev/null +++ b/V. Spring Boot Actuator/54.3.7 RabbitMQ Metrics.md @@ -0,0 +1,3 @@ +### 54.3.7 RabbitMQ指标 + +自动配置将使用名为`RabbitMQ`的度量启用所有可用RabbitMQ连接工厂的检测。 From 9542cd875425b9ed5e543289f6abb770cc3ca601 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E7=83=AD=E5=BF=83=E5=B8=82=E6=B0=91=E9=92=9F=E5=B0=8F?= =?UTF-8?q?=E5=BC=BA?= Date: Thu, 24 Oct 2019 13:55:39 +0800 Subject: [PATCH 581/865] Update SUMMARY.md --- SUMMARY.md | 3 +++ 1 file changed, 3 insertions(+) diff --git a/SUMMARY.md b/SUMMARY.md index 57daf37a..ae56c071 100644 --- a/SUMMARY.md +++ b/SUMMARY.md @@ -379,6 +379,9 @@ * [54.3.5 缓存指标](V. Spring Boot Actuator/54.3.5 Cache Metrics.md) * [54.3.6 数据源指标](V. Spring Boot Actuator/54.3.6 DataSource Metrics.md) * [54.3.7 RabbitMQ指标](V. Spring Boot Actuator/54.3.7 RabbitMQ Metrics.md) + * [54.4 注册自定义指标](V. Spring Boot Actuator/54.4 Registering custom metrics.md) + * [54.5 自定义单个指标](V. Spring Boot Actuator/54.5 Customizing individual metrics.md) + * [54.5.1 Per-meter属性](V. Spring Boot Actuator/54.5.1 Per-meter properties.md) * [55. 审计](V. Spring Boot Actuator/55. Auditing.md) * [56. 追踪](V. Spring Boot Actuator/56. Tracing.md) * [56.1 自定义追踪](V. Spring Boot Actuator/56.1 Custom Tracing.md) From a8df9a154a9e8416933c30fa3a8b719570c10109 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E7=83=AD=E5=BF=83=E5=B8=82=E6=B0=91=E9=92=9F=E5=B0=8F?= =?UTF-8?q?=E5=BC=BA?= Date: Thu, 24 Oct 2019 14:02:15 +0800 Subject: [PATCH 582/865] Create 54.4 Registering custom metrics.md --- V. Spring Boot Actuator/54.4 Registering custom metrics.md | 3 +++ 1 file changed, 3 insertions(+) create mode 100644 V. Spring Boot Actuator/54.4 Registering custom metrics.md diff --git a/V. Spring Boot Actuator/54.4 Registering custom metrics.md b/V. Spring Boot Actuator/54.4 Registering custom metrics.md new file mode 100644 index 00000000..28e59dd6 --- /dev/null +++ b/V. Spring Boot Actuator/54.4 Registering custom metrics.md @@ -0,0 +1,3 @@ +### 54.4 注册自定义指标 + +要注册自定义指标,请创建一个`MeterBinder` bean。默认情况下,所有`MeterBinder` bean都将自动应用到micrometer `MeterRegistry.Config`。 From aa65cbf255613b13b26c7bbc915652b21bc02ceb Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E7=83=AD=E5=BF=83=E5=B8=82=E6=B0=91=E9=92=9F=E5=B0=8F?= =?UTF-8?q?=E5=BC=BA?= Date: Thu, 24 Oct 2019 14:14:06 +0800 Subject: [PATCH 583/865] Create 54.5 Customizing individual metrics.md --- .../54.5 Customizing individual metrics.md | 11 +++++++++++ 1 file changed, 11 insertions(+) create mode 100644 V. Spring Boot Actuator/54.5 Customizing individual metrics.md diff --git a/V. Spring Boot Actuator/54.5 Customizing individual metrics.md b/V. Spring Boot Actuator/54.5 Customizing individual metrics.md new file mode 100644 index 00000000..70d4e71c --- /dev/null +++ b/V. Spring Boot Actuator/54.5 Customizing individual metrics.md @@ -0,0 +1,11 @@ +### 54.5 自定义单个指标 + +如果需要对特定的`Meter`实例应用定制,可以使用`io.micrometer.core.instrument.config。MeterFilter`接口。默认情况下,所有的`MeterFilter` bean都将自动应用到micrometer `MeterRegistry.Config`。 + +例如,如果你想把所有以`com.example`开头的meter ID,由`mytag.region`标签重命名为`mytag.area`。你可以这样做: +```java +@Bean +public MeterFilter renameRegionTagMeterFilter() { + return MeterFilter.renameTag("com.example", "mytag.region", "mytag.area"); +} +``` From 24bfc2cb5e37965d12a3303b6c7d2cea43ef37e2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E7=83=AD=E5=BF=83=E5=B8=82=E6=B0=91=E9=92=9F=E5=B0=8F?= =?UTF-8?q?=E5=BC=BA?= Date: Thu, 24 Oct 2019 14:30:20 +0800 Subject: [PATCH 584/865] Create 54.5.1 Per-meter properties.md --- .../54.5.1 Per-meter properties.md | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) create mode 100644 V. Spring Boot Actuator/54.5.1 Per-meter properties.md diff --git a/V. Spring Boot Actuator/54.5.1 Per-meter properties.md b/V. Spring Boot Actuator/54.5.1 Per-meter properties.md new file mode 100644 index 00000000..179e8cec --- /dev/null +++ b/V. Spring Boot Actuator/54.5.1 Per-meter properties.md @@ -0,0 +1,19 @@ +### 54.5.1 Per-meter属性 + +除了`MeterFilter` bean之外,还可以使用属性在per-meter的基础上应用一组有限的定制。per-meter自定义适用于任何以给定名称开头的meter ID。例如,下面将禁用ID以`example.remote`开头的任何meter: +```properties +management.metrics.enable.example.remote = false +``` + +以下属性允许per-meter自定义: + +**表 54.1. Per-meter自定义** + +|名称|描述| +|:----|:----| +|`management.metrics.enable`|是否拒绝meter发出任何指标数据| +|`management.metrics.distribution.percentiles-histogram`|是否发布适合计算可聚合(跨维度)百分比近似值的直方图| +|`management.metrics.distribution.percentiles`|发布应用程序中计算的百分比值| +|`management.metrics.distribution.sla`|发布带有sla定义的桶的累积直方图| + +有关`百分比直方图`、`百分比`和`sla`背后概念的更多细节,请参阅micrometer文档中的[“直方图和百分比”部分](https://micrometer.io/docs/concepts#_histograms_and_percentiles)。 From c4c9424a2fd972f831a2144d68602c4d46c74893 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E7=83=AD=E5=BF=83=E5=B8=82=E6=B0=91=E9=92=9F=E5=B0=8F?= =?UTF-8?q?=E5=BC=BA?= Date: Thu, 24 Oct 2019 14:38:24 +0800 Subject: [PATCH 585/865] Update SUMMARY.md --- SUMMARY.md | 1 + 1 file changed, 1 insertion(+) diff --git a/SUMMARY.md b/SUMMARY.md index ae56c071..d0fbd0d6 100644 --- a/SUMMARY.md +++ b/SUMMARY.md @@ -382,6 +382,7 @@ * [54.4 注册自定义指标](V. Spring Boot Actuator/54.4 Registering custom metrics.md) * [54.5 自定义单个指标](V. Spring Boot Actuator/54.5 Customizing individual metrics.md) * [54.5.1 Per-meter属性](V. Spring Boot Actuator/54.5.1 Per-meter properties.md) + * [54.6 度量端点](V. Spring Boot Actuator/54.6 Metrics endpoint.md) * [55. 审计](V. Spring Boot Actuator/55. Auditing.md) * [56. 追踪](V. Spring Boot Actuator/56. Tracing.md) * [56.1 自定义追踪](V. Spring Boot Actuator/56.1 Custom Tracing.md) From 65b524d7cdc1b7033c621a4f91d8161a20cdb619 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E7=83=AD=E5=BF=83=E5=B8=82=E6=B0=91=E9=92=9F=E5=B0=8F?= =?UTF-8?q?=E5=BC=BA?= Date: Thu, 24 Oct 2019 14:56:06 +0800 Subject: [PATCH 586/865] Create 54.6 Metrics endpoint.md --- V. Spring Boot Actuator/54.6 Metrics endpoint.md | 11 +++++++++++ 1 file changed, 11 insertions(+) create mode 100644 V. Spring Boot Actuator/54.6 Metrics endpoint.md diff --git a/V. Spring Boot Actuator/54.6 Metrics endpoint.md b/V. Spring Boot Actuator/54.6 Metrics endpoint.md new file mode 100644 index 00000000..eef9c75c --- /dev/null +++ b/V. Spring Boot Actuator/54.6 Metrics endpoint.md @@ -0,0 +1,11 @@ +### 54.6 度量端点 + +Spring Boot提供了一个`metrics`端点,可以使用它来检查应用程序收集的度量数据。该端点在缺省情况下不可用,必须公开。更多详细信息,请参阅[公开端点](https://docs.spring.io/spring-boot/docs/2.0.0.RELEASE/reference/htmlsingle/#production-ready-endpoints-exposing-endpoints)。 + +导航到`/actuator/metrics`显示可用的meter名称列表。你可以通过提供一个选择器(例如`/actuator/metrics/jvm.memory.max`),来查看关于某个特定仪表的信息。 + +**注** 这里使用的名称应该与代码中使用的名称相匹配,而不是经过约定之后的名称——对于将其发送到的监视系统来说,这是一种规范化的命名约定。换句话说,如果`jvm.memory.max`在Prometheus中显示为`jvm_memory_max`,因为它的snake case命名约定,你仍然应该使用`jvm.memory.max`。在检查`metrics`端点中的度量数据时,将其作为选择器。 + +你还可以在URL的末尾添加任意数量的`tag=KEY:VALUE`查询参数,以便按维向下钻取一个meter,例如`/actuator/metrics/jvm.memory.max?tag=area:nonheap`。 + +**注** 报告的测量值是所有与meter名称和所应用的任何标记匹配的meter的统计数据的总和。因此,在上面的示例中,返回的“值”统计量是堆的“代码缓存”、“压缩类空间”和“元空间”区域的最大内存占用的总和。如果您只是想查看“Metaspace”的最大大小,你可以添加一个额外的`tag=id:Metaspace`,即`/actuator/metrics/jvm.memory.max?tag=area:nonheap&tag=id:Metaspace`。 From 81c3bd4b34ad74e377e59f47e545d7bf1e988b01 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E7=83=AD=E5=BF=83=E5=B8=82=E6=B0=91=E9=92=9F=E5=B0=8F?= =?UTF-8?q?=E5=BC=BA?= Date: Fri, 25 Oct 2019 16:28:40 +0800 Subject: [PATCH 587/865] Update and rename 53. Auditing.md to 55. Auditing.md --- V. Spring Boot Actuator/53. Auditing.md | 2 -- V. Spring Boot Actuator/55. Auditing.md | 5 +++++ 2 files changed, 5 insertions(+), 2 deletions(-) delete mode 100644 V. Spring Boot Actuator/53. Auditing.md create mode 100644 V. Spring Boot Actuator/55. Auditing.md diff --git a/V. Spring Boot Actuator/53. Auditing.md b/V. Spring Boot Actuator/53. Auditing.md deleted file mode 100644 index 16023dca..00000000 --- a/V. Spring Boot Actuator/53. Auditing.md +++ /dev/null @@ -1,2 +0,0 @@ -### 53. 审计 -Spring Boot执行器有一个灵活的审计框架,一旦Spring Security处于活动状态(默认抛出'authentication success','failure'和'access denied'异常),它就会发布事件。这对于报告非常有用,同时可以基于认证失败实现一个锁定策略。为了自定义发布的安全事件,你可以提供自己的`AbstractAuthenticationAuditListener`,`AbstractAuthorizationAuditListener`实现。你也可以使用审计服务处理自己的业务事件。为此,你可以将存在的`AuditEventRepository`注入到自己的组件,并直接使用它,或者只是简单地通过Spring `ApplicationEventPublisher`发布`AuditApplicationEvent`(使用`ApplicationEventPublisherAware`)。 diff --git a/V. Spring Boot Actuator/55. Auditing.md b/V. Spring Boot Actuator/55. Auditing.md new file mode 100644 index 00000000..e3507717 --- /dev/null +++ b/V. Spring Boot Actuator/55. Auditing.md @@ -0,0 +1,5 @@ +### 55. 审计 + +一旦Spring Security处于活动状态,Spring Boot执行器有一个灵活的审计框架会发布事件(默认抛出“authentication success”、“failure”和“access denied”异常)。这对于报告非常有用,同时可以基于认证失败实现一个锁定策略。为了自定义发布的安全事件,你可以提供自己的`AbstractAuthenticationAuditListener`,`AbstractAuthorizationAuditListener`实现。 + +你也可以使用审计服务处理自己的业务事件。为此,你可以将存在的`AuditEventRepository`注入到自己的组件,并直接使用它,或者只是简单地通过Spring `ApplicationEventPublisher`发布`AuditApplicationEvent`(使用`ApplicationEventPublisherAware`)。 From 47f57c7eff2953b383535de1bfe658b2382b69db Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E7=83=AD=E5=BF=83=E5=B8=82=E6=B0=91=E9=92=9F=E5=B0=8F?= =?UTF-8?q?=E5=BC=BA?= Date: Fri, 25 Oct 2019 16:36:18 +0800 Subject: [PATCH 588/865] Update and rename 54. Tracing.md to 56. HTTP Tracing.md --- V. Spring Boot Actuator/54. Tracing.md | 42 --------------------- V. Spring Boot Actuator/56. HTTP Tracing.md | 3 ++ 2 files changed, 3 insertions(+), 42 deletions(-) delete mode 100644 V. Spring Boot Actuator/54. Tracing.md create mode 100644 V. Spring Boot Actuator/56. HTTP Tracing.md diff --git a/V. Spring Boot Actuator/54. Tracing.md b/V. Spring Boot Actuator/54. Tracing.md deleted file mode 100644 index e7c89292..00000000 --- a/V. Spring Boot Actuator/54. Tracing.md +++ /dev/null @@ -1,42 +0,0 @@ -### 54. 追踪(Tracing) - -对于所有的HTTP请求Spring Boot自动启用追踪,你可以查看`trace`端点获取最近100条请求的基本信息: -```javascript -[{ - "timestamp": 1394343677415, - "info": { - "method": "GET", - "path": "/trace", - "headers": { - "request": { - "Accept": "text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8", - "Connection": "keep-alive", - "Accept-Encoding": "gzip, deflate", - "User-Agent": "Mozilla/5.0 Gecko/Firefox", - "Accept-Language": "en-US,en;q=0.5", - "Cookie": "_ga=GA1.1.827067509.1390890128; ..." - "Authorization": "Basic ...", - "Host": "localhost:8080" - }, - "response": { - "Strict-Transport-Security": "max-age=31536000 ; includeSubDomains", - "X-Application-Context": "application:8080", - "Content-Type": "application/json;charset=UTF-8", - "status": "200" - } - } - } -},{ - "timestamp": 1394343684465, - ... -}] -``` -以下会默认包含在追踪里: - -|名称|描述| -|:----|:----| -|Request Headers|来自请求的Headers| -|Response Headers|来自响应的Headers| -|Cookies|来自request headers的`Cookie`和来自response headers的`Set-Cookie`| -|Errors|error属性(如果有的话)| -|Time Taken|服务请求花费的毫秒数| diff --git a/V. Spring Boot Actuator/56. HTTP Tracing.md b/V. Spring Boot Actuator/56. HTTP Tracing.md new file mode 100644 index 00000000..e8a5c132 --- /dev/null +++ b/V. Spring Boot Actuator/56. HTTP Tracing.md @@ -0,0 +1,3 @@ +### 56. HTTP追踪 + +对于所有的HTTP请求,Spring Boot自动启用追踪。你可以查看`httptrace`端点获取最近100条请求-响应的基本信息。 From 1a9bfc9311b427ef0a14061ce7fdf35dd021fd54 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E7=83=AD=E5=BF=83=E5=B8=82=E6=B0=91=E9=92=9F=E5=B0=8F?= =?UTF-8?q?=E5=BC=BA?= Date: Fri, 25 Oct 2019 16:38:26 +0800 Subject: [PATCH 589/865] Update SUMMARY.md --- SUMMARY.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/SUMMARY.md b/SUMMARY.md index d0fbd0d6..cd333516 100644 --- a/SUMMARY.md +++ b/SUMMARY.md @@ -384,8 +384,8 @@ * [54.5.1 Per-meter属性](V. Spring Boot Actuator/54.5.1 Per-meter properties.md) * [54.6 度量端点](V. Spring Boot Actuator/54.6 Metrics endpoint.md) * [55. 审计](V. Spring Boot Actuator/55. Auditing.md) - * [56. 追踪](V. Spring Boot Actuator/56. Tracing.md) - * [56.1 自定义追踪](V. Spring Boot Actuator/56.1 Custom Tracing.md) + * [56. HTTP追踪](V. Spring Boot Actuator/56. HTTP Tracing.md) + * [56.1 自定义HTTP追踪](V. Spring Boot Actuator/56.1 Custom HTTP tracing.md) * [57. 进程监控](V. Spring Boot Actuator/57. Process Monitoring.md) * [57.1 扩展配置](V. Spring Boot Actuator/57.1 Extend Configuration.md) * [57.2 以编程方式](V. Spring Boot Actuator/57.2 Programmatically.md) From 4dd15952edc0625f3b9a83239268c06516e9710a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E7=83=AD=E5=BF=83=E5=B8=82=E6=B0=91=E9=92=9F=E5=B0=8F?= =?UTF-8?q?=E5=BC=BA?= Date: Fri, 25 Oct 2019 16:56:34 +0800 Subject: [PATCH 590/865] Update and rename 54.1 Custom tracing.md to 56.1 Custom HTTP tracing.md --- V. Spring Boot Actuator/54.1 Custom tracing.md | 4 ---- V. Spring Boot Actuator/56.1 Custom HTTP tracing.md | 5 +++++ 2 files changed, 5 insertions(+), 4 deletions(-) delete mode 100644 V. Spring Boot Actuator/54.1 Custom tracing.md create mode 100644 V. Spring Boot Actuator/56.1 Custom HTTP tracing.md diff --git a/V. Spring Boot Actuator/54.1 Custom tracing.md b/V. Spring Boot Actuator/54.1 Custom tracing.md deleted file mode 100644 index 92336534..00000000 --- a/V. Spring Boot Actuator/54.1 Custom tracing.md +++ /dev/null @@ -1,4 +0,0 @@ -### 54.1 自定义追踪 -如果需要追踪其他事件,你可以注入[TraceRepository](http://github.com/spring-projects/spring-boot/tree/master/spring-boot-actuator/src/main/java/org/springframework/boot/actuate/trace/TraceRepository.java)到你的Spring Beans中,`add`方法接收一个`Map`结构的参数,该数据将转换为JSON并被记录下来。 - -默认使用`InMemoryTraceRepository`存储最新的100个事件,如果需要扩充容量,你可以定义自己的`InMemoryTraceRepository`实例,甚至创建自己的`TraceRepository`实现。 diff --git a/V. Spring Boot Actuator/56.1 Custom HTTP tracing.md b/V. Spring Boot Actuator/56.1 Custom HTTP tracing.md new file mode 100644 index 00000000..f8ce189e --- /dev/null +++ b/V. Spring Boot Actuator/56.1 Custom HTTP tracing.md @@ -0,0 +1,5 @@ +### 56.1 自定义HTTP追踪 + +要自定义每个跟踪中包含的项,请使用`management.trace.http.include`配置属性。 + +默认情况下,使用一个`InMemoryHttpTraceRepository`来存储最后100个请求-响应交换的跟踪。如果需要扩展容量,可以定义自己的`InMemoryHttpTraceRepository` bean实例。你还可以创建自己的替代`HttpTraceRepository`实现。 From c6bcc4e0fbb2ae6cedff9ac05016afa07a54d1c2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E7=83=AD=E5=BF=83=E5=B8=82=E6=B0=91=E9=92=9F=E5=B0=8F?= =?UTF-8?q?=E5=BC=BA?= Date: Sat, 2 Nov 2019 21:32:33 +0800 Subject: [PATCH 591/865] Update and rename 55. Process monitoring.md to 57. Process Monitoring.md --- V. Spring Boot Actuator/55. Process monitoring.md | 6 ------ V. Spring Boot Actuator/57. Process Monitoring.md | 9 +++++++++ 2 files changed, 9 insertions(+), 6 deletions(-) delete mode 100644 V. Spring Boot Actuator/55. Process monitoring.md create mode 100644 V. Spring Boot Actuator/57. Process Monitoring.md diff --git a/V. Spring Boot Actuator/55. Process monitoring.md b/V. Spring Boot Actuator/55. Process monitoring.md deleted file mode 100644 index 1f0f7f55..00000000 --- a/V. Spring Boot Actuator/55. Process monitoring.md +++ /dev/null @@ -1,6 +0,0 @@ -### 55. 进程监控 -在Spring Boot执行器中,你可以找到几个类,它们创建的文件利于进程监控: -- `ApplicationPidFileWriter`创建一个包含应用PID的文件(默认位于应用目录,文件名为`application.pid`)。 -- `EmbeddedServerPortFileWriter`创建一个或多个包含内嵌服务器端口的文件(默认位于应用目录,文件名为`application.port`)。 - -这些writers默认没被激活,但你可以使用以下描述的任何方式来启用它们。 diff --git a/V. Spring Boot Actuator/57. Process Monitoring.md b/V. Spring Boot Actuator/57. Process Monitoring.md new file mode 100644 index 00000000..6d968322 --- /dev/null +++ b/V. Spring Boot Actuator/57. Process Monitoring.md @@ -0,0 +1,9 @@ +### 55. 进程监控 + +在`Spring Boot`模块中,你可以找到两个类来创建通常对进程监控有用的文件: +- `ApplicationPidFileWriter`创建一个包含应用PID的文件(默认位于应用目录,文件名为`application.pid`)。 +- `WebServerPortFileWriter`创建一个或多个包含运行的服务器端口的文件(默认位于应用目录,文件名为`application.port`)。 + +这些writers默认没被激活,但你可以启用它们: +- [55.1 扩展配置](https://docs.spring.io/spring-boot/docs/2.0.0.RELEASE/reference/htmlsingle/#production-ready-process-monitoring-configuration) +- [57.2 以编程方式](https://docs.spring.io/spring-boot/docs/2.0.0.RELEASE/reference/htmlsingle/#production-ready-process-monitoring-programmatically) From aba2800d2191e4fac0506cc476f24fd0f863a5db Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E7=83=AD=E5=BF=83=E5=B8=82=E6=B0=91=E9=92=9F=E5=B0=8F?= =?UTF-8?q?=E5=BC=BA?= Date: Sat, 2 Nov 2019 21:35:44 +0800 Subject: [PATCH 592/865] Update and rename 55.1 Extend configuration.md to 57.1 Extend Configuration.md --- ... Extend configuration.md => 57.1 Extend Configuration.md} | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) rename V. Spring Boot Actuator/{55.1 Extend configuration.md => 57.1 Extend Configuration.md} (69%) diff --git a/V. Spring Boot Actuator/55.1 Extend configuration.md b/V. Spring Boot Actuator/57.1 Extend Configuration.md similarity index 69% rename from V. Spring Boot Actuator/55.1 Extend configuration.md rename to V. Spring Boot Actuator/57.1 Extend Configuration.md index cb0ac840..d9a91467 100644 --- a/V. Spring Boot Actuator/55.1 Extend configuration.md +++ b/V. Spring Boot Actuator/57.1 Extend Configuration.md @@ -1,7 +1,8 @@ -### 55.1 扩展配置 +### 57.1 扩展配置 + 在`META-INF/spring.factories`文件中,你可以激活创建PID文件的`listener(s)`,示例: ```java org.springframework.context.ApplicationListener=\ org.springframework.boot.system.ApplicationPidFileWriter,\ -org.springframework.boot.actuate.system.EmbeddedServerPortFileWriter +org.springframework.boot.system.EmbeddedServerPortFileWriter ``` From fc1e3b161ee503597b5e8f09ab1969e5ae8b5824 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E7=83=AD=E5=BF=83=E5=B8=82=E6=B0=91=E9=92=9F=E5=B0=8F?= =?UTF-8?q?=E5=BC=BA?= Date: Sat, 2 Nov 2019 21:41:50 +0800 Subject: [PATCH 593/865] Update and rename 55.2 Programmatically.md to 57.2 Programmatically.md --- .../{55.2 Programmatically.md => 57.2 Programmatically.md} | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) rename V. Spring Boot Actuator/{55.2 Programmatically.md => 57.2 Programmatically.md} (86%) diff --git a/V. Spring Boot Actuator/55.2 Programmatically.md b/V. Spring Boot Actuator/57.2 Programmatically.md similarity index 86% rename from V. Spring Boot Actuator/55.2 Programmatically.md rename to V. Spring Boot Actuator/57.2 Programmatically.md index 845f8da4..e2d38190 100644 --- a/V. Spring Boot Actuator/55.2 Programmatically.md +++ b/V. Spring Boot Actuator/57.2 Programmatically.md @@ -1,3 +1,4 @@ -### 55.2 以编程方式 +### 57.2 以编程方式 + 你也可以通过调用`SpringApplication.addListeners(…)`方法并传递相应的`Writer`对象来激活一个监听器,该方法允许你通过`Writer`构造器自定义文件名和路径。 From d282626a1094686523f8b54a4d46d5fa009fc215 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E7=83=AD=E5=BF=83=E5=B8=82=E6=B0=91=E9=92=9F=E5=B0=8F?= =?UTF-8?q?=E5=BC=BA?= Date: Sat, 2 Nov 2019 21:49:11 +0800 Subject: [PATCH 594/865] Update and rename 56. Cloud Foundry support.md to 58. Cloud Foundry Support.md --- ...loud Foundry support.md => 58. Cloud Foundry Support.md} | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) rename V. Spring Boot Actuator/{56. Cloud Foundry support.md => 58. Cloud Foundry Support.md} (78%) diff --git a/V. Spring Boot Actuator/56. Cloud Foundry support.md b/V. Spring Boot Actuator/58. Cloud Foundry Support.md similarity index 78% rename from V. Spring Boot Actuator/56. Cloud Foundry support.md rename to V. Spring Boot Actuator/58. Cloud Foundry Support.md index 4d2a4abb..208ad50f 100644 --- a/V. Spring Boot Actuator/56. Cloud Foundry support.md +++ b/V. Spring Boot Actuator/58. Cloud Foundry Support.md @@ -1,7 +1,7 @@ -### 56. Cloud Foundry支持 +### 58. Cloud Foundry支持 -当你部署到一个兼容的Cloud Foundry实例时,Spring Boot的执行器模块包含的额外支持将会被激活。`/cloudfoundryapplication`路径向所有的`NamedMvcEndpoint`bean提供替代的安全的路径。 +当你部署到一个兼容的Cloud Foundry实例时,Spring Boot的执行器模块包含的额外支持将会被激活。`/cloudfoundryapplication`路径向所有的`@Endpoint`bean提供替代的安全的路径。 扩展的支持允许Cloud Foundry management UIs(比如你可以用来查看部署好的应用的网络应用程序)增加Spring Boot执行器信息。例如,应用状态页面包含了所有的健康信息,而不是典型的“运行中”或者“已停止”状态。 -**注** `/cloudfoundryapplication`路径不能被常规用户直接访问。为了使用端点,必须在请求时传递一个有效的UAA token。 \ No newline at end of file +**注** `/cloudfoundryapplication`路径不能被常规用户直接访问。为了使用端点,必须在请求时传递一个有效的UAA token。 From 5a78f5b50d37ed55f0141828c6629a80ff27437d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E7=83=AD=E5=BF=83=E5=B8=82=E6=B0=91=E9=92=9F=E5=B0=8F?= =?UTF-8?q?=E5=BC=BA?= Date: Sat, 2 Nov 2019 21:51:07 +0800 Subject: [PATCH 595/865] Update and rename 56.1 Disabling extended Cloud Foundry actuator support.md to 58.1 Disabling Extended Cloud Foundry Actuator Support.md --- ...58.1 Disabling Extended Cloud Foundry Actuator Support.md} | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) rename V. Spring Boot Actuator/{56.1 Disabling extended Cloud Foundry actuator support.md => 58.1 Disabling Extended Cloud Foundry Actuator Support.md} (76%) diff --git a/V. Spring Boot Actuator/56.1 Disabling extended Cloud Foundry actuator support.md b/V. Spring Boot Actuator/58.1 Disabling Extended Cloud Foundry Actuator Support.md similarity index 76% rename from V. Spring Boot Actuator/56.1 Disabling extended Cloud Foundry actuator support.md rename to V. Spring Boot Actuator/58.1 Disabling Extended Cloud Foundry Actuator Support.md index 15b993d1..18a06a51 100644 --- a/V. Spring Boot Actuator/56.1 Disabling extended Cloud Foundry actuator support.md +++ b/V. Spring Boot Actuator/58.1 Disabling Extended Cloud Foundry Actuator Support.md @@ -1,8 +1,8 @@ -### 56.1 禁用扩展的Cloud Foundry执行器支持 +### 58.1 禁用扩展的Cloud Foundry执行器支持 如果你想要完全禁用`/cloudfoundryapplication`端点,你可以将如下内容加入你的`application.properties`文件: **application.properties.** ```properties management.cloudfoundry.enabled=false -``` \ No newline at end of file +``` From a462e1f4f1973c7d539ebbd7322be2795a317b88 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E7=83=AD=E5=BF=83=E5=B8=82=E6=B0=91=E9=92=9F=E5=B0=8F?= =?UTF-8?q?=E5=BC=BA?= Date: Sat, 2 Nov 2019 21:52:58 +0800 Subject: [PATCH 596/865] Update and rename 56.2 Cloud Foundry self signed certificates.md to 58.2 Cloud Foundry Self-signed Certificates.md --- ...ates.md => 58.2 Cloud Foundry Self-signed Certificates.md} | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) rename V. Spring Boot Actuator/{56.2 Cloud Foundry self signed certificates.md => 58.2 Cloud Foundry Self-signed Certificates.md} (86%) diff --git a/V. Spring Boot Actuator/56.2 Cloud Foundry self signed certificates.md b/V. Spring Boot Actuator/58.2 Cloud Foundry Self-signed Certificates.md similarity index 86% rename from V. Spring Boot Actuator/56.2 Cloud Foundry self signed certificates.md rename to V. Spring Boot Actuator/58.2 Cloud Foundry Self-signed Certificates.md index d0c0f845..70503534 100644 --- a/V. Spring Boot Actuator/56.2 Cloud Foundry self signed certificates.md +++ b/V. Spring Boot Actuator/58.2 Cloud Foundry Self-signed Certificates.md @@ -1,8 +1,8 @@ -### 56.2 Cloud Foundry自签名证书 +### 58.2 Cloud Foundry自签名证书 默认地,对`/cloudfoundryapplication`端点的安全验证会使用SSL调用不同的Cloud Foundry服务。如果你的Cloud Foundry UAA或者Cloud Controller服务使用自签名证书,你将会需要设置如下属性: **application.properties.** ```properties management.cloudfoundry.skip-ssl-validation=true -``` \ No newline at end of file +``` From 299d940606461a76659a9f4c2f62b1dfe4bcbe4d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E7=83=AD=E5=BF=83=E5=B8=82=E6=B0=91=E9=92=9F=E5=B0=8F?= =?UTF-8?q?=E5=BC=BA?= Date: Sat, 2 Nov 2019 22:03:28 +0800 Subject: [PATCH 597/865] Update and rename 56.3 Custom security configuration.md to 58.3 Custom context path.md --- .../56.3 Custom security configuration.md | 19 -------- .../58.3 Custom context path.md | 45 +++++++++++++++++++ 2 files changed, 45 insertions(+), 19 deletions(-) delete mode 100644 V. Spring Boot Actuator/56.3 Custom security configuration.md create mode 100644 V. Spring Boot Actuator/58.3 Custom context path.md diff --git a/V. Spring Boot Actuator/56.3 Custom security configuration.md b/V. Spring Boot Actuator/56.3 Custom security configuration.md deleted file mode 100644 index 4016db73..00000000 --- a/V. Spring Boot Actuator/56.3 Custom security configuration.md +++ /dev/null @@ -1,19 +0,0 @@ -### 56.3 自定义安全配置 - -如果你设定了自定义的安全配置,同时你想要扩展Cloud Foundry执行器支持,你应当确保`/cloudfoundryapplication/**`路径开放。没有一个直接开放的路径,你的Cloud Foundry应用管理器将无法获得端点数据。 - -对于Spring Security,你将要在你的配置里包含类似与`mvcMatchers("/cloudfoundryapplication/**").permitAll()`的东西: -```java -@Override -protected void configure(HttpSecurity http) throws Exception { - http - .authorizeRequests() - .mvcMatchers("/cloudfoundryapplication/**") - .permitAll() - .mvcMatchers("/mypath") - .hasAnyRole("SUPERUSER") - .anyRequest() - .authenticated().and() - .httpBasic(); -} -``` \ No newline at end of file diff --git a/V. Spring Boot Actuator/58.3 Custom context path.md b/V. Spring Boot Actuator/58.3 Custom context path.md new file mode 100644 index 00000000..3eb11469 --- /dev/null +++ b/V. Spring Boot Actuator/58.3 Custom context path.md @@ -0,0 +1,45 @@ +### 58.3 自定义上下文路径 + +如果服务器的上下文路径没有配置为`/`,则云计算端点在应用程序的根上不可用。例如,如果配置为`server.servlet.context-path=/foo`, 则Cloud Foundry的端点位于`/foo/cloudfoundryapplication/*`。 + +如果你希望云计算端点始终在`/cloudfoundryapplication/*`上可用,无论服务器的上下文路径如何,你都需要在应用程序中显式地配置它。配置将根据使用的web服务器而有所不同。对于Tomcat,可以添加以下配置: +```java +@Bean +public TomcatServletWebServerFactory servletWebServerFactory() { + return new TomcatServletWebServerFactory() { + + @Override + protected void prepareContext(Host host, + ServletContextInitializer[] initializers) { + super.prepareContext(host, initializers); + StandardContext child = new StandardContext(); + child.addLifecycleListener(new Tomcat.FixContextListener()); + child.setPath("/cloudfoundryapplication"); + ServletContainerInitializer initializer = getServletContextInitializer( + getContextPath()); + child.addServletContainerInitializer(initializer, Collections.emptySet()); + child.setCrossContext(true); + host.addChild(child); + } + + }; +} + +private ServletContainerInitializer getServletContextInitializer(String contextPath) { + return (c, context) -> { + Servlet servlet = new GenericServlet() { + + @Override + public void service(ServletRequest req, ServletResponse res) + throws ServletException, IOException { + ServletContext context = req.getServletContext() + .getContext(contextPath); + context.getRequestDispatcher("/cloudfoundryapplication").forward(req, + res); + } + + }; + context.addServlet("cloudfoundry", servlet).addMapping("/*"); + }; +} +``` From 3d9f8880df28615fac0855d31bc36fc36d3b3334 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E7=83=AD=E5=BF=83=E5=B8=82=E6=B0=91=E9=92=9F=E5=B0=8F?= =?UTF-8?q?=E5=BC=BA?= Date: Sat, 2 Nov 2019 22:07:50 +0800 Subject: [PATCH 598/865] Update and rename 57. What to read next.md to 59. What to Read Next.md --- V. Spring Boot Actuator/57. What to read next.md | 4 ---- V. Spring Boot Actuator/59. What to Read Next.md | 5 +++++ 2 files changed, 5 insertions(+), 4 deletions(-) delete mode 100644 V. Spring Boot Actuator/57. What to read next.md create mode 100644 V. Spring Boot Actuator/59. What to Read Next.md diff --git a/V. Spring Boot Actuator/57. What to read next.md b/V. Spring Boot Actuator/57. What to read next.md deleted file mode 100644 index 21b660e0..00000000 --- a/V. Spring Boot Actuator/57. What to read next.md +++ /dev/null @@ -1,4 +0,0 @@ -### 57. 接下来阅读什么 -如果想探索本章节讨论的某些内容,你可以看下执行器的[示例应用](https://github.com/spring-projects/spring-boot/tree/v2.0.0.RELEASE/spring-boot-samples),你也可能想了解图形工具比如[Graphite](http://graphite.wikidot.com/)。 - -此外,你可以继续了解[‘deployment options’](https://docs.spring.io/spring-boot/docs/2.0.0.RELEASE/reference/htmlsingle/#deployment)或直接跳到Spring Boot的[build tool plugins](https://docs.spring.io/spring-boot/docs/2.0.0.RELEASE/reference/htmlsingle/#build-tool-plugins)。 diff --git a/V. Spring Boot Actuator/59. What to Read Next.md b/V. Spring Boot Actuator/59. What to Read Next.md new file mode 100644 index 00000000..19b5ee3c --- /dev/null +++ b/V. Spring Boot Actuator/59. What to Read Next.md @@ -0,0 +1,5 @@ +### 59. 接下来阅读什么 + +如果想探索本章节讨论的某些内容,你可以看下执行器的[示例应用](https://github.com/spring-projects/spring-boot/tree/v2.0.0.RELEASE/spring-boot-samples),你也可能想了解图形工具比如[Graphite](http://graphite.wikidot.com/)。 + +此外,你可以继续了解[部署选项](https://docs.spring.io/spring-boot/docs/2.0.0.RELEASE/reference/htmlsingle/#deployment)或直接跳到Spring Boot的[构建工具插件](https://docs.spring.io/spring-boot/docs/2.0.0.RELEASE/reference/htmlsingle/#build-tool-plugins)。 From 584fcd102d2483811b3c12da4240ce375fb05a6b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E7=83=AD=E5=BF=83=E5=B8=82=E6=B0=91=E9=92=9F=E5=B0=8F?= =?UTF-8?q?=E5=BC=BA?= Date: Sat, 2 Nov 2019 22:09:44 +0800 Subject: [PATCH 599/865] Update SUMMARY.md --- SUMMARY.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/SUMMARY.md b/SUMMARY.md index cd333516..25da6bbd 100644 --- a/SUMMARY.md +++ b/SUMMARY.md @@ -390,8 +390,8 @@ * [57.1 扩展配置](V. Spring Boot Actuator/57.1 Extend Configuration.md) * [57.2 以编程方式](V. Spring Boot Actuator/57.2 Programmatically.md) * [58. Cloud Foundry支持](V. Spring Boot Actuator/58. Cloud Foundry Support.md) - * [58.1 禁用扩展的Cloud Foundry执行器支持](V. Spring Boot Actuator/58.1 Disabling extended Cloud Foundry Actuator Support.md) - * [58.2 Cloud Foundry自签名证书](V. Spring Boot Actuator/58.2 Cloud Foundry self signed Certificates.md) + * [58.1 禁用扩展的Cloud Foundry执行器支持](V. Spring Boot Actuator/58.1 Disabling Extended Cloud Foundry Actuator Support.md) + * [58.2 Cloud Foundry自签名证书](V. Spring Boot Actuator/58.2 Cloud Foundry Self-signed Certificates.md) * [58.3 自定义安全配置](V. Spring Boot Actuator/58.3 Custom Security Configuration.md) * [59. 接下来阅读什么](V. Spring Boot Actuator/59. What to Read Next.md) * [VI. 部署到云端](VI. Deploying Spring Boot applications/README.md) From 0865733bb0889fc58a73d24b3a4e703bc06b7d46 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E7=83=AD=E5=BF=83=E5=B8=82=E6=B0=91=E9=92=9F=E5=B0=8F?= =?UTF-8?q?=E5=BC=BA?= Date: Sat, 2 Nov 2019 22:19:53 +0800 Subject: [PATCH 600/865] Update SUMMARY.md --- SUMMARY.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/SUMMARY.md b/SUMMARY.md index 25da6bbd..b0734e51 100644 --- a/SUMMARY.md +++ b/SUMMARY.md @@ -392,7 +392,7 @@ * [58. Cloud Foundry支持](V. Spring Boot Actuator/58. Cloud Foundry Support.md) * [58.1 禁用扩展的Cloud Foundry执行器支持](V. Spring Boot Actuator/58.1 Disabling Extended Cloud Foundry Actuator Support.md) * [58.2 Cloud Foundry自签名证书](V. Spring Boot Actuator/58.2 Cloud Foundry Self-signed Certificates.md) - * [58.3 自定义安全配置](V. Spring Boot Actuator/58.3 Custom Security Configuration.md) + * [58.3 自定义上下文路径](V. Spring Boot Actuator/58.3 Custom context path.md.md) * [59. 接下来阅读什么](V. Spring Boot Actuator/59. What to Read Next.md) * [VI. 部署到云端](VI. Deploying Spring Boot applications/README.md) * [58. 部署到云端](VI. Deploying Spring Boot applications/58. Deploying to the cloud.md) From d9e2a503a98d39dc48363ff17184e15d695ddcb8 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E7=83=AD=E5=BF=83=E5=B8=82=E6=B0=91=E9=92=9F=E5=B0=8F?= =?UTF-8?q?=E5=BC=BA?= Date: Sat, 2 Nov 2019 22:31:50 +0800 Subject: [PATCH 601/865] Update SUMMARY.md --- SUMMARY.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/SUMMARY.md b/SUMMARY.md index b0734e51..28191de4 100644 --- a/SUMMARY.md +++ b/SUMMARY.md @@ -392,7 +392,7 @@ * [58. Cloud Foundry支持](V. Spring Boot Actuator/58. Cloud Foundry Support.md) * [58.1 禁用扩展的Cloud Foundry执行器支持](V. Spring Boot Actuator/58.1 Disabling Extended Cloud Foundry Actuator Support.md) * [58.2 Cloud Foundry自签名证书](V. Spring Boot Actuator/58.2 Cloud Foundry Self-signed Certificates.md) - * [58.3 自定义上下文路径](V. Spring Boot Actuator/58.3 Custom context path.md.md) + * [58.3 自定义上下文路径](V. Spring Boot Actuator/58.3 Custom context path.md) * [59. 接下来阅读什么](V. Spring Boot Actuator/59. What to Read Next.md) * [VI. 部署到云端](VI. Deploying Spring Boot applications/README.md) * [58. 部署到云端](VI. Deploying Spring Boot applications/58. Deploying to the cloud.md) From ef172fe007a90fcc421f267335c5b713b2afaad8 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E7=83=AD=E5=BF=83=E5=B8=82=E6=B0=91=E9=92=9F=E5=B0=8F?= =?UTF-8?q?=E5=BC=BA?= Date: Wed, 6 Nov 2019 09:02:05 +0800 Subject: [PATCH 602/865] Update README.md --- README.md | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/README.md b/README.md index 6ee195e6..0a70448a 100644 --- a/README.md +++ b/README.md @@ -12,5 +12,4 @@ GitBook : [Spring Boot参考指南](https://jack80342.gitbook.io/spring-boot/) GitHub : [Spring Boot参考指南](https://github.com/jack80342/Spring-Boot-Reference-Guide) - 我从二零一七年夏天开始翻译这份文档。为什么翻译这份文档,原因我已经忘了。这份文档在[qibaoguang](https://github.com/qibaoguang)的1.4.1版本上新增了Spring Boot 2.0.0版本的内容,对修改的地方也做了更新。在杭州工作之后,九九六。如果没有大的翻译错误,就不做更新了。 - Good luck!🍭 + 我从二零一七年夏天开始翻译这份文档。为什么翻译这份文档,原因我已经忘了。这份文档在[qibaoguang](https://github.com/qibaoguang)的1.4.1版本上新增了Spring Boot 2.0.0版本的内容,对修改的地方也做了更新。 From b3e48739ed9083d69c94f7f1556f71861468c0dd Mon Sep 17 00:00:00 2001 From: Zhong Zengqiang Date: Sun, 10 Nov 2019 13:00:54 +0800 Subject: [PATCH 603/865] =?UTF-8?q?=E4=BF=AE=E6=94=B9=E7=9B=AE=E5=BD=95?= =?UTF-8?q?=E5=90=8D?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../58. Deploying to the cloud.md | 0 .../58.1 Cloud Foundry.md | 0 .../58.1.1 Binding to services.md | 0 .../58.2 Heroku.md | 0 .../58.3 Openshift.md | 0 .../58.4 Amazon Web Services\357\274\210AWS\357\274\211.md" | 0 .../58.4.1 AWS Elastic Beanstalk.md | 0 .../58.4.2 Summary.md | 0 .../58.5 Boxfuse and Amazon Web Services.md | 0 .../58.6 Google App Engine.md | 0 .../59. Installing Spring Boot applications.md | 0 .../59.1 Supported operating systems.md | 0 .../59.2 Unix&Linux services.md | 0 ...ation as an init.d service\357\274\210System V\357\274\211.md" | 0 .../59.2.2 Installation as a systemd service.md | 0 .../59.2.3 Customizing the startup script.md | 0 .../59.3 Microsoft Windows services.md | 0 .../60. What to read next.md | 0 .../README.md | 0 19 files changed, 0 insertions(+), 0 deletions(-) rename {VI. Deploying Spring Boot applications => VI. Deploying Spring Boot Applications}/58. Deploying to the cloud.md (100%) rename {VI. Deploying Spring Boot applications => VI. Deploying Spring Boot Applications}/58.1 Cloud Foundry.md (100%) rename {VI. Deploying Spring Boot applications => VI. Deploying Spring Boot Applications}/58.1.1 Binding to services.md (100%) rename {VI. Deploying Spring Boot applications => VI. Deploying Spring Boot Applications}/58.2 Heroku.md (100%) rename {VI. Deploying Spring Boot applications => VI. Deploying Spring Boot Applications}/58.3 Openshift.md (100%) rename "VI. Deploying Spring Boot applications/58.4 Amazon Web Services\357\274\210AWS\357\274\211.md" => "VI. Deploying Spring Boot Applications/58.4 Amazon Web Services\357\274\210AWS\357\274\211.md" (100%) rename {VI. Deploying Spring Boot applications => VI. Deploying Spring Boot Applications}/58.4.1 AWS Elastic Beanstalk.md (100%) rename {VI. Deploying Spring Boot applications => VI. Deploying Spring Boot Applications}/58.4.2 Summary.md (100%) rename {VI. Deploying Spring Boot applications => VI. Deploying Spring Boot Applications}/58.5 Boxfuse and Amazon Web Services.md (100%) rename {VI. Deploying Spring Boot applications => VI. Deploying Spring Boot Applications}/58.6 Google App Engine.md (100%) rename {VI. Deploying Spring Boot applications => VI. Deploying Spring Boot Applications}/59. Installing Spring Boot applications.md (100%) rename {VI. Deploying Spring Boot applications => VI. Deploying Spring Boot Applications}/59.1 Supported operating systems.md (100%) rename {VI. Deploying Spring Boot applications => VI. Deploying Spring Boot Applications}/59.2 Unix&Linux services.md (100%) rename "VI. Deploying Spring Boot applications/59.2.1 Installation as an init.d service\357\274\210System V\357\274\211.md" => "VI. Deploying Spring Boot Applications/59.2.1 Installation as an init.d service\357\274\210System V\357\274\211.md" (100%) rename {VI. Deploying Spring Boot applications => VI. Deploying Spring Boot Applications}/59.2.2 Installation as a systemd service.md (100%) rename {VI. Deploying Spring Boot applications => VI. Deploying Spring Boot Applications}/59.2.3 Customizing the startup script.md (100%) rename {VI. Deploying Spring Boot applications => VI. Deploying Spring Boot Applications}/59.3 Microsoft Windows services.md (100%) rename {VI. Deploying Spring Boot applications => VI. Deploying Spring Boot Applications}/60. What to read next.md (100%) rename {VI. Deploying Spring Boot applications => VI. Deploying Spring Boot Applications}/README.md (100%) diff --git a/VI. Deploying Spring Boot applications/58. Deploying to the cloud.md b/VI. Deploying Spring Boot Applications/58. Deploying to the cloud.md similarity index 100% rename from VI. Deploying Spring Boot applications/58. Deploying to the cloud.md rename to VI. Deploying Spring Boot Applications/58. Deploying to the cloud.md diff --git a/VI. Deploying Spring Boot applications/58.1 Cloud Foundry.md b/VI. Deploying Spring Boot Applications/58.1 Cloud Foundry.md similarity index 100% rename from VI. Deploying Spring Boot applications/58.1 Cloud Foundry.md rename to VI. Deploying Spring Boot Applications/58.1 Cloud Foundry.md diff --git a/VI. Deploying Spring Boot applications/58.1.1 Binding to services.md b/VI. Deploying Spring Boot Applications/58.1.1 Binding to services.md similarity index 100% rename from VI. Deploying Spring Boot applications/58.1.1 Binding to services.md rename to VI. Deploying Spring Boot Applications/58.1.1 Binding to services.md diff --git a/VI. Deploying Spring Boot applications/58.2 Heroku.md b/VI. Deploying Spring Boot Applications/58.2 Heroku.md similarity index 100% rename from VI. Deploying Spring Boot applications/58.2 Heroku.md rename to VI. Deploying Spring Boot Applications/58.2 Heroku.md diff --git a/VI. Deploying Spring Boot applications/58.3 Openshift.md b/VI. Deploying Spring Boot Applications/58.3 Openshift.md similarity index 100% rename from VI. Deploying Spring Boot applications/58.3 Openshift.md rename to VI. Deploying Spring Boot Applications/58.3 Openshift.md diff --git "a/VI. Deploying Spring Boot applications/58.4 Amazon Web Services\357\274\210AWS\357\274\211.md" "b/VI. Deploying Spring Boot Applications/58.4 Amazon Web Services\357\274\210AWS\357\274\211.md" similarity index 100% rename from "VI. Deploying Spring Boot applications/58.4 Amazon Web Services\357\274\210AWS\357\274\211.md" rename to "VI. Deploying Spring Boot Applications/58.4 Amazon Web Services\357\274\210AWS\357\274\211.md" diff --git a/VI. Deploying Spring Boot applications/58.4.1 AWS Elastic Beanstalk.md b/VI. Deploying Spring Boot Applications/58.4.1 AWS Elastic Beanstalk.md similarity index 100% rename from VI. Deploying Spring Boot applications/58.4.1 AWS Elastic Beanstalk.md rename to VI. Deploying Spring Boot Applications/58.4.1 AWS Elastic Beanstalk.md diff --git a/VI. Deploying Spring Boot applications/58.4.2 Summary.md b/VI. Deploying Spring Boot Applications/58.4.2 Summary.md similarity index 100% rename from VI. Deploying Spring Boot applications/58.4.2 Summary.md rename to VI. Deploying Spring Boot Applications/58.4.2 Summary.md diff --git a/VI. Deploying Spring Boot applications/58.5 Boxfuse and Amazon Web Services.md b/VI. Deploying Spring Boot Applications/58.5 Boxfuse and Amazon Web Services.md similarity index 100% rename from VI. Deploying Spring Boot applications/58.5 Boxfuse and Amazon Web Services.md rename to VI. Deploying Spring Boot Applications/58.5 Boxfuse and Amazon Web Services.md diff --git a/VI. Deploying Spring Boot applications/58.6 Google App Engine.md b/VI. Deploying Spring Boot Applications/58.6 Google App Engine.md similarity index 100% rename from VI. Deploying Spring Boot applications/58.6 Google App Engine.md rename to VI. Deploying Spring Boot Applications/58.6 Google App Engine.md diff --git a/VI. Deploying Spring Boot applications/59. Installing Spring Boot applications.md b/VI. Deploying Spring Boot Applications/59. Installing Spring Boot applications.md similarity index 100% rename from VI. Deploying Spring Boot applications/59. Installing Spring Boot applications.md rename to VI. Deploying Spring Boot Applications/59. Installing Spring Boot applications.md diff --git a/VI. Deploying Spring Boot applications/59.1 Supported operating systems.md b/VI. Deploying Spring Boot Applications/59.1 Supported operating systems.md similarity index 100% rename from VI. Deploying Spring Boot applications/59.1 Supported operating systems.md rename to VI. Deploying Spring Boot Applications/59.1 Supported operating systems.md diff --git a/VI. Deploying Spring Boot applications/59.2 Unix&Linux services.md b/VI. Deploying Spring Boot Applications/59.2 Unix&Linux services.md similarity index 100% rename from VI. Deploying Spring Boot applications/59.2 Unix&Linux services.md rename to VI. Deploying Spring Boot Applications/59.2 Unix&Linux services.md diff --git "a/VI. Deploying Spring Boot applications/59.2.1 Installation as an init.d service\357\274\210System V\357\274\211.md" "b/VI. Deploying Spring Boot Applications/59.2.1 Installation as an init.d service\357\274\210System V\357\274\211.md" similarity index 100% rename from "VI. Deploying Spring Boot applications/59.2.1 Installation as an init.d service\357\274\210System V\357\274\211.md" rename to "VI. Deploying Spring Boot Applications/59.2.1 Installation as an init.d service\357\274\210System V\357\274\211.md" diff --git a/VI. Deploying Spring Boot applications/59.2.2 Installation as a systemd service.md b/VI. Deploying Spring Boot Applications/59.2.2 Installation as a systemd service.md similarity index 100% rename from VI. Deploying Spring Boot applications/59.2.2 Installation as a systemd service.md rename to VI. Deploying Spring Boot Applications/59.2.2 Installation as a systemd service.md diff --git a/VI. Deploying Spring Boot applications/59.2.3 Customizing the startup script.md b/VI. Deploying Spring Boot Applications/59.2.3 Customizing the startup script.md similarity index 100% rename from VI. Deploying Spring Boot applications/59.2.3 Customizing the startup script.md rename to VI. Deploying Spring Boot Applications/59.2.3 Customizing the startup script.md diff --git a/VI. Deploying Spring Boot applications/59.3 Microsoft Windows services.md b/VI. Deploying Spring Boot Applications/59.3 Microsoft Windows services.md similarity index 100% rename from VI. Deploying Spring Boot applications/59.3 Microsoft Windows services.md rename to VI. Deploying Spring Boot Applications/59.3 Microsoft Windows services.md diff --git a/VI. Deploying Spring Boot applications/60. What to read next.md b/VI. Deploying Spring Boot Applications/60. What to read next.md similarity index 100% rename from VI. Deploying Spring Boot applications/60. What to read next.md rename to VI. Deploying Spring Boot Applications/60. What to read next.md diff --git a/VI. Deploying Spring Boot applications/README.md b/VI. Deploying Spring Boot Applications/README.md similarity index 100% rename from VI. Deploying Spring Boot applications/README.md rename to VI. Deploying Spring Boot Applications/README.md From cd8112c48f5489efa872daba8fb837662597cfc8 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E7=83=AD=E5=BF=83=E5=B8=82=E6=B0=91=E9=92=9F=E5=B0=8F?= =?UTF-8?q?=E5=BC=BA?= Date: Sun, 10 Nov 2019 13:05:00 +0800 Subject: [PATCH 604/865] Update SUMMARY.md --- SUMMARY.md | 38 +++++++++++++++++++------------------- 1 file changed, 19 insertions(+), 19 deletions(-) diff --git a/SUMMARY.md b/SUMMARY.md index 28191de4..61eac2cb 100644 --- a/SUMMARY.md +++ b/SUMMARY.md @@ -394,25 +394,25 @@ * [58.2 Cloud Foundry自签名证书](V. Spring Boot Actuator/58.2 Cloud Foundry Self-signed Certificates.md) * [58.3 自定义上下文路径](V. Spring Boot Actuator/58.3 Custom context path.md) * [59. 接下来阅读什么](V. Spring Boot Actuator/59. What to Read Next.md) -* [VI. 部署到云端](VI. Deploying Spring Boot applications/README.md) - * [58. 部署到云端](VI. Deploying Spring Boot applications/58. Deploying to the cloud.md) - * [58.1 Cloud Foundry](VI. Deploying Spring Boot applications/58.1 Cloud Foundry.md) - * [58.1.1 绑定服务](VI. Deploying Spring Boot applications/58.1.1 Binding to services.md) - * [58.2 Heroku](VI. Deploying Spring Boot applications/58.2 Heroku.md) - * [58.3 Openshift](VI. Deploying Spring Boot applications/58.3 Openshift.md) - * [58.4 亚马逊网络服务(AWS)](VI. Deploying Spring Boot applications/58.4 Amazon Web Services(AWS).md) - * [58.4.1 AWS Elastic Beanstalk](VI. Deploying Spring Boot applications/58.4.1 AWS Elastic Beanstalk.md) - * [58.4.2 总结](VI. Deploying Spring Boot applications/58.4.2 Summary.md) - * [58.5 Boxfuse和亚马逊网络服务](VI. Deploying Spring Boot applications/58.5 Boxfuse and Amazon Web Services.md) - * [58.6 Google App Engine](VI. Deploying Spring Boot applications/58.6 Google App Engine.md) - * [59. 安装Spring Boot应用](VI. Deploying Spring Boot applications/59. Installing Spring Boot applications.md) - * [59.1 支持的操作系统](VI. Deploying Spring Boot applications/59.1 Supported operating systems.md) - * [59.2 Unix/Linux服务](VI. Deploying Spring Boot applications/59.2 Unix&Linux services.md) - * [59.2.1 安装为init.d服务(System V)](VI. Deploying Spring Boot applications/59.2.1 Installation as an init.d service(System V).md) - * [59.2.2 安装为Systemd服务](VI. Deploying Spring Boot applications/59.2.2 Installation as a systemd service.md) - * [59.2.3 自定义启动脚本](VI. Deploying Spring Boot applications/59.2.3 Customizing the startup script.md) - * [59.3 Microsoft Windows服务](VI. Deploying Spring Boot applications/59.3 Microsoft Windows services.md) - * [60. 接下来阅读什么](VI. Deploying Spring Boot applications/60. What to read next.md) +* [VI. 部署到云端](VI. Deploying Spring Boot Applications/README.md) + * [58. 部署到云端](VI. Deploying Spring Boot Applications/58. Deploying to the cloud.md) + * [58.1 Cloud Foundry](VI. Deploying Spring Boot Applications/58.1 Cloud Foundry.md) + * [58.1.1 绑定服务](VI. Deploying Spring Boot Applications/58.1.1 Binding to services.md) + * [58.2 Heroku](VI. Deploying Spring Boot Applications/58.2 Heroku.md) + * [58.3 Openshift](VI. Deploying Spring Boot Applications/58.3 Openshift.md) + * [58.4 亚马逊网络服务(AWS)](VI. Deploying Spring Boot Applications/58.4 Amazon Web Services(AWS).md) + * [58.4.1 AWS Elastic Beanstalk](VI. Deploying Spring Boot Applications/58.4.1 AWS Elastic Beanstalk.md) + * [58.4.2 总结](VI. Deploying Spring Boot Applications/58.4.2 Summary.md) + * [58.5 Boxfuse和亚马逊网络服务](VI. Deploying Spring Boot Applications/58.5 Boxfuse and Amazon Web Services.md) + * [58.6 Google App Engine](VI. Deploying Spring Boot Applications/58.6 Google App Engine.md) + * [59. 安装Spring Boot应用](VI. Deploying Spring Boot Applications/59. Installing Spring Boot applications.md) + * [59.1 支持的操作系统](VI. Deploying Spring Boot Applications/59.1 Supported operating systems.md) + * [59.2 Unix/Linux服务](VI. Deploying Spring Boot Applications/59.2 Unix&Linux services.md) + * [59.2.1 安装为init.d服务(System V)](VI. Deploying Spring Boot Applications/59.2.1 Installation as an init.d service(System V).md) + * [59.2.2 安装为Systemd服务](VI. Deploying Spring Boot Applications/59.2.2 Installation as a systemd service.md) + * [59.2.3 自定义启动脚本](VI. Deploying Spring Boot Applications/59.2.3 Customizing the startup script.md) + * [59.3 Microsoft Windows服务](VI. Deploying Spring Boot Applications/59.3 Microsoft Windows services.md) + * [60. 接下来阅读什么](VI. Deploying Spring Boot Applications/60. What to read next.md) * [VII. Spring Boot CLI](VII. Spring Boot CLI/README.md) * [61. 安装CLI](VII. Spring Boot CLI/61. Installing the CLI.md) * [62. 使用CLI](VII. Spring Boot CLI/62. Using the CLI.md) From a8a8caece2254c9b231ea9c727142c02f455a62f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E7=83=AD=E5=BF=83=E5=B8=82=E6=B0=91=E9=92=9F=E5=B0=8F?= =?UTF-8?q?=E5=BC=BA?= Date: Sun, 10 Nov 2019 13:12:09 +0800 Subject: [PATCH 605/865] Update and rename 58. Deploying to the cloud.md to 60. Deploying to the Cloud.md --- ...oying to the cloud.md => 60. Deploying to the Cloud.md} | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) rename VI. Deploying Spring Boot Applications/{58. Deploying to the cloud.md => 60. Deploying to the Cloud.md} (80%) diff --git a/VI. Deploying Spring Boot Applications/58. Deploying to the cloud.md b/VI. Deploying Spring Boot Applications/60. Deploying to the Cloud.md similarity index 80% rename from VI. Deploying Spring Boot Applications/58. Deploying to the cloud.md rename to VI. Deploying Spring Boot Applications/60. Deploying to the Cloud.md index 11f67a10..0f9803b2 100644 --- a/VI. Deploying Spring Boot Applications/58. Deploying to the cloud.md +++ b/VI. Deploying Spring Boot Applications/60. Deploying to the Cloud.md @@ -1,7 +1,8 @@ -###58. 部署到云端 -对于大多数流行云PaaS(平台即服务)提供商,Spring Boot的可执行jars就是为它们准备的。这些提供商往往要求你自己提供容器,它们只负责管理应用的进程(不特别针对Java应用程序),所以它们需要一些中间层来将你的应用适配到云概念中的一个运行进程。 +### 60. 部署到云端 -两个流行的云提供商,Heroku和Cloud Foundry,采取一个打包('buildpack')方法。为了启动你的应用程序,不管需要什么,buildpack都会将它们打包到你的部署代码:它可能是一个JDK和一个java调用,也可能是一个内嵌的webserver,或者是一个成熟的应用服务器。buildpack是可插拔的,但你最好尽可能少的对它进行自定义设置。这可以减少不受你控制的功能范围,最小化部署和生产环境的发散。 +对于大多数流行云PaaS(平台即服务)提供商,Spring Boot的可执行jars就是为它们准备的。这些提供商往往要求你自己提供容器。它们只负责管理应用的进程(不特别针对Java应用程序),所以它们需要一个中间层来将你的应用适配到云概念中的一个运行进程。 + +两个流行的云提供商,Heroku和Cloud Foundry,采取一个打包('buildpack')方法。为了启动你的应用程序,不管需要什么,buildpack都会将它们打包到你的部署代码。它可能是一个JDK和一个java调用,也可能是一个内嵌的webserver,或者是一个成熟的应用服务器。buildpack是可插拔的,但你最好尽可能少的对它进行自定义设置。这可以减少不受你控制的功能范围,最小化部署和生产环境的发散。 理想情况下,你的应用就像一个Spring Boot可执行jar,所有运行需要的东西都打包到它内部。 From 8e9c2cc7aa0caa6bf554b13abc6cad1d3b97d81d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E7=83=AD=E5=BF=83=E5=B8=82=E6=B0=91=E9=92=9F=E5=B0=8F?= =?UTF-8?q?=E5=BC=BA?= Date: Sun, 10 Nov 2019 13:21:36 +0800 Subject: [PATCH 606/865] Update SUMMARY.md --- SUMMARY.md | 36 ++++++++++++++++++------------------ 1 file changed, 18 insertions(+), 18 deletions(-) diff --git a/SUMMARY.md b/SUMMARY.md index 61eac2cb..33380d0b 100644 --- a/SUMMARY.md +++ b/SUMMARY.md @@ -395,24 +395,24 @@ * [58.3 自定义上下文路径](V. Spring Boot Actuator/58.3 Custom context path.md) * [59. 接下来阅读什么](V. Spring Boot Actuator/59. What to Read Next.md) * [VI. 部署到云端](VI. Deploying Spring Boot Applications/README.md) - * [58. 部署到云端](VI. Deploying Spring Boot Applications/58. Deploying to the cloud.md) - * [58.1 Cloud Foundry](VI. Deploying Spring Boot Applications/58.1 Cloud Foundry.md) - * [58.1.1 绑定服务](VI. Deploying Spring Boot Applications/58.1.1 Binding to services.md) - * [58.2 Heroku](VI. Deploying Spring Boot Applications/58.2 Heroku.md) - * [58.3 Openshift](VI. Deploying Spring Boot Applications/58.3 Openshift.md) - * [58.4 亚马逊网络服务(AWS)](VI. Deploying Spring Boot Applications/58.4 Amazon Web Services(AWS).md) - * [58.4.1 AWS Elastic Beanstalk](VI. Deploying Spring Boot Applications/58.4.1 AWS Elastic Beanstalk.md) - * [58.4.2 总结](VI. Deploying Spring Boot Applications/58.4.2 Summary.md) - * [58.5 Boxfuse和亚马逊网络服务](VI. Deploying Spring Boot Applications/58.5 Boxfuse and Amazon Web Services.md) - * [58.6 Google App Engine](VI. Deploying Spring Boot Applications/58.6 Google App Engine.md) - * [59. 安装Spring Boot应用](VI. Deploying Spring Boot Applications/59. Installing Spring Boot applications.md) - * [59.1 支持的操作系统](VI. Deploying Spring Boot Applications/59.1 Supported operating systems.md) - * [59.2 Unix/Linux服务](VI. Deploying Spring Boot Applications/59.2 Unix&Linux services.md) - * [59.2.1 安装为init.d服务(System V)](VI. Deploying Spring Boot Applications/59.2.1 Installation as an init.d service(System V).md) - * [59.2.2 安装为Systemd服务](VI. Deploying Spring Boot Applications/59.2.2 Installation as a systemd service.md) - * [59.2.3 自定义启动脚本](VI. Deploying Spring Boot Applications/59.2.3 Customizing the startup script.md) - * [59.3 Microsoft Windows服务](VI. Deploying Spring Boot Applications/59.3 Microsoft Windows services.md) - * [60. 接下来阅读什么](VI. Deploying Spring Boot Applications/60. What to read next.md) + * [60. 部署到云端](VI. Deploying Spring Boot Applications/60. Deploying to the Cloud.md) + * [60.1 Cloud Foundry](VI. Deploying Spring Boot Applications/60.1 Cloud Foundry.md) + * [60.1.1 绑定服务](VI. Deploying Spring Boot Applications/60.1.1 Binding to Services.md) + * [60.2 Heroku](VI. Deploying Spring Boot Applications/60.2 Heroku.md) + * [60.3 Openshift](VI. Deploying Spring Boot Applications/60.3 Openshift.md) + * [60.4 亚马逊网络服务(AWS)](VI. Deploying Spring Boot Applications/60.4 Amazon Web Services(AWS).md) + * [60.4.1 AWS Elastic Beanstalk](VI. Deploying Spring Boot Applications/60.4.1 AWS Elastic Beanstalk.md) + * [60.4.2 总结](VI. Deploying Spring Boot Applications/60.4.2 Summary.md) + * [60.5 Boxfuse和亚马逊网络服务](VI. Deploying Spring Boot Applications/60.5 Boxfuse and Amazon Web Services.md) + * [60.6 Google App Engine](VI. Deploying Spring Boot Applications/60.6 Google App Engine.md) + * [61. 安装Spring Boot应用](VI. Deploying Spring Boot Applications/61. Installing Spring Boot Applications.md) + * [61.1 支持的操作系统](VI. Deploying Spring Boot Applications/61.1 Supported Operating Systems.md) + * [61.2 Unix/Linux服务](VI. Deploying Spring Boot Applications/61.2 Unix&Linux services.md) + * [61.2.1 安装为init.d服务(System V)](VI. Deploying Spring Boot Applications/61.2.1 Installation as an init.d Service(System V).md) + * [61.2.2 安装为Systemd服务](VI. Deploying Spring Boot Applications/61.2.2 Installation as a systemd Service.md) + * [61.2.3 自定义启动脚本](VI. Deploying Spring Boot Applications/61.2.3 Customizing the Startup Script.md) + * [61.3 Microsoft Windows服务](VI. Deploying Spring Boot Applications/61.3 Microsoft Windows Services.md) + * [62. 接下来阅读什么](VI. Deploying Spring Boot Applications/62. What to Read Next.md) * [VII. Spring Boot CLI](VII. Spring Boot CLI/README.md) * [61. 安装CLI](VII. Spring Boot CLI/61. Installing the CLI.md) * [62. 使用CLI](VII. Spring Boot CLI/62. Using the CLI.md) From 613b45d94aeb5acbcf8421339c651495c47b542f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E7=83=AD=E5=BF=83=E5=B8=82=E6=B0=91=E9=92=9F=E5=B0=8F?= =?UTF-8?q?=E5=BC=BA?= Date: Sun, 10 Nov 2019 13:24:08 +0800 Subject: [PATCH 607/865] Update 60. Deploying to the Cloud.md --- .../60. Deploying to the Cloud.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/VI. Deploying Spring Boot Applications/60. Deploying to the Cloud.md b/VI. Deploying Spring Boot Applications/60. Deploying to the Cloud.md index 0f9803b2..1ba02362 100644 --- a/VI. Deploying Spring Boot Applications/60. Deploying to the Cloud.md +++ b/VI. Deploying Spring Boot Applications/60. Deploying to the Cloud.md @@ -6,4 +6,4 @@ 理想情况下,你的应用就像一个Spring Boot可执行jar,所有运行需要的东西都打包到它内部。 -本章节我们将看到在“Getting Started”章节开发的简单应用是怎么在云端运行的。 +本章节我们将看到在“Getting Started”章节[开发的简单应用](https://docs.spring.io/spring-boot/docs/2.0.0.RELEASE/reference/htmlsingle/#getting-started-first-application)是怎么在云端运行的。 From 6071e4fe7949228c94220bcd52808ac7a26b5870 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E7=83=AD=E5=BF=83=E5=B8=82=E6=B0=91=E9=92=9F=E5=B0=8F?= =?UTF-8?q?=E5=BC=BA?= Date: Sun, 10 Nov 2019 13:42:41 +0800 Subject: [PATCH 608/865] Update and rename 58.1 Cloud Foundry.md to 60.1 Cloud Foundry.md --- ... Cloud Foundry.md => 60.1 Cloud Foundry.md} | 18 ++++++++++-------- 1 file changed, 10 insertions(+), 8 deletions(-) rename VI. Deploying Spring Boot Applications/{58.1 Cloud Foundry.md => 60.1 Cloud Foundry.md} (67%) diff --git a/VI. Deploying Spring Boot Applications/58.1 Cloud Foundry.md b/VI. Deploying Spring Boot Applications/60.1 Cloud Foundry.md similarity index 67% rename from VI. Deploying Spring Boot Applications/58.1 Cloud Foundry.md rename to VI. Deploying Spring Boot Applications/60.1 Cloud Foundry.md index 48803fc7..131893e5 100644 --- a/VI. Deploying Spring Boot Applications/58.1 Cloud Foundry.md +++ b/VI. Deploying Spring Boot Applications/60.1 Cloud Foundry.md @@ -1,16 +1,18 @@ -### 58.1 Cloud Foundry +### 60.1 Cloud Foundry 如果不指定其他打包方式,Cloud Foundry会启用它提供的默认打包方式。Cloud Foundry的[Java buildpack](https://github.com/cloudfoundry/java-buildpack)对Spring应用有出色的支持,包括Spring Boot。你可以部署独立的可执行jar应用,也可以部署传统的`.war`形式的应用。 -一旦你构建应用(比如,使用`mvn clean package`)并[安装`cf`命令行工具](http://docs.cloudfoundry.org/devguide/installcf/install-go-cli.html),你可以使用下面的`cf push`命令(将路径指向你编译后的`.jar`)来部署应用。在发布应用前,确保[你已登陆cf命令行客户端](http://docs.cloudfoundry.org/devguide/installcf/whats-new-v6.html#login)。 +一旦你构建应用(比如,使用`mvn clean package`)并[安装`cf`命令行工具](https://docs.cloudfoundry.org/cf-cli/install-go-cli.html),你可以使用下面的`cf push`命令(将路径指向你编译后的`.jar`)来部署应用。在发布应用前,确保[你已登陆cf命令行客户端](https://docs.cloudfoundry.org/cf-cli/getting-started.html#login)。下面的代码行展示了如何使用`cf push`命令来部署应用程序: ```shell $ cf push acloudyspringtime -p target/demo-0.0.1-SNAPSHOT.jar ``` -查看[`cf push`文档](http://docs.cloudfoundry.org/devguide/installcf/whats-new-v6.html#push)获取更多可选项。如果相同目录下存在[manifest.yml](http://docs.cloudfoundry.org/devguide/deploy-apps/manifest.html),Cloud Foundry会使用它。 -就此,`cf`将开始上传你的应用: -```java -Uploading acloudyspringtime... OK +**注** 在前面的例子中,我们将`acloudyspringtime`替换为你为应用程序指定的`cf`值。 + +查看[`cf push`文档](https://docs.cloudfoundry.org/cf-cli/getting-started.html#push)获取更多可选项。如果相同目录下存在[manifest.yml](https://docs.cloudfoundry.org/devguide/deploy-apps/manifest.html),Cloud Foundry会使用它。 + +就此,`cf`将开始上传你的应用,生成如下图所示的输出: +``` Uploading acloudyspringtime... OK Preparing to start acloudyspringtime... OK -----> Downloaded app package (8.9M) @@ -35,7 +37,7 @@ App started ``` 恭喜!应用现在处于运行状态! -检验部署应用的状态是很简单的: +应用程序启动后,可以使用`cf apps`命令验证部署的应用程序的状态,如下例所示: ```shell $ cf apps Getting applications in ... @@ -46,4 +48,4 @@ name requested state instances memory disk urls acloudyspringtime started 1/1 512M 1G acloudyspringtime.cfapps.io ... ``` -一旦Cloud Foundry意识到你的应用已经部署,你就可以点击给定的应用URI,此处是[acloudyspringtime.cfapps.io/](http://acloudyspringtime.cfapps.io/)。 +一旦Cloud Foundry意识到你的应用已经部署,你就可以点击给定的应用URI。在前面的示例中,你可以通过[http://acloudyspringtime.cfapps.io/](http://acloudyspringtime.cfapps.io/)找到它。 From 43391af92dd0c77b8a92366acde2bdb283e84b03 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E7=83=AD=E5=BF=83=E5=B8=82=E6=B0=91=E9=92=9F=E5=B0=8F?= =?UTF-8?q?=E5=BC=BA?= Date: Sun, 10 Nov 2019 13:48:20 +0800 Subject: [PATCH 609/865] Update and rename 58.1.1 Binding to services.md to 60.1.1 Binding to Services.md --- ...Binding to services.md => 60.1.1 Binding to Services.md} | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) rename VI. Deploying Spring Boot Applications/{58.1.1 Binding to services.md => 60.1.1 Binding to Services.md} (64%) diff --git a/VI. Deploying Spring Boot Applications/58.1.1 Binding to services.md b/VI. Deploying Spring Boot Applications/60.1.1 Binding to Services.md similarity index 64% rename from VI. Deploying Spring Boot Applications/58.1.1 Binding to services.md rename to VI. Deploying Spring Boot Applications/60.1.1 Binding to Services.md index 67f3f803..4c534765 100644 --- a/VI. Deploying Spring Boot Applications/58.1.1 Binding to services.md +++ b/VI. Deploying Spring Boot Applications/60.1.1 Binding to Services.md @@ -1,4 +1,4 @@ -### 58.1.1 绑定服务 +### 60.1.1 绑定服务 默认情况下,运行应用的元数据和服务连接信息被暴露为应用的环境变量(比如`$VCAP_SERVICES`),采用这种架构的原因是因为Cloud Foundry多语言特性(任何语言和平台都支持作为buildpack),进程级别的环境变量是语言无关(language agnostic)的。 @@ -18,6 +18,6 @@ class MyBean implements EnvironmentAware { } ``` -所有的Cloud Foundry属性都以`vcap`作为前缀,你可以使用vcap属性获取应用信息(比如应用的公共URL)和服务信息(比如数据库证书),具体参考`CloudFoundryVcapEnvironmentPostProcessor` Javadoc。 +所有的Cloud Foundry属性都以`vcap`作为前缀,你可以使用vcap属性获取应用信息(比如应用的公共URL)和服务信息(比如数据库证书),具体参考[CloudFoundryVcapEnvironmentPostProcessor](https://docs.spring.io/spring-boot/docs/2.0.0.RELEASE/api/org/springframework/boot/cloud/CloudFoundryVcapEnvironmentPostProcessor.html)的Javadoc。 -**注**:[Spring Cloud Connectors](http://cloud.spring.io/spring-cloud-connectors/)项目很适合比如配置数据源的任务,Spring Boot为它提供了自动配置支持和一个`spring-boot-starter-cloud-connectors` starter。 +**注**:[Spring Cloud Connectors](https://cloud.spring.io/spring-cloud-connectors/)项目很适合比如配置数据源的任务。Spring Boot为它提供了自动配置支持和一个`spring-boot-starter-cloud-connectors` starter。 From c88ba5fabe40945c66ce6680884781518e27b573 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E7=83=AD=E5=BF=83=E5=B8=82=E6=B0=91=E9=92=9F=E5=B0=8F?= =?UTF-8?q?=E5=BC=BA?= Date: Sun, 10 Nov 2019 13:53:39 +0800 Subject: [PATCH 610/865] Update and rename 58.2 Heroku.md to 60.2 Heroku.md --- .../{58.2 Heroku.md => 60.2 Heroku.md} | 19 ++++++++----------- 1 file changed, 8 insertions(+), 11 deletions(-) rename VI. Deploying Spring Boot Applications/{58.2 Heroku.md => 60.2 Heroku.md} (84%) diff --git a/VI. Deploying Spring Boot Applications/58.2 Heroku.md b/VI. Deploying Spring Boot Applications/60.2 Heroku.md similarity index 84% rename from VI. Deploying Spring Boot Applications/58.2 Heroku.md rename to VI. Deploying Spring Boot Applications/60.2 Heroku.md index 0b7f5ad8..83beb737 100644 --- a/VI. Deploying Spring Boot Applications/58.2 Heroku.md +++ b/VI. Deploying Spring Boot Applications/60.2 Heroku.md @@ -1,14 +1,15 @@ -###58.2 Heroku +### 60.2 Heroku + Heroku是另外一个流行的Paas平台,你可以提供一个`Procfile`来定义Heroku的构建过程,它提供部署应用所需的指令。Heroku为Java应用分配一个端口,确保能够路由到外部URI。 你必须配置你的应用监听正确的端口,下面是用于我们的starter REST应用的`Procfile`: -```shell +``` web: java -Dserver.port=$PORT -jar target/demo-0.0.1-SNAPSHOT.jar ``` Spring Boot将`-D`参数作为属性,通过Spring `Environment`实例访问。`server.port`配置属性适合于内嵌的Tomcat,Jetty或Undertow实例启用时使用,`$PORT`环境变量被分配给Heroku Paas使用。 这就是你需要做的所有内容,对于Heroku部署来说,经常做的工作就是使用`git push`将代码推送到生产环境。 -```shell +``` $ git push heroku master Initializing repository, done. @@ -22,15 +23,12 @@ Total 95 (delta 31), reused 0 (delta 0) -----> Installing OpenJDK 1.8... done -----> Installing Maven 3.3.1... done -----> Installing settings.xml... done ------> executing /app/tmp/cache/.maven/bin/mvn -B - -Duser.home=/tmp/build_0c35a5d2-a067-4abc-a232-14b1fb7a8229 - -Dmaven.repo.local=/app/tmp/cache/.m2/repository - -s /app/tmp/cache/.m2/settings.xml -DskipTests=true clean install +-----> Executing: mvn -B -DskipTests=true clean install [INFO] Scanning for projects... - Downloading: http://repo.spring.io/... - Downloaded: http://repo.spring.io/... (818 B at 1.8 KB/sec) - .... + Downloading: https://repo.spring.io/... + Downloaded: https://repo.spring.io/... (818 B at 1.8 KB/sec) + .... Downloaded: http://s3pository.heroku.com/jvm/... (152 KB at 595.3 KB/sec) [INFO] Installing /tmp/build_0c35a5d2-a067-4abc-a232-14b1fb7a8229/target/... [INFO] Installing /tmp/build_0c35a5d2-a067-4abc-a232-14b1fb7a8229/pom.xml ... @@ -51,6 +49,5 @@ Total 95 (delta 31), reused 0 (delta 0) To git@heroku.com:agile-sierra-1405.git * [new branch] master -> master - ``` 现在你的应用已经启动并运行在Heroku。 From a80790612f81781f27c80d9938f97e98346bf17b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E7=83=AD=E5=BF=83=E5=B8=82=E6=B0=91=E9=92=9F=E5=B0=8F?= =?UTF-8?q?=E5=BC=BA?= Date: Sun, 17 Nov 2019 13:31:49 +0800 Subject: [PATCH 611/865] Update and rename 58.3 Openshift.md to 60.3 Openshift.md --- .../58.3 Openshift.md | 41 ------------------- .../60.3 Openshift.md | 8 ++++ 2 files changed, 8 insertions(+), 41 deletions(-) delete mode 100644 VI. Deploying Spring Boot Applications/58.3 Openshift.md create mode 100644 VI. Deploying Spring Boot Applications/60.3 Openshift.md diff --git a/VI. Deploying Spring Boot Applications/58.3 Openshift.md b/VI. Deploying Spring Boot Applications/58.3 Openshift.md deleted file mode 100644 index 9bfda368..00000000 --- a/VI. Deploying Spring Boot Applications/58.3 Openshift.md +++ /dev/null @@ -1,41 +0,0 @@ -###58.3 Openshift - -[Openshift](https://www.openshift.com/)是RedHat公共(和企业)PaaS解决方案。和Heroku相似,它也是通过运行被git提交触发的脚本来工作的,所以你可以使用任何你喜欢的方式编写Spring Boot应用启动脚本,只要Java运行时环境可用(这是在Openshift上可以要求的一个标准特性)。为了实现这样的效果,你可以使用[DIY Cartridge](https://www.openshift.com/developers/do-it-yourself),并在`.openshift/action_scripts`下hooks你的仓库: - -基本模式如下: - -1.确保Java和构建工具已被远程安装,比如使用一个`pre_build` hook(默认会安装Java和Maven,不会安装Gradle)。 - -2.使用一个`build` hook去构建你的jar(使用Maven或Gradle),比如: -```shell -#!/bin/bash -cd $OPENSHIFT_REPO_DIR -mvn package -s .openshift/settings.xml -DskipTests=true -``` -3.添加一个调用`java -jar …`的`start` hook - -```shell -#!/bin/bash -cd $OPENSHIFT_REPO_DIR -nohup java -jar target/*.jar --server.port=${OPENSHIFT_DIY_PORT} --server.address=${OPENSHIFT_DIY_IP} & -``` -4.使用一个`stop` hook - -```shell -#!/bin/bash -source $OPENSHIFT_CARTRIDGE_SDK_BASH -PID=$(ps -ef | grep java.*\.jar | grep -v grep | awk '{ print $2 }') -if [ -z "$PID" ] -then - client_result "Application is already stopped" -else - kill $PID -fi -``` -5.将内嵌的服务绑定到平台提供的`application.properties`定义的环境变量,比如: -```shell -spring.datasource.url: jdbc:mysql://${OPENSHIFT_MYSQL_DB_HOST}:${OPENSHIFT_MYSQL_DB_PORT}/${OPENSHIFT_APP_NAME} -spring.datasource.username: ${OPENSHIFT_MYSQL_DB_USERNAME} -spring.datasource.password: ${OPENSHIFT_MYSQL_DB_PASSWORD} -``` -在Openshift的网站上有一篇[running Gradle in Openshift](https://www.openshift.com/blogs/run-gradle-builds-on-openshift)博客,如果想使用gradle构建运行的应用可以参考它。 diff --git a/VI. Deploying Spring Boot Applications/60.3 Openshift.md b/VI. Deploying Spring Boot Applications/60.3 Openshift.md new file mode 100644 index 00000000..478ce022 --- /dev/null +++ b/VI. Deploying Spring Boot Applications/60.3 Openshift.md @@ -0,0 +1,8 @@ +### 60.3 Openshift + +[Openshift](https://www.openshift.com/)是Kubernetes容器编排平台的红帽公共(和企业)扩展。与Kubernetes类似,OpenShift有许多安装基于Spring Boot的应用程序的选项。OpenShift有很多描述如何部署Spring启动应用程序的资源,包括: + +- [使用S2I构建器](https://blog.openshift.com/using-openshift-enterprise-grade-spring-boot-deployments/) +- [架构指南](https://access.redhat.com/documentation/en-us/reference_architectures/2017/html-single/spring_boot_microservices_on_red_hat_openshift_container_platform_3/) +- [在Wildfly上作为传统web应用程序运行](https://blog.openshift.com/using-spring-boot-on-openshift/) +- [OpenShift Commons简报](https://blog.openshift.com/openshift-commons-briefing-96-cloud-native-applications-spring-rhoar/) From c76e6cf57d4277db0efc0aff6a19fe4a5112ac2d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E7=83=AD=E5=BF=83=E5=B8=82=E6=B0=91=E9=92=9F=E5=B0=8F?= =?UTF-8?q?=E5=BC=BA?= Date: Sun, 17 Nov 2019 13:35:52 +0800 Subject: [PATCH 612/865] =?UTF-8?q?Update=20and=20rename=2058.4=20Amazon?= =?UTF-8?q?=20Web=20Services=EF=BC=88AWS=EF=BC=89.md=20to=2060.4=20Amazon?= =?UTF-8?q?=20Web=20Services=EF=BC=88AWS=EF=BC=89.md?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../60.4 Amazon Web Services\357\274\210AWS\357\274\211.md" | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) rename "VI. Deploying Spring Boot Applications/58.4 Amazon Web Services\357\274\210AWS\357\274\211.md" => "VI. Deploying Spring Boot Applications/60.4 Amazon Web Services\357\274\210AWS\357\274\211.md" (79%) diff --git "a/VI. Deploying Spring Boot Applications/58.4 Amazon Web Services\357\274\210AWS\357\274\211.md" "b/VI. Deploying Spring Boot Applications/60.4 Amazon Web Services\357\274\210AWS\357\274\211.md" similarity index 79% rename from "VI. Deploying Spring Boot Applications/58.4 Amazon Web Services\357\274\210AWS\357\274\211.md" rename to "VI. Deploying Spring Boot Applications/60.4 Amazon Web Services\357\274\210AWS\357\274\211.md" index 541a77d2..0050a69d 100644 --- "a/VI. Deploying Spring Boot Applications/58.4 Amazon Web Services\357\274\210AWS\357\274\211.md" +++ "b/VI. Deploying Spring Boot Applications/60.4 Amazon Web Services\357\274\210AWS\357\274\211.md" @@ -1,4 +1,4 @@ -### 58.4 亚马逊网络服务(AWS) +### 60.4 亚马逊网络服务(AWS) 亚马逊网络服务提供了多种安装基于Spring Boot的应用的方式, 比如传统的网络应用(war),又比如内嵌网络服务器的可执行jar文件。选项包括: @@ -8,4 +8,4 @@ - AWS Cloud Formation - AWS Container Registry -每个选项都有不同的特点和定价模式。在这里,我们只描述最简单的选项:AWS Elastic Beanstalk。 \ No newline at end of file +每个选项都有不同的特点和定价模式。在这里,我们只描述最简单的选项:AWS Elastic Beanstalk。 From b25d75536ab3493c2cb6a52d6d62efbb38d4605a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E7=83=AD=E5=BF=83=E5=B8=82=E6=B0=91=E9=92=9F=E5=B0=8F?= =?UTF-8?q?=E5=BC=BA?= Date: Sun, 17 Nov 2019 13:49:32 +0800 Subject: [PATCH 613/865] Update and rename 58.4.1 AWS Elastic Beanstalk.md to 60.4.1 AWS Elastic Beanstalk.md --- .../58.4.1 AWS Elastic Beanstalk.md | 28 ------------------- .../60.4.1 AWS Elastic Beanstalk.md | 25 +++++++++++++++++ 2 files changed, 25 insertions(+), 28 deletions(-) delete mode 100644 VI. Deploying Spring Boot Applications/58.4.1 AWS Elastic Beanstalk.md create mode 100644 VI. Deploying Spring Boot Applications/60.4.1 AWS Elastic Beanstalk.md diff --git a/VI. Deploying Spring Boot Applications/58.4.1 AWS Elastic Beanstalk.md b/VI. Deploying Spring Boot Applications/58.4.1 AWS Elastic Beanstalk.md deleted file mode 100644 index 7f097bc8..00000000 --- a/VI. Deploying Spring Boot Applications/58.4.1 AWS Elastic Beanstalk.md +++ /dev/null @@ -1,28 +0,0 @@ -### 58.4.1 AWS Elastic Beanstalk - -就像在官方的[Elastic Beanstalk Java指南](https://docs.aws.amazon.com/elasticbeanstalk/latest/dg/create_deploy_Java.html)里描述的那样,有两种主要的方式来部署Java应用。你可以使用““Tomcat平台”或者“Java SE平台”。 - -**使用Tomcat平台** - -这个选项适用于产生war文件的Spring Boot工程。不需要任何特殊的配置,按照官方的指南一步步来就好。 - -**使用Java SE平台** - -这个选项适用于产生jar文件并运行一个内嵌的网络容器的Spring Boot工程。Elastic Beanstalk环境在80端口上运行一个nginx实例,来代理运行在5000端口上的实际的应用。在你的`application.properties`中加入以下内容,来进行配置: -```properties -server.port=5000 -``` -**最佳实践** - -**上传二进制文件代替源码** - -默认地,Elastic Beanstalk上传源码并在AWS进行编译。为了上传二进制文件作为替代,在你的`.elasticbeanstalk/config.yml`文件中加入以下内容: -```properties -deploy: - artifact: target/demo-0.0.1-SNAPSHOT.jar -Reduce costs by setting the environment type -``` -默认地,Elastic Beanstalk环境负载均衡。负载均衡器会优先考虑成本,为了避免这个,按照[亚马逊文档](https://docs.aws.amazon.com/elasticbeanstalk/latest/dg/environments-create-wizard.html#environments-create-wizard-capacity)里描述的那样,设置环境类型为“单个实例”。单个实例环境可以使用CLI或者以下命令进行创建: -```command -eb create -s -``` \ No newline at end of file diff --git a/VI. Deploying Spring Boot Applications/60.4.1 AWS Elastic Beanstalk.md b/VI. Deploying Spring Boot Applications/60.4.1 AWS Elastic Beanstalk.md new file mode 100644 index 00000000..fbb377fb --- /dev/null +++ b/VI. Deploying Spring Boot Applications/60.4.1 AWS Elastic Beanstalk.md @@ -0,0 +1,25 @@ +### 60.4.1 AWS Elastic Beanstalk + +就像在官方的[Elastic Beanstalk Java指南](https://docs.aws.amazon.com/elasticbeanstalk/latest/dg/create_deploy_Java.html)里描述的那样,有两种主要的方式来部署Java应用。你可以使用“Tomcat平台”或者“Java SE平台”。 + +**使用Tomcat平台** + +这个选项适用于产生war文件的Spring Boot工程。不需要任何特殊的配置,按照官方的指南一步步来就好。 + +**使用Java SE平台** + +这个选项适用于产生jar文件并运行一个内嵌的网络容器的Spring Boot工程。Elastic Beanstalk环境在80端口上运行一个nginx实例,来代理运行在5000端口上的实际的应用。在你的`application.properties`文件中加入以下内容,来进行配置: +```properties +server.port=5000 +``` + +**注** 默认地,Elastic Beanstalk上传源码并在AWS进行编译。为了上传二进制文件作为替代,在你的`.elasticbeanstalk/config.yml`文件中加入以下内容: +```properties +deploy: + artifact: target/demo-0.0.1-SNAPSHOT.jar +``` + +**注** 默认地,Elastic Beanstalk环境负载均衡。负载均衡器会优先考虑成本,为了避免这个,按照[亚马逊文档](https://docs.aws.amazon.com/elasticbeanstalk/latest/dg/environments-create-wizard.html#environments-create-wizard-capacity)里描述的那样,设置环境类型为“单个实例”。单个实例环境可以使用CLI或者以下命令进行创建: +```command +eb create -s +``` From 0b18f1db86782bedbebd13d1e880e62e12cf0f8b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E7=83=AD=E5=BF=83=E5=B8=82=E6=B0=91=E9=92=9F=E5=B0=8F?= =?UTF-8?q?=E5=BC=BA?= Date: Sun, 17 Nov 2019 13:52:02 +0800 Subject: [PATCH 614/865] Update and rename 58.4.2 Summary.md to 60.4.2 Summary.md --- .../{58.4.2 Summary.md => 60.4.2 Summary.md} | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) rename VI. Deploying Spring Boot Applications/{58.4.2 Summary.md => 60.4.2 Summary.md} (87%) diff --git a/VI. Deploying Spring Boot Applications/58.4.2 Summary.md b/VI. Deploying Spring Boot Applications/60.4.2 Summary.md similarity index 87% rename from VI. Deploying Spring Boot Applications/58.4.2 Summary.md rename to VI. Deploying Spring Boot Applications/60.4.2 Summary.md index 289a24df..b8a58bb0 100644 --- a/VI. Deploying Spring Boot Applications/58.4.2 Summary.md +++ b/VI. Deploying Spring Boot Applications/60.4.2 Summary.md @@ -1,3 +1,3 @@ -### 58.4.2 总结 +### 60.4.2 总结 -这是接触AWS的最简单的方式之一,但还有更多的事情需要考虑。比如,怎么样使用Elastic Beanstalk maven插件代替CLI,把Elastic Beanstalk集成到CI/CD工具中,等等。有一个[博客](https://exampledriven.wordpress.com/2017/01/09/spring-boot-aws-elastic-beanstalk-example/)详细地讨论了这些主题。 \ No newline at end of file +这是接触AWS的最简单的方式之一,但还有更多的事情需要考虑。比如,怎么样使用Elastic Beanstalk maven插件代替CLI,把Elastic Beanstalk集成到CI/CD工具中,等等。有一个[博客](https://exampledriven.wordpress.com/2017/01/09/spring-boot-aws-elastic-beanstalk-example/)详细地讨论了这些主题。 From 4c3bf96653666b850e5e09bd39d91eac45dda31c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E7=83=AD=E5=BF=83=E5=B8=82=E6=B0=91=E9=92=9F=E5=B0=8F?= =?UTF-8?q?=E5=BC=BA?= Date: Sun, 17 Nov 2019 14:13:22 +0800 Subject: [PATCH 615/865] Update and rename 58.5 Boxfuse and Amazon Web Services.md to 60.5 Boxfuse and Amazon Web Services.md --- ...es.md => 60.5 Boxfuse and Amazon Web Services.md} | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) rename VI. Deploying Spring Boot Applications/{58.5 Boxfuse and Amazon Web Services.md => 60.5 Boxfuse and Amazon Web Services.md} (74%) diff --git a/VI. Deploying Spring Boot Applications/58.5 Boxfuse and Amazon Web Services.md b/VI. Deploying Spring Boot Applications/60.5 Boxfuse and Amazon Web Services.md similarity index 74% rename from VI. Deploying Spring Boot Applications/58.5 Boxfuse and Amazon Web Services.md rename to VI. Deploying Spring Boot Applications/60.5 Boxfuse and Amazon Web Services.md index f42aee61..354d1013 100644 --- a/VI. Deploying Spring Boot Applications/58.5 Boxfuse and Amazon Web Services.md +++ b/VI. Deploying Spring Boot Applications/60.5 Boxfuse and Amazon Web Services.md @@ -1,17 +1,18 @@ -### 58.5 Boxfuse和亚马逊网络服务 +### 60.5 Boxfuse和亚马逊网络服务 [Boxfuse](https://boxfuse.com/)的工作机制是将你的Spring Boot可执行jar或war转换进一个最小化的VM镜像,该镜像不需改变就能部署到VirtualBox或AWS。Boxfuse深度集成Spring Boot并使用你的Spring Boot配置文件自动配置端口和健康检查URLs,它将该信息用于产生的镜像及它提供的所有资源(实例,安全分组,可伸缩的负载均衡等)。 -一旦创建一个[Boxfuse account](https://console.boxfuse.com/),并将它连接到你的AWS账号,安装最新版Boxfuse客户端,你就能按照以下操作将Spring Boot应用部署到AWS(首先要确保应用被Maven或Gradle构建过,比如`mvn clean package`): +一旦创建一个[Boxfuse账号](https://console.boxfuse.com/),并将它连接到你的AWS账号,安装最新版Boxfuse客户端,确保应用被Maven或Gradle构建过,比如`mvn clean package`)。你可以使用类似下面的命令将Spring Boot应用部署到AWS: ```shell $ boxfuse run myapp-1.0.jar -env=prod ``` + 更多选项可查看[`boxfuse run`文档](https://boxfuse.com/docs/commandline/run.html),如果当前目录存在一个[boxfuse.conf](https://boxfuse.com/docs/commandline/#configuration)文件,Boxfuse将使用它。 **注** 如果你的可执行jar或war包含[`application-boxfuse.properties`](https://boxfuse.com/docs/payloads/springboot.html#configuration)文件,Boxfuse默认在启动时会激活一个名为`boxfuse`的Spring profile,然后在该profile包含的属性基础上构建自己的配置。 -此刻`boxfuse`将为你的应用创建一个镜像并上传到AWS,然后配置并启动需要的资源: -```shell +此刻,`boxfuse`将为你的应用创建一个镜像并上传到AWS,然后配置并启动需要的资源。其输出结果与下面的示例类似: +``` Fusing Image for myapp-1.0.jar ... Image fused in 00:06.838s (53937 K) -> axelfontaine/myapp:1.0 Creating axelfontaine/myapp ... @@ -30,6 +31,7 @@ Remapping Elastic IP 52.28.233.167 to i-92ef9f53 ... Waiting 15s for AWS to complete Elastic IP Zero Downtime transition ... Deployment completed successfully. axelfontaine/myapp:1.0 is up and running at http://myapp-axelfontaine.boxfuse.io/ ``` + 你的应用现在应该已经在AWS上启动并运行了。 -这里有篇[在EC2部署Spring Boot应用](https://boxfuse.com/blog/spring-boot-ec2.html)的博客,Boxfuse官网也有[Boxfuse集成Spring Boot文档](https://boxfuse.com/docs/payloads/springboot.html),你可以拿来作为参考。 +请参阅有关[在EC2部署Spring Boot应用](https://boxfuse.com/blog/spring-boot-ec2.html)的博客,以及[Boxfuse集成Spring Boot文档](https://boxfuse.com/docs/payloads/springboot.html),以开始运行该应用程序的Maven构建。 From 8931786b7ac33fbb9848476d495623416cbd8c36 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E7=83=AD=E5=BF=83=E5=B8=82=E6=B0=91=E9=92=9F=E5=B0=8F?= =?UTF-8?q?=E5=BC=BA?= Date: Sun, 17 Nov 2019 14:31:36 +0800 Subject: [PATCH 616/865] Update and rename 58.6 Google App Engine.md to 60.6 Google Cloud.md --- .../58.6 Google App Engine.md | 3 -- .../60.6 Google Cloud.md | 44 +++++++++++++++++++ 2 files changed, 44 insertions(+), 3 deletions(-) delete mode 100644 VI. Deploying Spring Boot Applications/58.6 Google App Engine.md create mode 100644 VI. Deploying Spring Boot Applications/60.6 Google Cloud.md diff --git a/VI. Deploying Spring Boot Applications/58.6 Google App Engine.md b/VI. Deploying Spring Boot Applications/58.6 Google App Engine.md deleted file mode 100644 index 61b64f9c..00000000 --- a/VI. Deploying Spring Boot Applications/58.6 Google App Engine.md +++ /dev/null @@ -1,3 +0,0 @@ -### 58.6 Google App Engine - -Google App Engine关联了Servlet 2.5 API,如果不做一些修改你是不能在其上部署Spring应用的,具体查看本指南的[Servlet 2.5章节](../IX. ‘How-to’ guides/81.5. Deploying a WAR in an Old (Servlet 2.5) Container.md)。 diff --git a/VI. Deploying Spring Boot Applications/60.6 Google Cloud.md b/VI. Deploying Spring Boot Applications/60.6 Google Cloud.md new file mode 100644 index 00000000..993849e8 --- /dev/null +++ b/VI. Deploying Spring Boot Applications/60.6 Google Cloud.md @@ -0,0 +1,44 @@ +### 60.6 Google Cloud + +谷歌云有几个用于启动Spring Boot应用程序的选项。最简单的入门方法可能是App Engine,但是你也可以找到用Container Engine在容器中运行Spring Boot的方法,或者用Compute Engine在虚拟机中运行Spring Boot的方法。 + +要在App Engine中运行,你可以首先在UI中创建一个项目,它为您设置一个惟一的标识符,并设置HTTP路由。将一个Java应用程序添加到项目中,并保持它为空,然后使用[谷歌云SDK](https://cloud.google.com/sdk/downloads)将你的Spring Boot应用程序从命令行或CI构建推入该位置。 + +App Engine需要你创建一个`app.yaml`文件来描述应用程序所需的资源。通常,你把这个文件放在`src/main/appengine`,它应该类似于以下文件: +```properties +service: default + +runtime: java +env: flex + +runtime_config: + jdk: openjdk8 + +handlers: +- url: /.* + script: this field is required, but ignored + +manual_scaling: + instances: 1 + +health_check: + enable_health_check: False + +env_variables: + ENCRYPT_KEY: your_encryption_key_here +``` + +你可以通过将项目ID添加到构建配置中来部署应用程序(例如,使用Maven插件),如下面的示例所示: +```xml + + com.google.cloud.tools + appengine-maven-plugin + 1.3.0 + + myproject + + +``` +然后使用`mvn appengine:deploy`进行部署(如果需要首先进行身份验证,则构建将失败)。 + +**注** 谷歌App Engine Classic与Servlet 2.5 API绑定在一起,因此如果不进行一些修改,就不能在那里部署Spring应用程序。请参阅本指南的[Servlet 2.5部分](https://docs.spring.io/spring-boot/docs/2.0.0.RELEASE/reference/htmlsingle/#howto-servlet-2-5)。 From eeed2317e0c3ed897fadd169358de8d36195bcd4 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E7=83=AD=E5=BF=83=E5=B8=82=E6=B0=91=E9=92=9F=E5=B0=8F?= =?UTF-8?q?=E5=BC=BA?= Date: Sun, 17 Nov 2019 14:40:07 +0800 Subject: [PATCH 617/865] Update SUMMARY.md --- SUMMARY.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/SUMMARY.md b/SUMMARY.md index 33380d0b..ac824819 100644 --- a/SUMMARY.md +++ b/SUMMARY.md @@ -404,7 +404,7 @@ * [60.4.1 AWS Elastic Beanstalk](VI. Deploying Spring Boot Applications/60.4.1 AWS Elastic Beanstalk.md) * [60.4.2 总结](VI. Deploying Spring Boot Applications/60.4.2 Summary.md) * [60.5 Boxfuse和亚马逊网络服务](VI. Deploying Spring Boot Applications/60.5 Boxfuse and Amazon Web Services.md) - * [60.6 Google App Engine](VI. Deploying Spring Boot Applications/60.6 Google App Engine.md) + * [60.6 Google Cloud](VI. Deploying Spring Boot Applications/60.6 Google Cloud.md) * [61. 安装Spring Boot应用](VI. Deploying Spring Boot Applications/61. Installing Spring Boot Applications.md) * [61.1 支持的操作系统](VI. Deploying Spring Boot Applications/61.1 Supported Operating Systems.md) * [61.2 Unix/Linux服务](VI. Deploying Spring Boot Applications/61.2 Unix&Linux services.md) From 562240563c7c766714013be31e0ae5da1c2e927c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E7=83=AD=E5=BF=83=E5=B8=82=E6=B0=91=E9=92=9F=E5=B0=8F?= =?UTF-8?q?=E5=BC=BA?= Date: Sun, 17 Nov 2019 14:45:02 +0800 Subject: [PATCH 618/865] Update and rename 59. Installing Spring Boot applications.md to 61. Installing Spring Boot Applications.md --- ...1. Installing Spring Boot Applications.md} | 24 +++++++++---------- 1 file changed, 11 insertions(+), 13 deletions(-) rename VI. Deploying Spring Boot Applications/{59. Installing Spring Boot applications.md => 61. Installing Spring Boot Applications.md} (65%) diff --git a/VI. Deploying Spring Boot Applications/59. Installing Spring Boot applications.md b/VI. Deploying Spring Boot Applications/61. Installing Spring Boot Applications.md similarity index 65% rename from VI. Deploying Spring Boot Applications/59. Installing Spring Boot applications.md rename to VI. Deploying Spring Boot Applications/61. Installing Spring Boot Applications.md index 7cc163fe..c8ea7451 100644 --- a/VI. Deploying Spring Boot Applications/59. Installing Spring Boot applications.md +++ b/VI. Deploying Spring Boot Applications/61. Installing Spring Boot Applications.md @@ -1,25 +1,23 @@ -### 59. 安装Spring Boot应用 +### 61. 安装Spring Boot应用 -除了使用`java -jar`运行Spring Boot应用,制作在Unix系统上完全可执行的应用也是可能的。完全可执行的jar可以像其它的可执行二进制文件一样被执行,或者可以用`init.d或systemd进行注册`。这会简化常见生产环境Spring Boot应用的安装和管理。 +除了使用`java -jar`运行Spring Boot应用,制作在Unix系统上完全可执行的应用也是可能的。完全可执行的jar可以像其它的可执行二进制文件一样被执行,或者可以用[`init.d`或`systemd`进行注册](https://docs.spring.io/spring-boot/docs/2.0.0.RELEASE/reference/htmlsingle/#deployment-service)。这会简化常见生产环境Spring Boot应用的安装和管理。 **警告⚠️** 通过在文件之前嵌入一段额外的脚本,来启动完全可执行的Jar。目前,一些工具尚不接受这种格式,所以你并不总是能够使用这项技术。比如,`jar -xf`可能会在解压一个完全可执行的jar或者war文件时悄悄地失败。建议你仅在想要直接执行它的情况下,将你的jar或者war文件制作为完全可执行的格式。不要在只是想要使用`java -jar`运行它,或者在一个servlet容器部署它的时候这样做。 在Maven中添加以下plugin配置可以创建一个"完全可执行"jar: ```xml - org.springframework.boot - spring-boot-maven-plugin - - true - + org.springframework.boot + spring-boot-maven-plugin + + true + ``` -对于Gradle等价的配置如下: +对于Gradle,等价的配置如下: ```shell -apply plugin: 'spring-boot' - -springBoot { - executable = true +bootJar { + launchScript() } ``` -然后输入`./my-application.jar`运行应用(`my-application`是你的artifact name)。包含jar文件的目录会被当作你的应用工作目录使用。 \ No newline at end of file +然后输入`./my-application.jar`运行应用(`my-application`是你的artifact name)。包含jar文件的目录会被当作你的应用工作目录使用。 From 3613aafc3225ec7a2e94566ccac52fee15d1201c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E7=83=AD=E5=BF=83=E5=B8=82=E6=B0=91=E9=92=9F=E5=B0=8F?= =?UTF-8?q?=E5=BC=BA?= Date: Sun, 17 Nov 2019 14:48:16 +0800 Subject: [PATCH 619/865] Update and rename 59.1 Supported operating systems.md to 61.1 Supported Operating Systems.md --- ...operating systems.md => 61.1 Supported Operating Systems.md} | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) rename VI. Deploying Spring Boot Applications/{59.1 Supported operating systems.md => 61.1 Supported Operating Systems.md} (85%) diff --git a/VI. Deploying Spring Boot Applications/59.1 Supported operating systems.md b/VI. Deploying Spring Boot Applications/61.1 Supported Operating Systems.md similarity index 85% rename from VI. Deploying Spring Boot Applications/59.1 Supported operating systems.md rename to VI. Deploying Spring Boot Applications/61.1 Supported Operating Systems.md index 728525a3..def7ee5a 100644 --- a/VI. Deploying Spring Boot Applications/59.1 Supported operating systems.md +++ b/VI. Deploying Spring Boot Applications/61.1 Supported Operating Systems.md @@ -1,3 +1,3 @@ -### 59.1 支持的操作系统 +### 61.1 支持的操作系统 默认的脚本支持大部分的Linux发行版,同时在CentOS和Ubuntu上进行了测试。其它的平台,比如OS X和FreeBSD将会需要使用自定义的`embeddedLaunchScript`。 From ffcc38e883f497961a87633ff8567588ab42394b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E7=83=AD=E5=BF=83=E5=B8=82=E6=B0=91=E9=92=9F=E5=B0=8F?= =?UTF-8?q?=E5=BC=BA?= Date: Sun, 17 Nov 2019 14:48:57 +0800 Subject: [PATCH 620/865] Update and rename 59.2 Unix&Linux services.md to 61.2 Unix&Linux Services.md --- ...{59.2 Unix&Linux services.md => 61.2 Unix&Linux Services.md} | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) rename VI. Deploying Spring Boot Applications/{59.2 Unix&Linux services.md => 61.2 Unix&Linux Services.md} (79%) diff --git a/VI. Deploying Spring Boot Applications/59.2 Unix&Linux services.md b/VI. Deploying Spring Boot Applications/61.2 Unix&Linux Services.md similarity index 79% rename from VI. Deploying Spring Boot Applications/59.2 Unix&Linux services.md rename to VI. Deploying Spring Boot Applications/61.2 Unix&Linux Services.md index 8bd35ff6..8f37db5e 100644 --- a/VI. Deploying Spring Boot Applications/59.2 Unix&Linux services.md +++ b/VI. Deploying Spring Boot Applications/61.2 Unix&Linux Services.md @@ -1,3 +1,3 @@ -### 59.2 Unix/Linux服务 +### 61.2 Unix/Linux服务 你可以使用`init.d`或`systemd`启动Spring Boot应用,就像其他Unix/Linux服务那样。 From 7f8f7735a9b701527e14e9cec2d658ef94c3f865 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E7=83=AD=E5=BF=83=E5=B8=82=E6=B0=91=E9=92=9F=E5=B0=8F?= =?UTF-8?q?=E5=BC=BA?= Date: Sun, 17 Nov 2019 14:54:51 +0800 Subject: [PATCH 621/865] =?UTF-8?q?Update=20and=20rename=2059.2.1=20Instal?= =?UTF-8?q?lation=20as=20an=20init.d=20service=EF=BC=88System=20V=EF=BC=89?= =?UTF-8?q?.md=20to=2061.2.1=20Installation=20as=20an=20init.d=20Service?= =?UTF-8?q?=EF=BC=88System=20V=EF=BC=89.md?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- ...n as an init.d Service\357\274\210System V\357\274\211.md" | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) rename "VI. Deploying Spring Boot Applications/59.2.1 Installation as an init.d service\357\274\210System V\357\274\211.md" => "VI. Deploying Spring Boot Applications/61.2.1 Installation as an init.d Service\357\274\210System V\357\274\211.md" (84%) diff --git "a/VI. Deploying Spring Boot Applications/59.2.1 Installation as an init.d service\357\274\210System V\357\274\211.md" "b/VI. Deploying Spring Boot Applications/61.2.1 Installation as an init.d Service\357\274\210System V\357\274\211.md" similarity index 84% rename from "VI. Deploying Spring Boot Applications/59.2.1 Installation as an init.d service\357\274\210System V\357\274\211.md" rename to "VI. Deploying Spring Boot Applications/61.2.1 Installation as an init.d Service\357\274\210System V\357\274\211.md" index c00c9451..d5945cfd 100644 --- "a/VI. Deploying Spring Boot Applications/59.2.1 Installation as an init.d service\357\274\210System V\357\274\211.md" +++ "b/VI. Deploying Spring Boot Applications/61.2.1 Installation as an init.d Service\357\274\210System V\357\274\211.md" @@ -1,4 +1,4 @@ -### 59.2.1 安装为init.d服务(System V) +### 61.2.1 安装为init.d服务(System V) 如果你配置Spring Boot的Maven或Gradle插件产生一个[完全可执行jar](https://docs.spring.io/spring-boot/docs/2.0.0.RELEASE/reference/htmlsingle/#deployment-install),并且没有使用自定义的`embeddedLaunchScript`,那你的应用可以作为`init.d`服务使用。只要简单的建立jar到`init.d`的符号连接就能获取标准的`start`,`stop`,`restart `和`status`命令支持。 @@ -42,7 +42,7 @@ $ sudo chattr +i your-app.jar ``` 这会防止任何用户修改jar文件,包括root。 -如果root用户用来控制应用服务,并且你使用[.conf文件](https://docs.spring.io/spring-boot/docs/2.0.0.RELEASE/reference/htmlsingle/#deployment-script-customization-conf-file)自定义它的启动,该`.conf`文件将被root用户读取和评估,因此它也需要保护。使用`chmod`改变文件权限只能被拥有者读取,然后使用`chown`改变文件拥有者为root: +如果root用户用来控制应用服务,并且你[使用`.conf`文件](https://docs.spring.io/spring-boot/docs/2.0.0.RELEASE/reference/htmlsingle/#deployment-script-customization-conf-file)自定义它的启动,该`.conf`文件将被root用户读取和评估,因此它也需要保护。使用`chmod`改变文件权限只能被拥有者读取,然后使用`chown`改变文件拥有者为root: ```shell $ chmod 400 your-app.conf $ sudo chown root:root your-app.conf From 3e3cd8c743e6125811b08ec0dc3ef8660e5f6b3f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E7=83=AD=E5=BF=83=E5=B8=82=E6=B0=91=E9=92=9F=E5=B0=8F?= =?UTF-8?q?=E5=BC=BA?= Date: Sun, 17 Nov 2019 14:57:35 +0800 Subject: [PATCH 622/865] Update SUMMARY.md --- SUMMARY.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/SUMMARY.md b/SUMMARY.md index ac824819..7cb1b934 100644 --- a/SUMMARY.md +++ b/SUMMARY.md @@ -407,7 +407,7 @@ * [60.6 Google Cloud](VI. Deploying Spring Boot Applications/60.6 Google Cloud.md) * [61. 安装Spring Boot应用](VI. Deploying Spring Boot Applications/61. Installing Spring Boot Applications.md) * [61.1 支持的操作系统](VI. Deploying Spring Boot Applications/61.1 Supported Operating Systems.md) - * [61.2 Unix/Linux服务](VI. Deploying Spring Boot Applications/61.2 Unix&Linux services.md) + * [61.2 Unix/Linux服务](VI. Deploying Spring Boot Applications/61.2 Unix&Linux Services.md) * [61.2.1 安装为init.d服务(System V)](VI. Deploying Spring Boot Applications/61.2.1 Installation as an init.d Service(System V).md) * [61.2.2 安装为Systemd服务](VI. Deploying Spring Boot Applications/61.2.2 Installation as a systemd Service.md) * [61.2.3 自定义启动脚本](VI. Deploying Spring Boot Applications/61.2.3 Customizing the Startup Script.md) From 6b4713776ae1fe82a52842bf49595c782b81c76f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E7=83=AD=E5=BF=83=E5=B8=82=E6=B0=91=E9=92=9F=E5=B0=8F?= =?UTF-8?q?=E5=BC=BA?= Date: Sun, 17 Nov 2019 15:04:03 +0800 Subject: [PATCH 623/865] Update and rename 59.2.2 Installation as a systemd service.md to 61.2.2 Installation as a systemd Service.md --- ...rvice.md => 61.2.2 Installation as a systemd Service.md} | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) rename VI. Deploying Spring Boot Applications/{59.2.2 Installation as a systemd service.md => 61.2.2 Installation as a systemd Service.md} (75%) diff --git a/VI. Deploying Spring Boot Applications/59.2.2 Installation as a systemd service.md b/VI. Deploying Spring Boot Applications/61.2.2 Installation as a systemd Service.md similarity index 75% rename from VI. Deploying Spring Boot Applications/59.2.2 Installation as a systemd service.md rename to VI. Deploying Spring Boot Applications/61.2.2 Installation as a systemd Service.md index 7247a902..506fdc81 100644 --- a/VI. Deploying Spring Boot Applications/59.2.2 Installation as a systemd service.md +++ b/VI. Deploying Spring Boot Applications/61.2.2 Installation as a systemd Service.md @@ -1,6 +1,6 @@ -### 59.2.2 安装为Systemd服务 +### 61.2.2 安装为Systemd服务 -Systemd是System V init系统的继任者,很多现代Linux分发版本都在使用,尽管你可以继续使用`init.d`脚本,但使用`systemd` ‘service’脚本启动Spring Boot应用是有可能的。 +`systemd`是System V init系统的继任者,很多现代Linux分发版本都在使用。尽管你可以继续使用`init.d`脚本,但使用`systemd` ‘service’脚本启动Spring Boot应用是有可能的。 假设你在`/var/myapp`目录下安装一个Spring Boot应用,为了将它安装为一个`systemd`服务,你需要按照以下示例创建一个脚本,比如命名为`myapp.service`,然后将它放到`/etc/systemd/system`目录下: ```shell @@ -20,7 +20,7 @@ WantedBy=multi-user.target **提示** 注意`ExecStart`字段没有声明脚本行动命令,也就是说会使用默认的`run`命令。 -注意跟作为`init.d`服务运行不同,使用`systemd`这种方式运行应用,PID文件和控制台日志文件是由系统自己进行管理的,因此必须在‘service’脚本配置正确的字段,具体参考[service unit configuration man page](http://www.freedesktop.org/software/systemd/man/systemd.service.html)。 +注意跟作为`init.d`服务运行不同,使用`systemd`这种方式运行应用,PID文件和控制台日志文件是由系统自己进行管理的,因此必须在‘service’脚本配置正确的字段,具体参考[service unit configuration man page](https://www.freedesktop.org/software/systemd/man/systemd.service.html)。 使用以下命令标识应用自动在系统boot上启动: ```shell From 2f6578c9c6d281d91763e2553b07b53caf8fcdef Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E7=83=AD=E5=BF=83=E5=B8=82=E6=B0=91=E9=92=9F=E5=B0=8F?= =?UTF-8?q?=E5=BC=BA?= Date: Sun, 17 Nov 2019 15:29:19 +0800 Subject: [PATCH 624/865] Update and rename 59.2.3 Customizing the startup script.md to 61.2.3 Customizing the Startup Script.md --- ...cript.md => 61.2.3 Customizing the Startup Script.md} | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) rename VI. Deploying Spring Boot Applications/{59.2.3 Customizing the startup script.md => 61.2.3 Customizing the Startup Script.md} (85%) diff --git a/VI. Deploying Spring Boot Applications/59.2.3 Customizing the startup script.md b/VI. Deploying Spring Boot Applications/61.2.3 Customizing the Startup Script.md similarity index 85% rename from VI. Deploying Spring Boot Applications/59.2.3 Customizing the startup script.md rename to VI. Deploying Spring Boot Applications/61.2.3 Customizing the Startup Script.md index 8ecf1565..21e361d4 100644 --- a/VI. Deploying Spring Boot Applications/59.2.3 Customizing the startup script.md +++ b/VI. Deploying Spring Boot Applications/61.2.3 Customizing the Startup Script.md @@ -1,10 +1,10 @@ -### 59.2.3 自定义启动脚本 +### 61.2.3 自定义启动脚本 Maven或Gradle插件生成的默认内嵌启动脚本可以通过很多方法自定义,对于大多数开发者,使用默认脚本和一些自定义通常就足够了。如果发现不能自定义需要的东西,你可以使用`embeddedLaunchScript`选项生成自己的文件。 **在脚本生成时自定义** -自定义写入jar文件的启动脚本元素是有意义的,例如,为`init.d`脚本提供`description`,既然知道这会展示到前端,你可能会在生成jar时提供它。 +自定义写入jar文件的启动脚本元素是有意义的。例如,为`init.d`脚本提供“description”,既然知道这会展示到前端(并且,它不需改变),你可能会在生成jar时提供它。 为了自定义写入的元素,你需要为Spring Boot Maven或Gradle插件指定`embeddedLaunchScriptProperties`选项。 @@ -22,6 +22,7 @@ Maven或Gradle插件生成的默认内嵌启动脚本可以通过很多方法自 |`initInfoDescription`|“INIT INFO”部分的`Description`,对于Gradle默认为`Spring Boot Application`,对于Maven默认为`${project.description}`(失败会回退到`${project.name}`)| |`initInfoChkconfig`|“INIT INFO”部分的`chkconfig`,默认为`2345 99 01`| |`confFolder`|`CONF_FOLDER`的默认值,默认为包含jar的文件夹| +|`inlinedConfScript`|对应该内联到默认启动脚本中的文件脚本的引用。这可以用来在加载任何外部配置文件之前设置环境变量,比如`JAVA_OPTS`| |`logFolder`|`LOG_FOLDER`的默认值,只对`init.d`服务有效| |`logFilename`|`LOG_FILENAME`的默认值,只对`init.d`服务有效| |`pidFolder`|`PID_FOLDER`的默认值,只对`init.d`服务有效| @@ -51,7 +52,7 @@ Maven或Gradle插件生成的默认内嵌启动脚本可以通过很多方法自 |`DEBUG`|如果shell实例的`-x`标识有设值,则你能轻松看到脚本的处理逻辑| |`STOP_WAIT_TIME`|强制关闭应用之前的等待时间,单位为秒(默认为`60`秒)| -**注** `PID_FOLDER`,`LOG_FOLDER`和`LOG_FILENAME`变量只对`init.d`服务有效。对于`systemd`等价的自定义方式是使用‘service’脚本。 +**注** `PID_FOLDER`,`LOG_FOLDER`和`LOG_FILENAME`变量只对`init.d`服务有效。对于`systemd`等价的自定义方式是使用‘service’脚本。有关详细信息,请参阅[服务单元配置手册页](https://www.freedesktop.org/software/systemd/man/systemd.service.html)。 如果`JARFILE`和`APP_NAME`出现异常,上面的设置可以使用一个`.conf`文件进行配置。该文件预期是放到跟jar文件临近的地方,并且名字相同,但后缀为`.conf`而不是`.jar`。例如,一个命名为`/var/myapp/myapp.jar`的jar将使用名为`/var/myapp/myapp.conf`的配置文件: @@ -62,4 +63,4 @@ LOG_FOLDER=/custom/log/folder ``` **注** 如果不喜欢配置文件放到jar附近,你可以使用`CONF_FOLDER`环境变量指定文件的位置。 -想要学习如何正确的保护文件可以参考[the guidelines for securing an init.d service.](the guidelines for securing an init.d service)。 +想要学习如何正确的保护文件可以参考[the guidelines for securing an init.d service.](https://docs.spring.io/spring-boot/docs/2.0.0.RELEASE/reference/htmlsingle/#deployment-initd-service-securing)。 From 3c006f316e2681ebf20f006913659883a2fd5fb7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E7=83=AD=E5=BF=83=E5=B8=82=E6=B0=91=E9=92=9F=E5=B0=8F?= =?UTF-8?q?=E5=BC=BA?= Date: Sun, 17 Nov 2019 15:31:21 +0800 Subject: [PATCH 625/865] Update and rename 59.3 Microsoft Windows services.md to 61.3 Microsoft Windows services.md --- .../59.3 Microsoft Windows services.md | 3 --- .../61.3 Microsoft Windows services.md | 5 +++++ 2 files changed, 5 insertions(+), 3 deletions(-) delete mode 100644 VI. Deploying Spring Boot Applications/59.3 Microsoft Windows services.md create mode 100644 VI. Deploying Spring Boot Applications/61.3 Microsoft Windows services.md diff --git a/VI. Deploying Spring Boot Applications/59.3 Microsoft Windows services.md b/VI. Deploying Spring Boot Applications/59.3 Microsoft Windows services.md deleted file mode 100644 index 1864310e..00000000 --- a/VI. Deploying Spring Boot Applications/59.3 Microsoft Windows services.md +++ /dev/null @@ -1,3 +0,0 @@ -### 59.3 Microsoft Windows服务 - -在Window上,你可以使用[winsw](https://github.com/kohsuke/winsw)启动Spring Boot应用。这里有个单独维护的[示例](https://github.com/snicoll-scratches/spring-boot-daemon)为你演示了怎么一步步为Spring Boot应用创建Windows服务。 diff --git a/VI. Deploying Spring Boot Applications/61.3 Microsoft Windows services.md b/VI. Deploying Spring Boot Applications/61.3 Microsoft Windows services.md new file mode 100644 index 00000000..82e69f7f --- /dev/null +++ b/VI. Deploying Spring Boot Applications/61.3 Microsoft Windows services.md @@ -0,0 +1,5 @@ +### 61.3 Microsoft Windows服务 + +在Window上,你可以使用[winsw](https://github.com/kohsuke/winsw)启动Spring Boot应用。 + +这里有个单独维护的[示例](https://github.com/snicoll-scratches/spring-boot-daemon)为你演示了怎么一步步为Spring Boot应用创建Windows服务。 From 25acecc7a530bda9ffdc6ffde60258d30f51f3f2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E7=83=AD=E5=BF=83=E5=B8=82=E6=B0=91=E9=92=9F=E5=B0=8F?= =?UTF-8?q?=E5=BC=BA?= Date: Sun, 17 Nov 2019 15:31:48 +0800 Subject: [PATCH 626/865] Rename 61.3 Microsoft Windows services.md to 61.3 Microsoft Windows Services.md --- ...oft Windows services.md => 61.3 Microsoft Windows Services.md} | 0 1 file changed, 0 insertions(+), 0 deletions(-) rename VI. Deploying Spring Boot Applications/{61.3 Microsoft Windows services.md => 61.3 Microsoft Windows Services.md} (100%) diff --git a/VI. Deploying Spring Boot Applications/61.3 Microsoft Windows services.md b/VI. Deploying Spring Boot Applications/61.3 Microsoft Windows Services.md similarity index 100% rename from VI. Deploying Spring Boot Applications/61.3 Microsoft Windows services.md rename to VI. Deploying Spring Boot Applications/61.3 Microsoft Windows Services.md From 1bb5c20f903fc5f6bec3a7d49e3abf1d8b60b91e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E7=83=AD=E5=BF=83=E5=B8=82=E6=B0=91=E9=92=9F=E5=B0=8F?= =?UTF-8?q?=E5=BC=BA?= Date: Sun, 17 Nov 2019 15:35:45 +0800 Subject: [PATCH 627/865] Update and rename 60. What to read next.md to 62. What to Read Next.md --- .../60. What to read next.md | 5 ----- .../62. What to Read Next.md | 5 +++++ 2 files changed, 5 insertions(+), 5 deletions(-) delete mode 100644 VI. Deploying Spring Boot Applications/60. What to read next.md create mode 100644 VI. Deploying Spring Boot Applications/62. What to Read Next.md diff --git a/VI. Deploying Spring Boot Applications/60. What to read next.md b/VI. Deploying Spring Boot Applications/60. What to read next.md deleted file mode 100644 index 7dfe7b5d..00000000 --- a/VI. Deploying Spring Boot Applications/60. What to read next.md +++ /dev/null @@ -1,5 +0,0 @@ -### 60. 接下来阅读什么 - -打开[Cloud Foundry](http://www.cloudfoundry.com/),[Heroku](https://www.heroku.com/),[OpenShift](https://www.openshift.com/)和[Boxfuse](https://boxfuse.com/)网站获取更多Paas能提供的特性信息。这里只提到4个比较流行的Java PaaS提供商,由于Spring Boot遵从基于云的部署原则,所以你也可以自由考虑其他提供商。 - -下章节将继续讲解[Spring Boot CLI](https://docs.spring.io/spring-boot/docs/2.0.0.RELEASE/reference/htmlsingle/#cli),你也可以直接跳到[build tool plugins](https://docs.spring.io/spring-boot/docs/2.0.0.RELEASE/reference/htmlsingle/#build-tool-plugins)。 diff --git a/VI. Deploying Spring Boot Applications/62. What to Read Next.md b/VI. Deploying Spring Boot Applications/62. What to Read Next.md new file mode 100644 index 00000000..83a4df32 --- /dev/null +++ b/VI. Deploying Spring Boot Applications/62. What to Read Next.md @@ -0,0 +1,5 @@ +### 62. 接下来阅读什么 + +打开[Cloud Foundry](https://www.cloudfoundry.com/),[Heroku](https://www.heroku.com/),[OpenShift](https://www.openshift.com/)和[Boxfuse](https://boxfuse.com/)网站获取更多Paas能提供的特性信息。这里只提到4个比较流行的Java PaaS提供商,由于Spring Boot遵从基于云的部署原则,所以你也可以自由考虑其他提供商。 + +下章节将继续讲解[Spring Boot CLI](https://docs.spring.io/spring-boot/docs/2.0.0.RELEASE/reference/htmlsingle/#cli)。你也可以直接跳到[构建工具插件](https://docs.spring.io/spring-boot/docs/2.0.0.RELEASE/reference/htmlsingle/#build-tool-plugins)。 From 5b0b37bd5e962a21a40b720667b1c3075b318349 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E7=83=AD=E5=BF=83=E5=B8=82=E6=B0=91=E9=92=9F=E5=B0=8F?= =?UTF-8?q?=E5=BC=BA?= Date: Sat, 23 Nov 2019 14:26:33 +0800 Subject: [PATCH 628/865] Update SUMMARY.md --- SUMMARY.md | 32 ++++++++++++++++---------------- 1 file changed, 16 insertions(+), 16 deletions(-) diff --git a/SUMMARY.md b/SUMMARY.md index 7cb1b934..1d347dcc 100644 --- a/SUMMARY.md +++ b/SUMMARY.md @@ -414,22 +414,22 @@ * [61.3 Microsoft Windows服务](VI. Deploying Spring Boot Applications/61.3 Microsoft Windows Services.md) * [62. 接下来阅读什么](VI. Deploying Spring Boot Applications/62. What to Read Next.md) * [VII. Spring Boot CLI](VII. Spring Boot CLI/README.md) - * [61. 安装CLI](VII. Spring Boot CLI/61. Installing the CLI.md) - * [62. 使用CLI](VII. Spring Boot CLI/62. Using the CLI.md) - * [62.1 使用CLI运行应用](VII. Spring Boot CLI/62.1. Running applications using the CLI.md) - * [62.1.1 推断"grab"依赖](VII. Spring Boot CLI/62.1.1 Deduced “grab” dependencies.md) - * [62.1.2 推断"grab"坐标](VII. Spring Boot CLI/62.1.2 Deduced “grab” coordinates.md) - * [62.1.3 默认import语句](VII. Spring Boot CLI/62.1.3 Default import statements.md) - * [62.1.4 自动创建main方法](VII. Spring Boot CLI/62.1.4 Automatic main method.md) - * [62.1.5 自定义依赖管理](VII. Spring Boot CLI/62.1.5 Custom dependency management.md) - * [62.2 多源文件应用](VII. Spring Boot CLI/62.2 Applications with multiple source files.md) - * [62.3 应用打包](VII. Spring Boot CLI/62.3 Packaging your application.md) - * [62.4 初始化新工程](VII. Spring Boot CLI/62.4 Initialize a new project.md) - * [62.5 使用内嵌shell](VII. Spring Boot CLI/62.5 Using the embedded shell.md) - * [62.6 为CLI添加扩展](VII. Spring Boot CLI/62.6 Adding extensions to the CLI.md) - * [63. 使用Groovy beans DSL开发应用](VII. Spring Boot CLI/63. Developing application with the Groovy beans DSL.md) - * [64. 使用settings.xml配置CLI](VII. Spring Boot CLI/64. Configuring the CLI with settings.xml.md) - * [65. 接下来阅读什么](VII. Spring Boot CLI/65. What to read next.md) + * [63. 安装CLI](VII. Spring Boot CLI/63. Installing the CLI.md) + * [64. 使用CLI](VII. Spring Boot CLI/64. Using the CLI.md) + * [64.1 使用CLI运行应用](VII. Spring Boot CLI/64.1. Running Applications using the CLI.md) + * [64.1.1 推断"grab"依赖](VII. Spring Boot CLI/64.1.1 Deduced “grab” Dependencies.md) + * [64.1.2 推断"grab"坐标](VII. Spring Boot CLI/64.1.2 Deduced “grab” Coordinates.md) + * [64.1.3 默认import语句](VII. Spring Boot CLI/64.1.3 Default Import Statements.md) + * [64.1.4 自动创建main方法](VII. Spring Boot CLI/64.1.4 Automatic Main Method.md) + * [64.1.5 自定义依赖管理](VII. Spring Boot CLI/62.1.5 Custom Dependency Management.md) + * [64.2 多源文件应用](VII. Spring Boot CLI/64.2 Applications with Multiple Source Files.md) + * [64.3 应用打包](VII. Spring Boot CLI/64.3 Packaging Your Application.md) + * [64.4 初始化新工程](VII. Spring Boot CLI/64.4 Initialize a New Project.md) + * [64.5 使用内嵌shell](VII. Spring Boot CLI/64.5 Using the Embedded Shell.md) + * [64.6 为CLI添加扩展](VII. Spring Boot CLI/64.6 Adding Extensions to the CLI.md) + * [65. 使用Groovy beans DSL开发应用](VII. Spring Boot CLI/65. Developing Application with the Groovy Beans DSL.md) + * [66. 使用settings.xml配置CLI](VII. Spring Boot CLI/66. Configuring the CLI with settings.xml.md) + * [67. 接下来阅读什么](VII. Spring Boot CLI/67. What to Read Next.md) * [VIII. 构建工具插件](VIII. Build tool plugins/README.md) * [66. Spring Boot Maven插件](VIII. Build tool plugins/66. Spring Boot Maven plugin.md) * [66.1 包含该插件](VIII. Build tool plugins/66.1 Including the plugin.md) From 7e1da4444a76e1fed02ee29b288c7731e5fa49bd Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E7=83=AD=E5=BF=83=E5=B8=82=E6=B0=91=E9=92=9F=E5=B0=8F?= =?UTF-8?q?=E5=BC=BA?= Date: Sat, 23 Nov 2019 14:35:27 +0800 Subject: [PATCH 629/865] Update and rename 61. Installing the CLI.md to 63. Installing the CLI.md --- VII. Spring Boot CLI/61. Installing the CLI.md | 3 --- VII. Spring Boot CLI/63. Installing the CLI.md | 3 +++ 2 files changed, 3 insertions(+), 3 deletions(-) delete mode 100644 VII. Spring Boot CLI/61. Installing the CLI.md create mode 100644 VII. Spring Boot CLI/63. Installing the CLI.md diff --git a/VII. Spring Boot CLI/61. Installing the CLI.md b/VII. Spring Boot CLI/61. Installing the CLI.md deleted file mode 100644 index d7e6f881..00000000 --- a/VII. Spring Boot CLI/61. Installing the CLI.md +++ /dev/null @@ -1,3 +0,0 @@ -### 61. 安装CLI - -你可以手动安装Spring Boot CLI,也可以使用SDKMAN!(SDK管理器)或Homebrew,MacPorts(如果你是一个OSX用户),具体安装指令参考"Getting started"的[Section 10.2, “Installing the Spring Boot CLI” ](../II. Getting started/10.2. Installing the Spring Boot CLI.md)章节。 diff --git a/VII. Spring Boot CLI/63. Installing the CLI.md b/VII. Spring Boot CLI/63. Installing the CLI.md new file mode 100644 index 00000000..7450527e --- /dev/null +++ b/VII. Spring Boot CLI/63. Installing the CLI.md @@ -0,0 +1,3 @@ +### 63. 安装CLI + +你可以使用SDKMAN!(SDK管理器),或者如果你是一个OSX用户的话,你可以使用Homebrew、MacPorts,手动安装Spring Boot CLI(命令行界面)。具体安装说明,请参考"开始"那一章的[10.2. Spring Boot CLI安装](https://docs.spring.io/spring-boot/docs/2.0.0.RELEASE/reference/htmlsingle/#getting-started-installing-the-cli)。 From 61dcbee49ab745857606c0deeb0c3ce00762c85c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E7=83=AD=E5=BF=83=E5=B8=82=E6=B0=91=E9=92=9F=E5=B0=8F?= =?UTF-8?q?=E5=BC=BA?= Date: Sat, 23 Nov 2019 14:38:46 +0800 Subject: [PATCH 630/865] Update and rename 62. Using the CLI.md to 64. Using the CLI.md --- .../{62. Using the CLI.md => 64. Using the CLI.md} | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) rename VII. Spring Boot CLI/{62. Using the CLI.md => 64. Using the CLI.md} (79%) diff --git a/VII. Spring Boot CLI/62. Using the CLI.md b/VII. Spring Boot CLI/64. Using the CLI.md similarity index 79% rename from VII. Spring Boot CLI/62. Using the CLI.md rename to VII. Spring Boot CLI/64. Using the CLI.md index 0793801d..2910b07c 100644 --- a/VII. Spring Boot CLI/62. Using the CLI.md +++ b/VII. Spring Boot CLI/64. Using the CLI.md @@ -1,6 +1,6 @@ -### 62. 使用CLI +### 64. 使用CLI -一旦安装好CLI,你可以输入`spring`来运行它。如果不使用任何参数运行`spring`,将会展现一个简单的帮助界面: +一旦安装了CLI,就可以通过在命令行输入`spring`并按Enter来运行它。如果不使用任何参数运行`spring`,将会展现一个简单的帮助界面: ```shell $ spring usage: spring [--help] [--version] @@ -13,7 +13,8 @@ Available commands are: ... more command help is shown here ``` -你可以使用`help`获取任何支持命令的详细信息,例如: + +你可以输入`help`获取任何支持命令的详细信息,例如: ```shell $ spring help run spring run - Run a spring groovy script From 0c0ce144134afb1d883e07e7fe4a80a13e58940b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E7=83=AD=E5=BF=83=E5=B8=82=E6=B0=91=E9=92=9F=E5=B0=8F?= =?UTF-8?q?=E5=BC=BA?= Date: Sat, 23 Nov 2019 14:46:50 +0800 Subject: [PATCH 631/865] Update and rename 62.1. Running applications using the CLI.md to 64.1. Running Applications with the CLI.md --- ... the CLI.md => 64.1. Running Applications with the CLI.md} | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) rename VII. Spring Boot CLI/{62.1. Running applications using the CLI.md => 64.1. Running Applications with the CLI.md} (74%) diff --git a/VII. Spring Boot CLI/62.1. Running applications using the CLI.md b/VII. Spring Boot CLI/64.1. Running Applications with the CLI.md similarity index 74% rename from VII. Spring Boot CLI/62.1. Running applications using the CLI.md rename to VII. Spring Boot CLI/64.1. Running Applications with the CLI.md index a7d23e8a..3cec2dde 100644 --- a/VII. Spring Boot CLI/62.1. Running applications using the CLI.md +++ b/VII. Spring Boot CLI/64.1. Running Applications with the CLI.md @@ -1,4 +1,4 @@ -### 62.1 使用CLI运行应用 +### 64.1 使用CLI运行应用 你可以使用`run`命令编译和运行Groovy源代码。Spring Boot CLI完全自包含,以致于你不需要安装任何外部的Groovy。 @@ -28,3 +28,5 @@ $ spring run hello.groovy -- --server.port=9000 ```shell $ JAVA_OPTS=-Xmx1024m spring run hello.groovy ``` + +**注** 在微软Windows上设置`JAVA_OPTS`时,请确保引用整个指令,如`set "JAVA_OPTS=-Xms256m -Xmx2048m"`。这样做可以确保正确地将值传递给进程。 From f188189f382e51c919a159c10b93ed293c4df375 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E7=83=AD=E5=BF=83=E5=B8=82=E6=B0=91=E9=92=9F=E5=B0=8F?= =?UTF-8?q?=E5=BC=BA?= Date: Sat, 23 Nov 2019 14:47:35 +0800 Subject: [PATCH 632/865] Update SUMMARY.md --- SUMMARY.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/SUMMARY.md b/SUMMARY.md index 1d347dcc..d26769a7 100644 --- a/SUMMARY.md +++ b/SUMMARY.md @@ -416,7 +416,7 @@ * [VII. Spring Boot CLI](VII. Spring Boot CLI/README.md) * [63. 安装CLI](VII. Spring Boot CLI/63. Installing the CLI.md) * [64. 使用CLI](VII. Spring Boot CLI/64. Using the CLI.md) - * [64.1 使用CLI运行应用](VII. Spring Boot CLI/64.1. Running Applications using the CLI.md) + * [64.1 使用CLI运行应用](VII. Spring Boot CLI/64.1. Running Applications with the CLI.md) * [64.1.1 推断"grab"依赖](VII. Spring Boot CLI/64.1.1 Deduced “grab” Dependencies.md) * [64.1.2 推断"grab"坐标](VII. Spring Boot CLI/64.1.2 Deduced “grab” Coordinates.md) * [64.1.3 默认import语句](VII. Spring Boot CLI/64.1.3 Default Import Statements.md) From 61b08b2d90085c34a5e7c1ce28491144f91e3da9 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E7=83=AD=E5=BF=83=E5=B8=82=E6=B0=91=E9=92=9F=E5=B0=8F?= =?UTF-8?q?=E5=BC=BA?= Date: Sat, 23 Nov 2019 15:05:40 +0800 Subject: [PATCH 633/865] =?UTF-8?q?Update=20and=20rename=2062.1.1=20Deduce?= =?UTF-8?q?d=20=E2=80=9Cgrab=E2=80=9D=20dependencies.md=20to=2064.1.1=20De?= =?UTF-8?q?duced=20=E2=80=9Cgrab=E2=80=9D=20Dependencies.md?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- ...342\200\234grab\342\200\235 Dependencies.md" | 17 ++++++++--------- 1 file changed, 8 insertions(+), 9 deletions(-) rename "VII. Spring Boot CLI/62.1.1 Deduced \342\200\234grab\342\200\235 dependencies.md" => "VII. Spring Boot CLI/64.1.1 Deduced \342\200\234grab\342\200\235 Dependencies.md" (55%) diff --git "a/VII. Spring Boot CLI/62.1.1 Deduced \342\200\234grab\342\200\235 dependencies.md" "b/VII. Spring Boot CLI/64.1.1 Deduced \342\200\234grab\342\200\235 Dependencies.md" similarity index 55% rename from "VII. Spring Boot CLI/62.1.1 Deduced \342\200\234grab\342\200\235 dependencies.md" rename to "VII. Spring Boot CLI/64.1.1 Deduced \342\200\234grab\342\200\235 Dependencies.md" index 29e05b4b..153deb23 100644 --- "a/VII. Spring Boot CLI/62.1.1 Deduced \342\200\234grab\342\200\235 dependencies.md" +++ "b/VII. Spring Boot CLI/64.1.1 Deduced \342\200\234grab\342\200\235 Dependencies.md" @@ -1,12 +1,12 @@ -###62.1.1 推断"grab"依赖 +### 64.1.1 推断"grab"依赖 标准的Groovy包含一个`@Grab`注解,它允许你声明对第三方库的依赖。这项有用的技术允许Groovy以和Maven或Gradle相同的方式下载jars,但不需要使用构建工具。 -Spring Boot进一步延伸了该技术,它会基于你的代码尝试推导你"grab"哪个库。例如,由于`WebApplication`代码上使用了`@RestController`注解,"Tomcat"和"Spring MVC"将被获取(grabbed)。 +Spring Boot进一步延伸了该技术,它会基于你的代码尝试推导你"grab"哪个库。例如,由于`WebApplication`代码上使用了`@RestController`注解。Spring Boot会获取"Tomcat"和"Spring MVC"。 -下面items被用作"grab hints": +下列条目被用作"grab提示": -|items|Grabs| +|条目|Grabs| |-----|:-----| |`JdbcTemplate`,`NamedParameterJdbcTemplate`,`DataSource`|JDBC应用| |`@EnableJms`|JMS应用| @@ -14,12 +14,11 @@ Spring Boot进一步延伸了该技术,它会基于你的代码尝试推导你 |`@Test`|JUnit| |`@EnableRabbit`|RabbitMQ| |`@EnableReactor`|项目重构| -|extends `Specification`|Spock test| +|extends `Specification`|Spock测试| |`@EnableBatchProcessing`|Spring Batch| -|`@MessageEndpoint`,`@EnableIntegrationPatterns`|Spring集成| -|`@EnableDeviceResolver`|Spring Mobile| +|`@MessageEndpoint`,`@EnableIntegration`|Spring集成| |`@Controller`,`@RestController`,`@EnableWebMvc`|Spring MVC + 内嵌Tomcat| |`@EnableWebSecurity`|Spring Security| -|`@EnableTransactionManagement`|Spring Transaction Management| +|`@EnableTransactionManagement`|Spring事务管理| -**注** 想要理解自定义是如何生效的,可以查看Spring Boot CLI源码中的[CompilerAutoConfiguration](http://github.com/spring-projects/spring-boot/tree/master/spring-boot-cli/src/main/java/org/springframework/boot/cli/compiler/CompilerAutoConfiguration.java)子类。 +**注** 想要理解自定义是如何生效的,可以查看Spring Boot CLI源码中的[CompilerAutoConfiguration](https://github.com/spring-projects/spring-boot/tree/v2.0.0.RELEASE/spring-boot-project/spring-boot-cli/src/main/java/org/springframework/boot/cli/compiler/CompilerAutoConfiguration.java)子类。 From 66b2e43b65a4c49392639e72e8806e2ee1ba53ab Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E7=83=AD=E5=BF=83=E5=B8=82=E6=B0=91=E9=92=9F=E5=B0=8F?= =?UTF-8?q?=E5=BC=BA?= Date: Sat, 23 Nov 2019 15:13:25 +0800 Subject: [PATCH 634/865] =?UTF-8?q?Update=20and=20rename=2062.1.2=20Deduce?= =?UTF-8?q?d=20=E2=80=9Cgrab=E2=80=9D=20coordinates.md=20to=2064.1.2=20Ded?= =?UTF-8?q?uced=20=E2=80=9Cgrab=E2=80=9D=20Coordinates.md?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- ....1.2 Deduced \342\200\234grab\342\200\235 coordinates.md" | 2 -- ....1.2 Deduced \342\200\234grab\342\200\235 Coordinates.md" | 5 +++++ 2 files changed, 5 insertions(+), 2 deletions(-) delete mode 100644 "VII. Spring Boot CLI/62.1.2 Deduced \342\200\234grab\342\200\235 coordinates.md" create mode 100644 "VII. Spring Boot CLI/64.1.2 Deduced \342\200\234grab\342\200\235 Coordinates.md" diff --git "a/VII. Spring Boot CLI/62.1.2 Deduced \342\200\234grab\342\200\235 coordinates.md" "b/VII. Spring Boot CLI/62.1.2 Deduced \342\200\234grab\342\200\235 coordinates.md" deleted file mode 100644 index 86e6fe62..00000000 --- "a/VII. Spring Boot CLI/62.1.2 Deduced \342\200\234grab\342\200\235 coordinates.md" +++ /dev/null @@ -1,2 +0,0 @@ -###62.1.2 推断"grab"坐标 -Spring Boot扩展了Groovy标准`@Grab`注解,使其能够允许你指定一个没有`group`或`version`的依赖,例如`@Grab('freemarker')`。Spring Boot使用默认依赖元数据推断artifact’s的group和version,需要注意的是默认元数据和你使用的CLI版本有绑定关系-只有在迁移到新版本的CLI时它才会改变,这样你就可以控制何时改变依赖了,在[附录](https://docs.spring.io/spring-boot/docs/2.0.0.RELEASE/reference/htmlsingle/#appendix-dependency-versions)的表格中可以查看默认元数据包含的依赖和它们的版本。 diff --git "a/VII. Spring Boot CLI/64.1.2 Deduced \342\200\234grab\342\200\235 Coordinates.md" "b/VII. Spring Boot CLI/64.1.2 Deduced \342\200\234grab\342\200\235 Coordinates.md" new file mode 100644 index 00000000..0ee5a9a8 --- /dev/null +++ "b/VII. Spring Boot CLI/64.1.2 Deduced \342\200\234grab\342\200\235 Coordinates.md" @@ -0,0 +1,5 @@ +### 64.1.2 推断"grab"坐标 + +Spring Boot扩展了Groovy标准`@Grab`注解,使其能够允许你指定一个没有`group`或`version`的依赖,例如`@Grab('freemarker')`。Spring Boot使用默认依赖元数据推断artifact’s的group和version。 + +**注** 需要注意的是默认元数据和你使用的CLI版本有绑定关系-只有在迁移到新版本的CLI时它才会改变,这样你就可以控制何时改变依赖了,在[附录](https://docs.spring.io/spring-boot/docs/2.0.0.RELEASE/reference/htmlsingle/#appendix-dependency-versions)的表格中可以查看默认元数据包含的依赖和它们的版本。 From 57896146a2b619f3f8e0288c3ca5d560e057824b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E7=83=AD=E5=BF=83=E5=B8=82=E6=B0=91=E9=92=9F=E5=B0=8F?= =?UTF-8?q?=E5=BC=BA?= Date: Sat, 23 Nov 2019 15:15:21 +0800 Subject: [PATCH 635/865] Update and rename 62.1.3 Default import statements.md to 64.1.3 Default Import Statements.md --- ...import statements.md => 64.1.3 Default Import Statements.md} | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) rename VII. Spring Boot CLI/{62.1.3 Default import statements.md => 64.1.3 Default Import Statements.md} (91%) diff --git a/VII. Spring Boot CLI/62.1.3 Default import statements.md b/VII. Spring Boot CLI/64.1.3 Default Import Statements.md similarity index 91% rename from VII. Spring Boot CLI/62.1.3 Default import statements.md rename to VII. Spring Boot CLI/64.1.3 Default Import Statements.md index 57a1bace..ae9b2a23 100644 --- a/VII. Spring Boot CLI/62.1.3 Default import statements.md +++ b/VII. Spring Boot CLI/64.1.3 Default Import Statements.md @@ -1,4 +1,4 @@ -###62.1.3 默认import语句 +### 64.1.3 默认import语句 为了帮助你减少Groovy代码量,一些`import`语句被自动包含进来了。注意上面的示例中引用`@Component`,`@RestController`和`@RequestMapping`而没有使用全限定名或`import`语句。 From 15ff76cd68d027914585ea49cbfb32fc5a63d4ea Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E7=83=AD=E5=BF=83=E5=B8=82=E6=B0=91=E9=92=9F=E5=B0=8F?= =?UTF-8?q?=E5=BC=BA?= Date: Sat, 23 Nov 2019 15:17:12 +0800 Subject: [PATCH 636/865] Update and rename 62.1.4 Automatic main method.md to 64.1.4 Automatic Main Method.md --- VII. Spring Boot CLI/62.1.4 Automatic main method.md | 3 --- VII. Spring Boot CLI/64.1.4 Automatic Main Method.md | 3 +++ 2 files changed, 3 insertions(+), 3 deletions(-) delete mode 100644 VII. Spring Boot CLI/62.1.4 Automatic main method.md create mode 100644 VII. Spring Boot CLI/64.1.4 Automatic Main Method.md diff --git a/VII. Spring Boot CLI/62.1.4 Automatic main method.md b/VII. Spring Boot CLI/62.1.4 Automatic main method.md deleted file mode 100644 index b3809be9..00000000 --- a/VII. Spring Boot CLI/62.1.4 Automatic main method.md +++ /dev/null @@ -1,3 +0,0 @@ -###62.1.4 自动创建main方法 - -跟等效的Java应用不同,你不需要在Groovy脚本中添加一个`public static void main(String[] args)`方法。Spring Boot会使用你编译后的代码自动创建一个`SpringApplication`。 diff --git a/VII. Spring Boot CLI/64.1.4 Automatic Main Method.md b/VII. Spring Boot CLI/64.1.4 Automatic Main Method.md new file mode 100644 index 00000000..1e50939d --- /dev/null +++ b/VII. Spring Boot CLI/64.1.4 Automatic Main Method.md @@ -0,0 +1,3 @@ +### 64.1.4 自动创建main方法 + +跟等效的Java应用不同,你不需要在`Groovy`脚本中添加一个`public static void main(String[] args)`方法。Spring Boot会使用你编译后的代码自动创建一个`SpringApplication`。 From 2eec9fff18bb7cf29f2ad4c399432cbba7288be2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E7=83=AD=E5=BF=83=E5=B8=82=E6=B0=91=E9=92=9F=E5=B0=8F?= =?UTF-8?q?=E5=BC=BA?= Date: Sat, 23 Nov 2019 15:26:22 +0800 Subject: [PATCH 637/865] Update and rename 62.1.5 Custom dependency management.md to 64.1.5 Custom Dependency Management.md --- ... management.md => 64.1.5 Custom Dependency Management.md} | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) rename VII. Spring Boot CLI/{62.1.5 Custom dependency management.md => 64.1.5 Custom Dependency Management.md} (91%) diff --git a/VII. Spring Boot CLI/62.1.5 Custom dependency management.md b/VII. Spring Boot CLI/64.1.5 Custom Dependency Management.md similarity index 91% rename from VII. Spring Boot CLI/62.1.5 Custom dependency management.md rename to VII. Spring Boot CLI/64.1.5 Custom Dependency Management.md index 1e4a0a43..a36cb09b 100644 --- a/VII. Spring Boot CLI/62.1.5 Custom dependency management.md +++ b/VII. Spring Boot CLI/64.1.5 Custom Dependency Management.md @@ -1,4 +1,5 @@ -### 62.1.5 自定义依赖管理 +### 64.1.5 自定义依赖管理 + 默认情况下,CLI使用在解析`@Grab`依赖时`spring-boot-dependencies`声明的依赖管理,其他的依赖管理会覆盖默认的依赖管理,并可以通过`@DependencyManagementBom`注解进行配置。该注解的值必须是一个或多个Maven BOMs的候选(`groupId:artifactId:version`)。 例如,以下声明: @@ -12,7 +13,7 @@ @DependencyManagementBom(["com.example.custom-bom:1.0.0", "com.example.another-bom:1.0.0"]) ``` -意味着`another-bom`的依赖将覆盖`custom-bom`依赖。 +这意味着`another-bom`的依赖将覆盖`custom-bom`依赖。 能够使用`@Grab`的地方,你同样可以使用`@DependencyManagementBom`。然而,为了确保依赖管理的一致次序,你在应用中至多使用一次`@DependencyManagementBom`。[Spring IO Platform](http://platform.spring.io/)是一个非常有用的依赖元数据源(Spring Boot的超集),例如: `@DependencyManagementBom('io.spring.platform:platform-bom:1.1.2.RELEASE')`。 From 0db4f1b2195494b6d1469c68cc9c455983eab78e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E7=83=AD=E5=BF=83=E5=B8=82=E6=B0=91=E9=92=9F=E5=B0=8F?= =?UTF-8?q?=E5=BC=BA?= Date: Sat, 23 Nov 2019 15:27:01 +0800 Subject: [PATCH 638/865] Update 64.1.5 Custom Dependency Management.md --- VII. Spring Boot CLI/64.1.5 Custom Dependency Management.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/VII. Spring Boot CLI/64.1.5 Custom Dependency Management.md b/VII. Spring Boot CLI/64.1.5 Custom Dependency Management.md index a36cb09b..ac35f9e9 100644 --- a/VII. Spring Boot CLI/64.1.5 Custom Dependency Management.md +++ b/VII. Spring Boot CLI/64.1.5 Custom Dependency Management.md @@ -15,5 +15,5 @@ ``` 这意味着`another-bom`的依赖将覆盖`custom-bom`依赖。 -能够使用`@Grab`的地方,你同样可以使用`@DependencyManagementBom`。然而,为了确保依赖管理的一致次序,你在应用中至多使用一次`@DependencyManagementBom`。[Spring IO Platform](http://platform.spring.io/)是一个非常有用的依赖元数据源(Spring Boot的超集),例如: +能够使用`@Grab`的地方,你同样可以使用`@DependencyManagementBom`。然而,为了确保依赖管理的一致次序,你在应用中至多使用一次`@DependencyManagementBom`。[Spring IO Platform](https://platform.spring.io/)是一个非常有用的依赖元数据源(Spring Boot的超集),例如: `@DependencyManagementBom('io.spring.platform:platform-bom:1.1.2.RELEASE')`。 From a3e866ab270900dd4a4a6fd46178fa33caaae4c9 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E7=83=AD=E5=BF=83=E5=B8=82=E6=B0=91=E9=92=9F=E5=B0=8F?= =?UTF-8?q?=E5=BC=BA?= Date: Sat, 23 Nov 2019 15:28:58 +0800 Subject: [PATCH 639/865] Update and rename 62.2 Applications with multiple source files.md to 64.2 Applications with Multiple Source Files.md --- .../62.2 Applications with multiple source files.md | 6 ------ .../64.2 Applications with Multiple Source Files.md | 6 ++++++ 2 files changed, 6 insertions(+), 6 deletions(-) delete mode 100644 VII. Spring Boot CLI/62.2 Applications with multiple source files.md create mode 100644 VII. Spring Boot CLI/64.2 Applications with Multiple Source Files.md diff --git a/VII. Spring Boot CLI/62.2 Applications with multiple source files.md b/VII. Spring Boot CLI/62.2 Applications with multiple source files.md deleted file mode 100644 index a5c39f6c..00000000 --- a/VII. Spring Boot CLI/62.2 Applications with multiple source files.md +++ /dev/null @@ -1,6 +0,0 @@ -### 62.2 多源文件应用 - -你可以在所有接收文件输入的命令中使用shell通配符。这允许你轻松处理来自一个目录下的多个文件,例如: -```shell -$ spring run *.groovy -``` diff --git a/VII. Spring Boot CLI/64.2 Applications with Multiple Source Files.md b/VII. Spring Boot CLI/64.2 Applications with Multiple Source Files.md new file mode 100644 index 00000000..fc179c2b --- /dev/null +++ b/VII. Spring Boot CLI/64.2 Applications with Multiple Source Files.md @@ -0,0 +1,6 @@ +### 64.2 多源文件应用 + +你可以在所有接收文件输入的命令中使用shell通配符。这允许你处理来自一个目录下的多个文件,例如: +```shell +$ spring run *.groovy +``` From d93993ddff00ef2d6ac7acafeb2e0f02fb6c5666 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E7=83=AD=E5=BF=83=E5=B8=82=E6=B0=91=E9=92=9F=E5=B0=8F?= =?UTF-8?q?=E5=BC=BA?= Date: Sat, 23 Nov 2019 15:35:57 +0800 Subject: [PATCH 640/865] Update and rename 62.3 Packaging your application.md to 64.3 Packaging Your Application.md --- ...r application.md => 64.3 Packaging Your Application.md} | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) rename VII. Spring Boot CLI/{62.3 Packaging your application.md => 64.3 Packaging Your Application.md} (62%) diff --git a/VII. Spring Boot CLI/62.3 Packaging your application.md b/VII. Spring Boot CLI/64.3 Packaging Your Application.md similarity index 62% rename from VII. Spring Boot CLI/62.3 Packaging your application.md rename to VII. Spring Boot CLI/64.3 Packaging Your Application.md index c0460bb5..76a33b17 100644 --- a/VII. Spring Boot CLI/62.3 Packaging your application.md +++ b/VII. Spring Boot CLI/64.3 Packaging Your Application.md @@ -1,15 +1,16 @@ -### 62.3 应用打包 +### 64.3 应用打包 你可以使用`jar`命令打包应用程序为一个可执行的jar文件,例如: ```shell $ spring jar my-app.jar *.groovy ``` -最终的jar包括编译应用产生的类和所有依赖,这样你就可以使用`java -jar`来执行它了。该jar文件也包含了来自应用classpath的实体。你可以使用`--include`和`--exclude`添加明确的路径(两者都是用逗号分割,同样都接收值为'+'和'-'的前缀,'-'意味着它们将从默认设置中移除),默认包含(includes): +最终的jar包括编译应用产生的类和所有依赖,这样你就可以使用`java -jar`来执行它了。该jar文件也包含了来自应用classpath的实体。你可以使用`--include`和`--exclude`添加或排除明确的路径。两者都是用逗号分割,同样都接收'+'和'-'形式的前缀。'-'意味着它们将从默认设置中移除。默认包含(includes): ```shell public/**, resources/**, static/**, templates/**, META-INF/**, * ``` + 默认排除(excludes): ```shell .*, repository/**, build/**, target/**, **/*.jar, **/*.groovy ``` -查看`spring help jar`可以获得更多信息。 +在命令行中输入`spring help jar`,获得更多信息。 From d12439000fbee0cd87143026b44efc319ea10a44 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E7=83=AD=E5=BF=83=E5=B8=82=E6=B0=91=E9=92=9F=E5=B0=8F?= =?UTF-8?q?=E5=BC=BA?= Date: Sat, 23 Nov 2019 15:43:45 +0800 Subject: [PATCH 641/865] Update and rename 62.4 Initialize a new project.md to 64.4 Initialize a New Project.md --- ...ze a new project.md => 64.4 Initialize a New Project.md} | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) rename VII. Spring Boot CLI/{62.4 Initialize a new project.md => 64.4 Initialize a New Project.md} (93%) diff --git a/VII. Spring Boot CLI/62.4 Initialize a new project.md b/VII. Spring Boot CLI/64.4 Initialize a New Project.md similarity index 93% rename from VII. Spring Boot CLI/62.4 Initialize a new project.md rename to VII. Spring Boot CLI/64.4 Initialize a New Project.md index d4013ece..14af702a 100644 --- a/VII. Spring Boot CLI/62.4 Initialize a new project.md +++ b/VII. Spring Boot CLI/64.4 Initialize a New Project.md @@ -1,4 +1,4 @@ -### 62.4 初始化新工程 +### 64.4 初始化新工程 `init`命令允许你使用[start.spring.io](https://start.spring.io/)在不离开shell的情况下创建一个新的项目,例如: ```shell @@ -6,6 +6,7 @@ $ spring init --dependencies=web,data-jpa my-project Using service at https://start.spring.io Project extracted to '/Users/developer/example/my-project' ``` + 这创建了一个`my-project`目录,它是一个基于Maven且依赖`spring-boot-starter-web`和`spring-boot-starter-data-jpa`的项目。你可以使用`--list`参数列出该服务的能力。 ```shell $ spring init --list @@ -30,7 +31,8 @@ maven-project - Maven Project [format:project, build:maven] (default) ... ``` -`init`命令支持很多选项,查看`help`输出可以获得更多详情。例如,下面的命令创建一个使用Java8和打包为`war`的gradle项目: + +`init`命令支持很多选项,查看`help`输出可以获得更多详情。例如,下面的命令创建一个使用Java8和打包为`war`的Gradle项目: ```shell $ spring init --build=gradle --java-version=1.8 --dependencies=websocket --packaging=war sample-app.zip Using service at https://start.spring.io From af7d1059760bacd0e3bb693f0c11a5975975e8df Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E7=83=AD=E5=BF=83=E5=B8=82=E6=B0=91=E9=92=9F=E5=B0=8F?= =?UTF-8?q?=E5=BC=BA?= Date: Sat, 23 Nov 2019 15:47:04 +0800 Subject: [PATCH 642/865] Update and rename 62.5 Using the embedded shell.md to 64.5 Using the Embedded Shell.md --- ...embedded shell.md => 64.5 Using the Embedded Shell.md} | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) rename VII. Spring Boot CLI/{62.5 Using the embedded shell.md => 64.5 Using the Embedded Shell.md} (74%) diff --git a/VII. Spring Boot CLI/62.5 Using the embedded shell.md b/VII. Spring Boot CLI/64.5 Using the Embedded Shell.md similarity index 74% rename from VII. Spring Boot CLI/62.5 Using the embedded shell.md rename to VII. Spring Boot CLI/64.5 Using the Embedded Shell.md index cd09352b..65246b23 100644 --- a/VII. Spring Boot CLI/62.5 Using the embedded shell.md +++ b/VII. Spring Boot CLI/64.5 Using the Embedded Shell.md @@ -1,13 +1,15 @@ -### 62.5 使用内嵌shell +### 64.5 使用内嵌shell + Spring Boot包括完整的BASH和zsh shells的命令行脚本,如果这两种你都不使用(可能你是一个Window用户),那你可以使用`shell`命令启用一个集成shell。 ```shell $ spring shell Spring Boot (v2.0.0.RELEASE) Hit TAB to complete. Type \'help' and hit RETURN for help, and \'exit' to quit. ``` -从内嵌shell中可以直接运行其他命令: + +在内嵌shell中,可以直接运行其他命令: ```shell $ version Spring CLI v2.0.0.RELEASE ``` -内嵌shell支持ANSI彩色输出和tab补全,如果需要运行一个原生命令,你可以使用`!`前缀,点击`ctrl-c`将退出内嵌shell。 +内嵌shell支持ANSI彩色输出和tab补全。如果需要运行一个原生命令,你可以使用`!`前缀,点击`ctrl-c`将退出内嵌shell。 From 9cbdb4bde5f963265c2ed92caff7c724da239ec5 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E7=83=AD=E5=BF=83=E5=B8=82=E6=B0=91=E9=92=9F=E5=B0=8F?= =?UTF-8?q?=E5=BC=BA?= Date: Sat, 23 Nov 2019 15:48:48 +0800 Subject: [PATCH 643/865] Update and rename 62.6 Adding extensions to the CLI.md to 64.6 Adding Extensions to the CLI.md --- ...sions to the CLI.md => 64.6 Adding Extensions to the CLI.md} | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) rename VII. Spring Boot CLI/{62.6 Adding extensions to the CLI.md => 64.6 Adding Extensions to the CLI.md} (94%) diff --git a/VII. Spring Boot CLI/62.6 Adding extensions to the CLI.md b/VII. Spring Boot CLI/64.6 Adding Extensions to the CLI.md similarity index 94% rename from VII. Spring Boot CLI/62.6 Adding extensions to the CLI.md rename to VII. Spring Boot CLI/64.6 Adding Extensions to the CLI.md index 3383f8c5..08eae2b3 100644 --- a/VII. Spring Boot CLI/62.6 Adding extensions to the CLI.md +++ b/VII. Spring Boot CLI/64.6 Adding Extensions to the CLI.md @@ -1,4 +1,4 @@ -### 62.6 为CLI添加扩展 +### 64.6 为CLI添加扩展 使用`install`命令可以为CLI添加扩展,该命令接收一个或多个格式为`group:artifact:version`的artifact坐标集,例如: ```shell From f59f4bbcc615c3fef627f41e82594c08f1eb5812 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E7=83=AD=E5=BF=83=E5=B8=82=E6=B0=91=E9=92=9F=E5=B0=8F?= =?UTF-8?q?=E5=BC=BA?= Date: Sat, 23 Nov 2019 15:51:33 +0800 Subject: [PATCH 644/865] Update and rename 63. Developing application with the Groovy beans DSL.md to 65. Developing Application with the Groovy Beans DSL.md --- ... => 65. Developing Application with the Groovy Beans DSL.md} | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) rename VII. Spring Boot CLI/{63. Developing application with the Groovy beans DSL.md => 65. Developing Application with the Groovy Beans DSL.md} (91%) diff --git a/VII. Spring Boot CLI/63. Developing application with the Groovy beans DSL.md b/VII. Spring Boot CLI/65. Developing Application with the Groovy Beans DSL.md similarity index 91% rename from VII. Spring Boot CLI/63. Developing application with the Groovy beans DSL.md rename to VII. Spring Boot CLI/65. Developing Application with the Groovy Beans DSL.md index 7d68df5d..9a7f086f 100644 --- a/VII. Spring Boot CLI/63. Developing application with the Groovy beans DSL.md +++ b/VII. Spring Boot CLI/65. Developing Application with the Groovy Beans DSL.md @@ -1,4 +1,4 @@ -### 63. 使用Groovy beans DSL开发应用 +### 65. 使用Groovy beans DSL开发应用 Spring框架4.0版本对`beans{}`"DSL"(借鉴自[Grails](http://grails.org/))提供原生支持,你可以使用相同格式在Groovy应用程序脚本中嵌入bean定义。有时这是引入外部特性的很好方式,比如中间件声明,例如: ```java From 7bceb1b8598798c66dfbd66991602623eacab489 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E7=83=AD=E5=BF=83=E5=B8=82=E6=B0=91=E9=92=9F=E5=B0=8F?= =?UTF-8?q?=E5=BC=BA?= Date: Sat, 23 Nov 2019 15:52:51 +0800 Subject: [PATCH 645/865] Update and rename 64. Configuring the CLI with settings.xml.md to 66. Configuring the CLI with settings.xml.md --- ...ngs.xml.md => 66. Configuring the CLI with settings.xml.md} | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) rename VII. Spring Boot CLI/{64. Configuring the CLI with settings.xml.md => 66. Configuring the CLI with settings.xml.md} (90%) diff --git a/VII. Spring Boot CLI/64. Configuring the CLI with settings.xml.md b/VII. Spring Boot CLI/66. Configuring the CLI with settings.xml.md similarity index 90% rename from VII. Spring Boot CLI/64. Configuring the CLI with settings.xml.md rename to VII. Spring Boot CLI/66. Configuring the CLI with settings.xml.md index 46a9876a..445da720 100644 --- a/VII. Spring Boot CLI/64. Configuring the CLI with settings.xml.md +++ b/VII. Spring Boot CLI/66. Configuring the CLI with settings.xml.md @@ -1,4 +1,5 @@ -### 64. 使用settings.xml配置CLI +### 66. 使用settings.xml配置CLI + Spring Boot CLI使用Maven的依赖解析引擎Aether来解析依赖,它充分利用发现的`~/.m2/settings.xml` Maven设置去配置Aether。 CLI支持以下配置: From 9c58f19a2928df763a7922d1c0d8a0ddd5ae6e9d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E7=83=AD=E5=BF=83=E5=B8=82=E6=B0=91=E9=92=9F=E5=B0=8F?= =?UTF-8?q?=E5=BC=BA?= Date: Sat, 23 Nov 2019 15:56:09 +0800 Subject: [PATCH 646/865] Update and rename 65. What to read next.md to 67. What to Read Next.md --- VII. Spring Boot CLI/65. What to read next.md | 4 ---- VII. Spring Boot CLI/67. What to Read Next.md | 5 +++++ 2 files changed, 5 insertions(+), 4 deletions(-) delete mode 100644 VII. Spring Boot CLI/65. What to read next.md create mode 100644 VII. Spring Boot CLI/67. What to Read Next.md diff --git a/VII. Spring Boot CLI/65. What to read next.md b/VII. Spring Boot CLI/65. What to read next.md deleted file mode 100644 index fa6f44b3..00000000 --- a/VII. Spring Boot CLI/65. What to read next.md +++ /dev/null @@ -1,4 +0,0 @@ -### 65. 接下来阅读什么 -GitHub仓库有一些[groovy脚本示例](https://github.com/spring-projects/spring-boot/tree/v2.0.0.RELEASE/spring-boot-cli/samples)可用于尝试Spring Boot CLI,[源码](https://github.com/spring-projects/spring-boot/tree/v2.0.0.RELEASE/spring-boot-cli/src/main/java/org/springframework/boot/cli)里也有丰富的文档说明。 - -如果发现已触及CLI工具的限制,你可以将应用完全转换为Gradle或Maven构建的groovy工程。下一章节将覆盖Spring Boot的[构建工具](../VIII. Build tool plugins/README.md),这些工具可以跟Gradle或Maven一起使用。 diff --git a/VII. Spring Boot CLI/67. What to Read Next.md b/VII. Spring Boot CLI/67. What to Read Next.md new file mode 100644 index 00000000..ff7e8d7e --- /dev/null +++ b/VII. Spring Boot CLI/67. What to Read Next.md @@ -0,0 +1,5 @@ +### 67. 接下来阅读什么 + +GitHub仓库有一些[groovy脚本示例](https://github.com/spring-projects/spring-boot/tree/v2.0.0.RELEASE/spring-boot-project/spring-boot-cli/samples)可用于尝试Spring Boot CLI。[源码](https://github.com/spring-projects/spring-boot/tree/v2.0.0.RELEASE/spring-boot-project/spring-boot-cli/src/main/java/org/springframework/boot/cli)里也有丰富的文档说明。 + +如果发现已触及CLI工具的限制,你可以将应用完全转换为Gradle或Maven构建的Groovy工程。下一章节将覆盖Spring Boot的[构建工具](https://docs.spring.io/spring-boot/docs/2.0.0.RELEASE/reference/htmlsingle/#build-tool-plugins)。这些工具可以跟Gradle或Maven一起使用。 From 85828ad3c0aafc9f7b07dc30d490701cf8d7cf73 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E7=83=AD=E5=BF=83=E5=B8=82=E6=B0=91=E9=92=9F=E5=B0=8F?= =?UTF-8?q?=E5=BC=BA?= Date: Sat, 23 Nov 2019 16:02:36 +0800 Subject: [PATCH 647/865] Update SUMMARY.md --- SUMMARY.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/SUMMARY.md b/SUMMARY.md index d26769a7..d527d349 100644 --- a/SUMMARY.md +++ b/SUMMARY.md @@ -421,7 +421,7 @@ * [64.1.2 推断"grab"坐标](VII. Spring Boot CLI/64.1.2 Deduced “grab” Coordinates.md) * [64.1.3 默认import语句](VII. Spring Boot CLI/64.1.3 Default Import Statements.md) * [64.1.4 自动创建main方法](VII. Spring Boot CLI/64.1.4 Automatic Main Method.md) - * [64.1.5 自定义依赖管理](VII. Spring Boot CLI/62.1.5 Custom Dependency Management.md) + * [64.1.5 自定义依赖管理](VII. Spring Boot CLI/64.1.5 Custom Dependency Management.md) * [64.2 多源文件应用](VII. Spring Boot CLI/64.2 Applications with Multiple Source Files.md) * [64.3 应用打包](VII. Spring Boot CLI/64.3 Packaging Your Application.md) * [64.4 初始化新工程](VII. Spring Boot CLI/64.4 Initialize a New Project.md) From 070e8a9022df4689b73684c5bc2ac81c5f6e1fac Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E7=83=AD=E5=BF=83=E5=B8=82=E6=B0=91=E9=92=9F=E5=B0=8F?= =?UTF-8?q?=E5=BC=BA?= Date: Tue, 26 Nov 2019 20:40:03 +0800 Subject: [PATCH 648/865] Update README.md --- VIII. Build tool plugins/README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/VIII. Build tool plugins/README.md b/VIII. Build tool plugins/README.md index a726c8bf..d4fd38c3 100644 --- a/VIII. Build tool plugins/README.md +++ b/VIII. Build tool plugins/README.md @@ -1,3 +1,3 @@ ### 构建工具插件 -Spring Boot为Maven和Gradle提供构建工具插件,该插件提供各种各样的特性,包括打包可执行jars。本章节提供关于插件的更多详情及用于扩展一个不支持的构建系统所需的帮助信息。如果你是刚刚开始,那可能需要先阅读[Part III, “Using Spring Boot”](../III. Using Spring Boot/README.md)章节的[“Chapter 13, Build systems”](../III. Using Spring Boot/13. Build systems.md)。 +Spring Boot为Maven和Gradle提供构建工具插件,该插件提供各种各样的特性,包括打包可执行jars。本章节提供关于插件的更多详情及用于扩展一个不支持的构建系统所需的帮助信息。如果你是刚刚开始,那可能需要先阅读[第三部分 使用Spring Boot](https://docs.spring.io/spring-boot/docs/2.0.0.RELEASE/reference/htmlsingle/#using-boot)章节的[13. 构建系统](https://docs.spring.io/spring-boot/docs/2.0.0.RELEASE/reference/htmlsingle/#using-boot-build-systems)。 From cc32b2ad1db47f5dffced92084cd79568ad6263f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E7=83=AD=E5=BF=83=E5=B8=82=E6=B0=91=E9=92=9F=E5=B0=8F?= =?UTF-8?q?=E5=BC=BA?= Date: Tue, 26 Nov 2019 20:53:07 +0800 Subject: [PATCH 649/865] Update SUMMARY.md --- SUMMARY.md | 32 ++++++++++++++++---------------- 1 file changed, 16 insertions(+), 16 deletions(-) diff --git a/SUMMARY.md b/SUMMARY.md index d527d349..5e0ce3a6 100644 --- a/SUMMARY.md +++ b/SUMMARY.md @@ -431,22 +431,22 @@ * [66. 使用settings.xml配置CLI](VII. Spring Boot CLI/66. Configuring the CLI with settings.xml.md) * [67. 接下来阅读什么](VII. Spring Boot CLI/67. What to Read Next.md) * [VIII. 构建工具插件](VIII. Build tool plugins/README.md) - * [66. Spring Boot Maven插件](VIII. Build tool plugins/66. Spring Boot Maven plugin.md) - * [66.1 包含该插件](VIII. Build tool plugins/66.1 Including the plugin.md) - * [66.2 打包可执行jar和war文件](VIII. Build tool plugins/66.2 Packaging executable jar and war files.md) - * [67. Spring Boot Gradle插件](VIII. Build tool plugins/67. Spring Boot Gradle plugin.md) - * [68. Spring Boot AntLib模块](VIII. Build tool plugins/68. Spring Boot AntLib module.md) - * [68.1. Spring Boot Ant任务](VIII. Build tool plugins/68.1. Spring Boot Ant tasks.md) - * [68.1.1. spring-boot:exejar](VIII. Build tool plugins/68.1.1. spring-boot:exejar.md) - * [68.1.2. 示例](VIII. Build tool plugins/68.1.2. Examples.md) - * [68.2. spring-boot:findmainclass](VIII. Build tool plugins/68.2. spring-boot:findmainclass.md) - * [68.2.1. 示例](VIII. Build tool plugins/68.2.1. Examples.md) -   * [69. 对其他构建系统的支持](VIII. Build tool plugins/69. Supporting other build systems.md) - * [69.1. 重新打包存档](VIII. Build tool plugins/69.1. Repackaging archives.md) - * [69.2. 内嵌库](VIII. Build tool plugins/69.2.Nested libraries.md) - * [69.3. 查找main类](VIII. Build tool plugins/69.3. Finding a main class.md) - * [69.4. repackage实现示例](VIII. Build tool plugins/69.4. Example repackage implementation.md) - * [70. 接下来阅读什么](VIII. Build tool plugins/70. What to read next.md) + * [68. Spring Boot Maven插件](VIII. Build tool plugins/68. Spring Boot Maven Plugin.md) + * [68.1 包含该插件](VIII. Build tool plugins/68.1 Including the Plugin.md) + * [68.2 打包可执行jar和war文件](VIII. Build tool plugins/68.2 Packaging Executable Jar and War Files.md) + * [69. Spring Boot Gradle插件](VIII. Build tool plugins/69. Spring Boot Gradle Plugin.md) + * [70. Spring Boot AntLib模块](VIII. Build tool plugins/70. Spring Boot AntLib Module.md) + * [70.1. Spring Boot Ant任务](VIII. Build tool plugins/70.1. Spring Boot Ant Tasks.md) + * [70.1.1. spring-boot:exejar](VIII. Build tool plugins/70.1.1. spring-boot:exejar.md) + * [70.1.2. 示例](VIII. Build tool plugins/70.1.2. Examples.md) + * [70.2. spring-boot:findmainclass](VIII. Build tool plugins/70.2. spring-boot:findmainclass.md) + * [70.2.1. 示例](VIII. Build tool plugins/70.2.1. Examples.md) +   * [71. 对其他构建系统的支持](VIII. Build tool plugins/71. Supporting Other Build Systems.md) + * [71.1. 重新打包存档](VIII. Build tool plugins/71.1. Repackaging Archives.md) + * [71.2. 内嵌库](VIII. Build tool plugins/71.2.Nested Libraries.md) + * [71.3. 查找main类](VIII. Build tool plugins/71.3. Finding a Main Class.md) + * [71.4. repackage实现示例](VIII. Build tool plugins/71.4. Example Repackage Implementation.md) + * [72. 接下来阅读什么](VIII. Build tool plugins/72. What to Read Next.md) * [IX. How-to指南](IX. ‘How-to’ guides/README.md) * [71. Spring Boot应用](IX. ‘How-to’ guides/71. Spring Boot application.md) * [71.1 创建自己的FailureAnalyzer](IX. ‘How-to’ guides/71.1 Create your own FailureAnalyzer.md) From 3e4d1da2d781caca779dbe6b03939c380cc7d8ea Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E7=83=AD=E5=BF=83=E5=B8=82=E6=B0=91=E9=92=9F=E5=B0=8F?= =?UTF-8?q?=E5=BC=BA?= Date: Tue, 26 Nov 2019 21:01:40 +0800 Subject: [PATCH 650/865] Update and rename 66. Spring Boot Maven plugin.md to 68. Spring Boot Maven Plugin.md --- VIII. Build tool plugins/66. Spring Boot Maven plugin.md | 5 ----- VIII. Build tool plugins/68. Spring Boot Maven Plugin.md | 5 +++++ 2 files changed, 5 insertions(+), 5 deletions(-) delete mode 100644 VIII. Build tool plugins/66. Spring Boot Maven plugin.md create mode 100644 VIII. Build tool plugins/68. Spring Boot Maven Plugin.md diff --git a/VIII. Build tool plugins/66. Spring Boot Maven plugin.md b/VIII. Build tool plugins/66. Spring Boot Maven plugin.md deleted file mode 100644 index 2bb3688d..00000000 --- a/VIII. Build tool plugins/66. Spring Boot Maven plugin.md +++ /dev/null @@ -1,5 +0,0 @@ -### 66. Spring Boot Maven插件 - -[Spring Boot Maven插件](https://docs.spring.io/spring-boot/docs/2.0.0.RELEASE/maven-plugin/)为Maven提供Spring Boot支持,它允许你打包可执行jar或war存档,然后就地运行应用。为了使用它,你需要使用Maven 3.2(或更高版本)。 - -**注** 参考[Spring Boot Maven Plugin Site](https://docs.spring.io/spring-boot/docs/2.0.0.RELEASE/maven-plugin//)可以获取全部的插件文档。 diff --git a/VIII. Build tool plugins/68. Spring Boot Maven Plugin.md b/VIII. Build tool plugins/68. Spring Boot Maven Plugin.md new file mode 100644 index 00000000..a66dae7e --- /dev/null +++ b/VIII. Build tool plugins/68. Spring Boot Maven Plugin.md @@ -0,0 +1,5 @@ +### 68. Spring Boot Maven插件 + +[Spring Boot Maven插件](https://docs.spring.io/spring-boot/docs/2.0.0.RELEASE/maven-plugin)为Maven提供Spring Boot支持,它允许你打包可执行jar或war存档,然后就地运行应用。为了使用它,你需要使用Maven 3.2(或更高版本)。 + +**注** 参考[Spring Boot Maven Plugin Site](https://docs.spring.io/spring-boot/docs/2.0.0.RELEASE/maven-plugin)可以获取全部的插件文档。 From 4387eb8dfd68d733702e8b3d847b862640f5afec Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E7=83=AD=E5=BF=83=E5=B8=82=E6=B0=91=E9=92=9F=E5=B0=8F?= =?UTF-8?q?=E5=BC=BA?= Date: Tue, 26 Nov 2019 21:07:31 +0800 Subject: [PATCH 651/865] Update and rename 66.1 Including the plugin.md to 68.1 Including the Plugin.md --- .../66.1 Including the plugin.md | 52 ------------------- .../68.1 Including the Plugin.md | 52 +++++++++++++++++++ 2 files changed, 52 insertions(+), 52 deletions(-) delete mode 100644 VIII. Build tool plugins/66.1 Including the plugin.md create mode 100644 VIII. Build tool plugins/68.1 Including the Plugin.md diff --git a/VIII. Build tool plugins/66.1 Including the plugin.md b/VIII. Build tool plugins/66.1 Including the plugin.md deleted file mode 100644 index 6339a844..00000000 --- a/VIII. Build tool plugins/66.1 Including the plugin.md +++ /dev/null @@ -1,52 +0,0 @@ -### 66.1 包含该插件 - -想要使用Spring Boot Maven插件只需简单地在你的pom.xml的`plugins`部分包含相应的XML: -```xml - - - 4.0.0 - - - - - org.springframework.boot - spring-boot-maven-plugin - 2.0.0.RELEASE - - - - repackage - - - - - - - -``` -该配置会在Maven生命周期的`package`阶段重新打包一个jar或war。下面的示例展示在`target`目录下既有重新打包后的jar,也有原始的jar: -```shell -$ mvn package -$ ls target/*.jar -target/myproject-1.0.0.jar target/myproject-1.0.0.jar.original -``` -如果不包含像上面那样的``,你可以自己运行该插件(但只有在package目标也被使用的情况),例如: -```shell -$ mvn package spring-boot:repackage -$ ls target/*.jar -target/myproject-1.0.0.jar target/myproject-1.0.0.jar.original -``` -如果使用一个里程碑或快照版本,你还需要添加正确的`pluginRepository`元素: -```xml - - - spring-snapshots - http://repo.spring.io/snapshot - - - spring-milestones - http://repo.spring.io/milestone - - -``` diff --git a/VIII. Build tool plugins/68.1 Including the Plugin.md b/VIII. Build tool plugins/68.1 Including the Plugin.md new file mode 100644 index 00000000..24193ade --- /dev/null +++ b/VIII. Build tool plugins/68.1 Including the Plugin.md @@ -0,0 +1,52 @@ +### 68.1 包含该插件 + +想要使用Spring Boot Maven插件只需在你的`pom.xml`的`plugins`部分包含相应的XML: +```xml + + + 4.0.0 + + + + + org.springframework.boot + spring-boot-maven-plugin + 2.0.0.RELEASE + + + + repackage + + + + + + + +``` +该配置会在Maven生命周期的`package`阶段重新打包一个jar或war。下面的示例展示在`target`目录下既有重新打包后的jar,也有原始的jar: +```shell +$ mvn package +$ ls target/*.jar +target/myproject-1.0.0.jar target/myproject-1.0.0.jar.original +``` +如果不包含像上面那样的``,你可以自己运行该插件(但只有在package目标也被使用的情况),例如: +```shell +$ mvn package spring-boot:repackage +$ ls target/*.jar +target/myproject-1.0.0.jar target/myproject-1.0.0.jar.original +``` +如果使用一个里程碑或快照版本,你还需要添加正确的`pluginRepository`元素: +```xml + + + spring-snapshots + https://repo.spring.io/snapshot + + + spring-milestones + https://repo.spring.io/milestone + + +``` From 95eef669e8581b3d12d33a673c1e35df2eb56d4b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E7=83=AD=E5=BF=83=E5=B8=82=E6=B0=91=E9=92=9F=E5=B0=8F?= =?UTF-8?q?=E5=BC=BA?= Date: Tue, 26 Nov 2019 21:15:00 +0800 Subject: [PATCH 652/865] Update and rename 66.2 Packaging executable jar and war files.md to 68.2 Packaging Executable Jar and War Files.md --- ...68.2 Packaging Executable Jar and War Files.md} | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) rename VIII. Build tool plugins/{66.2 Packaging executable jar and war files.md => 68.2 Packaging Executable Jar and War Files.md} (79%) diff --git a/VIII. Build tool plugins/66.2 Packaging executable jar and war files.md b/VIII. Build tool plugins/68.2 Packaging Executable Jar and War Files.md similarity index 79% rename from VIII. Build tool plugins/66.2 Packaging executable jar and war files.md rename to VIII. Build tool plugins/68.2 Packaging Executable Jar and War Files.md index 6aec2834..a5590014 100644 --- a/VIII. Build tool plugins/66.2 Packaging executable jar and war files.md +++ b/VIII. Build tool plugins/68.2 Packaging Executable Jar and War Files.md @@ -1,13 +1,13 @@ -### 66.2 打包可执行jar和war文件 +### 68.2 打包可执行jar和war文件 一旦`spring-boot-maven-plugin`被包含到你的`pom.xml`中,Spring Boot就会自动尝试使用`spring-boot:repackage`目标重写存档以使它们能够执行。为了构建一个jar或war,你应该使用常规的`packaging`元素配置你的项目: ```xml - - jar - + xsi:schemaLocation="http://maven.apache.org/POM/4.0.0%20http://maven.apache.org/xsd/maven-4.0.0.xsd"> + + jar + ``` 生成的存档在`package`阶段会被Spring Boot增强。你想启动的main类即可以通过指定一个配置选项,也可以通过为manifest添加一个`Main-Class`属性这种常规的方式实现。如果你没有指定一个main类,该插件会搜索带有`public static void main(String[] args)`方法的类。 @@ -39,6 +39,6 @@ $ java -jar target/mymodule-0.0.1-SNAPSHOT.jar ``` -**注** 具体参考[“Section 85.1, “Create a deployable war file”” ](../IX. ‘How-to’ guides/85.1. Create a deployable war file.md)章节。 +**注** 具体参考[87.1 创建可部署的war文件](https://docs.spring.io/spring-boot/docs/2.0.0.RELEASE/reference/htmlsingle/#howto-create-a-deployable-war-file)章节。 -高级配置选项和示例可在[插件信息页面](https://docs.spring.io/spring-boot/docs/2.0.0.RELEASE/maven-plugin/)获取。 +高级配置选项和示例可在[插件信息页面](https://docs.spring.io/spring-boot/docs/2.0.0.RELEASE/maven-plugin)获取。 From 78e950e0df0727d7c725be4f8c47148ac2884642 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E7=83=AD=E5=BF=83=E5=B8=82=E6=B0=91=E9=92=9F=E5=B0=8F?= =?UTF-8?q?=E5=BC=BA?= Date: Tue, 26 Nov 2019 21:17:25 +0800 Subject: [PATCH 653/865] Update and rename 67. Spring Boot Gradle plugin.md to 69. Spring Boot Gradle Plugin.md --- ...ot Gradle plugin.md => 69. Spring Boot Gradle Plugin.md} | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) rename VIII. Build tool plugins/{67. Spring Boot Gradle plugin.md => 69. Spring Boot Gradle Plugin.md} (63%) diff --git a/VIII. Build tool plugins/67. Spring Boot Gradle plugin.md b/VIII. Build tool plugins/69. Spring Boot Gradle Plugin.md similarity index 63% rename from VIII. Build tool plugins/67. Spring Boot Gradle plugin.md rename to VIII. Build tool plugins/69. Spring Boot Gradle Plugin.md index 3d44137d..e540c630 100644 --- a/VIII. Build tool plugins/67. Spring Boot Gradle plugin.md +++ b/VIII. Build tool plugins/69. Spring Boot Gradle Plugin.md @@ -1,5 +1,5 @@ -### 67. Spring Boot Gradle插件 +### 69. Spring Boot Gradle插件 Spring Boot Gradle插件为Gradle提供Spring Boot支持,它允许你打包可执行jar或war存档,运行Spring Boot应用,使用`spring-boot-dependencies`提供的依赖管理。需要Gradle 3.4或之后的版本。更多细节请参考插件的文档: -- 参考 ([HTML](https://docs.spring.io/spring-boot/docs/2.0.0.RELEASE/gradle-plugin//reference/html) 与 [PDF](https://docs.spring.io/spring-boot/docs/2.0.0.RELEASE/gradle-plugin//reference/pdf/spring-boot-gradle-plugin-reference.pdf)) -- [API](https://docs.spring.io/spring-boot/docs/2.0.0.RELEASE/gradle-plugin//api) +- 参考 ([HTML](https://docs.spring.io/spring-boot/docs/2.0.0.RELEASE/gradle-plugin/reference/html) 与 [PDF](https://docs.spring.io/spring-boot/docs/2.0.0.RELEASE/gradle-plugin/reference/pdf/spring-boot-gradle-plugin-reference.pdf)) +- [API](https://docs.spring.io/spring-boot/docs/2.0.0.RELEASE/gradle-plugin/api) From d5e9285ae0a91e31ee72811f3ca57a1a29e9cfed Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E7=83=AD=E5=BF=83=E5=B8=82=E6=B0=91=E9=92=9F=E5=B0=8F?= =?UTF-8?q?=E5=BC=BA?= Date: Tue, 26 Nov 2019 21:21:58 +0800 Subject: [PATCH 654/865] Update and rename 68. Spring Boot AntLib module.md to 70. Spring Boot AntLib Module.md --- ... AntLib module.md => 70. Spring Boot AntLib Module.md} | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) rename VIII. Build tool plugins/{68. Spring Boot AntLib module.md => 70. Spring Boot AntLib Module.md} (81%) diff --git a/VIII. Build tool plugins/68. Spring Boot AntLib module.md b/VIII. Build tool plugins/70. Spring Boot AntLib Module.md similarity index 81% rename from VIII. Build tool plugins/68. Spring Boot AntLib module.md rename to VIII. Build tool plugins/70. Spring Boot AntLib Module.md index 3a915fcf..fcac8c6d 100644 --- a/VIII. Build tool plugins/68. Spring Boot AntLib module.md +++ b/VIII. Build tool plugins/70. Spring Boot AntLib Module.md @@ -1,11 +1,11 @@ -###68. Spring Boot AntLib模块 +### 70. Spring Boot AntLib模块 Spring Boot AntLib模块为Apache Ant提供基本的Spring Boot支持,你可以使用该模块创建可执行的jars。在`build.xml`添加额外的`spring-boot`命名空间就可以使用该模块了: ```xml - ... + xmlns:spring-boot="antlib:org.springframework.boot.ant" + name="myapp" default="build"> + ... ``` 你需要记得在启动Ant时使用`-lib`选项,例如: From 4a2fa6dd8ab4e2768f8916be5bcd0bfa667e0eb8 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E7=83=AD=E5=BF=83=E5=B8=82=E6=B0=91=E9=92=9F=E5=B0=8F?= =?UTF-8?q?=E5=BC=BA?= Date: Tue, 26 Nov 2019 21:24:48 +0800 Subject: [PATCH 655/865] Update 69. Spring Boot Gradle Plugin.md --- VIII. Build tool plugins/69. Spring Boot Gradle Plugin.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/VIII. Build tool plugins/69. Spring Boot Gradle Plugin.md b/VIII. Build tool plugins/69. Spring Boot Gradle Plugin.md index e540c630..d587caba 100644 --- a/VIII. Build tool plugins/69. Spring Boot Gradle Plugin.md +++ b/VIII. Build tool plugins/69. Spring Boot Gradle Plugin.md @@ -1,5 +1,5 @@ ### 69. Spring Boot Gradle插件 -Spring Boot Gradle插件为Gradle提供Spring Boot支持,它允许你打包可执行jar或war存档,运行Spring Boot应用,使用`spring-boot-dependencies`提供的依赖管理。需要Gradle 3.4或之后的版本。更多细节请参考插件的文档: +Spring Boot Gradle插件为Gradle提供Spring Boot支持。它允许你打包可执行jar或war存档,运行Spring Boot应用,使用`spring-boot-dependencies`提供的依赖管理。需要Gradle 4.0或之后的版本。更多细节请参考插件的文档: - 参考 ([HTML](https://docs.spring.io/spring-boot/docs/2.0.0.RELEASE/gradle-plugin/reference/html) 与 [PDF](https://docs.spring.io/spring-boot/docs/2.0.0.RELEASE/gradle-plugin/reference/pdf/spring-boot-gradle-plugin-reference.pdf)) - [API](https://docs.spring.io/spring-boot/docs/2.0.0.RELEASE/gradle-plugin/api) From d09f971f08dd439fc15cbef5d8532ca8aa87c079 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E7=83=AD=E5=BF=83=E5=B8=82=E6=B0=91=E9=92=9F=E5=B0=8F?= =?UTF-8?q?=E5=BC=BA?= Date: Tue, 26 Nov 2019 21:35:25 +0800 Subject: [PATCH 656/865] Update and rename 68.1. Spring Boot Ant tasks.md to 70.1. Spring Boot Ant Tasks.md --- VIII. Build tool plugins/68.1. Spring Boot Ant tasks.md | 2 -- VIII. Build tool plugins/70.1. Spring Boot Ant Tasks.md | 5 +++++ 2 files changed, 5 insertions(+), 2 deletions(-) delete mode 100644 VIII. Build tool plugins/68.1. Spring Boot Ant tasks.md create mode 100644 VIII. Build tool plugins/70.1. Spring Boot Ant Tasks.md diff --git a/VIII. Build tool plugins/68.1. Spring Boot Ant tasks.md b/VIII. Build tool plugins/68.1. Spring Boot Ant tasks.md deleted file mode 100644 index 1b42d1da..00000000 --- a/VIII. Build tool plugins/68.1. Spring Boot Ant tasks.md +++ /dev/null @@ -1,2 +0,0 @@ -###68.1. Spring Boot Ant任务 -一旦声明`spring-boot-antlib`命名空间,以下任务就可用了。 diff --git a/VIII. Build tool plugins/70.1. Spring Boot Ant Tasks.md b/VIII. Build tool plugins/70.1. Spring Boot Ant Tasks.md new file mode 100644 index 00000000..3cbb722d --- /dev/null +++ b/VIII. Build tool plugins/70.1. Spring Boot Ant Tasks.md @@ -0,0 +1,5 @@ +### 68.1. Spring Boot Ant任务 + +一旦声明`spring-boot-antlib`命名空间,以下任务就可用了: +- [70.1.1. spring-boot:exejar](https://docs.spring.io/spring-boot/docs/2.0.0.RELEASE/reference/htmlsingle/#spring-boot-ant-exejar) +- [70.2. spring-boot:findmainclass](https://docs.spring.io/spring-boot/docs/2.0.0.RELEASE/reference/htmlsingle/#spring-boot-ant-findmainclass) From b9cbb0c49b31bba1dc28a6a114e842912589c92d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E7=83=AD=E5=BF=83=E5=B8=82=E6=B0=91=E9=92=9F=E5=B0=8F?= =?UTF-8?q?=E5=BC=BA?= Date: Sun, 1 Dec 2019 13:38:21 +0800 Subject: [PATCH 657/865] Update and rename 68.1.1. spring-boot:exejar.md to 70.1.1. spring-boot:exejar.md --- .../68.1.1. spring-boot:exejar.md | 16 ---------------- .../70.1.1. spring-boot:exejar.md | 16 ++++++++++++++++ 2 files changed, 16 insertions(+), 16 deletions(-) delete mode 100644 VIII. Build tool plugins/68.1.1. spring-boot:exejar.md create mode 100644 VIII. Build tool plugins/70.1.1. spring-boot:exejar.md diff --git a/VIII. Build tool plugins/68.1.1. spring-boot:exejar.md b/VIII. Build tool plugins/68.1.1. spring-boot:exejar.md deleted file mode 100644 index ebe13e3c..00000000 --- a/VIII. Build tool plugins/68.1.1. spring-boot:exejar.md +++ /dev/null @@ -1,16 +0,0 @@ -###68.1.1. spring-boot:exejar - -`exejar`任务可用于创建Spring Boot可执行jar,该任务支持以下属性: - -|属性|描述|是否必须| -|:----|:----|:-----| -|`destfile`|将要创建的目的jar文件|是| -|`classes`|Java类文件的根目录|是| -|`start-class`|运行的main类|否(默认为找到的第一个声明`main`方法的类)| - -以下元素可以跟任务一块使用: - -|元素|描述| -|:----|:----| -|`resources`|一个或多个[Resource Collections](http://ant.apache.org/manual/Types/resources.html#collection),描述将添加到创建的jar文件中的资源集合| -|`lib`|一个或多个[Resource Collections](http://ant.apache.org/manual/Types/resources.html#collection),表示需要添加进jar库的集合,组成了应用运行时的classpath依赖| diff --git a/VIII. Build tool plugins/70.1.1. spring-boot:exejar.md b/VIII. Build tool plugins/70.1.1. spring-boot:exejar.md new file mode 100644 index 00000000..9164fb0f --- /dev/null +++ b/VIII. Build tool plugins/70.1.1. spring-boot:exejar.md @@ -0,0 +1,16 @@ +### 70.1.1. spring-boot:exejar + +`exejar`任务可用于创建Spring Boot可执行jar,该任务支持以下属性: + +|属性|描述|是否必须| +|:----|:----|:-----| +|`destfile`|将要创建的目的jar文件|是| +|`classes`|Java类文件的根目录|是| +|`start-class`|运行的main类|否(默认为找到的第一个声明`main`方法的类)| + +以下元素可以跟任务一块使用: + +|元素|描述| +|:----|:----| +|`resources`|一个或多个[Resource Collections](https://ant.apache.org/manual/Types/resources.html#collection),描述将添加到创建的jar文件中的[资源](https://ant.apache.org/manual/Types/resources.html)集合| +|`lib`|一个或多个[Resource Collections](https://ant.apache.org/manual/Types/resources.html#collection),表示需要添加进jar库的集合,组成了应用运行时的classpath依赖| From 391bf7f32ec3f6181f304a382e521ec240db76f5 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E7=83=AD=E5=BF=83=E5=B8=82=E6=B0=91=E9=92=9F=E5=B0=8F?= =?UTF-8?q?=E5=BC=BA?= Date: Sun, 1 Dec 2019 13:43:14 +0800 Subject: [PATCH 658/865] Update and rename 68.1.2. Examples.md to 70.1.2. Examples.md --- VIII. Build tool plugins/68.1.2. Examples.md | 23 ------------------ VIII. Build tool plugins/70.1.2. Examples.md | 25 ++++++++++++++++++++ 2 files changed, 25 insertions(+), 23 deletions(-) delete mode 100644 VIII. Build tool plugins/68.1.2. Examples.md create mode 100644 VIII. Build tool plugins/70.1.2. Examples.md diff --git a/VIII. Build tool plugins/68.1.2. Examples.md b/VIII. Build tool plugins/68.1.2. Examples.md deleted file mode 100644 index 2e55fb70..00000000 --- a/VIII. Build tool plugins/68.1.2. Examples.md +++ /dev/null @@ -1,23 +0,0 @@ -### 68.1.2. 示例 - -**指定start-class** -```xml - - - - - - - - -``` - -**探测start-class** -```xml - - - - - -``` diff --git a/VIII. Build tool plugins/70.1.2. Examples.md b/VIII. Build tool plugins/70.1.2. Examples.md new file mode 100644 index 00000000..fb3a3a5e --- /dev/null +++ b/VIII. Build tool plugins/70.1.2. Examples.md @@ -0,0 +1,25 @@ +### 70.1.2. 示例 + +本节将展示Ant任务的两个示例。 + +**指定start-class** +```xml + + + + + + + + +``` + +**探测start-class** +```xml + + + + + +``` From edd79ce4806e4aa3e0bcf62f2420a21608067583 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E7=83=AD=E5=BF=83=E5=B8=82=E6=B0=91=E9=92=9F=E5=B0=8F?= =?UTF-8?q?=E5=BC=BA?= Date: Sun, 1 Dec 2019 13:47:45 +0800 Subject: [PATCH 659/865] Update and rename 68.2. spring-boot:findmainclass.md to 70.2. spring-boot:findmainclass.md --- ...boot:findmainclass.md => 70.2. spring-boot:findmainclass.md} | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) rename VIII. Build tool plugins/{68.2. spring-boot:findmainclass.md => 70.2. spring-boot:findmainclass.md} (92%) diff --git a/VIII. Build tool plugins/68.2. spring-boot:findmainclass.md b/VIII. Build tool plugins/70.2. spring-boot:findmainclass.md similarity index 92% rename from VIII. Build tool plugins/68.2. spring-boot:findmainclass.md rename to VIII. Build tool plugins/70.2. spring-boot:findmainclass.md index 41c5c72a..abd38c91 100644 --- a/VIII. Build tool plugins/68.2. spring-boot:findmainclass.md +++ b/VIII. Build tool plugins/70.2. spring-boot:findmainclass.md @@ -1,4 +1,4 @@ -###68.2. spring-boot:findmainclass +### 70.2. spring-boot:findmainclass `findmainclass`任务是`exejar`内部用于定位声明`main`方法类的,如果构建需要,你可以直接使用该任务,支持属性如下: From 141fe6fe8cb91a778f458a08e8f88643368d1bed Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E7=83=AD=E5=BF=83=E5=B8=82=E6=B0=91=E9=92=9F=E5=B0=8F?= =?UTF-8?q?=E5=BC=BA?= Date: Sun, 1 Dec 2019 13:51:30 +0800 Subject: [PATCH 660/865] Update and rename 68.2.1. Examples.md to 70.2.1. Examples.md --- .../{68.2.1. Examples.md => 70.2.1. Examples.md} | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) rename VIII. Build tool plugins/{68.2.1. Examples.md => 70.2.1. Examples.md} (58%) diff --git a/VIII. Build tool plugins/68.2.1. Examples.md b/VIII. Build tool plugins/70.2.1. Examples.md similarity index 58% rename from VIII. Build tool plugins/68.2.1. Examples.md rename to VIII. Build tool plugins/70.2.1. Examples.md index c0a04862..e1f0aa46 100644 --- a/VIII. Build tool plugins/68.2.1. Examples.md +++ b/VIII. Build tool plugins/70.2.1. Examples.md @@ -1,4 +1,7 @@ -###68.2.1. 示例 +### 70.2.1. 示例 + +本节包含三个使用`findmainclass`的示例。 + **查找并记录** ```xml @@ -10,5 +13,5 @@ **覆盖并设置** ```xml - + ``` From 969df87a364c7d655f960d21296f0972dc55a04f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E7=83=AD=E5=BF=83=E5=B8=82=E6=B0=91=E9=92=9F=E5=B0=8F?= =?UTF-8?q?=E5=BC=BA?= Date: Sun, 1 Dec 2019 13:59:01 +0800 Subject: [PATCH 661/865] Update and rename 69. Supporting other build systems.md to 71. Supporting Other Build Systems.md --- .../69. Supporting other build systems.md | 5 ----- .../71. Supporting Other Build Systems.md | 5 +++++ 2 files changed, 5 insertions(+), 5 deletions(-) delete mode 100644 VIII. Build tool plugins/69. Supporting other build systems.md create mode 100644 VIII. Build tool plugins/71. Supporting Other Build Systems.md diff --git a/VIII. Build tool plugins/69. Supporting other build systems.md b/VIII. Build tool plugins/69. Supporting other build systems.md deleted file mode 100644 index 651d6f43..00000000 --- a/VIII. Build tool plugins/69. Supporting other build systems.md +++ /dev/null @@ -1,5 +0,0 @@ -### 69. 对其他构建系统的支持 - -如果想使用除了Maven和Gradle之外的构建工具,你可能需要开发自己的插件。可执行jars需要遵循一个特定格式,并且一些实体需要以不压缩的方式写入(详情查看附录中的[可执行jar格式](http://docs.spring.io/spring-boot/docs/current-SNAPSHOT/reference/htmlsingle/#executable-jar)章节)。 - -Spring Boot Maven和Gradle插件在实际生成jars的过程中会使用`spring-boot-loader-tools`,如果需要,你也可以自由地使用该library。 diff --git a/VIII. Build tool plugins/71. Supporting Other Build Systems.md b/VIII. Build tool plugins/71. Supporting Other Build Systems.md new file mode 100644 index 00000000..a747195f --- /dev/null +++ b/VIII. Build tool plugins/71. Supporting Other Build Systems.md @@ -0,0 +1,5 @@ +### 71. 对其他构建系统的支持 + +如果想使用除了Maven、Gradle和Ant之外的构建工具,你可能需要开发自己的插件。可执行jars需要遵循一个特定格式,并且一些实体需要以不压缩的方式写入(详情查看附录中的[可执行jar格式](https://docs.spring.io/spring-boot/docs/2.0.0.RELEASE/reference/htmlsingle/#executable-jar)章节)。 + +Spring Boot Maven和Gradle插件在实际生成jars的过程中会使用`spring-boot-loader-tools`,如果需要,你也可以自由地使用该library。 From 2bc2378c017a56a5e0eb7484d22624ab20a04081 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E7=83=AD=E5=BF=83=E5=B8=82=E6=B0=91=E9=92=9F=E5=B0=8F?= =?UTF-8?q?=E5=BC=BA?= Date: Sun, 1 Dec 2019 14:01:12 +0800 Subject: [PATCH 662/865] Update and rename 69.1. Repackaging archives.md to 71.1. Repackaging Archives.md --- ...1. Repackaging archives.md => 71.1. Repackaging Archives.md} | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) rename VIII. Build tool plugins/{69.1. Repackaging archives.md => 71.1. Repackaging Archives.md} (92%) diff --git a/VIII. Build tool plugins/69.1. Repackaging archives.md b/VIII. Build tool plugins/71.1. Repackaging Archives.md similarity index 92% rename from VIII. Build tool plugins/69.1. Repackaging archives.md rename to VIII. Build tool plugins/71.1. Repackaging Archives.md index 8c611581..5448c9f7 100644 --- a/VIII. Build tool plugins/69.1. Repackaging archives.md +++ b/VIII. Build tool plugins/71.1. Repackaging Archives.md @@ -1,3 +1,3 @@ -### 69.1. 重新打包存档 +### 71.1. 重新打包存档 使用`org.springframework.boot.loader.tools.Repackager`可以将一个存在的存档重新打包,这样它就变成一个自包含的可执行存档。`Repackager`类需要提供单一的构造器参数,该参数指向一个存在的jar或war包。你可以使用两个可用的`repackage()`方法中的一个来替换原始的文件或写入新的目标,在repackager运行前还可以指定各种配置。 From 28e5bda0ae98c3ed33571c0175af9fa2da70dfb1 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E7=83=AD=E5=BF=83=E5=B8=82=E6=B0=91=E9=92=9F=E5=B0=8F?= =?UTF-8?q?=E5=BC=BA?= Date: Sun, 1 Dec 2019 14:03:50 +0800 Subject: [PATCH 663/865] Update and rename 69.2.Nested libraries.md to 71.2. Nested Libraries.md --- .../{69.2.Nested libraries.md => 71.2. Nested Libraries.md} | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) rename VIII. Build tool plugins/{69.2.Nested libraries.md => 71.2. Nested Libraries.md} (92%) diff --git a/VIII. Build tool plugins/69.2.Nested libraries.md b/VIII. Build tool plugins/71.2. Nested Libraries.md similarity index 92% rename from VIII. Build tool plugins/69.2.Nested libraries.md rename to VIII. Build tool plugins/71.2. Nested Libraries.md index c7a3f709..7ff76837 100644 --- a/VIII. Build tool plugins/69.2.Nested libraries.md +++ b/VIII. Build tool plugins/71.2. Nested Libraries.md @@ -1,4 +1,4 @@ -### 69.2. 内嵌库 +### 71.2. 内嵌库 当重新打包一个存档时,你可以使用`org.springframework.boot.loader.tools.Libraries`接口来包含对依赖文件的引用。在这里我们不提供任何该`Libraries`接口的具体实现,因为它们通常跟具体的构建系统相关。 From 8f32a5e1dc841f2187bcf1f343f237eb4533ca85 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E7=83=AD=E5=BF=83=E5=B8=82=E6=B0=91=E9=92=9F=E5=B0=8F?= =?UTF-8?q?=E5=BC=BA?= Date: Sun, 1 Dec 2019 14:05:31 +0800 Subject: [PATCH 664/865] Update and rename 69.3. Finding a main class.md to 71.3. Finding a Main Class.md --- ...3. Finding a main class.md => 71.3. Finding a Main Class.md} | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) rename VIII. Build tool plugins/{69.3. Finding a main class.md => 71.3. Finding a Main Class.md} (91%) diff --git a/VIII. Build tool plugins/69.3. Finding a main class.md b/VIII. Build tool plugins/71.3. Finding a Main Class.md similarity index 91% rename from VIII. Build tool plugins/69.3. Finding a main class.md rename to VIII. Build tool plugins/71.3. Finding a Main Class.md index 96615993..19217c03 100644 --- a/VIII. Build tool plugins/69.3. Finding a main class.md +++ b/VIII. Build tool plugins/71.3. Finding a Main Class.md @@ -1,3 +1,3 @@ -### 69.3. 查找main类 +### 71.3. 查找main类 如果你没有使用`Repackager.setMainClass()`指定一个main类,该repackager将使用[ASM](http://asm.ow2.org/)去读取class文件,然后尝试查找一个合适的,具有`public static void main(String[] args)`方法的类。如果发现多个候选者,将会抛出异常。 From f1c7ea506feb887dd7f512a6ab94863bfe023d7d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E7=83=AD=E5=BF=83=E5=B8=82=E6=B0=91=E9=92=9F=E5=B0=8F?= =?UTF-8?q?=E5=BC=BA?= Date: Sun, 1 Dec 2019 14:07:30 +0800 Subject: [PATCH 665/865] Update and rename 69.4. Example repackage implementation.md to 71.4. Example Repackage Implementation.md --- .../69.4. Example repackage implementation.md | 14 -------------- .../71.4. Example Repackage Implementation.md | 14 ++++++++++++++ 2 files changed, 14 insertions(+), 14 deletions(-) delete mode 100644 VIII. Build tool plugins/69.4. Example repackage implementation.md create mode 100644 VIII. Build tool plugins/71.4. Example Repackage Implementation.md diff --git a/VIII. Build tool plugins/69.4. Example repackage implementation.md b/VIII. Build tool plugins/69.4. Example repackage implementation.md deleted file mode 100644 index 232be81a..00000000 --- a/VIII. Build tool plugins/69.4. Example repackage implementation.md +++ /dev/null @@ -1,14 +0,0 @@ -### 69.4. repackage实现示例 - -这是一个典型的repackage示例: -```java -Repackager repackager = new Repackager(sourceJarFile); -repackager.setBackupSource(false); -repackager.repackage(new Libraries() { - @Override - public void doWithLibraries(LibraryCallback callback) throws IOException { - // Build system specific implementation, callback for each dependency - // callback.library(new Library(nestedFile, LibraryScope.COMPILE)); - } - }); -``` diff --git a/VIII. Build tool plugins/71.4. Example Repackage Implementation.md b/VIII. Build tool plugins/71.4. Example Repackage Implementation.md new file mode 100644 index 00000000..0fcb5311 --- /dev/null +++ b/VIII. Build tool plugins/71.4. Example Repackage Implementation.md @@ -0,0 +1,14 @@ +### 71.4. repackage实现示例 + +这是一个典型的repackage示例: +```java +Repackager repackager = new Repackager(sourceJarFile); +repackager.setBackupSource(false); +repackager.repackage(new Libraries() { + @Override + public void doWithLibraries(LibraryCallback callback) throws IOException { + // Build system specific implementation, callback for each dependency + // callback.library(new Library(nestedFile, LibraryScope.COMPILE)); + } + }); +``` From 4b61e2951ab5f534a124b7df1faaa388057be7a6 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E7=83=AD=E5=BF=83=E5=B8=82=E6=B0=91=E9=92=9F=E5=B0=8F?= =?UTF-8?q?=E5=BC=BA?= Date: Sun, 1 Dec 2019 14:10:25 +0800 Subject: [PATCH 666/865] Update and rename 70. What to read next.md to 72. What to Read Next.md --- VIII. Build tool plugins/70. What to read next.md | 5 ----- VIII. Build tool plugins/72. What to Read Next.md | 5 +++++ 2 files changed, 5 insertions(+), 5 deletions(-) delete mode 100644 VIII. Build tool plugins/70. What to read next.md create mode 100644 VIII. Build tool plugins/72. What to Read Next.md diff --git a/VIII. Build tool plugins/70. What to read next.md b/VIII. Build tool plugins/70. What to read next.md deleted file mode 100644 index 8e4d1abc..00000000 --- a/VIII. Build tool plugins/70. What to read next.md +++ /dev/null @@ -1,5 +0,0 @@ -### 70. 接下来阅读什么 - -如果对构建工具插件如何工作感兴趣,你可以查看GitHub上的[spring-boot-tools](https://github.com/spring-projects/spring-boot/tree/v2.0.0.RELEASE/spring-boot-tools)模块,附加中有详细的[可执行jar格式](https://docs.spring.io/spring-boot/docs/2.0.0.RELEASE/reference/htmlsingle/#executable-jar)。 - -如果有特定构建相关的问题,可以查看[how-to](../IX. ‘How-to’ guides/README.md)指南。 diff --git a/VIII. Build tool plugins/72. What to Read Next.md b/VIII. Build tool plugins/72. What to Read Next.md new file mode 100644 index 00000000..67542b36 --- /dev/null +++ b/VIII. Build tool plugins/72. What to Read Next.md @@ -0,0 +1,5 @@ +### 72. 接下来阅读什么 + +如果对构建工具插件如何工作感兴趣,你可以查看GitHub上的[spring-boot-tools](https://github.com/spring-projects/spring-boot/tree/v2.0.0.RELEASE/spring-boot-project/spring-boot-tools)模块。附加中有详细的[可执行jar格式](https://docs.spring.io/spring-boot/docs/2.0.0.RELEASE/reference/htmlsingle/#executable-jar)。 + +如果有特定构建相关的问题,可以查看[how-to](https://docs.spring.io/spring-boot/docs/2.0.0.RELEASE/reference/htmlsingle/#howto)指南。 From d8d81fede7f52bae3834b43234a6cc7416613c1a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E7=83=AD=E5=BF=83=E5=B8=82=E6=B0=91=E9=92=9F=E5=B0=8F?= =?UTF-8?q?=E5=BC=BA?= Date: Sun, 1 Dec 2019 14:15:16 +0800 Subject: [PATCH 667/865] Update README.md --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 0a70448a..d672fd60 100644 --- a/README.md +++ b/README.md @@ -12,4 +12,4 @@ GitBook : [Spring Boot参考指南](https://jack80342.gitbook.io/spring-boot/) GitHub : [Spring Boot参考指南](https://github.com/jack80342/Spring-Boot-Reference-Guide) - 我从二零一七年夏天开始翻译这份文档。为什么翻译这份文档,原因我已经忘了。这份文档在[qibaoguang](https://github.com/qibaoguang)的1.4.1版本上新增了Spring Boot 2.0.0版本的内容,对修改的地方也做了更新。 + 我从二零一七年夏天开始翻译这份文档。这份文档在[qibaoguang](https://github.com/qibaoguang)的1.4.1版本上新增了Spring Boot 2.0.0版本的内容,对修改的地方也做了更新。 From d4ba607700a8210d5df4b6879f48caedd7ed40be Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E7=83=AD=E5=BF=83=E5=B8=82=E6=B0=91=E9=92=9F=E5=B0=8F?= =?UTF-8?q?=E5=BC=BA?= Date: Sun, 1 Dec 2019 14:24:04 +0800 Subject: [PATCH 668/865] Update SUMMARY.md --- SUMMARY.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/SUMMARY.md b/SUMMARY.md index 5e0ce3a6..713ec6ec 100644 --- a/SUMMARY.md +++ b/SUMMARY.md @@ -443,7 +443,7 @@ * [70.2.1. 示例](VIII. Build tool plugins/70.2.1. Examples.md)   * [71. 对其他构建系统的支持](VIII. Build tool plugins/71. Supporting Other Build Systems.md) * [71.1. 重新打包存档](VIII. Build tool plugins/71.1. Repackaging Archives.md) - * [71.2. 内嵌库](VIII. Build tool plugins/71.2.Nested Libraries.md) + * [71.2. 内嵌库](VIII. Build tool plugins/71.2. Nested Libraries.md) * [71.3. 查找main类](VIII. Build tool plugins/71.3. Finding a Main Class.md) * [71.4. repackage实现示例](VIII. Build tool plugins/71.4. Example Repackage Implementation.md) * [72. 接下来阅读什么](VIII. Build tool plugins/72. What to Read Next.md) From 08c460849908602913ee293f6635469a57d22ed7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E7=83=AD=E5=BF=83=E5=B8=82=E6=B0=91=E9=92=9F=E5=B0=8F?= =?UTF-8?q?=E5=BC=BA?= Date: Wed, 4 Dec 2019 13:06:30 +0800 Subject: [PATCH 669/865] Update README.md --- "IX. \342\200\230How-to\342\200\231 guides/README.md" | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git "a/IX. \342\200\230How-to\342\200\231 guides/README.md" "b/IX. \342\200\230How-to\342\200\231 guides/README.md" index 5df2a394..0df2b670 100644 --- "a/IX. \342\200\230How-to\342\200\231 guides/README.md" +++ "b/IX. \342\200\230How-to\342\200\231 guides/README.md" @@ -2,6 +2,6 @@ 本章节将回答一些常见的"我该怎么做"类型的问题,这些问题在我们使用Spring Boot时经常遇到。这虽然不是一个详尽的列表,但它覆盖了很多方面。 -如果遇到一个特殊的我们没有覆盖的问题,你可以查看[stackoverflow.com](http://stackoverflow.com/tags/spring-boot),看是否已经有人给出了答案;这也是一个很好的提新问题的地方(请使用`spring-boot`标签)。 +如果遇到一个特殊的我们没有覆盖的问题,你可以查看[stackoverflow.com](https://stackoverflow.com/tags/spring-boot),看是否已经有人给出了答案。这也是一个很好的提新问题的地方(请使用`spring-boot`标签)。 -我们也乐意扩展本章节;如果想添加一个'how-to',你可以给我们发一个[pull请求](http://github.com/spring-projects/spring-boot/tree/master)。 +我们也乐意扩展本章节。如果想添加一个'how-to',你可以给我们发一个[合并请求](https://github.com/spring-projects/spring-boot/tree/v2.0.0.RELEASE)。 From 81562a8de9870a82cf1f43377636052bc5a78e9f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E7=83=AD=E5=BF=83=E5=B8=82=E6=B0=91=E9=92=9F=E5=B0=8F?= =?UTF-8?q?=E5=BC=BA?= Date: Wed, 4 Dec 2019 13:10:48 +0800 Subject: [PATCH 670/865] Update SUMMARY.md --- SUMMARY.md | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/SUMMARY.md b/SUMMARY.md index 713ec6ec..7be82297 100644 --- a/SUMMARY.md +++ b/SUMMARY.md @@ -448,12 +448,12 @@ * [71.4. repackage实现示例](VIII. Build tool plugins/71.4. Example Repackage Implementation.md) * [72. 接下来阅读什么](VIII. Build tool plugins/72. What to Read Next.md) * [IX. How-to指南](IX. ‘How-to’ guides/README.md) - * [71. Spring Boot应用](IX. ‘How-to’ guides/71. Spring Boot application.md) - * [71.1 创建自己的FailureAnalyzer](IX. ‘How-to’ guides/71.1 Create your own FailureAnalyzer.md) - * [71.2 解决自动配置问题](IX. ‘How-to’ guides/71.2 Troubleshoot auto-configuration.md) - * [71.3 启动前自定义Environment或ApplicationContext](IX. ‘How-to’ guides/71.3 Customize the Environment or ApplicationContext before it starts.md) - * [71.4 构建ApplicationContext层次结构](IX. ‘How-to’ guides/71.4 Build an ApplicationContext hierarchy(adding a parent or root context).md) - * [71.5 创建no-web应用](IX. ‘How-to’ guides/71.5 Create a non-web application.md) + * [73. Spring Boot应用](IX. ‘How-to’ guides/73. Spring Boot application.md) + * [73.1 创建自己的FailureAnalyzer](IX. ‘How-to’ guides/73.1 Create your own FailureAnalyzer.md) + * [73.2 解决自动配置问题](IX. ‘How-to’ guides/73.2 Troubleshoot auto-configuration.md) + * [73.3 启动前自定义Environment或ApplicationContext](IX. ‘How-to’ guides/73.3 Customize the Environment or ApplicationContext before it starts.md) + * [73.4 构建ApplicationContext层次结构](IX. ‘How-to’ guides/73.4 Build an ApplicationContext hierarchy(adding a parent or root context).md) + * [73.5 创建no-web应用](IX. ‘How-to’ guides/73.5 Create a non-web application.md) * [72. 属性&配置](IX. ‘How-to’ guides/72. Properties & configuration.md) * [72.1. 运行时暴露属性](IX. ‘How-to’ guides/72.1. Automatically expand properties at build time.md) * [72.1.1. 使用Maven自动暴露属性](IX. ‘How-to’ guides/72.1.1. Automatic property expansion using Maven.md) From f548ca1869377a72b2b08b25416867a98d98ae30 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E7=83=AD=E5=BF=83=E5=B8=82=E6=B0=91=E9=92=9F=E5=B0=8F?= =?UTF-8?q?=E5=BC=BA?= Date: Wed, 4 Dec 2019 13:13:16 +0800 Subject: [PATCH 671/865] Update and rename 71. Spring Boot application.md to 73. Spring Boot Application.md --- .../71. Spring Boot application.md" | 1 - .../73. Spring Boot Application.md" | 3 +++ 2 files changed, 3 insertions(+), 1 deletion(-) delete mode 100644 "IX. \342\200\230How-to\342\200\231 guides/71. Spring Boot application.md" create mode 100644 "IX. \342\200\230How-to\342\200\231 guides/73. Spring Boot Application.md" diff --git "a/IX. \342\200\230How-to\342\200\231 guides/71. Spring Boot application.md" "b/IX. \342\200\230How-to\342\200\231 guides/71. Spring Boot application.md" deleted file mode 100644 index 22c3ab58..00000000 --- "a/IX. \342\200\230How-to\342\200\231 guides/71. Spring Boot application.md" +++ /dev/null @@ -1 +0,0 @@ -### 71. Spring Boot应用 diff --git "a/IX. \342\200\230How-to\342\200\231 guides/73. Spring Boot Application.md" "b/IX. \342\200\230How-to\342\200\231 guides/73. Spring Boot Application.md" new file mode 100644 index 00000000..4963ac67 --- /dev/null +++ "b/IX. \342\200\230How-to\342\200\231 guides/73. Spring Boot Application.md" @@ -0,0 +1,3 @@ +### 73. Spring Boot应用 + +本节包含与Spring Boot应用直接相关的主题。 From a0cf3564084f18538e6294edda2915cfe63caea0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E7=83=AD=E5=BF=83=E5=B8=82=E6=B0=91=E9=92=9F=E5=B0=8F?= =?UTF-8?q?=E5=BC=BA?= Date: Wed, 4 Dec 2019 13:17:46 +0800 Subject: [PATCH 672/865] Update SUMMARY.md --- SUMMARY.md | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/SUMMARY.md b/SUMMARY.md index 7be82297..5b322880 100644 --- a/SUMMARY.md +++ b/SUMMARY.md @@ -448,12 +448,12 @@ * [71.4. repackage实现示例](VIII. Build tool plugins/71.4. Example Repackage Implementation.md) * [72. 接下来阅读什么](VIII. Build tool plugins/72. What to Read Next.md) * [IX. How-to指南](IX. ‘How-to’ guides/README.md) - * [73. Spring Boot应用](IX. ‘How-to’ guides/73. Spring Boot application.md) - * [73.1 创建自己的FailureAnalyzer](IX. ‘How-to’ guides/73.1 Create your own FailureAnalyzer.md) - * [73.2 解决自动配置问题](IX. ‘How-to’ guides/73.2 Troubleshoot auto-configuration.md) - * [73.3 启动前自定义Environment或ApplicationContext](IX. ‘How-to’ guides/73.3 Customize the Environment or ApplicationContext before it starts.md) - * [73.4 构建ApplicationContext层次结构](IX. ‘How-to’ guides/73.4 Build an ApplicationContext hierarchy(adding a parent or root context).md) - * [73.5 创建no-web应用](IX. ‘How-to’ guides/73.5 Create a non-web application.md) + * [73. Spring Boot应用](IX. ‘How-to’ guides/73. Spring Boot Application.md) + * [73.1 创建自己的FailureAnalyzer](IX. ‘How-to’ guides/73.1 Create Your Own FailureAnalyzer.md) + * [73.2 解决自动配置问题](IX. ‘How-to’ guides/73.2 Troubleshoot Auto-configuration.md) + * [73.3 启动前自定义Environment或ApplicationContext](IX. ‘How-to’ guides/73.3 Customize the Environment or ApplicationContext Before It Starts.md) + * [73.4 构建ApplicationContext层次结构](IX. ‘How-to’ guides/73.4 Build an ApplicationContext Hierarchy(Adding a Parent or Root Context).md) + * [73.5 创建no-web应用](IX. ‘How-to’ guides/73.5 Create a Non-web Application.md) * [72. 属性&配置](IX. ‘How-to’ guides/72. Properties & configuration.md) * [72.1. 运行时暴露属性](IX. ‘How-to’ guides/72.1. Automatically expand properties at build time.md) * [72.1.1. 使用Maven自动暴露属性](IX. ‘How-to’ guides/72.1.1. Automatic property expansion using Maven.md) From 1cf50a688afeeaa30017245d335d97a57bb686b7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E7=83=AD=E5=BF=83=E5=B8=82=E6=B0=91=E9=92=9F=E5=B0=8F?= =?UTF-8?q?=E5=BC=BA?= Date: Wed, 4 Dec 2019 13:26:02 +0800 Subject: [PATCH 673/865] Update and rename 71.1 Create your own FailureAnalyzer.md to 73.1 Create Your Own FailureAnalyzer.md --- .../73.1 Create Your Own FailureAnalyzer.md" | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) rename "IX. \342\200\230How-to\342\200\231 guides/71.1 Create your own FailureAnalyzer.md" => "IX. \342\200\230How-to\342\200\231 guides/73.1 Create Your Own FailureAnalyzer.md" (65%) diff --git "a/IX. \342\200\230How-to\342\200\231 guides/71.1 Create your own FailureAnalyzer.md" "b/IX. \342\200\230How-to\342\200\231 guides/73.1 Create Your Own FailureAnalyzer.md" similarity index 65% rename from "IX. \342\200\230How-to\342\200\231 guides/71.1 Create your own FailureAnalyzer.md" rename to "IX. \342\200\230How-to\342\200\231 guides/73.1 Create Your Own FailureAnalyzer.md" index b2e6e1f0..effd4b53 100644 --- "a/IX. \342\200\230How-to\342\200\231 guides/71.1 Create your own FailureAnalyzer.md" +++ "b/IX. \342\200\230How-to\342\200\231 guides/73.1 Create Your Own FailureAnalyzer.md" @@ -1,10 +1,13 @@ -###71.1 创建自己的FailureAnalyzer -[`FailureAnalyzer`](https://docs.spring.io/spring-boot/docs/2.0.0.RELEASE/api/org/springframework/boot/diagnostics/FailureAnalyzer.html)是拦截启动时的异常并将它转换为可读消息的很好方式(包装进[`FailureAnalysis`](https://docs.spring.io/spring-boot/docs/2.0.0.RELEASE/api/org/springframework/boot/diagnostics/FailureAnalysis.html))。Spring Boot为应用上下文相关异常, JSR-303校验等提供分析器,实际上创建你自己的分析器也相当简单。 +### 73.1 创建自己的FailureAnalyzer + +[`FailureAnalyzer`](https://docs.spring.io/spring-boot/docs/2.0.0.RELEASE/api/org/springframework/boot/diagnostics/FailureAnalyzer.html)是拦截启动时的异常并将它转换为可读消息的很好方式(包装进[`FailureAnalysis`](https://docs.spring.io/spring-boot/docs/2.0.0.RELEASE/api/org/springframework/boot/diagnostics/FailureAnalysis.html))。Spring Boot为应用上下文相关异常,JSR-303校验等提供分析器。实际上创建你自己的分析器也相当简单。 `AbstractFailureAnalyzer`是`FailureAnalyzer`的一个方便扩展,根据指定类型的异常是否出现来进行处理。你可以继承它,这样就可以处理实际出现的异常。如果出于某些原因,不能处理该异常,那就返回`null`让其他实现处理。 -`FailureAnalyzer`的实现需要注册到`META-INF/spring.factories`,以下注册了`ProjectConstraintViolationFailureAnalyzer`: +`FailureAnalyzer`的实现必须注册到`META-INF/spring.factories`。以下注册了`ProjectConstraintViolationFailureAnalyzer`: ```properties org.springframework.boot.diagnostics.FailureAnalyzer=\ com.example.ProjectConstraintViolationFailureAnalyzer ``` + +**注** 如果你需要访问`BeanFactory`或`Environment`,你的`FailureAnalyzer`可以简单地分别实现`BeanFactoryAware`或`EnvironmentAware`。 From aacb2cfc9d16b48996c7d0d6bdb0f08f2bfe5290 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E7=83=AD=E5=BF=83=E5=B8=82=E6=B0=91=E9=92=9F=E5=B0=8F?= =?UTF-8?q?=E5=BC=BA?= Date: Mon, 9 Dec 2019 20:57:24 +0800 Subject: [PATCH 674/865] Update and rename 71.2 Troubleshoot auto-configuration.md to 73.2 Troubleshoot Auto-configuration.md --- .../73.2 Troubleshoot Auto-configuration.md" | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-) rename "IX. \342\200\230How-to\342\200\231 guides/71.2 Troubleshoot auto-configuration.md" => "IX. \342\200\230How-to\342\200\231 guides/73.2 Troubleshoot Auto-configuration.md" (54%) diff --git "a/IX. \342\200\230How-to\342\200\231 guides/71.2 Troubleshoot auto-configuration.md" "b/IX. \342\200\230How-to\342\200\231 guides/73.2 Troubleshoot Auto-configuration.md" similarity index 54% rename from "IX. \342\200\230How-to\342\200\231 guides/71.2 Troubleshoot auto-configuration.md" rename to "IX. \342\200\230How-to\342\200\231 guides/73.2 Troubleshoot Auto-configuration.md" index 9fd161a4..2abcc943 100644 --- "a/IX. \342\200\230How-to\342\200\231 guides/71.2 Troubleshoot auto-configuration.md" +++ "b/IX. \342\200\230How-to\342\200\231 guides/73.2 Troubleshoot Auto-configuration.md" @@ -1,4 +1,4 @@ -### 71.2 解决自动配置问题 +### 73.2 解决自动配置问题 Spring Boot自动配置总是尝试尽最大努力去做正确的事,但有时候会失败并且很难说出失败原因。 @@ -7,9 +7,8 @@ Spring Boot自动配置总是尝试尽最大努力去做正确的事,但有时 通过查看源码和javadoc可以获取更多问题的答案,以下是一些经验: * 查找名为`*AutoConfiguration`的类并阅读源码,特别是`@Conditional*`注解,这可以帮你找出它们启用哪些特性及何时启用。 -将`--debug`添加到命令行或添加系统属性`-Ddebug`可以在控制台查看日志,该日志会记录你的应用中所有自动配置的决策。在运行Actuator的app中,通过查看`autoconfig`端点(`/autoconfig`或等效的JMX)可以获取相同信息。 -* 查找`@ConfigurationProperties`的类(比如[ServerProperties](http://github.com/spring-projects/spring-boot/tree/master/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/web/ServerProperties.java))并看下有哪些可用的外部配置选项。`@ConfigurationProperties`类有一个用于充当外部配置前缀的`name`属性,因此`ServerProperties`的`prefix="server"`,它的配置属性有`server.port`,`server.address`等。在运行Actuator的应用中可以查看`configprops`端点。 -* 查看`RelaxedPropertyResolver`明确地将配置从`Environment`暴露出去,它经常会使用前缀。 -* 查看`@Value`注解,它直接绑定到`Environment`。相比`RelaxedPropertyResolver`,这种方式稍微缺乏灵活性,但它也允许松散的绑定,特别是OS环境变量(所以`CAPITALS_AND_UNDERSCORES`是`period.separated`的同义词)。 +将`--debug`添加到命令行或添加系统属性`-Ddebug`可以在控制台查看日志,该日志会记录你的应用中所有自动配置的决策。在运行Actuator的app中,通过查看`autoconfig`端点(`/actuator/conditions`或等效的JMX)可以获取相同信息。 +* 查找`@ConfigurationProperties`的类(比如[ServerProperties](https://github.com/spring-projects/spring-boot/tree/v2.0.0.RELEASE/spring-boot-project/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/web/ServerProperties.java))并看下有哪些可用的外部配置选项。`@ConfigurationProperties`类有一个用于充当外部配置前缀的`name`属性,因此`ServerProperties`的`prefix="server"`,它的配置属性有`server.port`,`server.address`等。在运行Actuator的应用中可以查看`configprops`端点。 +* 使用`绑定器`上的`bind`方法以轻松的方式从`环境`中显式地提取配置值。它通常与前缀一起使用。 +* 查看`@Value`注解,它直接绑定到`Environment`。 * 查看`@ConditionalOnExpression`注解,它根据SpEL表达式的结果来开启或关闭特性,通常使用解析自`Environment`的占位符进行计算。 - From 3eebac641e628645478825d1455aff5f7090fc84 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E7=83=AD=E5=BF=83=E5=B8=82=E6=B0=91=E9=92=9F=E5=B0=8F?= =?UTF-8?q?=E5=BC=BA?= Date: Mon, 9 Dec 2019 21:26:23 +0800 Subject: [PATCH 675/865] Update and rename 71.3 Customize the Environment or ApplicationContext before it starts.md to 73.3 Customize the Environment or ApplicationContext Before It Starts.md --- ...or ApplicationContext before it starts.md" | 14 ------ ...or ApplicationContext Before It Starts.md" | 47 +++++++++++++++++++ 2 files changed, 47 insertions(+), 14 deletions(-) delete mode 100644 "IX. \342\200\230How-to\342\200\231 guides/71.3 Customize the Environment or ApplicationContext before it starts.md" create mode 100644 "IX. \342\200\230How-to\342\200\231 guides/73.3 Customize the Environment or ApplicationContext Before It Starts.md" diff --git "a/IX. \342\200\230How-to\342\200\231 guides/71.3 Customize the Environment or ApplicationContext before it starts.md" "b/IX. \342\200\230How-to\342\200\231 guides/71.3 Customize the Environment or ApplicationContext before it starts.md" deleted file mode 100644 index fe8cb9af..00000000 --- "a/IX. \342\200\230How-to\342\200\231 guides/71.3 Customize the Environment or ApplicationContext before it starts.md" +++ /dev/null @@ -1,14 +0,0 @@ -### 71.3 启动前自定义Environment或ApplicationContext - -每个`SpringApplication`都有`ApplicationListeners`和`ApplicationContextInitializers`,用于自定义上下文(context)或环境(environment)。Spring Boot从`META-INF/spring.factories`下加载很多这样的内部使用的自定义,有很多方法可以注册其他的自定义: - -* 以编程方式为每个应用注册自定义,通过在`SpringApplication`运行前调用它的`addListeners`和`addInitializers`方法来实现。 -* 以声明方式为每个应用注册自定义,通过设置`context.initializer.classes`或`context.listener.classes`来实现。 -* 以声明方式为所有应用注册自定义,通过添加一个`META-INF/spring.factories`并打包成一个jar文件(该应用将它作为一个库)来实现。 - -`SpringApplication`会给监听器(即使是在上下文被创建之前就存在的)发送一些特定的`ApplicationEvents`,然后也会注册监听`ApplicationContext`发布的事件的监听器,查看Spring Boot特性章节中的[Section 23.5, “Application events and listeners” ](../IV. Spring Boot features/23.5. Application events and listeners.md)可以获取完整列表。 - -在应用上下文刷新前使用`EnvironmentPostProcessor`自定义`Environment`是可能的,每个实现都需要注册到`META-INF/spring.factories`: -```properties -org.springframework.boot.env.EnvironmentPostProcessor=com.example.YourEnvironmentPostProcessor -``` diff --git "a/IX. \342\200\230How-to\342\200\231 guides/73.3 Customize the Environment or ApplicationContext Before It Starts.md" "b/IX. \342\200\230How-to\342\200\231 guides/73.3 Customize the Environment or ApplicationContext Before It Starts.md" new file mode 100644 index 00000000..9a09b9f7 --- /dev/null +++ "b/IX. \342\200\230How-to\342\200\231 guides/73.3 Customize the Environment or ApplicationContext Before It Starts.md" @@ -0,0 +1,47 @@ +### 73.3 启动前自定义Environment或ApplicationContext + +每个`SpringApplication`都有`ApplicationListeners`和`ApplicationContextInitializers`,用于自定义上下文(context)或环境(environment)。Spring Boot从`META-INF/spring.factories`下加载很多这样的内部使用的自定义,有很多方法可以注册其他的自定义: + +* 以编程方式为每个应用注册自定义,通过在`SpringApplication`运行前调用它的`addListeners`和`addInitializers`方法来实现。 +* 以声明方式为每个应用注册自定义,通过设置`context.initializer.classes`或`context.listener.classes`来实现。 +* 以声明方式为所有应用注册自定义,通过添加一个`META-INF/spring.factories`并打包成一个jar文件(该应用将它作为一个库)来实现。 + +`SpringApplication`会给监听器(即使是在上下文被创建之前就存在的)发送一些特定的`ApplicationEvents`,然后也会注册监听`ApplicationContext`发布的事件的监听器,查看Spring Boot特性章节中的[23.5. 应用事件和监听器](https://docs.spring.io/spring-boot/docs/2.0.0.RELEASE/reference/htmlsingle/#boot-features-application-events-and-listeners)可以获取完整列表。 + +在应用上下文刷新前使用`EnvironmentPostProcessor`自定义`Environment`是可能的,每个实现都需要注册到`META-INF/spring.factories`: +```properties +org.springframework.boot.env.EnvironmentPostProcessor=com.example.YourEnvironmentPostProcessor +``` + +可以加载任意文件并将它们添加到`环境`中。例如,下面的例子从类路径加载一个YAML配置文件: +```java +public class EnvironmentPostProcessorExample implements EnvironmentPostProcessor { + + private final YamlPropertySourceLoader loader = new YamlPropertySourceLoader(); + + @Override + public void postProcessEnvironment(ConfigurableEnvironment environment, + SpringApplication application) { + Resource path = new ClassPathResource("com/example/myapp/config.yml"); + PropertySource propertySource = loadYaml(path); + environment.getPropertySources().addLast(propertySource); + } + + private PropertySource loadYaml(Resource path) { + if (!path.exists()) { + throw new IllegalArgumentException("Resource " + path + " does not exist"); + } + try { + return this.loader.load("custom-resource", path).get(0); + } + catch (IOException ex) { + throw new IllegalStateException( + "Failed to load yaml configuration from " + path, ex); + } + } + +} +``` +**注** 在默认情况下,`环境`已经准备好了所有通常由Spring Boot加载的属性源。因此,可以从环境中获取文件的位置。前面的示例将`自定义资源属性源`添加到列表的末尾,以便在任何其他位置定义的键具有优先级。自定义实现可以定义另一种顺序。 + +**警告** 虽然在`@SpringBootApplication`上使用`@PropertySource`似乎是在`环境`中加载自定义资源的一种方便而简单的方法,但是我们不推荐使用它,因为SpringBoot在刷新`ApplicationContext`之前就准备好了`环境`。使用`@PropertySource`定义的任何键加载太迟,对自动配置没有任何影响。 From 4e840091682a9194db0c1edf81e5775d953b2408 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E7=83=AD=E5=BF=83=E5=B8=82=E6=B0=91=E9=92=9F=E5=B0=8F?= =?UTF-8?q?=E5=BC=BA?= Date: Mon, 9 Dec 2019 21:39:30 +0800 Subject: [PATCH 676/865] =?UTF-8?q?Update=20and=20rename=2071.4=20Build=20?= =?UTF-8?q?an=20ApplicationContext=20hierarchy=EF=BC=88adding=20a=20parent?= =?UTF-8?q?=20or=20root=20context=EF=BC=89.md=20to=2073.4=20Build=20an=20A?= =?UTF-8?q?pplicationContext=20Hierarchy=EF=BC=88Adding=20a=20Parent=20or?= =?UTF-8?q?=20Root=20Context=EF=BC=89.md?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- ...\357\274\210adding a parent or root context\357\274\211.md" | 3 --- ...\357\274\210Adding a Parent or Root Context\357\274\211.md" | 3 +++ 2 files changed, 3 insertions(+), 3 deletions(-) delete mode 100644 "IX. \342\200\230How-to\342\200\231 guides/71.4 Build an ApplicationContext hierarchy\357\274\210adding a parent or root context\357\274\211.md" create mode 100644 "IX. \342\200\230How-to\342\200\231 guides/73.4 Build an ApplicationContext Hierarchy\357\274\210Adding a Parent or Root Context\357\274\211.md" diff --git "a/IX. \342\200\230How-to\342\200\231 guides/71.4 Build an ApplicationContext hierarchy\357\274\210adding a parent or root context\357\274\211.md" "b/IX. \342\200\230How-to\342\200\231 guides/71.4 Build an ApplicationContext hierarchy\357\274\210adding a parent or root context\357\274\211.md" deleted file mode 100644 index b04fbca5..00000000 --- "a/IX. \342\200\230How-to\342\200\231 guides/71.4 Build an ApplicationContext hierarchy\357\274\210adding a parent or root context\357\274\211.md" +++ /dev/null @@ -1,3 +0,0 @@ -### 71.4 构建ApplicationContext层次结构(添加父或根上下文) - -你可以使用`ApplicationBuilder`类创建parent/child `ApplicationContext`层次结构,查看'Spring Boot特性'章节的[Section 23.4, “Fluent builder API” ](../IV. Spring Boot features/23.4. Fluent builder API.md)获取更多信息。 diff --git "a/IX. \342\200\230How-to\342\200\231 guides/73.4 Build an ApplicationContext Hierarchy\357\274\210Adding a Parent or Root Context\357\274\211.md" "b/IX. \342\200\230How-to\342\200\231 guides/73.4 Build an ApplicationContext Hierarchy\357\274\210Adding a Parent or Root Context\357\274\211.md" new file mode 100644 index 00000000..ae8bd39b --- /dev/null +++ "b/IX. \342\200\230How-to\342\200\231 guides/73.4 Build an ApplicationContext Hierarchy\357\274\210Adding a Parent or Root Context\357\274\211.md" @@ -0,0 +1,3 @@ +### 73.4 构建ApplicationContext层次结构(添加父或根上下文) + +你可以使用`ApplicationBuilder`类创建parent/child `ApplicationContext`层次结构,查看“Spring Boot特性”章节的[23.4. 流式构建API](https://docs.spring.io/spring-boot/docs/2.0.0.RELEASE/reference/htmlsingle/#boot-features-fluent-builder-api)获取更多信息。 From 69c45c12122242bc663891ab02aa168a29c7226b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E7=83=AD=E5=BF=83=E5=B8=82=E6=B0=91=E9=92=9F=E5=B0=8F?= =?UTF-8?q?=E5=BC=BA?= Date: Mon, 9 Dec 2019 21:43:14 +0800 Subject: [PATCH 677/865] Update and rename 71.5 Create a non-web application.md to 73.5 Create a Non-web Application.md --- .../73.5 Create a Non-web Application.md" | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) rename "IX. \342\200\230How-to\342\200\231 guides/71.5 Create a non-web application.md" => "IX. \342\200\230How-to\342\200\231 guides/73.5 Create a Non-web Application.md" (96%) diff --git "a/IX. \342\200\230How-to\342\200\231 guides/71.5 Create a non-web application.md" "b/IX. \342\200\230How-to\342\200\231 guides/73.5 Create a Non-web Application.md" similarity index 96% rename from "IX. \342\200\230How-to\342\200\231 guides/71.5 Create a non-web application.md" rename to "IX. \342\200\230How-to\342\200\231 guides/73.5 Create a Non-web Application.md" index 308d3c8f..6d68cd45 100644 --- "a/IX. \342\200\230How-to\342\200\231 guides/71.5 Create a non-web application.md" +++ "b/IX. \342\200\230How-to\342\200\231 guides/73.5 Create a Non-web Application.md" @@ -1,3 +1,3 @@ -### 71.5 创建no-web应用 +### 73.5 创建no-web应用 不是所有的Spring应用都必须是web应用(或web服务)。如果你想在`main`方法中执行一些代码,但需要启动一个Spring应用去设置需要的底层设施,那使用Spring Boot的`SpringApplication`特性可以很容易实现。`SpringApplication`会根据它是否需要一个web应用来改变它的`ApplicationContext`类,首先你需要做的是去掉servlet API依赖,如果不能这样做(比如基于相同的代码运行两个应用),那你可以明确地调用`SpringApplication.setWebEnvironment(false)`或设置`applicationContextClass`属性(通过Java API或使用外部配置)。你想运行的,作为业务逻辑的应用代码可以实现为一个`CommandLineRunner`,并将上下文降级为一个`@Bean`定义。 From 5545b908d8187c36cbd75b0e609f39eac10e8937 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E7=83=AD=E5=BF=83=E5=B8=82=E6=B0=91=E9=92=9F=E5=B0=8F?= =?UTF-8?q?=E5=BC=BA?= Date: Tue, 10 Dec 2019 12:38:31 +0800 Subject: [PATCH 678/865] Update SUMMARY.md --- SUMMARY.md | 22 +++++++++++----------- 1 file changed, 11 insertions(+), 11 deletions(-) diff --git a/SUMMARY.md b/SUMMARY.md index 5b322880..346e7a2b 100644 --- a/SUMMARY.md +++ b/SUMMARY.md @@ -454,17 +454,17 @@ * [73.3 启动前自定义Environment或ApplicationContext](IX. ‘How-to’ guides/73.3 Customize the Environment or ApplicationContext Before It Starts.md) * [73.4 构建ApplicationContext层次结构](IX. ‘How-to’ guides/73.4 Build an ApplicationContext Hierarchy(Adding a Parent or Root Context).md) * [73.5 创建no-web应用](IX. ‘How-to’ guides/73.5 Create a Non-web Application.md) - * [72. 属性&配置](IX. ‘How-to’ guides/72. Properties & configuration.md) - * [72.1. 运行时暴露属性](IX. ‘How-to’ guides/72.1. Automatically expand properties at build time.md) - * [72.1.1. 使用Maven自动暴露属性](IX. ‘How-to’ guides/72.1.1. Automatic property expansion using Maven.md) - * [72.1.2. 使用Gradle自动暴露属性](IX. ‘How-to’ guides/72.1.2. Automatic property expansion using Gradle.md) - * [72.2. 外部化SpringApplication配置](IX. ‘How-to’ guides/72.2. Externalize the configuration of SpringApplication.md) - * [72.3 改变应用程序外部配置文件的位置](IX. ‘How-to’ guides/72.3 Change the location of external properties of an application.md) - * [72.4 使用'short'命令行参数](IX. ‘How-to’ guides/72.4 Use ‘short’ command line arguments.md) - * [72.5 使用YAML配置外部属性](IX. ‘How-to’ guides/72.5 Use YAML for external properties.md) - * [72.6 设置生效的Spring profiles](IX. ‘How-to’ guides/72.6 Set the active Spring profiles.md) - * [72.7 根据环境改变配置](IX. ‘How-to’ guides/72.7 Change configuration depending on the environment.md) - * [72.8 发现外部属性的内置选项](IX. ‘How-to’ guides/72.8 Discover built-in options for external properties.md) + * [74. 属性与配置](IX. ‘How-to’ guides/74. Properties and Configuration.md) + * [74.1. 运行时暴露属性](IX. ‘How-to’ guides/74.1. Automatically Expand Properties at Build Time.md) + * [74.1.1. 使用Maven自动暴露属性](IX. ‘How-to’ guides/74.1.1. Automatic Property Expansion Using Maven.md) + * [74.1.2. 使用Gradle自动暴露属性](IX. ‘How-to’ guides/74.1.2. Automatic Property Expansion Using Gradle.md) + * [74.2. 外部化SpringApplication配置](IX. ‘How-to’ guides/74.2. Externalize the Configuration of SpringApplication.md) + * [74.3 改变应用程序外部配置文件的位置](IX. ‘How-to’ guides/74.3 Change the Location of External Properties of an Application.md) + * [74.4 使用'short'命令行参数](IX. ‘How-to’ guides/72.4 Use ‘Short’ Command Line Arguments.md) + * [74.5 使用YAML配置外部属性](IX. ‘How-to’ guides/74.5 Use YAML for External Properties.md) + * [74.6 设置生效的Spring profiles](IX. ‘How-to’ guides/74.6 Set the Active Spring Profiles.md) + * [74.7 根据环境改变配置](IX. ‘How-to’ guides/74.7 Change Configuration Depending on the Environment.md) + * [74.8 发现外部属性的内置选项](IX. ‘How-to’ guides/74.8 Discover Built-in Options for External Properties.md) * [73. 内嵌servlet容器](IX. ‘How-to’ guides/73. Embedded servlet containers.md) * [73.1 为应用添加Servlet,Filter或Listener](IX. ‘How-to’ guides/73.1 Add a Servlet, Filter or ServletContextListener to an application.md) * [73.1.1 使用Spring bean添加Servlet, Filter或Listener](IX. ‘How-to’ guides/73.1.1 Add a Servlet, Filter or Listener using a Spring bean.md) From 4846b9094583ce0ec0f18f7187cc49154f683b7b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E7=83=AD=E5=BF=83=E5=B8=82=E6=B0=91=E9=92=9F=E5=B0=8F?= =?UTF-8?q?=E5=BC=BA?= Date: Tue, 10 Dec 2019 12:39:20 +0800 Subject: [PATCH 679/865] Update SUMMARY.md --- SUMMARY.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/SUMMARY.md b/SUMMARY.md index 346e7a2b..76586862 100644 --- a/SUMMARY.md +++ b/SUMMARY.md @@ -460,7 +460,7 @@ * [74.1.2. 使用Gradle自动暴露属性](IX. ‘How-to’ guides/74.1.2. Automatic Property Expansion Using Gradle.md) * [74.2. 外部化SpringApplication配置](IX. ‘How-to’ guides/74.2. Externalize the Configuration of SpringApplication.md) * [74.3 改变应用程序外部配置文件的位置](IX. ‘How-to’ guides/74.3 Change the Location of External Properties of an Application.md) - * [74.4 使用'short'命令行参数](IX. ‘How-to’ guides/72.4 Use ‘Short’ Command Line Arguments.md) + * [74.4 使用'short'命令行参数](IX. ‘How-to’ guides/74.4 Use ‘Short’ Command Line Arguments.md) * [74.5 使用YAML配置外部属性](IX. ‘How-to’ guides/74.5 Use YAML for External Properties.md) * [74.6 设置生效的Spring profiles](IX. ‘How-to’ guides/74.6 Set the Active Spring Profiles.md) * [74.7 根据环境改变配置](IX. ‘How-to’ guides/74.7 Change Configuration Depending on the Environment.md) From 6eab26b67fe7f06368137dddfbb013df687fd4d5 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E7=83=AD=E5=BF=83=E5=B8=82=E6=B0=91=E9=92=9F=E5=B0=8F?= =?UTF-8?q?=E5=BC=BA?= Date: Tue, 10 Dec 2019 12:43:31 +0800 Subject: [PATCH 680/865] Update and rename 72. Properties & configuration.md to 74. Properties and Configuration.md --- .../72. Properties & configuration.md" | 1 - .../74. Properties and Configuration.md" | 3 +++ 2 files changed, 3 insertions(+), 1 deletion(-) delete mode 100644 "IX. \342\200\230How-to\342\200\231 guides/72. Properties & configuration.md" create mode 100644 "IX. \342\200\230How-to\342\200\231 guides/74. Properties and Configuration.md" diff --git "a/IX. \342\200\230How-to\342\200\231 guides/72. Properties & configuration.md" "b/IX. \342\200\230How-to\342\200\231 guides/72. Properties & configuration.md" deleted file mode 100644 index 3171572a..00000000 --- "a/IX. \342\200\230How-to\342\200\231 guides/72. Properties & configuration.md" +++ /dev/null @@ -1 +0,0 @@ -### 72. 属性&配置 diff --git "a/IX. \342\200\230How-to\342\200\231 guides/74. Properties and Configuration.md" "b/IX. \342\200\230How-to\342\200\231 guides/74. Properties and Configuration.md" new file mode 100644 index 00000000..8da1680f --- /dev/null +++ "b/IX. \342\200\230How-to\342\200\231 guides/74. Properties and Configuration.md" @@ -0,0 +1,3 @@ +### 74. 属性与配置 + +本节包括有关设置和读取属性、配置设置及其与Spring Boot应用程序的交互的主题。 From e158c6194d9533d7d4102484f761b0e60ca6f119 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E7=83=AD=E5=BF=83=E5=B8=82=E6=B0=91=E9=92=9F=E5=B0=8F?= =?UTF-8?q?=E5=BC=BA?= Date: Tue, 10 Dec 2019 12:45:45 +0800 Subject: [PATCH 681/865] Update and rename 72.1. Automatically expand properties at build time.md to 74.1. Automatically Expand Properties at Build Time.md --- .../72.1. Automatically expand properties at build time.md" | 3 --- .../74.1. Automatically Expand Properties at Build Time.md" | 3 +++ 2 files changed, 3 insertions(+), 3 deletions(-) delete mode 100644 "IX. \342\200\230How-to\342\200\231 guides/72.1. Automatically expand properties at build time.md" create mode 100644 "IX. \342\200\230How-to\342\200\231 guides/74.1. Automatically Expand Properties at Build Time.md" diff --git "a/IX. \342\200\230How-to\342\200\231 guides/72.1. Automatically expand properties at build time.md" "b/IX. \342\200\230How-to\342\200\231 guides/72.1. Automatically expand properties at build time.md" deleted file mode 100644 index 4d9dce34..00000000 --- "a/IX. \342\200\230How-to\342\200\231 guides/72.1. Automatically expand properties at build time.md" +++ /dev/null @@ -1,3 +0,0 @@ -###72.1. 运行时暴露属性 - -相对于在项目构建配置中硬编码某些配置,你可以使用已存在的构建配置自动暴露它们,Maven和Gradle都支持。 diff --git "a/IX. \342\200\230How-to\342\200\231 guides/74.1. Automatically Expand Properties at Build Time.md" "b/IX. \342\200\230How-to\342\200\231 guides/74.1. Automatically Expand Properties at Build Time.md" new file mode 100644 index 00000000..3b4cbd36 --- /dev/null +++ "b/IX. \342\200\230How-to\342\200\231 guides/74.1. Automatically Expand Properties at Build Time.md" @@ -0,0 +1,3 @@ +### 74.1. 运行时暴露属性 + +相对于在项目构建配置中硬编码某些配置,你可以使用已存在的构建配置自动暴露它们。Maven和Gradle都支持。 From 3afe662bbadcb27d75c5b25aa9d679ecc8a55f07 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E7=83=AD=E5=BF=83=E5=B8=82=E6=B0=91=E9=92=9F=E5=B0=8F?= =?UTF-8?q?=E5=BC=BA?= Date: Tue, 10 Dec 2019 12:52:46 +0800 Subject: [PATCH 682/865] Update and rename 72.1.1. Automatic property expansion using Maven.md to 74.1.1. Automatic Property Expansion Using Maven.md --- ....1.1. Automatic Property Expansion Using Maven.md" | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) rename "IX. \342\200\230How-to\342\200\231 guides/72.1.1. Automatic property expansion using Maven.md" => "IX. \342\200\230How-to\342\200\231 guides/74.1.1. Automatic Property Expansion Using Maven.md" (68%) diff --git "a/IX. \342\200\230How-to\342\200\231 guides/72.1.1. Automatic property expansion using Maven.md" "b/IX. \342\200\230How-to\342\200\231 guides/74.1.1. Automatic Property Expansion Using Maven.md" similarity index 68% rename from "IX. \342\200\230How-to\342\200\231 guides/72.1.1. Automatic property expansion using Maven.md" rename to "IX. \342\200\230How-to\342\200\231 guides/74.1.1. Automatic Property Expansion Using Maven.md" index 56bfe72f..9e77be67 100644 --- "a/IX. \342\200\230How-to\342\200\231 guides/72.1.1. Automatic property expansion using Maven.md" +++ "b/IX. \342\200\230How-to\342\200\231 guides/74.1.1. Automatic Property Expansion Using Maven.md" @@ -1,11 +1,14 @@ -###72.1.1. 使用Maven自动暴露属性 +### 74.1.1. 使用Maven自动暴露属性 -你可以使用Maven的资源过滤(resource filter)自动暴露来自Maven项目的属性,如果使用`spring-boot-starter-parent`,你可以通过`@..@`占位符引用Maven项目的属性,例如: +你可以使用Maven的资源过滤自动暴露来自Maven项目的属性,如果使用`spring-boot-starter-parent`,你可以通过`@..@`占位符引用Maven项目的属性,例如: ```properties app.encoding=@project.build.sourceEncoding@ app.java.version=@java.version@ ``` -**注** 如果启用`addResources`标识,`spring-boot:run`可以将`src/main/resources`直接添加到classpath(出于热加载目的),这就绕过了资源过滤和本特性。你可以使用`exec:java`目标进行替代,或自定义该插件的配置,具体查看[插件使用页面](https://docs.spring.io/spring-boot/docs/2.0.0.RELEASE/maven-plugin//usage.html)。 + +**注** 仅对生产配置进行过滤(换句话说,对`src/test/resources`不应用过滤)。 + +**注** 如果启用`addResources`标识,`spring-boot:run`可以将`src/main/resources`直接添加到classpath(出于热加载目的),这就绕过了资源过滤和本特性。你可以使用`exec:java`目标进行替代,或自定义该插件的配置,具体查看[插件使用页面](https://docs.spring.io/spring-boot/docs/2.0.0.RELEASE/maven-plugin/usage.html)。 如果不使用starter parent,你需要将以下片段添加到`pom.xml`中(``元素内): ```xml @@ -31,4 +34,4 @@ app.java.version=@java.version@ ``` -**注** 如果你在配置中使用标准的Spring占位符(比如`${foo}`)且没有将`useDefaultDelimiters`属性设置为`false`,那构建时这些属性将被暴露出去。 +**注** 如果你在配置中使用标准的Spring占位符(比如`${placeholder}`)且没有将`useDefaultDelimiters`属性设置为`false`,那构建时这些属性将被暴露出去。 From a7e04dae64548d301367945a4755180a8335f228 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E7=83=AD=E5=BF=83=E5=B8=82=E6=B0=91=E9=92=9F=E5=B0=8F?= =?UTF-8?q?=E5=BC=BA?= Date: Tue, 10 Dec 2019 12:55:18 +0800 Subject: [PATCH 683/865] Update and rename 72.1.2. Automatic property expansion using Gradle.md to 74.1.2. Automatic Property Expansion Using Gradle.md --- .../74.1.2. Automatic Property Expansion Using Gradle.md" | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) rename "IX. \342\200\230How-to\342\200\231 guides/72.1.2. Automatic property expansion using Gradle.md" => "IX. \342\200\230How-to\342\200\231 guides/74.1.2. Automatic Property Expansion Using Gradle.md" (92%) diff --git "a/IX. \342\200\230How-to\342\200\231 guides/72.1.2. Automatic property expansion using Gradle.md" "b/IX. \342\200\230How-to\342\200\231 guides/74.1.2. Automatic Property Expansion Using Gradle.md" similarity index 92% rename from "IX. \342\200\230How-to\342\200\231 guides/72.1.2. Automatic property expansion using Gradle.md" rename to "IX. \342\200\230How-to\342\200\231 guides/74.1.2. Automatic Property Expansion Using Gradle.md" index bd8a97a8..898ae75e 100644 --- "a/IX. \342\200\230How-to\342\200\231 guides/72.1.2. Automatic property expansion using Gradle.md" +++ "b/IX. \342\200\230How-to\342\200\231 guides/74.1.2. Automatic Property Expansion Using Gradle.md" @@ -1,4 +1,4 @@ -###72.1.2. 使用Gradle自动暴露属性 +### 74.1.2. 使用Gradle自动暴露属性 你可以通过配置Java插件的`processResources`任务自动暴露来自Gradle项目的属性: ```gradle From e42be9066e4069d92e75895e98957f749330c015 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E7=83=AD=E5=BF=83=E5=B8=82=E6=B0=91=E9=92=9F=E5=B0=8F?= =?UTF-8?q?=E5=BC=BA?= Date: Tue, 10 Dec 2019 12:59:34 +0800 Subject: [PATCH 684/865] Update and rename 72.2. Externalize the configuration of SpringApplication.md to 74.2. Externalize the Configuration of SpringApplication.md --- ...74.2. Externalize the Configuration of SpringApplication.md" | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) rename "IX. \342\200\230How-to\342\200\231 guides/72.2. Externalize the configuration of SpringApplication.md" => "IX. \342\200\230How-to\342\200\231 guides/74.2. Externalize the Configuration of SpringApplication.md" (94%) diff --git "a/IX. \342\200\230How-to\342\200\231 guides/72.2. Externalize the configuration of SpringApplication.md" "b/IX. \342\200\230How-to\342\200\231 guides/74.2. Externalize the Configuration of SpringApplication.md" similarity index 94% rename from "IX. \342\200\230How-to\342\200\231 guides/72.2. Externalize the configuration of SpringApplication.md" rename to "IX. \342\200\230How-to\342\200\231 guides/74.2. Externalize the Configuration of SpringApplication.md" index 27d9dcb1..13eaca87 100644 --- "a/IX. \342\200\230How-to\342\200\231 guides/72.2. Externalize the configuration of SpringApplication.md" +++ "b/IX. \342\200\230How-to\342\200\231 guides/74.2. Externalize the Configuration of SpringApplication.md" @@ -1,4 +1,4 @@ -### 72.2. 外部化SpringApplication配置 +### 74.2. 外部化SpringApplication配置 SpringApplication已经被属性化(主要是setters),所以你可以在创建应用时使用它的Java API修改其行为,或者使用以`spring.main.*`为key的属性来外部化这些配置。比如,在`application.properties`中可能会有以下内容: ```java From d2a9e8851c555ced6cb279f9ad7f9a1c0913dc24 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E7=83=AD=E5=BF=83=E5=B8=82=E6=B0=91=E9=92=9F=E5=B0=8F?= =?UTF-8?q?=E5=BC=BA?= Date: Tue, 10 Dec 2019 13:03:09 +0800 Subject: [PATCH 685/865] Update and rename 72.3 Change the location of external properties of an application.md to 74.3 Change the Location of External Properties of an Application.md --- ...he Location of External Properties of an Application.md" | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) rename "IX. \342\200\230How-to\342\200\231 guides/72.3 Change the location of external properties of an application.md" => "IX. \342\200\230How-to\342\200\231 guides/74.3 Change the Location of External Properties of an Application.md" (74%) diff --git "a/IX. \342\200\230How-to\342\200\231 guides/72.3 Change the location of external properties of an application.md" "b/IX. \342\200\230How-to\342\200\231 guides/74.3 Change the Location of External Properties of an Application.md" similarity index 74% rename from "IX. \342\200\230How-to\342\200\231 guides/72.3 Change the location of external properties of an application.md" rename to "IX. \342\200\230How-to\342\200\231 guides/74.3 Change the Location of External Properties of an Application.md" index 8f2a41e5..7ba7174d 100644 --- "a/IX. \342\200\230How-to\342\200\231 guides/72.3 Change the location of external properties of an application.md" +++ "b/IX. \342\200\230How-to\342\200\231 guides/74.3 Change the Location of External Properties of an Application.md" @@ -1,6 +1,6 @@ -### 72.3 改变应用程序外部配置文件的位置 +### 74.3 改变应用程序外部配置文件的位置 -默认情况下,来自不同源的属性以一个定义好的顺序添加到Spring的`Environment`中(精确顺序可查看'Sprin Boot特性'章节的[Chapter 24, Externalized Configuration](../IV. Spring Boot features/24. Externalized Configuration.md))。 +默认情况下,来自不同源的属性以一个定义好的顺序添加到Spring的`Environment`中(精确顺序可查看'Sprin Boot特性'章节的[24.外部化配置](https://docs.spring.io/spring-boot/docs/2.0.0.RELEASE/reference/htmlsingle/#boot-features-external-config))。 为应用程序源添加`@PropertySource`注解是一种很好的添加和修改源顺序的方法。传递给`SpringApplication`静态便利设施(convenience)方法的类和使用`setSources()`添加的类都会被检查,以查看它们是否有`@PropertySources`,如果有,这些属性会被尽可能早的添加到`Environment`里,以确保`ApplicationContext`生命周期的所有阶段都能使用。以这种方式添加的属性优先级低于任何使用默认位置(比如`application.properties`)添加的属性,系统属性,环境变量或命令行参数。 @@ -9,4 +9,4 @@ * `spring.config.name`(`SPRING_CONFIG_NAME`)是根文件名,默认为`application`。 * `spring.config.location`(`SPRING_CONFIG_LOCATION`)是要加载的文件(例如,一个classpath资源或URL)。Spring Boot为该文档设置一个单独的`Environment`属性,它可以被系统属性,环境变量或命令行参数覆盖。 -不管你在environment设置什么,Spring Boot都将加载上面讨论过的`application.properties`。如果使用YAML,那具有`.yml`扩展的文件默认也会被添加到该列表,详情参考[ConfigFileApplicationListener](http://github.com/spring-projects/spring-boot/tree/master/spring-boot/src/main/java/org/springframework/boot/context/config/ConfigFileApplicationListener.java) +不管你在environment设置什么,Spring Boot都将加载上面讨论过的`application.properties`。如果使用YAML,那具有`.yml`扩展的文件默认也会被添加到该列表,详情参考[ConfigFileApplicationListener](https://github.com/spring-projects/spring-boot/tree/v2.0.0.RELEASE/spring-boot-project/spring-boot/src/main/java/org/springframework/boot/context/config/ConfigFileApplicationListener.java) From 2e0aa6fc4a64aefa9daccc158fc1e62d691af764 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E7=83=AD=E5=BF=83=E5=B8=82=E6=B0=91=E9=92=9F=E5=B0=8F?= =?UTF-8?q?=E5=BC=BA?= Date: Tue, 10 Dec 2019 13:08:37 +0800 Subject: [PATCH 686/865] =?UTF-8?q?Update=20and=20rename=2072.4=20Use=20?= =?UTF-8?q?=E2=80=98short=E2=80=99=20command=20line=20arguments.md=20to=20?= =?UTF-8?q?74.4=20Use=20=E2=80=98Short=E2=80=99=20Command=20Line=20Argumen?= =?UTF-8?q?ts.md?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- ...e \342\200\230Short\342\200\231 Command Line Arguments.md" | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) rename "IX. \342\200\230How-to\342\200\231 guides/72.4 Use \342\200\230short\342\200\231 command line arguments.md" => "IX. \342\200\230How-to\342\200\231 guides/74.4 Use \342\200\230Short\342\200\231 Command Line Arguments.md" (73%) diff --git "a/IX. \342\200\230How-to\342\200\231 guides/72.4 Use \342\200\230short\342\200\231 command line arguments.md" "b/IX. \342\200\230How-to\342\200\231 guides/74.4 Use \342\200\230Short\342\200\231 Command Line Arguments.md" similarity index 73% rename from "IX. \342\200\230How-to\342\200\231 guides/72.4 Use \342\200\230short\342\200\231 command line arguments.md" rename to "IX. \342\200\230How-to\342\200\231 guides/74.4 Use \342\200\230Short\342\200\231 Command Line Arguments.md" index 3e9415b1..a2cd1c27 100644 --- "a/IX. \342\200\230How-to\342\200\231 guides/72.4 Use \342\200\230short\342\200\231 command line arguments.md" +++ "b/IX. \342\200\230How-to\342\200\231 guides/74.4 Use \342\200\230Short\342\200\231 Command Line Arguments.md" @@ -1,9 +1,9 @@ -### 72.4 使用'short'命令行参数 +### 74.4 使用“短”命令行参数 有些人喜欢使用(例如)`--port=9000`代替`--server.port=9000`来设置命令行配置属性。你可以通过在`application.properties`中使用占位符来启用该功能,比如: ```properties server.port=${port:8080} ``` -**注** 如果你继承自`spring-boot-starter-parent` POM,为了防止和Spring格式的占位符产生冲突,`maven-resources-plugins`默认的过滤令牌(filter token)已经从`${*}`变为`@`(即`@maven.token@`代替`${maven.token}`)。如果直接启用maven对`application.properties`的过滤,你可能想使用[其他的分隔符](http://maven.apache.org/plugins/maven-resources-plugin/resources-mojo.html#delimiters)替换默认的过滤令牌。 +**注** 如果你继承自`spring-boot-starter-parent` POM,为了防止和Spring格式的占位符产生冲突,`maven-resources-plugins`默认的过滤令牌(filter token)已经从`${*}`变为`@`(即`@maven.token@`代替`${maven.token}`)。如果直接启用Maven对`application.properties`的过滤,你可能想使用[其他的分隔符](https://maven.apache.org/plugins/maven-resources-plugin/resources-mojo.html#delimiters)替换默认的过滤令牌。 **注** 在这种特殊的情况下,端口绑定能够在一个PaaS环境下工作,比如Heroku和Cloud Foundry,因为在这两个平台中`PORT`环境变量是自动设置的,并且Spring能够绑定`Environment`属性的大写同义词。 From 854318c519627bef545aec714b180e4a52bd416d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E7=83=AD=E5=BF=83=E5=B8=82=E6=B0=91=E9=92=9F=E5=B0=8F?= =?UTF-8?q?=E5=BC=BA?= Date: Tue, 10 Dec 2019 13:09:46 +0800 Subject: [PATCH 687/865] Update SUMMARY.md --- SUMMARY.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/SUMMARY.md b/SUMMARY.md index 76586862..68014b5d 100644 --- a/SUMMARY.md +++ b/SUMMARY.md @@ -460,7 +460,7 @@ * [74.1.2. 使用Gradle自动暴露属性](IX. ‘How-to’ guides/74.1.2. Automatic Property Expansion Using Gradle.md) * [74.2. 外部化SpringApplication配置](IX. ‘How-to’ guides/74.2. Externalize the Configuration of SpringApplication.md) * [74.3 改变应用程序外部配置文件的位置](IX. ‘How-to’ guides/74.3 Change the Location of External Properties of an Application.md) - * [74.4 使用'short'命令行参数](IX. ‘How-to’ guides/74.4 Use ‘Short’ Command Line Arguments.md) + * [74.4 使用“短”命令行参数](IX. ‘How-to’ guides/74.4 Use ‘Short’ Command Line Arguments.md) * [74.5 使用YAML配置外部属性](IX. ‘How-to’ guides/74.5 Use YAML for External Properties.md) * [74.6 设置生效的Spring profiles](IX. ‘How-to’ guides/74.6 Set the Active Spring Profiles.md) * [74.7 根据环境改变配置](IX. ‘How-to’ guides/74.7 Change Configuration Depending on the Environment.md) From 5455d1576ca42b4b74a80d90e0629649219b0f07 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E7=83=AD=E5=BF=83=E5=B8=82=E6=B0=91=E9=92=9F=E5=B0=8F?= =?UTF-8?q?=E5=BC=BA?= Date: Tue, 10 Dec 2019 13:13:24 +0800 Subject: [PATCH 688/865] Update and rename 72.5 Use YAML for external properties.md to 74.5 Use YAML for External Properties.md --- .../74.5 Use YAML for External Properties.md" | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) rename "IX. \342\200\230How-to\342\200\231 guides/72.5 Use YAML for external properties.md" => "IX. \342\200\230How-to\342\200\231 guides/74.5 Use YAML for External Properties.md" (77%) diff --git "a/IX. \342\200\230How-to\342\200\231 guides/72.5 Use YAML for external properties.md" "b/IX. \342\200\230How-to\342\200\231 guides/74.5 Use YAML for External Properties.md" similarity index 77% rename from "IX. \342\200\230How-to\342\200\231 guides/72.5 Use YAML for external properties.md" rename to "IX. \342\200\230How-to\342\200\231 guides/74.5 Use YAML for External Properties.md" index 4ea77dc5..3b38ad67 100644 --- "a/IX. \342\200\230How-to\342\200\231 guides/72.5 Use YAML for external properties.md" +++ "b/IX. \342\200\230How-to\342\200\231 guides/74.5 Use YAML for External Properties.md" @@ -1,4 +1,4 @@ -###72.5 使用YAML配置外部属性 +### 74.5 使用YAML配置外部属性 YAML是JSON的一个超集,可以非常方便的将外部配置以层次结构形式存储起来,比如: ```json @@ -19,4 +19,5 @@ spring.datasource.driverClassName=com.mysql.jdbc.Driver spring.datasource.url=jdbc:mysql://localhost/test server.port=9000 ``` -查看'Spring Boot特性'章节的[Section 24.6, “Using YAML instead of Properties”](../IV. Spring Boot features/24.6. Using YAML instead of Properties.md)可以获取更多关于YAML的信息。 + +查看'Spring Boot特性'章节的[24.6. 使用YAML代替Properties](https://docs.spring.io/spring-boot/docs/2.0.0.RELEASE/reference/htmlsingle/#boot-features-external-config-yaml)可以获取更多关于YAML的信息。 From 66e29755508e9598add6b6099f2f5f2e2498e039 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E7=83=AD=E5=BF=83=E5=B8=82=E6=B0=91=E9=92=9F=E5=B0=8F?= =?UTF-8?q?=E5=BC=BA?= Date: Tue, 10 Dec 2019 13:16:31 +0800 Subject: [PATCH 689/865] Update and rename 72.6 Set the active Spring profiles.md to 74.6 Set the Active Spring Profiles.md --- .../74.6 Set the Active Spring Profiles.md" | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) rename "IX. \342\200\230How-to\342\200\231 guides/72.6 Set the active Spring profiles.md" => "IX. \342\200\230How-to\342\200\231 guides/74.6 Set the Active Spring Profiles.md" (76%) diff --git "a/IX. \342\200\230How-to\342\200\231 guides/72.6 Set the active Spring profiles.md" "b/IX. \342\200\230How-to\342\200\231 guides/74.6 Set the Active Spring Profiles.md" similarity index 76% rename from "IX. \342\200\230How-to\342\200\231 guides/72.6 Set the active Spring profiles.md" rename to "IX. \342\200\230How-to\342\200\231 guides/74.6 Set the Active Spring Profiles.md" index a9bff5ef..b03e84e7 100644 --- "a/IX. \342\200\230How-to\342\200\231 guides/72.6 Set the active Spring profiles.md" +++ "b/IX. \342\200\230How-to\342\200\231 guides/74.6 Set the Active Spring Profiles.md" @@ -1,4 +1,4 @@ -### 72.6 设置生效的Spring profiles +### 74.6 设置生效的Spring profiles Spring `Environment`有一个API可以设置生效的profiles,但通常你会通过系统属性(`spring.profiles.active`)或OS环境变量(`SPRING_PROFILES_ACTIVE`)设置。比如,使用一个`-D`参数启动应用程序(记着把它放到`main`类或jar文件之前): ```shell @@ -10,4 +10,4 @@ spring.profiles.active=production ``` 通过这种方式设置的值会被系统属性或环境变量替换,但不会被`SpringApplicationBuilder.profiles()`方法替换。因此,后面的Java API可用来在不改变默认设置的情况下增加profiles。 -想要获取更多信息可查看'Spring Boot特性'章节的[Chapter 25, Profiles](..//IV. Spring Boot features/25. Profiles.md)。 +想要获取更多信息可查看'Spring Boot特性'章节的[25. Profiles](https://docs.spring.io/spring-boot/docs/2.0.0.RELEASE/reference/htmlsingle/#boot-features-profiles)。 From c245ba01245a0a5ec5cb1765be3e6679ebf0255a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E7=83=AD=E5=BF=83=E5=B8=82=E6=B0=91=E9=92=9F=E5=B0=8F?= =?UTF-8?q?=E5=BC=BA?= Date: Tue, 10 Dec 2019 13:21:11 +0800 Subject: [PATCH 690/865] Update and rename 72.7 Change configuration depending on the environment.md to 74.7 Change Configuration Depending on the Environment.md --- ...onfiguration Depending on the Environment.md" | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) rename "IX. \342\200\230How-to\342\200\231 guides/72.7 Change configuration depending on the environment.md" => "IX. \342\200\230How-to\342\200\231 guides/74.7 Change Configuration Depending on the Environment.md" (76%) diff --git "a/IX. \342\200\230How-to\342\200\231 guides/72.7 Change configuration depending on the environment.md" "b/IX. \342\200\230How-to\342\200\231 guides/74.7 Change Configuration Depending on the Environment.md" similarity index 76% rename from "IX. \342\200\230How-to\342\200\231 guides/72.7 Change configuration depending on the environment.md" rename to "IX. \342\200\230How-to\342\200\231 guides/74.7 Change Configuration Depending on the Environment.md" index 3e70cbfc..c568dfa2 100644 --- "a/IX. \342\200\230How-to\342\200\231 guides/72.7 Change configuration depending on the environment.md" +++ "b/IX. \342\200\230How-to\342\200\231 guides/74.7 Change Configuration Depending on the Environment.md" @@ -1,29 +1,29 @@ -### 72.7 根据环境改变配置 +### 74.7 根据环境改变配置 一个YAML文件实际上是一系列以`---`线分割的文档,每个文档都被单独解析为一个平坦的(flattened)map。 如果一个YAML文档包含一个`spring.profiles`关键字,那profiles的值(以逗号分割的profiles列表)将被传入Spring的`Environment.acceptsProfiles()`方法,并且如果这些profiles的任何一个被激活,对应的文档被包含到最终的合并中(否则不会)。 示例: -```json +```yaml server: - port: 9000 + port: 9000 --- spring: - profiles: development + profiles: development server: - port: 9001 + port: 9001 --- spring: - profiles: production + profiles: production server: - port: 0 + port: 0 ``` 在这个示例中,默认的端口是`9000`,但如果Spring profile `development`生效则该端口是`9001`,如果`production`生效则它是`0`。 -YAML文档以它们出现的顺序合并,所以后面的值会覆盖前面的值。 +**注** YAML文档以它们出现的顺序合并,所以后面的值会覆盖前面的值。 想要使用profiles文件完成同样的操作,你可以使用`application-${profile}.properties`指定特殊的,profile相关的值。 From d21ab3fee3cc591037d9364b783fc1b83d1cb6f6 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E7=83=AD=E5=BF=83=E5=B8=82=E6=B0=91=E9=92=9F=E5=B0=8F?= =?UTF-8?q?=E5=BC=BA?= Date: Tue, 10 Dec 2019 13:22:03 +0800 Subject: [PATCH 691/865] Update 74.7 Change Configuration Depending on the Environment.md --- ...ange Configuration Depending on the Environment.md" | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git "a/IX. \342\200\230How-to\342\200\231 guides/74.7 Change Configuration Depending on the Environment.md" "b/IX. \342\200\230How-to\342\200\231 guides/74.7 Change Configuration Depending on the Environment.md" index c568dfa2..d086340b 100644 --- "a/IX. \342\200\230How-to\342\200\231 guides/74.7 Change Configuration Depending on the Environment.md" +++ "b/IX. \342\200\230How-to\342\200\231 guides/74.7 Change Configuration Depending on the Environment.md" @@ -7,20 +7,20 @@ 示例: ```yaml server: - port: 9000 + port: 9000 --- spring: - profiles: development + profiles: development server: - port: 9001 + port: 9001 --- spring: - profiles: production + profiles: production server: - port: 0 + port: 0 ``` 在这个示例中,默认的端口是`9000`,但如果Spring profile `development`生效则该端口是`9001`,如果`production`生效则它是`0`。 From 0bf4812e579517aa1a240b2bf730083e57c78974 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E7=83=AD=E5=BF=83=E5=B8=82=E6=B0=91=E9=92=9F=E5=B0=8F?= =?UTF-8?q?=E5=BC=BA?= Date: Tue, 10 Dec 2019 13:27:29 +0800 Subject: [PATCH 692/865] Update and rename 72.8 Discover built-in options for external properties.md to 74.8 Discover Built-in Options for External Properties.md --- ...74.8 Discover Built-in Options for External Properties.md" | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) rename "IX. \342\200\230How-to\342\200\231 guides/72.8 Discover built-in options for external properties.md" => "IX. \342\200\230How-to\342\200\231 guides/74.8 Discover Built-in Options for External Properties.md" (59%) diff --git "a/IX. \342\200\230How-to\342\200\231 guides/72.8 Discover built-in options for external properties.md" "b/IX. \342\200\230How-to\342\200\231 guides/74.8 Discover Built-in Options for External Properties.md" similarity index 59% rename from "IX. \342\200\230How-to\342\200\231 guides/72.8 Discover built-in options for external properties.md" rename to "IX. \342\200\230How-to\342\200\231 guides/74.8 Discover Built-in Options for External Properties.md" index 654ac83c..e8c1f87d 100644 --- "a/IX. \342\200\230How-to\342\200\231 guides/72.8 Discover built-in options for external properties.md" +++ "b/IX. \342\200\230How-to\342\200\231 guides/74.8 Discover Built-in Options for External Properties.md" @@ -1,8 +1,8 @@ -### 72.8 发现外部属性的内置选项 +### 74.8 发现外部属性的内置选项 Spring Boot在运行时会将来自`application.properties`(或`.yml`)的外部属性绑定到应用,因为不可能将所有支持的属性放到一个地方,classpath下的其他jar也有支持的属性。 每个运行中且有Actuator特性的应用都会有一个`configprops`端点,它能够展示所有边界和可通过`@ConfigurationProperties`绑定的属性。 -附录中包含一个[application.properties](https://docs.spring.io/spring-boot/docs/2.0.0.RELEASE/reference/htmlsingle/#common-application-properties)示例,它列举了Spring Boot支持的大多数常用属性,查看`@ConfigurationProperties`,`@Value`,还有不经常使用的`RelaxedEnvironment`的源码可获取最权威的属性列表。 +附录中包含一个[application.properties](https://docs.spring.io/spring-boot/docs/2.0.0.RELEASE/reference/htmlsingle/#common-application-properties)示例。它列举了Spring Boot支持的大多数常用属性,查看`@ConfigurationProperties`,`@Value`,还有不经常使用的`Binder`的源码可获取最权威的属性列表。有关加载属性的准确顺序的详细信息,请参阅[24.外部化配置](https://docs.spring.io/spring-boot/docs/2.0.0.RELEASE/reference/htmlsingle/#boot-features-external-config)。 From a798f9838d6a8402042eb23802eb1feb1c77f0a0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E7=83=AD=E5=BF=83=E5=B8=82=E6=B0=91=E9=92=9F=E5=B0=8F?= =?UTF-8?q?=E5=BC=BA?= Date: Mon, 16 Dec 2019 22:17:06 +0800 Subject: [PATCH 693/865] Update SUMMARY.md --- SUMMARY.md | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/SUMMARY.md b/SUMMARY.md index 68014b5d..89766096 100644 --- a/SUMMARY.md +++ b/SUMMARY.md @@ -465,7 +465,9 @@ * [74.6 设置生效的Spring profiles](IX. ‘How-to’ guides/74.6 Set the Active Spring Profiles.md) * [74.7 根据环境改变配置](IX. ‘How-to’ guides/74.7 Change Configuration Depending on the Environment.md) * [74.8 发现外部属性的内置选项](IX. ‘How-to’ guides/74.8 Discover Built-in Options for External Properties.md) - * [73. 内嵌servlet容器](IX. ‘How-to’ guides/73. Embedded servlet containers.md) + * [75. 内嵌网络服务器](IX. ‘How-to’ guides/75. Embedded Web Servers.md) + * [75.1 使用另外的网络服务器](IX. ‘How-to’ guides/75.1 Use Another Web Server.md) + * [75.2 配置Jetty](IX. ‘How-to’ guides/75.2 Configure Jetty.md) * [73.1 为应用添加Servlet,Filter或Listener](IX. ‘How-to’ guides/73.1 Add a Servlet, Filter or ServletContextListener to an application.md) * [73.1.1 使用Spring bean添加Servlet, Filter或Listener](IX. ‘How-to’ guides/73.1.1 Add a Servlet, Filter or Listener using a Spring bean.md) * [73.1.2 使用classpath扫描添加Servlets, Filters和Listeners](IX. ‘How-to’ guides/73.1.2 Add Servlets, Filters, and Listeners using classpath scanning.md) From 13ac0e5d032cc27d96f8d75b74e45910682b4380 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E7=83=AD=E5=BF=83=E5=B8=82=E6=B0=91=E9=92=9F=E5=B0=8F?= =?UTF-8?q?=E5=BC=BA?= Date: Mon, 16 Dec 2019 22:46:09 +0800 Subject: [PATCH 694/865] Update and rename 73. Embedded servlet containers.md to 75. Embedded Web Servers.md --- .../73. Embedded servlet containers.md" | 1 - .../75. Embedded Web Servers.md" | 3 +++ 2 files changed, 3 insertions(+), 1 deletion(-) delete mode 100644 "IX. \342\200\230How-to\342\200\231 guides/73. Embedded servlet containers.md" create mode 100644 "IX. \342\200\230How-to\342\200\231 guides/75. Embedded Web Servers.md" diff --git "a/IX. \342\200\230How-to\342\200\231 guides/73. Embedded servlet containers.md" "b/IX. \342\200\230How-to\342\200\231 guides/73. Embedded servlet containers.md" deleted file mode 100644 index 8d700256..00000000 --- "a/IX. \342\200\230How-to\342\200\231 guides/73. Embedded servlet containers.md" +++ /dev/null @@ -1 +0,0 @@ -### 73. 内嵌servlet容器 diff --git "a/IX. \342\200\230How-to\342\200\231 guides/75. Embedded Web Servers.md" "b/IX. \342\200\230How-to\342\200\231 guides/75. Embedded Web Servers.md" new file mode 100644 index 00000000..62d2f7ea --- /dev/null +++ "b/IX. \342\200\230How-to\342\200\231 guides/75. Embedded Web Servers.md" @@ -0,0 +1,3 @@ +### 75. 内嵌网络服务器 + +每个Spring Boot网络应用程序都包含一个嵌入式网络服务器。该特性会导致许多操作问题,包括如何更改嵌入式服务器以及如何配置嵌入式服务器。本节将回答这些问题。 From f1b1055d9fefa4f3cd281003f7cec47b3c120328 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E7=83=AD=E5=BF=83=E5=B8=82=E6=B0=91=E9=92=9F=E5=B0=8F?= =?UTF-8?q?=E5=BC=BA?= Date: Mon, 16 Dec 2019 23:06:32 +0800 Subject: [PATCH 695/865] Create 75.1 Use Another Web Server.md --- .../75.1 Use Another Web Server.md" | 44 +++++++++++++++++++ 1 file changed, 44 insertions(+) create mode 100644 "IX. \342\200\230How-to\342\200\231 guides/75.1 Use Another Web Server.md" diff --git "a/IX. \342\200\230How-to\342\200\231 guides/75.1 Use Another Web Server.md" "b/IX. \342\200\230How-to\342\200\231 guides/75.1 Use Another Web Server.md" new file mode 100644 index 00000000..ad31c0d5 --- /dev/null +++ "b/IX. \342\200\230How-to\342\200\231 guides/75.1 Use Another Web Server.md" @@ -0,0 +1,44 @@ +### 75.1 使用另外的网络服务器 + +许多Spring Boot程序都包含默认的嵌入式容器。`spring-boot-starter-web`通过包含`spring-boot-starter-tomcat`来包含Tomcat。但是,你可以使用`spring-boot-starter-jetty`或`spring-boot-starter-undertow`来代替。`spring-boot-starter-webflux`通过包含`spring-boot-starter-reactor-netty`,包含了Reactor Netty。但是,你可以使用`spring-boot-starter-tomcat`、`spring-boot-starter-jetty`或者`spring-boot-starter-undertow`来代替。 + +**注** 许多starter只支持Spring MVC,因此它们将`spring-boot-starter-web`引入到你的应用程序类路径中。 + +如果需要使用不同的HTTP服务器,则需要排除默认依赖项,并包含所需的依赖项。Spring Boot为HTTP服务器提供了独立的启动程序,以帮助尽可能简化这个过程。 + +下面的Maven示例展示了如何在Spring MVC中排除Tomcat并包含Jetty: +```xml + + org.springframework.boot + spring-boot-starter-web + + + + org.springframework.boot + spring-boot-starter-tomcat + + + + + + org.springframework.boot + spring-boot-starter-jetty + +``` + +下面的Gradle例子展示了如何在Spring WebFlux中排除Netty并包含Undertow: +``` +configurations { + // exclude Reactor Netty + compile.exclude module: 'spring-boot-starter-reactor-netty' +} + +dependencies { + compile 'org.springframework.boot:spring-boot-starter-webflux' + // Use Undertow instead + compile 'org.springframework.boot:spring-boot-starter-undertow' + // ... +} +``` + +**注** `spring-boot-starter-reactor-netty`需要使用`WebClient`类,所以即使需要包含不同的HTTP服务器,也可能需要保持对Netty的依赖。 From b58174b0eedab6f415f16cc956ae32f8f93a6853 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E7=83=AD=E5=BF=83=E5=B8=82=E6=B0=91=E9=92=9F=E5=B0=8F?= =?UTF-8?q?=E5=BC=BA?= Date: Mon, 16 Dec 2019 23:15:30 +0800 Subject: [PATCH 696/865] Create 75.2 Configure Jetty.md --- .../75.2 Configure Jetty.md" | 3 +++ 1 file changed, 3 insertions(+) create mode 100644 "IX. \342\200\230How-to\342\200\231 guides/75.2 Configure Jetty.md" diff --git "a/IX. \342\200\230How-to\342\200\231 guides/75.2 Configure Jetty.md" "b/IX. \342\200\230How-to\342\200\231 guides/75.2 Configure Jetty.md" new file mode 100644 index 00000000..333d2549 --- /dev/null +++ "b/IX. \342\200\230How-to\342\200\231 guides/75.2 Configure Jetty.md" @@ -0,0 +1,3 @@ +### 75.2 配置Jetty + +通常,你可以遵循[74.8 发现外部属性的内置选项](https://docs.spring.io/spring-boot/docs/2.0.0.RELEASE/reference/htmlsingle/#howto-discover-build-in-options-for-external-properties)关于`@ConfigurationProperties`的部分(`ServerProperties`是这里的主要选项)。但是,你还应该查看[WebServerFactoryCustomizer](https://docs.spring.io/spring-boot/docs/2.0.0.RELEASE/api/org/springframework/boot/web/server/WebServerFactoryCustomizer.html)。Jetty API非常丰富。因此,一旦你访问了`JettyServletWebServerFactory`,就可以通过多种方式修改它。或者,如果需要更多的控制和定制,可以添加自己的`JettyServletWebServerFactory`。 From 3d61cb3386438b891cb99b863f2079d3ad4d6e59 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E7=83=AD=E5=BF=83=E5=B8=82=E6=B0=91=E9=92=9F=E5=B0=8F?= =?UTF-8?q?=E5=BC=BA?= Date: Tue, 17 Dec 2019 12:50:46 +0800 Subject: [PATCH 697/865] Update SUMMARY.md --- SUMMARY.md | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/SUMMARY.md b/SUMMARY.md index 89766096..a58bdfa3 100644 --- a/SUMMARY.md +++ b/SUMMARY.md @@ -468,9 +468,9 @@ * [75. 内嵌网络服务器](IX. ‘How-to’ guides/75. Embedded Web Servers.md) * [75.1 使用另外的网络服务器](IX. ‘How-to’ guides/75.1 Use Another Web Server.md) * [75.2 配置Jetty](IX. ‘How-to’ guides/75.2 Configure Jetty.md) - * [73.1 为应用添加Servlet,Filter或Listener](IX. ‘How-to’ guides/73.1 Add a Servlet, Filter or ServletContextListener to an application.md) - * [73.1.1 使用Spring bean添加Servlet, Filter或Listener](IX. ‘How-to’ guides/73.1.1 Add a Servlet, Filter or Listener using a Spring bean.md) - * [73.1.2 使用classpath扫描添加Servlets, Filters和Listeners](IX. ‘How-to’ guides/73.1.2 Add Servlets, Filters, and Listeners using classpath scanning.md) + * [75.3 为应用添加Servlet、Filter或Listener](IX. ‘How-to’ guides/75.3 Add a Servlet, Filter, or Listener to an Application.md) + * [75.3.1 使用Spring bean添加Servlet、Filter或Listener](IX. ‘How-to’ guides/75.3.1 Add a Servlet, Filter, or Listener by Using a Spring Bean.md) + * [75.3.2 使用类路径扫描添加Servlet、Filter和Listener](IX. ‘How-to’ guides/75.3.2 Add Servlets, Filters, and Listeners by Using Classpath Scanning.md) * [73.2 改变HTTP端口](IX. ‘How-to’ guides/73.2 Change the HTTP port.md) * [73.3 使用随机未分配的HTTP端口](IX. ‘How-to’ guides/73.3 Use a random unassigned HTTP port.md) * [73.4 发现运行时的HTTP端口](IX. ‘How-to’ guides/73.4 Discover the HTTP port at runtime.md) From 48d45d46492958b1e5c19273e69e1f6751eac056 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E7=83=AD=E5=BF=83=E5=B8=82=E6=B0=91=E9=92=9F=E5=B0=8F?= =?UTF-8?q?=E5=BC=BA?= Date: Tue, 17 Dec 2019 12:56:14 +0800 Subject: [PATCH 698/865] Update and rename 73.1 Add a Servlet, Filter or ServletContextListener to an application.md to 75.3 Add a Servlet, Filter, or Listener to an Application.md --- ..., Filter or ServletContextListener to an application.md" | 3 --- ...Add a Servlet, Filter, or Listener to an Application.md" | 6 ++++++ 2 files changed, 6 insertions(+), 3 deletions(-) delete mode 100644 "IX. \342\200\230How-to\342\200\231 guides/73.1 Add a Servlet, Filter or ServletContextListener to an application.md" create mode 100644 "IX. \342\200\230How-to\342\200\231 guides/75.3 Add a Servlet, Filter, or Listener to an Application.md" diff --git "a/IX. \342\200\230How-to\342\200\231 guides/73.1 Add a Servlet, Filter or ServletContextListener to an application.md" "b/IX. \342\200\230How-to\342\200\231 guides/73.1 Add a Servlet, Filter or ServletContextListener to an application.md" deleted file mode 100644 index 447148cf..00000000 --- "a/IX. \342\200\230How-to\342\200\231 guides/73.1 Add a Servlet, Filter or ServletContextListener to an application.md" +++ /dev/null @@ -1,3 +0,0 @@ -### 73.1 为应用添加Servlet,Filter或Listener - -这里有两种方式可以为应用添加`Servlet`,`Filter`,`ServletContextListener`和其他Servlet支持的特定listeners。你既可以为它们提供Spring beans,也可以为Servlet组件启用扫描(package scan)。 diff --git "a/IX. \342\200\230How-to\342\200\231 guides/75.3 Add a Servlet, Filter, or Listener to an Application.md" "b/IX. \342\200\230How-to\342\200\231 guides/75.3 Add a Servlet, Filter, or Listener to an Application.md" new file mode 100644 index 00000000..18181e81 --- /dev/null +++ "b/IX. \342\200\230How-to\342\200\231 guides/75.3 Add a Servlet, Filter, or Listener to an Application.md" @@ -0,0 +1,6 @@ +### 75.3 为应用添加Servlet、Filter或Listener + +这里有两种方式可以为应用添加`Servlet`、`Filter`、`ServletContextListener`和其他Servlet支持的特定listener。 + +- [75.3.1 使用Spring bean添加Servlet、Filter或Listener](https://docs.spring.io/spring-boot/docs/2.0.0.RELEASE/reference/htmlsingle/#howto-add-a-servlet-filter-or-listener-as-spring-bean) +- [75.3.2 使用类路径扫描添加Servlet、Filter和Listener](https://docs.spring.io/spring-boot/docs/2.0.0.RELEASE/reference/htmlsingle/#howto-add-a-servlet-filter-or-listener-using-scanning) From 088f90d04a25f88566677b0223def5a6418071aa Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E7=83=AD=E5=BF=83=E5=B8=82=E6=B0=91=E9=92=9F=E5=B0=8F?= =?UTF-8?q?=E5=BC=BA?= Date: Tue, 17 Dec 2019 13:07:32 +0800 Subject: [PATCH 699/865] Update 27.4.1 Servlets, Filters, and listeners.md --- .../27.4.1 Servlets, Filters, and listeners.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/IV. Spring Boot features/27.4.1 Servlets, Filters, and listeners.md b/IV. Spring Boot features/27.4.1 Servlets, Filters, and listeners.md index cabb7a0d..310ffb5a 100644 --- a/IV. Spring Boot features/27.4.1 Servlets, Filters, and listeners.md +++ b/IV. Spring Boot features/27.4.1 Servlets, Filters, and listeners.md @@ -2,7 +2,7 @@ 使用内嵌servlet容器时,你可以通过使用Spring beans或扫描Servlet组件的方式注册servlets,filters及特定Servlet相关的所有listeners(比如`HttpSessionListener`)。 -**将Servlets,Filters和listeners注册为Spring beans** +**将Servlet、Filter和listener注册为Spring bean** 所有`Servlet`,`Filter`或servlet `*Listener`实例,只要是Spring bean,都会注册到内嵌容器中。如果想在配置期间引用`application.properties`的属性,这是非常方便的。默认情况下,如果上下文只包含单个Servlet,那它将被映射到`/`。如果存在多个servlet beans,那么bean的名称将被用作路径的前缀,过滤器将映射到`/*`。 From b3850ddf767aad00c23f53f5a1d31f64f0a82574 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E7=83=AD=E5=BF=83=E5=B8=82=E6=B0=91=E9=92=9F=E5=B0=8F?= =?UTF-8?q?=E5=BC=BA?= Date: Tue, 17 Dec 2019 13:09:44 +0800 Subject: [PATCH 700/865] Update and rename 73.1.1 Add a Servlet, Filter or Listener using a Spring bean.md to 75.3.1 Add a Servlet, Filter, or Listener by Using a Spring Bean.md --- ...Filter or Listener using a Spring bean.md" | 29 ------------------- ...er, or Listener by Using a Spring Bean.md" | 21 ++++++++++++++ 2 files changed, 21 insertions(+), 29 deletions(-) delete mode 100644 "IX. \342\200\230How-to\342\200\231 guides/73.1.1 Add a Servlet, Filter or Listener using a Spring bean.md" create mode 100644 "IX. \342\200\230How-to\342\200\231 guides/75.3.1 Add a Servlet, Filter, or Listener by Using a Spring Bean.md" diff --git "a/IX. \342\200\230How-to\342\200\231 guides/73.1.1 Add a Servlet, Filter or Listener using a Spring bean.md" "b/IX. \342\200\230How-to\342\200\231 guides/73.1.1 Add a Servlet, Filter or Listener using a Spring bean.md" deleted file mode 100644 index 34a8821f..00000000 --- "a/IX. \342\200\230How-to\342\200\231 guides/73.1.1 Add a Servlet, Filter or Listener using a Spring bean.md" +++ /dev/null @@ -1,29 +0,0 @@ -###73.1.1 使用Spring bean添加Servlet, Filter或Listener - -想要添加`Servlet`,`Filter`或Servlet`*Listener`,你只需要为它提供一个`@Bean`定义,这种方式很适合注入配置或依赖。不过,需要注意的是它们不会导致其他很多beans的热初始化,因为它们需要在应用生命周期的早期进行安装(让它依赖`DataSource`或JPA配置不是好主意),你可以通过懒加载突破该限制(在第一次使用时才初始化)。 - -对于`Filters`或`Servlets`,你可以通过`FilterRegistrationBean`或`ServletRegistrationBean`添加映射和初始化参数。 - -**注** 在一个filter注册时,如果没指定`dispatcherType`,它将匹配`FORWARD`,`INCLUDE`和`REQUEST`。如果启用异步,它也将匹配`ASYNC`。如果迁移`web.xml`中没有`dispatcher`元素的filter,你需要自己指定一个`dispatcherType`: -```java -@Bean -public FilterRegistrationBean myFilterRegistration() { - FilterRegistrationBean registration = new FilterRegistrationBean(); - registration.setDispatcherTypes(DispatcherType.REQUEST); - .... - - return registration; -} -``` - -**禁止Servlet或Filter的注册** - -如上所述,任何`Servlet`或`Filter` beans都将自动注册到servlet容器。不过,为特定的`Filter`或`Servlet` bean创建一个registration,并将它标记为disabled,可以禁用该filter或servlet。例如: -```java -@Bean -public FilterRegistrationBean registration(MyFilter filter) { - FilterRegistrationBean registration = new FilterRegistrationBean(filter); - registration.setEnabled(false); - return registration; -} -``` diff --git "a/IX. \342\200\230How-to\342\200\231 guides/75.3.1 Add a Servlet, Filter, or Listener by Using a Spring Bean.md" "b/IX. \342\200\230How-to\342\200\231 guides/75.3.1 Add a Servlet, Filter, or Listener by Using a Spring Bean.md" new file mode 100644 index 00000000..85c5a3df --- /dev/null +++ "b/IX. \342\200\230How-to\342\200\231 guides/75.3.1 Add a Servlet, Filter, or Listener by Using a Spring Bean.md" @@ -0,0 +1,21 @@ +### 75.3.1 使用Spring bean添加Servlet, Filter或Listener + +想要使用Spring bean添加`Servlet`,`Filter`或Servlet`*Listener`,你只需要为它提供一个`@Bean`定义,这种方式很适合注入配置或依赖。不过,需要注意的是它们不会导致其他很多beans的热初始化,因为它们需要在应用生命周期的早期进行安装(让它依赖`DataSource`或JPA配置不是好主意),你可以通过懒加载突破该限制(在第一次使用时才初始化)。 + +对于`Filters`或`Servlets`,你可以通过`FilterRegistrationBean`或`ServletRegistrationBean`添加映射和初始化参数。 + +**注** 在一个filter注册时,如果没指定`dispatcherType`,它将使用`REQUEST`。这与Servlet规范的默认dispatcher类型一致。 + +与任何其他Spring bean一样,你可以定义Servlet筛选器bean的顺序。请确保查看了[将Servlet、Filter和listener注册为Spring bean](https://docs.spring.io/spring-boot/docs/2.0.0.RELEASE/reference/htmlsingle/#boot-features-embedded-container-servlets-filters-listeners-beans)章节。 + +**禁止Servlet或Filter的注册** + +如上所述,任何`Servlet`或`Filter` bean都将自动注册到servlet容器。不过,为特定的`Filter`或`Servlet` bean创建一个registration,并将它标记为disabled,可以禁用该filter或servlet。例如: +```java +@Bean +public FilterRegistrationBean registration(MyFilter filter) { + FilterRegistrationBean registration = new FilterRegistrationBean(filter); + registration.setEnabled(false); + return registration; +} +``` From 08c0ef93a049f0ca10c15766f0dbb9cad648eb52 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E7=83=AD=E5=BF=83=E5=B8=82=E6=B0=91=E9=92=9F=E5=B0=8F?= =?UTF-8?q?=E5=BC=BA?= Date: Tue, 17 Dec 2019 13:13:22 +0800 Subject: [PATCH 701/865] Update and rename 73.1.2 Add Servlets, Filters, and Listeners using classpath scanning.md to 75.3.2 Add Servlets, Filters, and Listeners by Using Classpath Scanning.md --- ...rvlets, Filters, and Listeners using classpath scanning.md" | 3 --- ...ets, Filters, and Listeners by Using Classpath Scanning.md" | 3 +++ 2 files changed, 3 insertions(+), 3 deletions(-) delete mode 100644 "IX. \342\200\230How-to\342\200\231 guides/73.1.2 Add Servlets, Filters, and Listeners using classpath scanning.md" create mode 100644 "IX. \342\200\230How-to\342\200\231 guides/75.3.2 Add Servlets, Filters, and Listeners by Using Classpath Scanning.md" diff --git "a/IX. \342\200\230How-to\342\200\231 guides/73.1.2 Add Servlets, Filters, and Listeners using classpath scanning.md" "b/IX. \342\200\230How-to\342\200\231 guides/73.1.2 Add Servlets, Filters, and Listeners using classpath scanning.md" deleted file mode 100644 index 278f17fc..00000000 --- "a/IX. \342\200\230How-to\342\200\231 guides/73.1.2 Add Servlets, Filters, and Listeners using classpath scanning.md" +++ /dev/null @@ -1,3 +0,0 @@ -###73.1.2 使用classpath扫描添加Servlets, Filters和Listeners - -通过把`@ServletComponentScan`注解到一个`@Configuration`类并指定包含要注册组件的package(s),可以将`@WebServlet`,`@WebFilter`和`@WebListener`注解的类自动注册到内嵌servlet容器。默认情况下,`@ServletComponentScan`将从被注解类的package开始扫描。 diff --git "a/IX. \342\200\230How-to\342\200\231 guides/75.3.2 Add Servlets, Filters, and Listeners by Using Classpath Scanning.md" "b/IX. \342\200\230How-to\342\200\231 guides/75.3.2 Add Servlets, Filters, and Listeners by Using Classpath Scanning.md" new file mode 100644 index 00000000..7625599e --- /dev/null +++ "b/IX. \342\200\230How-to\342\200\231 guides/75.3.2 Add Servlets, Filters, and Listeners by Using Classpath Scanning.md" @@ -0,0 +1,3 @@ +### 75.3.2 使用类路径扫描添加Servlet、Filter和Listener + +通过把`@ServletComponentScan`注解到一个`@Configuration`类并指定包含要注册组件的包,可以将`@WebServlet`,`@WebFilter`和`@WebListener`注解的类自动注册到内嵌servlet容器。默认情况下,`@ServletComponentScan`将从被注解类的包开始扫描。 From bbf7e7ad259a5766990cf2a25dd2d2f188c9dc4f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E7=83=AD=E5=BF=83=E5=B8=82=E6=B0=91=E9=92=9F=E5=B0=8F?= =?UTF-8?q?=E5=BC=BA?= Date: Fri, 20 Dec 2019 13:17:47 +0800 Subject: [PATCH 702/865] Update SUMMARY.md --- SUMMARY.md | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/SUMMARY.md b/SUMMARY.md index a58bdfa3..f341f040 100644 --- a/SUMMARY.md +++ b/SUMMARY.md @@ -471,10 +471,10 @@ * [75.3 为应用添加Servlet、Filter或Listener](IX. ‘How-to’ guides/75.3 Add a Servlet, Filter, or Listener to an Application.md) * [75.3.1 使用Spring bean添加Servlet、Filter或Listener](IX. ‘How-to’ guides/75.3.1 Add a Servlet, Filter, or Listener by Using a Spring Bean.md) * [75.3.2 使用类路径扫描添加Servlet、Filter和Listener](IX. ‘How-to’ guides/75.3.2 Add Servlets, Filters, and Listeners by Using Classpath Scanning.md) - * [73.2 改变HTTP端口](IX. ‘How-to’ guides/73.2 Change the HTTP port.md) - * [73.3 使用随机未分配的HTTP端口](IX. ‘How-to’ guides/73.3 Use a random unassigned HTTP port.md) - * [73.4 发现运行时的HTTP端口](IX. ‘How-to’ guides/73.4 Discover the HTTP port at runtime.md) - * [73.5 配置SSL](IX. ‘How-to’ guides/73.5 Configure SSL.md) + * [75.4 改变HTTP端口](IX. ‘How-to’ guides/75.4 Change the HTTP Port.md) + * [75.5 使用随机未分配的HTTP端口](IX. ‘How-to’ guides/75.5 Use a Random Unassigned HTTP Port.md) + * [75.6 发现运行时的HTTP端口](IX. ‘How-to’ guides/75.6 Discover the HTTP Port at Runtime.md) + * [75.7 配置SSL](IX. ‘How-to’ guides/75.7 Configure SSL.md) * [73.6 配置访问日志](IX. ‘How-to’ guides/73.6 Configure Access Logging.md) * [73.7 在前端代理服务器后使用](IX. ‘How-to’ guides/73.7 Use behind a front-end proxy server.md) * [73.7.1 自定义Tomcat代理配置](IX. ‘How-to’ guides/73.7.1 Customize Tomcat’s proxy configuration.md) From 9a1cebccd5526a7328620a2ae9e7f6814b5fa968 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E7=83=AD=E5=BF=83=E5=B8=82=E6=B0=91=E9=92=9F=E5=B0=8F?= =?UTF-8?q?=E5=BC=BA?= Date: Fri, 20 Dec 2019 13:22:09 +0800 Subject: [PATCH 703/865] Update and rename 73.2 Change the HTTP port.md to 75.4 Change the HTTP Port.md --- .../73.2 Change the HTTP port.md" | 5 ----- .../75.4 Change the HTTP Port.md" | 5 +++++ 2 files changed, 5 insertions(+), 5 deletions(-) delete mode 100644 "IX. \342\200\230How-to\342\200\231 guides/73.2 Change the HTTP port.md" create mode 100644 "IX. \342\200\230How-to\342\200\231 guides/75.4 Change the HTTP Port.md" diff --git "a/IX. \342\200\230How-to\342\200\231 guides/73.2 Change the HTTP port.md" "b/IX. \342\200\230How-to\342\200\231 guides/73.2 Change the HTTP port.md" deleted file mode 100644 index 7e439d16..00000000 --- "a/IX. \342\200\230How-to\342\200\231 guides/73.2 Change the HTTP port.md" +++ /dev/null @@ -1,5 +0,0 @@ -### 73.2 改变HTTP端口 - -在一个单独的应用中,主HTTP端口默认为`8080`,不过可以使用`server.port`设置(比如,在`application.properties`中或作为系统属性)。由于`Environment`值的宽松绑定,你也可以使用`SERVER_PORT`(比如,作为OS环境变量)。 - -想要创建`WebApplicationContext`但完全关闭HTTP端点,你可以设置`server.port=-1`(测试时可能有用)。具体详情可查看'Spring Boot特性'章节的[Section 27.3.4, “Customizing embedded servlet containers”](../IV. Spring Boot features/27.3.4 Customizing embedded servlet containers.md),或[ServerProperties](https://github.com/spring-projects/spring-boot/tree/v2.0.0.RELEASE/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/web/ServerProperties.java)源码。 diff --git "a/IX. \342\200\230How-to\342\200\231 guides/75.4 Change the HTTP Port.md" "b/IX. \342\200\230How-to\342\200\231 guides/75.4 Change the HTTP Port.md" new file mode 100644 index 00000000..86d6d4b5 --- /dev/null +++ "b/IX. \342\200\230How-to\342\200\231 guides/75.4 Change the HTTP Port.md" @@ -0,0 +1,5 @@ +### 75.4 改变HTTP端口 + +在一个单独的应用中,主HTTP端口默认为`8080`,不过可以使用`server.port`设置(比如,在`application.properties`中或作为系统属性)。由于`Environment`值的宽松绑定,你也可以使用`SERVER_PORT`(比如,作为OS环境变量)。 + +想要创建`WebApplicationContext`但完全关闭HTTP端点,你可以设置`server.port=-1`(测试时可能有用)。具体详情可查看'Spring Boot特性'章节的[27.4.4 自定义内嵌servlet容器](https://docs.spring.io/spring-boot/docs/2.0.0.RELEASE/reference/htmlsingle/#boot-features-customizing-embedded-containers),或[ServerProperties](https://github.com/spring-projects/spring-boot/tree/v2.0.0.RELEASE/spring-boot-project/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/web/ServerProperties.java)源码。 From f717ab6646a0513b2a3b520c849a6a4eff3d1299 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E7=83=AD=E5=BF=83=E5=B8=82=E6=B0=91=E9=92=9F=E5=B0=8F?= =?UTF-8?q?=E5=BC=BA?= Date: Fri, 20 Dec 2019 13:23:21 +0800 Subject: [PATCH 704/865] Update and rename 73.3 Use a random unassigned HTTP port.md to 75.5 Use a Random Unassigned HTTP Port.md --- .../75.5 Use a Random Unassigned HTTP Port.md" | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) rename "IX. \342\200\230How-to\342\200\231 guides/73.3 Use a random unassigned HTTP port.md" => "IX. \342\200\230How-to\342\200\231 guides/75.5 Use a Random Unassigned HTTP Port.md" (71%) diff --git "a/IX. \342\200\230How-to\342\200\231 guides/73.3 Use a random unassigned HTTP port.md" "b/IX. \342\200\230How-to\342\200\231 guides/75.5 Use a Random Unassigned HTTP Port.md" similarity index 71% rename from "IX. \342\200\230How-to\342\200\231 guides/73.3 Use a random unassigned HTTP port.md" rename to "IX. \342\200\230How-to\342\200\231 guides/75.5 Use a Random Unassigned HTTP Port.md" index 263cc8a2..576d8776 100644 --- "a/IX. \342\200\230How-to\342\200\231 guides/73.3 Use a random unassigned HTTP port.md" +++ "b/IX. \342\200\230How-to\342\200\231 guides/75.5 Use a Random Unassigned HTTP Port.md" @@ -1,3 +1,3 @@ -### 73.3 使用随机未分配的HTTP端口 +### 75.5 使用随机未分配的HTTP端口 想扫描获取一个未使用的端口(使用操作系统本地端口以防冲突)可以设置`server.port=0`。 From d607fc6a2e9fdcb36bd0319c9c1656a14af1acdf Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E7=83=AD=E5=BF=83=E5=B8=82=E6=B0=91=E9=92=9F=E5=B0=8F?= =?UTF-8?q?=E5=BC=BA?= Date: Fri, 20 Dec 2019 13:26:33 +0800 Subject: [PATCH 705/865] Update SUMMARY.md --- SUMMARY.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/SUMMARY.md b/SUMMARY.md index f341f040..82c88a35 100644 --- a/SUMMARY.md +++ b/SUMMARY.md @@ -473,7 +473,7 @@ * [75.3.2 使用类路径扫描添加Servlet、Filter和Listener](IX. ‘How-to’ guides/75.3.2 Add Servlets, Filters, and Listeners by Using Classpath Scanning.md) * [75.4 改变HTTP端口](IX. ‘How-to’ guides/75.4 Change the HTTP Port.md) * [75.5 使用随机未分配的HTTP端口](IX. ‘How-to’ guides/75.5 Use a Random Unassigned HTTP Port.md) - * [75.6 发现运行时的HTTP端口](IX. ‘How-to’ guides/75.6 Discover the HTTP Port at Runtime.md) + * [75.6 在运行时发现HTTP端口](IX. ‘How-to’ guides/75.6 Discover the HTTP Port at Runtime.md) * [75.7 配置SSL](IX. ‘How-to’ guides/75.7 Configure SSL.md) * [73.6 配置访问日志](IX. ‘How-to’ guides/73.6 Configure Access Logging.md) * [73.7 在前端代理服务器后使用](IX. ‘How-to’ guides/73.7 Use behind a front-end proxy server.md) From 4eb32dcf76ea8692f284babe824f89832c41a7b9 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E7=83=AD=E5=BF=83=E5=B8=82=E6=B0=91=E9=92=9F=E5=B0=8F?= =?UTF-8?q?=E5=BC=BA?= Date: Fri, 20 Dec 2019 13:31:27 +0800 Subject: [PATCH 706/865] Update and rename 73.4 Discover the HTTP port at runtime.md to 75.6 Discover the HTTP Port at Runtime.md --- .../75.6 Discover the HTTP Port at Runtime.md" | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) rename "IX. \342\200\230How-to\342\200\231 guides/73.4 Discover the HTTP port at runtime.md" => "IX. \342\200\230How-to\342\200\231 guides/75.6 Discover the HTTP Port at Runtime.md" (94%) diff --git "a/IX. \342\200\230How-to\342\200\231 guides/73.4 Discover the HTTP port at runtime.md" "b/IX. \342\200\230How-to\342\200\231 guides/75.6 Discover the HTTP Port at Runtime.md" similarity index 94% rename from "IX. \342\200\230How-to\342\200\231 guides/73.4 Discover the HTTP port at runtime.md" rename to "IX. \342\200\230How-to\342\200\231 guides/75.6 Discover the HTTP Port at Runtime.md" index 01aeb6d1..dee15006 100644 --- "a/IX. \342\200\230How-to\342\200\231 guides/73.4 Discover the HTTP port at runtime.md" +++ "b/IX. \342\200\230How-to\342\200\231 guides/75.6 Discover the HTTP Port at Runtime.md" @@ -1,4 +1,4 @@ -### 73.4 发现运行时的HTTP端口 +### 75.6 在运行时发现HTTP端口 你可以从输出的日志或通过它的`EmbeddedWebServer`从`ServletWebServerApplicationContext`获取服务器正在运行的端口。获取和确认服务器已经初始化的最好方式是添加一个`ApplicationListener`类型的`@Bean`,然后当事件发布时将容器pull出来。 From ee4492a65c688044743a8b2e49d9f792f2c6650c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E7=83=AD=E5=BF=83=E5=B8=82=E6=B0=91=E9=92=9F=E5=B0=8F?= =?UTF-8?q?=E5=BC=BA?= Date: Fri, 20 Dec 2019 13:35:25 +0800 Subject: [PATCH 707/865] Update and rename 73.5 Configure SSL.md to 75.7 Configure SSL.md --- .../75.7 Configure SSL.md" | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) rename "IX. \342\200\230How-to\342\200\231 guides/73.5 Configure SSL.md" => "IX. \342\200\230How-to\342\200\231 guides/75.7 Configure SSL.md" (85%) diff --git "a/IX. \342\200\230How-to\342\200\231 guides/73.5 Configure SSL.md" "b/IX. \342\200\230How-to\342\200\231 guides/75.7 Configure SSL.md" similarity index 85% rename from "IX. \342\200\230How-to\342\200\231 guides/73.5 Configure SSL.md" rename to "IX. \342\200\230How-to\342\200\231 guides/75.7 Configure SSL.md" index ecf8866a..15e5d937 100644 --- "a/IX. \342\200\230How-to\342\200\231 guides/73.5 Configure SSL.md" +++ "b/IX. \342\200\230How-to\342\200\231 guides/75.7 Configure SSL.md" @@ -1,4 +1,4 @@ -### 73.5 配置SSL +### 75.7 配置SSL 你可以以声明方式配置SSL,一般通过在`application.properties`或`application.yml`设置各种各样的`server.ssl.*`属性,例如: ```json @@ -7,6 +7,6 @@ server.ssl.key-store = classpath:keystore.jks server.ssl.key-store-password = secret server.ssl.key-password = another-secret ``` -查看[Ssl](https://github.com/spring-projects/spring-boot/tree/v2.0.0.RELEASE/spring-boot/src/main/java/org/springframework/boot/web/server/Ssl.java)获取所有支持的配置。 +查看[Ssl](https://github.com/spring-projects/spring-boot/tree/v2.0.0.RELEASE/spring-boot-project/spring-boot/src/main/java/org/springframework/boot/web/server/Ssl.java)获取所有支持的配置。 使用类似于以上示例的配置意味着该应用将不支持端口为8080的普通HTTP连接。Spring Boot不支持通过`application.properties`同时配置HTTP连接器和HTTPS连接器。如果你两个都想要,那就需要以编程的方式配置它们中的一个。推荐使用`application.properties`配置HTTPS,因为HTTP连接器是两个中最容易以编程方式进行配置的,查看[spring-boot-sample-tomcat-multi-connectors](https://github.com/spring-projects/spring-boot/tree/v2.0.0.RELEASE/spring-boot-samples/spring-boot-sample-tomcat-multi-connectors)可获取示例项目。 From 1bff8c2ec6153611feb01d0d001c06d278d6d4a7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E7=83=AD=E5=BF=83=E5=B8=82=E6=B0=91=E9=92=9F=E5=B0=8F?= =?UTF-8?q?=E5=BC=BA?= Date: Sat, 21 Dec 2019 12:57:35 +0800 Subject: [PATCH 708/865] =?UTF-8?q?=E6=96=B0=E5=A2=9E=E9=85=8D=E7=BD=AEHTT?= =?UTF-8?q?P/2?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- SUMMARY.md | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/SUMMARY.md b/SUMMARY.md index 82c88a35..5cccbdd0 100644 --- a/SUMMARY.md +++ b/SUMMARY.md @@ -475,6 +475,10 @@ * [75.5 使用随机未分配的HTTP端口](IX. ‘How-to’ guides/75.5 Use a Random Unassigned HTTP Port.md) * [75.6 在运行时发现HTTP端口](IX. ‘How-to’ guides/75.6 Discover the HTTP Port at Runtime.md) * [75.7 配置SSL](IX. ‘How-to’ guides/75.7 Configure SSL.md) + * [75.8 配置HTTP/2](IX. ‘How-to’ guides/75.8 Configure HTTP/2.md) + * [75.8.1 HTTP/2与Undertow](IX. ‘How-to’ guides/75.8.1 HTTP/2 with Undertow.md) + * [75.8.2 HTTP/2与Jetty](IX. ‘How-to’ guides/75.8.2 HTTP/2 with Jetty.md) + * [75.8.3 HTTP/2与Tomcat](IX. ‘How-to’ guides/75.8.3 HTTP/2 with Tomcat.md) * [73.6 配置访问日志](IX. ‘How-to’ guides/73.6 Configure Access Logging.md) * [73.7 在前端代理服务器后使用](IX. ‘How-to’ guides/73.7 Use behind a front-end proxy server.md) * [73.7.1 自定义Tomcat代理配置](IX. ‘How-to’ guides/73.7.1 Customize Tomcat’s proxy configuration.md) From 9eae62dd3c58518aaab212c096b646ab5b1cf877 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E7=83=AD=E5=BF=83=E5=B8=82=E6=B0=91=E9=92=9F=E5=B0=8F?= =?UTF-8?q?=E5=BC=BA?= Date: Sat, 21 Dec 2019 13:11:26 +0800 Subject: [PATCH 709/865] Create 75.8 Configure HTTP2.md --- .../75.8 Configure HTTP2.md" | 5 +++++ 1 file changed, 5 insertions(+) create mode 100644 "IX. \342\200\230How-to\342\200\231 guides/75.8 Configure HTTP2.md" diff --git "a/IX. \342\200\230How-to\342\200\231 guides/75.8 Configure HTTP2.md" "b/IX. \342\200\230How-to\342\200\231 guides/75.8 Configure HTTP2.md" new file mode 100644 index 00000000..9c1aa272 --- /dev/null +++ "b/IX. \342\200\230How-to\342\200\231 guides/75.8 Configure HTTP2.md" @@ -0,0 +1,5 @@ +### 75.8 配置HTTP/2 + +你可以使用`server.http2.enabled`配置属性,在Spring Boot应用程序中启用HTTP/2支持。这项支持取决于所选的web服务器和应用程序环境,因为JDK8不支持那个协议开箱即用。 + +**注** Spring Boot不支持`h2c`,即明文版本的HTTP/2协议。因此必须[首先配置SSL](https://docs.spring.io/spring-boot/docs/2.0.0.RELEASE/reference/htmlsingle/#howto-configure-ssl)。 From 4b350de3adfa8a8a5282c50e4318a02dabcf80bf Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E7=83=AD=E5=BF=83=E5=B8=82=E6=B0=91=E9=92=9F=E5=B0=8F?= =?UTF-8?q?=E5=BC=BA?= Date: Sat, 21 Dec 2019 13:17:47 +0800 Subject: [PATCH 710/865] Create 75.8.1 HTTP2 with Undertow.md --- .../75.8.1 HTTP2 with Undertow.md" | 3 +++ 1 file changed, 3 insertions(+) create mode 100644 "IX. \342\200\230How-to\342\200\231 guides/75.8.1 HTTP2 with Undertow.md" diff --git "a/IX. \342\200\230How-to\342\200\231 guides/75.8.1 HTTP2 with Undertow.md" "b/IX. \342\200\230How-to\342\200\231 guides/75.8.1 HTTP2 with Undertow.md" new file mode 100644 index 00000000..c2c429a7 --- /dev/null +++ "b/IX. \342\200\230How-to\342\200\231 guides/75.8.1 HTTP2 with Undertow.md" @@ -0,0 +1,3 @@ +### 75.8.1 HTTP/2与Undertow + +Undertow从1.4.0+开始,在JDK8上支持HTTP/2,不需要任何额外的要求。 From 6efee4205ffe1406f0a518c6e9514c94d6e92816 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E7=83=AD=E5=BF=83=E5=B8=82=E6=B0=91=E9=92=9F=E5=B0=8F?= =?UTF-8?q?=E5=BC=BA?= Date: Sat, 21 Dec 2019 13:23:08 +0800 Subject: [PATCH 711/865] Create 75.8.2 HTTP2 with Jetty.md --- .../75.8.2 HTTP2 with Jetty.md" | 3 +++ 1 file changed, 3 insertions(+) create mode 100644 "IX. \342\200\230How-to\342\200\231 guides/75.8.2 HTTP2 with Jetty.md" diff --git "a/IX. \342\200\230How-to\342\200\231 guides/75.8.2 HTTP2 with Jetty.md" "b/IX. \342\200\230How-to\342\200\231 guides/75.8.2 HTTP2 with Jetty.md" new file mode 100644 index 00000000..b6fe2a0a --- /dev/null +++ "b/IX. \342\200\230How-to\342\200\231 guides/75.8.2 HTTP2 with Jetty.md" @@ -0,0 +1,3 @@ +### 75.8.2 HTTP/2与Jetty + +从Jetty 9.4.8开始,Conscrypt库也支持HTTP/2。要启用这种支持,你的应用程序需要有两个附加的依赖项:`org.eclipse.jetty:jetty-alpn-conscrypt-server`和`org.eclipse.jetty.http2:http2-server`。 From d7b63ab9187d228f922a9c09a6ca493e4262aa21 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E7=83=AD=E5=BF=83=E5=B8=82=E6=B0=91=E9=92=9F=E5=B0=8F?= =?UTF-8?q?=E5=BC=BA?= Date: Sat, 21 Dec 2019 13:24:52 +0800 Subject: [PATCH 712/865] Update SUMMARY.md --- SUMMARY.md | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/SUMMARY.md b/SUMMARY.md index 5cccbdd0..7e78f0bc 100644 --- a/SUMMARY.md +++ b/SUMMARY.md @@ -475,10 +475,10 @@ * [75.5 使用随机未分配的HTTP端口](IX. ‘How-to’ guides/75.5 Use a Random Unassigned HTTP Port.md) * [75.6 在运行时发现HTTP端口](IX. ‘How-to’ guides/75.6 Discover the HTTP Port at Runtime.md) * [75.7 配置SSL](IX. ‘How-to’ guides/75.7 Configure SSL.md) - * [75.8 配置HTTP/2](IX. ‘How-to’ guides/75.8 Configure HTTP/2.md) - * [75.8.1 HTTP/2与Undertow](IX. ‘How-to’ guides/75.8.1 HTTP/2 with Undertow.md) - * [75.8.2 HTTP/2与Jetty](IX. ‘How-to’ guides/75.8.2 HTTP/2 with Jetty.md) - * [75.8.3 HTTP/2与Tomcat](IX. ‘How-to’ guides/75.8.3 HTTP/2 with Tomcat.md) + * [75.8 配置HTTP/2](IX. ‘How-to’ guides/75.8 Configure HTTP2.md) + * [75.8.1 HTTP/2与Undertow](IX. ‘How-to’ guides/75.8.1 HTTP2 with Undertow.md) + * [75.8.2 HTTP/2与Jetty](IX. ‘How-to’ guides/75.8.2 HTTP2 with Jetty.md) + * [75.8.3 HTTP/2与Tomcat](IX. ‘How-to’ guides/75.8.3 HTTP2 with Tomcat.md) * [73.6 配置访问日志](IX. ‘How-to’ guides/73.6 Configure Access Logging.md) * [73.7 在前端代理服务器后使用](IX. ‘How-to’ guides/73.7 Use behind a front-end proxy server.md) * [73.7.1 自定义Tomcat代理配置](IX. ‘How-to’ guides/73.7.1 Customize Tomcat’s proxy configuration.md) From 82442950d03dfb2896c4bc52676e4b5f72447084 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E7=83=AD=E5=BF=83=E5=B8=82=E6=B0=91=E9=92=9F=E5=B0=8F?= =?UTF-8?q?=E5=BC=BA?= Date: Sat, 21 Dec 2019 13:35:05 +0800 Subject: [PATCH 713/865] Create 75.8.3 HTTP2 with Tomcat.md --- .../75.8.3 HTTP2 with Tomcat.md" | 13 +++++++++++++ 1 file changed, 13 insertions(+) create mode 100644 "IX. \342\200\230How-to\342\200\231 guides/75.8.3 HTTP2 with Tomcat.md" diff --git "a/IX. \342\200\230How-to\342\200\231 guides/75.8.3 HTTP2 with Tomcat.md" "b/IX. \342\200\230How-to\342\200\231 guides/75.8.3 HTTP2 with Tomcat.md" new file mode 100644 index 00000000..5991f890 --- /dev/null +++ "b/IX. \342\200\230How-to\342\200\231 guides/75.8.3 HTTP2 with Tomcat.md" @@ -0,0 +1,13 @@ +### 75.8.3 HTTP/2与Tomcat + +默认情况下,Spring Boot提供Tomcat 8.5.x。对于该版本,只有在主机操作系统上安装了`libtcnative`库及其依赖项时,才支持HTTP/2。 + +必须使库文件夹对JVM库路径可用。你可以使用诸如`-Djava.library.path=/usr/local/opt/tomcat-native/lib`这样的JVM参数来实现这一点。关于这方面的更多信息,请参阅[Tomcat官方文档](https://tomcat.apache.org/tomcat-8.5-doc/apr.html)。 +在没有那个本地支持的情况下启动Tomcat 8.5,会记录以下错误: +``` +ERROR 8787 --- [ main] o.a.coyote.http11.Http11NioProtocol : The upgrade handler [org.apache.coyote.http2.Http2Protocol] for [h2] only supports upgrade via ALPN but has been configured for the ["https-jsse-nio-8443"] connector that does not support ALPN. +``` + +这个错误不是致命的,应用程序仍然使用HTTP/1.1 SSL支持启动。 + +使用Tomcat 9.0.x与JDK9运行应用程序,不需要安装任何本机库。要使用Tomcat 9,可以覆盖`tomcat.version`构建属性,来使用你选择的版本。 From 0f0d9d250ae7e475b1a4140b7e6fdb3794300aeb Mon Sep 17 00:00:00 2001 From: Zhong Zengqiang Date: Sun, 22 Dec 2019 19:38:51 +0800 Subject: [PATCH 714/865] =?UTF-8?q?=E6=9B=B4=E6=96=B075.9=20Configure=20Ac?= =?UTF-8?q?cess=20Logging=E3=80=8175.10=20Running=20Behind=20a=20Front-end?= =?UTF-8?q?=20Proxy=20Server=E3=80=8175.10.1=20Customize=20Tomcat=E2=80=99?= =?UTF-8?q?s=20Proxy=20Configuration?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- ...unning Behind a Front-end Proxy Server.md" | 6 +- ...omcat\342\200\231s Proxy Configuration.md" | 2 +- .../75.9 Configure Access Logging.md" | 12 +- SUMMARY.md | 1202 ++++++++--------- 4 files changed, 611 insertions(+), 611 deletions(-) rename "IX. \342\200\230How-to\342\200\231 guides/73.7 Use behind a front-end proxy server.md" => "IX. \342\200\230How-to\342\200\231 guides/75.10 Running Behind a Front-end Proxy Server.md" (60%) rename "IX. \342\200\230How-to\342\200\231 guides/73.7.1 Customize Tomcat\342\200\231s proxy configuration.md" => "IX. \342\200\230How-to\342\200\231 guides/75.10.1 Customize Tomcat\342\200\231s Proxy Configuration.md" (96%) rename "IX. \342\200\230How-to\342\200\231 guides/73.6 Configure Access Logging.md" => "IX. \342\200\230How-to\342\200\231 guides/75.9 Configure Access Logging.md" (70%) diff --git "a/IX. \342\200\230How-to\342\200\231 guides/73.7 Use behind a front-end proxy server.md" "b/IX. \342\200\230How-to\342\200\231 guides/75.10 Running Behind a Front-end Proxy Server.md" similarity index 60% rename from "IX. \342\200\230How-to\342\200\231 guides/73.7 Use behind a front-end proxy server.md" rename to "IX. \342\200\230How-to\342\200\231 guides/75.10 Running Behind a Front-end Proxy Server.md" index 54adbc54..3d826b74 100644 --- "a/IX. \342\200\230How-to\342\200\231 guides/73.7 Use behind a front-end proxy server.md" +++ "b/IX. \342\200\230How-to\342\200\231 guides/75.10 Running Behind a Front-end Proxy Server.md" @@ -1,7 +1,7 @@ -###73.7 在前端代理服务器后使用 +### 75.10 在前端代理服务器后运行 你的应用可能需要发送`302`跳转或使用指向自己的绝对路径渲染内容。当在代理服务器后面运行时,调用者需要的是代理服务器链接而不是部署应用的实际物理机器地址,通常的解决方式是代理服务器将前端地址放到headers并告诉后端服务器如何拼装链接。 -如果代理添加约定的`X-Forwarded-For`和`X-Forwarded-Proto` headers(大多数都是开箱即用的),只要将`application.properties`中的`server.use-forward-headers`设置为`true`,绝对链接就能正确的渲染。 +如果代理添加约定的`X-Forwarded-For`和`X-Forwarded-Proto` headers(大多数代理服务器会这样做),只要将`application.properties`中的`server.use-forward-headers`设置为`true`,绝对链接就能正确的渲染。 -**注** 如果应用运行在Cloud Foundry或Heroku,`server.use-forward-headers`属性没指定的话默认为`true`,其他实例默认为`false`。 +**注** 如果应用运行在Cloud Foundry或Heroku,`server.use-forward-headers`属性默认为`true`。其他实例默认为`false`。 diff --git "a/IX. \342\200\230How-to\342\200\231 guides/73.7.1 Customize Tomcat\342\200\231s proxy configuration.md" "b/IX. \342\200\230How-to\342\200\231 guides/75.10.1 Customize Tomcat\342\200\231s Proxy Configuration.md" similarity index 96% rename from "IX. \342\200\230How-to\342\200\231 guides/73.7.1 Customize Tomcat\342\200\231s proxy configuration.md" rename to "IX. \342\200\230How-to\342\200\231 guides/75.10.1 Customize Tomcat\342\200\231s Proxy Configuration.md" index 84843e30..b1667b27 100644 --- "a/IX. \342\200\230How-to\342\200\231 guides/73.7.1 Customize Tomcat\342\200\231s proxy configuration.md" +++ "b/IX. \342\200\230How-to\342\200\231 guides/75.10.1 Customize Tomcat\342\200\231s Proxy Configuration.md" @@ -1,4 +1,4 @@ -###73.7.1 自定义Tomcat代理配置 +### 75.10.1 自定义Tomcat代理配置 如果使用的是Tomcat,你可以配置用于传输"forwarded"信息的headers名: ```properties diff --git "a/IX. \342\200\230How-to\342\200\231 guides/73.6 Configure Access Logging.md" "b/IX. \342\200\230How-to\342\200\231 guides/75.9 Configure Access Logging.md" similarity index 70% rename from "IX. \342\200\230How-to\342\200\231 guides/73.6 Configure Access Logging.md" rename to "IX. \342\200\230How-to\342\200\231 guides/75.9 Configure Access Logging.md" index 85d5a3eb..b387a28f 100644 --- "a/IX. \342\200\230How-to\342\200\231 guides/73.6 Configure Access Logging.md" +++ "b/IX. \342\200\230How-to\342\200\231 guides/75.9 Configure Access Logging.md" @@ -1,23 +1,23 @@ -### 73.6 配置访问日志 +### 75.9 配置访问日志 -通过相应的命令空间可以为Tomcat、Undertow和Jetty配置访问日志,例如下面是为Tomcat配置的一个[自定义模式](https://tomcat.apache.org/tomcat-8.0-doc/config/valve.html#Access_Logging)的访问日志: +通过相应的命令空间可以为Tomcat、Undertow和Jetty配置访问日志,例如下面是为Tomcat配置的一个[自定义模式](https://tomcat.apache.org/tomcat-8.5-doc/config/valve.html#Access_Logging)的访问日志: ```properties server.tomcat.basedir=my-tomcat server.tomcat.accesslog.enabled=true server.tomcat.accesslog.pattern=%t %a "%r" %s (%D ms) ``` -**注** 日志默认路径为tomcat基础路径下的`logs`目录,该dir默认是个临时目录,所以你可能想改变Tomcat的base目录或为日志指定绝对路径。上述示例中,你可以在相对于应用工作目录的`my-tomcat/logs`访问到日志。 +**注** 日志默认路径为Tomcat基础路径下的`logs`目录,该dir默认是个临时目录,所以你可能想改变Tomcat的base目录或为日志指定绝对路径。上述示例中,你可以在相对于应用工作目录的`my-tomcat/logs`访问到日志。 Undertow的访问日志配置方式类似: ```properties server.undertow.accesslog.enabled=true server.undertow.accesslog.pattern=%t %a "%r" %s (%D ms) ``` -日志存储在相对于应用工作目录的`logs`目录下,可以通过`server.undertow.accesslog.directory`自定义。 +日志存储在相对于应用工作目录的`logs`目录下,可以通过`server.undertow.accesslog.directory`属性自定义。 -最后,jetty的访问日志也可以这样配置: +最后,Jetty的访问日志也可以这样配置: ```properties server.jetty.accesslog.enabled=true server.jetty.accesslog.filename=/var/log/jetty-access.log ``` -默认地,日志会被重定向到`System.err`。更多细节,请查看[文档](https://www.eclipse.org/jetty/documentation/9.3.x/configuring-jetty-request-logs.html)。 \ No newline at end of file +默认地,日志会被重定向到`System.err`。更多细节,请查看[Jetty文档](https://www.eclipse.org/jetty/documentation/9.4.x/configuring-jetty-request-logs.html)。 \ No newline at end of file diff --git a/SUMMARY.md b/SUMMARY.md index 7e78f0bc..53482c9e 100644 --- a/SUMMARY.md +++ b/SUMMARY.md @@ -1,601 +1,601 @@ -# Summary - -* [I. Spring Boot文档](I. Spring Boot Documentation/README.md) - * [1. 关于本文档](I. Spring Boot Documentation/1. About the Documentation.md) - * [2. 获取帮助](I. Spring Boot Documentation/2. Getting Help.md) - * [3. 第一步](I. Spring Boot Documentation/3. First Steps.md) - * [4. 使用Spring Boot](I. Spring Boot Documentation/4. Working with Spring Boot.md) - * [5. 了解Spring Boot特性](I. Spring Boot Documentation/5. Learning about Spring Boot Features.md) - * [6. 迁移到生产环境](I. Spring Boot Documentation/6. Moving to Production.md) - * [7. 高级主题](I. Spring Boot Documentation/7. Advanced Topics.md) -* [II. 开始](II. Getting Started/README.md) - * [8. Spring Boot介绍](II. Getting Started/8. Introducing Spring Boot.md) - * [9. 系统要求](II. Getting Started/9. System Requirements.md) - * [9.1. Servlet容器](II. Getting Started/9.1. Servlet Containers.md) - * [10. Spring Boot安装](II. Getting Started/10. Installing Spring Boot.md) - * [10.1. 为Java开发者准备的安装指南](II. Getting Started/10.1. Installation Instructions for the Java Developer.md) - * [10.1.1. Maven安装](II. Getting Started/10.1.1. Maven Installation.md) - * [10.1.2. Gradle安装](II. Getting Started/10.1.2. Gradle Installation.md) - * [10.2. Spring Boot CLI安装](II. Getting Started/10.2. Installing the Spring Boot CLI.md) - * [10.2.1. 手动安装](II. Getting Started/10.2.1. Manual Installation.md) - * [10.2.2. 使用SDKMAN进行安装](II. Getting Started/10.2.2. Installation with SDKMAN.md) - * [10.2.3. 使用OSX Homebrew进行安装](II. Getting Started/10.2.3. OSX Homebrew Installation.md) - * [10.2.4. 使用MacPorts进行安装](II. Getting Started/10.2.4. MacPorts Installation.md) - * [10.2.5. 命令行实现](II. Getting Started/10.2.5. Command-line Completion.md) - * [10.2.6. Spring CLI示例快速入门](II. Getting Started/10.2.6. Quick-start Spring CLI Example.md) - * [10.3. 从Spring Boot早期版本升级](II. Getting Started/10.3. Upgrading from an Earlier Version of Spring Boot.md) - * [11. 开发你的第一个Spring Boot应用](II. Getting Started/11. Developing Your First Spring Boot Application.md) - * [11.1. 创建POM](II. Getting Started/11.1. Creating the POM.md) - * [11.2. 添加classpath依赖](II. Getting Started/11.2. Adding Classpath Dependencies.md) - * [11.3. 编写代码](II. Getting Started/11.3. Writing the Code.md) - * [11.3.1. @RestController和@RequestMapping注解](II. Getting Started/11.3.1. The @RestController and @RequestMapping Annotations.md) - * [11.3.2. @EnableAutoConfiguration注解](II. Getting Started/11.3.2. The @EnableAutoConfiguration Annotation.md) - * [11.3.3. main方法](II. Getting Started/11.3.3. The “main” Method.md) - * [11.4. 运行示例](II. Getting Started/11.4. Running the Example.md) - * [11.5. 创建一个可执行jar](II. Getting Started/11.5. Creating an Executable Jar.md) - * [12. 接下来阅读什么](II. Getting Started/12. What to Read Next.md) -* [III. 使用Spring Boot](III. Using Spring Boot/README.md) - * [13. 构建系统](III. Using Spring Boot/13. Build Systems.md) - * [13.1. 依赖管理](III. Using Spring Boot/13.1. Dependency Management.md) - * [13.2. Maven](III. Using Spring Boot/13.2. Maven.md) - * [13.2.1. 继承starter parent](III. Using Spring Boot/13.2.1. Inheriting the Starter Parent.md) - * [13.2.2. 在不使用parent POM的情况下玩转Spring Boot](III. Using Spring Boot/13.2.2. Using Spring Boot without the Parent POM.md) - * [13.2.3. 使用Spring Boot Maven插件](III. Using Spring Boot/13.2.3. Using the Spring Boot Maven Plugin.md) - * [13.3. Gradle](III. Using Spring Boot/13.3. Gradle.md) - * [13.4. Ant](III. Using Spring Boot/13.4. Ant.md) - * [13.5. Starters](III. Using Spring Boot/13.5. Starters.md) - * [14. 组织你的代码](III. Using Spring Boot/14. Structuring Your Code.md) - * [14.1. 使用"default"包](III. Using Spring Boot/14.1. Using the “default” Package.md) - * [14.2. 放置应用的main类](III. Using Spring Boot/14.2. Locating the Main Application Class.md) -   * [15. 配置类](III. Using Spring Boot/15. Configuration Classes.md) - * [15.1. 导入其他配置类](III. Using Spring Boot/15.1. Importing Additional Configuration Classes.md) - * [15.2. 导入XML配置](III. Using Spring Boot/15.2. Importing XML Configuration.md) - * [16. 自动配置](III. Using Spring Boot/16. Auto-configuration.md) - * [16.1. 逐步替换自动配置](III. Using Spring Boot/16.1. Gradually Replacing Auto-configuration.md) -      * [16.2. 禁用特定的自动配置类](III. Using Spring Boot/16.2. Disabling Specific Auto-configuration Classes.md) -   * [17. Spring Beans和依赖注入](III. Using Spring Boot/17. Spring Beans and Dependency Injection.md) - * [18. 使用@SpringBootApplication注解](III. Using Spring Boot/18. Using the @SpringBootApplication Annotation.md) - * [19. 运行应用程序](III. Using Spring Boot/19. Running Your Application.md) - * [19.1. 从IDE中运行](III. Using Spring Boot/19.1. Running from an IDE.md) - * [19.2. 作为一个打包后的应用运行](III. Using Spring Boot/19.2. Running as a Packaged Application.md) - * [19.3. 使用Maven插件运行](III. Using Spring Boot/19.3. Using the Maven Plugin.md) - * [19.4. 使用Gradle插件运行](III. Using Spring Boot/19.4. Using the Gradle Plugin.md) - * [19.5. 热交换](III. Using Spring Boot/19.5. Hot Swapping.md) - * [20. 开发者工具](III. Using Spring Boot/20. Developer Tools.md) - * [20.1. 默认属性](III. Using Spring Boot/20.1. Property Defaults.md) - * [20.2. 自动重启](III. Using Spring Boot/20.2. Automatic Restart.md) - * [20.2.1. 在状况评估里记录更改](III. Using Spring Boot/20.2.1. Logging changes in condition evaluation.md) - * [20.2.2. 排除资源](III. Using Spring Boot/20.2.2. Excluding Resources.md) - * [20.2.3. 查看其他路径](III. Using Spring Boot/20.2.3. Watching Additional Paths.md) - * [20.2.4. 禁用重启](III. Using Spring Boot/20.2.4. Disabling Restart.md) - * [20.2.5. 使用触发器文件](III. Using Spring Boot/20.2.5. Using a Trigger File.md) - * [20.2.6. 自定义restart类加载器](III. Using Spring Boot/20.2.6. Customizing the Restart Classloader.md) - * [20.2.7. 已知限制](III. Using Spring Boot/20.2.7. Known Limitations.md) - * [20.3. LiveReload](III. Using Spring Boot/20.3. LiveReload.md) -      * [20.4. 全局设置](III. Using Spring Boot/20.4. Global Settings.md) - * [20.5. 远程应用](III. Using Spring Boot/20.5. Remote Applications.md) - * [20.5.1. 运行远程客户端应用](III. Using Spring Boot/20.5.1. Running the Remote Client Application.md) -         * [20.5.2. 远程更新](III. Using Spring Boot/20.5.2. Remote Update.md) - * [21. 打包用于生产的应用](III. Using Spring Boot/21. Packaging Your Application for Production.md) - * [22. 接下来阅读什么](III. Using Spring Boot/22. What to Read Next.md) -* [IV. Spring Boot特性](IV. Spring Boot features/README.md) - * [23. SpringApplication](IV. Spring Boot features/23. SpringApplication.md) - * [23.1. 启动失败](IV. Spring Boot features/23.1. Startup Failure.md) - * [23.2. 自定义Banner](IV. Spring Boot features/23.2. Customizing the Banner.md) - * [23.3. 自定义SpringApplication](IV. Spring Boot features/23.3. Customizing SpringApplication.md) - * [23.4. 流式构建API](IV. Spring Boot features/23.4. Fluent Builder API.md) - * [23.5. 应用事件和监听器](IV. Spring Boot features/23.5. Application Events and Listeners.md) -      * [23.6. Web环境](IV. Spring Boot features/23.6. Web Environment.md) - * [23.7. 访问应用参数](IV. Spring Boot features/23.7. Accessing Application Arguments.md) - * [23.8. 使用ApplicationRunner或CommandLineRunner](IV. Spring Boot features/23.8. Using the ApplicationRunner or CommandLineRunner.md) -      * [23.9. 应用退出](IV. Spring Boot features/23.9. Application Exit.md) - * [23.10. Admin特性](IV. Spring Boot features/23.10. Admin Features.md) - * [24.外化配置](IV. Spring Boot features/24. Externalized Configuration.md) -      * [24.1. 配置随机值](IV. Spring Boot features/24.1. Configuring Random Values.md) - * [24.2. 访问命令行属性](IV. Spring Boot features/24.2. Accessing Command Line Properties.md) - * [24.3. 应用属性文件](IV. Spring Boot features/24.3. Application Property Files.md) - * [24.4. Profile-specific属性](IV. Spring Boot features/24.4. Profile-specific Properties.md) - * [24.5. 属性占位符](IV. Spring Boot features/24.5. Placeholders in Properties.md) -      * [24.6. 使用YAML代替Properties](IV. Spring Boot features/24.6. Using YAML Instead of Properties.md) - * [24.6.1. 加载YAML](IV. Spring Boot features/24.6.1. Loading YAML.md) - * [24.6.2. 在Spring环境中使用YAML暴露属性](IV. Spring Boot features/24.6.2. Exposing YAML as Properties in the Spring Environment.md) -         * [24.6.3. Multi-profile YAML文档](IV. Spring Boot features/24.6.3. Multi-profile YAML Documents.md) -         * [24.6.4. YAML缺点](IV. Spring Boot features/24.6.4. YAML Shortcomings.md) -         * [24.6.5. 合并YAML列表](IV. Spring Boot features/24.6.5. Merging YAML Lists.md) - * [24.7. 类型安全的配置属性](IV. Spring Boot features/24.7. Type-safe Configuration Properties.md) -         * [24.7.1. 第三方配置](IV. Spring Boot features/24.7.1. Third-party Configuration.md) -         * [24.7.2. Relaxed绑定](IV. Spring Boot features/24.7.2. Relaxed Binding.md) -         * [24.7.3. 属性转换](IV. Spring Boot features/24.7.3. Properties Conversion.md) - * [24.7.4. @ConfigurationProperties校验](IV. Spring Boot features/24.7.4. @ConfigurationProperties Validation.md) - * [24.7.5. @ConfigurationProperties vs @Value](IV. Spring Boot features/24.7.5. @ConfigurationProperties vs. @Value.md) - * [25. Profiles](IV. Spring Boot features/25. Profiles.md) - * [25.1. 添加激活的profiles](IV. Spring Boot features/25.1. Adding Active Profiles.md) - * [25.2.以编程方式设置profiles](IV. Spring Boot features/25.2. Programmatically Setting Profiles.md) - * [25.3. Profile-specific配置文件](IV. Spring Boot features/25.3. Profile-specific Configuration Files.md) - * [26. 日志](IV. Spring Boot features/26. Logging.md) - * [26.1. 日志格式](IV. Spring Boot features/26.1. Log Format.md) - * [26.2. 控制台输出](IV. Spring Boot features/26.2. Console Output.md) - * [26.2.1. Color-coded输出](IV. Spring Boot features/26.2.1. Color-coded Output.md) - * [26.3. 文件输出](IV. Spring Boot features/26.3. File Output.md) - * [26.4. 日志级别](IV. Spring Boot features/26.4. Log Levels.md) - * [26.5. 自定义日志配置](IV. Spring Boot features/26.5. Custom Log Configuration.md) - * [26.6. Logback扩展](IV. Spring Boot features/26.6. Logback Extensions.md) - * [26.6.1. Profile-specific配置](IV. Spring Boot features/26.6.1. Profile-specific Configuration.md) - * [26.6.2. Environment属性](IV. Spring Boot features/26.6.2. Environment Properties.md) - * [27. 开发Web应用](IV. Spring Boot features/27. Developing Web Applications.md) - * [27.1. Spring Web MVC框架](IV. Spring Boot features/27.1. The “Spring Web MVC Framework”.md) - * [27.1.1. Spring MVC自动配置](IV. Spring Boot features/27.1.1. Spring MVC Auto-configuration.md) - * [27.1.2. HttpMessageConverters](IV. Spring Boot features/27.1.2. HttpMessageConverters.md) - * [27.1.3. 自定义JSON序列化器和反序列化器](IV. Spring Boot features/27.1.3. Custom JSON Serializers and Deserializers.md) - * [27.1.4. MessageCodesResolver](IV. Spring Boot features/27.1.4. MessageCodesResolver.md) - * [27.1.5. 静态内容](IV. Spring Boot features/27.1.5. Static Content.md) - * [27.1.6. 欢迎页](IV. Spring Boot features/27.1.6. Welcome Page.md) - * [27.1.7. 定制网站图标](IV. Spring Boot features/27.1.7. Custom Favicon.md) - * [27.1.8. 路径匹配与内容协商](IV. Spring Boot features/27.1.8. Path Matching and Content Negotiation.md) - * [27.1.9. ConfigurableWebBindingInitializer](IV. Spring Boot features/27.1.9. ConfigurableWebBindingInitializer.md) - * [27.1.10. 模板引擎](IV. Spring Boot features/27.1.10. Template Engines.md) - * [27.1.11. 错误处理](IV. Spring Boot features/27.1.11. Error Handling.md) - * [27.1.12. Spring HATEOAS](IV. Spring Boot features/27.1.12. Spring HATEOAS.md) - * [27.1.13. CORS支持](IV. Spring Boot features/27.1.13. CORS support.md) - * [27.2 Spring WebFlux框架](IV. Spring Boot features/27.2 The “Spring WebFlux Framework”.md) - * [27.2.1 Spring WebFlux自动配置](IV. Spring Boot features/27.2.1 Spring WebFlux Auto-configuration.md) - * [27.2.2 HTTP编解码器——HttpMessageReaders与HttpMessageWriters](IV. Spring Boot features/27.2.2 HTTP Codecs with HttpMessageReaders and HttpMessageWriters.md) - * [27.2.3 静态内容](IV. Spring Boot features/27.2.3 Static Content.md) - * [27.2.4 模板引擎](IV. Spring Boot features/27.2.4 Template Engines.md) - * [27.2.5 错误处理](IV. Spring Boot features/27.2.5 Error Handling.md) - * [27.2.6 网络过滤器](IV. Spring Boot features/27.2.6 Web Filters.md) - * [27.3. JAX-RS和Jersey](IV. Spring Boot features/27.3. JAX-RS and Jersey.md) - * [27.4 内嵌servlet容器支持](IV. Spring Boot features/27.4 Embedded Servlet Container Support.md) - * [27.4.1 Servlets、Filters和listeners](IV. Spring Boot features/27.4.1 Servlets, Filters, and listeners.md) - * [27.4.2 Servlet上下文初始化](IV. Spring Boot features/27.4.2 Servlet Context Initialization.md) - * [27.4.3 ServletWebServerApplicationContext](IV. Spring Boot features/27.4.3 The ServletWebServerApplicationContext.md) - * [27.4.4 自定义内嵌servlet容器](IV. Spring Boot features/27.4.4 Customizing Embedded Servlet Containers.md) - * [27.4.5 JSP的限制](IV. Spring Boot features/27.4.5 JSP Limitations.md) - * [28. 安全](IV. Spring Boot features/28. Security.md) - * [28.1 MVC安全](IV. Spring Boot features/28.1 MVC Security.md) - * [28.2 WebFlux安全](IV. Spring Boot features/28.2 WebFlux Security.md) - * [28.3 OAuth2](IV. Spring Boot features/28.3 OAuth2.md) - * [28.3.1 客户端](IV. Spring Boot features/28.3.1 Client.md) - * [28.4 执行器安全](IV. Spring Boot features/28.4 Actuator Security.md) - * [28.4.1 跨站请求伪造保护](IV. Spring Boot features/28.4.1 Cross Site Request Forgery Protection.md) - * [29. 使用SQL数据库](IV. Spring Boot features/29. Working with SQL Databases.md) - * [29.1. 配置DataSource](IV. Spring Boot features/29.1. Configure a DataSource.md) - * [29.1.1. 对内嵌数据库的支持](IV. Spring Boot features/29.1.1. Embedded Database Support.md) - * [29.1.2. 连接生产环境数据库](IV. Spring Boot features/29.1.2. Connection to a Production Database.md) - * [29.1.3. 连接JNDI数据库](IV. Spring Boot features/29.1.3. Connection to a JNDI DataSource.md) - * [29.2. 使用JdbcTemplate](IV. Spring Boot features/29.2. Using JdbcTemplate.md) - * [29.3. JPA和Spring Data](IV. Spring Boot features/29.3. JPA and Spring Data.md) - * [29.3.1. 实体类](IV. Spring Boot features/29.3.1. Entity Classes.md) - * [29.3.2. Spring Data JPA仓库](IV. Spring Boot features/29.3.2. Spring Data JPA Repositories.md) - * [29.3.3. 创建和删除JPA数据库](IV. Spring Boot features/29.3.3. Creating and Dropping JPA Databases.md) - * [29.3.4. 在视图中打开实体管理器](IV. Spring Boot features/29.3.4. Open EntityManager in View.md) - * [29.4 使用H2的web控制台](IV. Spring Boot features/29.4 Using H2’s Web Console.md) - * [29.4.1 改变H2控制台路径](IV. Spring Boot features/29.4.1 Changing the H2 Console’s Path.md) - * [29.5 使用jOOQ](IV. Spring Boot features/29.5 Using jOOQ.md) - * [29.5.1 代码生成](IV. Spring Boot features/29.5.1 Code Generation.md) - * [29.5.2 使用DSLContext](IV. Spring Boot features/29.5.2 Using DSLContext.md) - * [29.5.3 jOOQ SQL方言](IV. Spring Boot features/29.5.3 jOOQ SQL Dialect.md) - * [29.5.4 自定义jOOQ](IV. Spring Boot features/29.5.4 Customizing jOOQ.md) - * [30. 使用NoSQL技术](IV. Spring Boot features/30. Working with NoSQL Technologies.md) - * [30.1. Redis](IV. Spring Boot features/30.1. Redis.md) - * [30.1.1. 连接Redis](IV. Spring Boot features/30.1.1. Connecting to Redis.md) - * [30.2. MongoDB](IV. Spring Boot features/30.2. MongoDB.md) - * [30.2.1. 连接MongoDB数据库](IV. Spring Boot features/30.2.1. Connecting to a MongoDB Database.md) - * [30.2.2. MongoDBTemplate](IV. Spring Boot features/30.2.2. MongoTemplate.md) - * [30.2.3. Spring Data MongoDB仓库](IV. Spring Boot features/30.2.3. Spring Data MongoDB Repositories.md) - * [30.2.4 内嵌的Mongo](IV. Spring Boot features/30.2.4 Embedded Mongo.md) - * [30.3 Neo4j](IV. Spring Boot features/30.3 Neo4j.md) - * [30.3.1 连接Neo4j数据库](IV. Spring Boot features/30.3.1 Connecting to a Neo4j Database.md) - * [30.3.2 使用内嵌模式](IV. Spring Boot features/30.3.2 Using the Embedded Mode.md) - * [30.3.3 Neo4jSession](IV. Spring Boot features/30.3.3 Neo4jSession.md) - * [30.3.4 Spring Data Neo4j仓库](IV. Spring Boot features/30.3.4 Spring Data Neo4j Repositories.md) - * [30.3.5 仓库示例](IV. Spring Boot features/30.3.5 Repository Example.md) - * [30.4 Gemfire](IV. Spring Boot features/30.4 Gemfire.md) - * [30.5 Solr](IV. Spring Boot features/30.5 Solr.md) - * [30.5.1 连接Solr](IV. Spring Boot features/30.5.1 Connecting to Solr.md) - * [30.5.2 Spring Data Solr仓库](IV. Spring Boot features/30.5.2 Spring Data Solr Repositories.md) - * [30.6 Elasticsearch](IV. Spring Boot features/30.6 Elasticsearch.md) - * [30.6.1 使用Jest连接Elasticsearch](IV. Spring Boot features/30.6.1 Connecting to Elasticsearch by Using Jest.md) - * [30.6.2 使用Spring Data连接Elasticsearch](IV. Spring Boot features/30.6.2 Connecting to Elasticsearch by Using Spring Data.md) - * [30.6.3 Spring Data Elasticseach仓库](IV. Spring Boot features/30.6.3 Spring Data Elasticsearch Repositories.md) - * [30.7 Cassandra](IV. Spring Boot features/30.7 Cassandra.md) - * [30.7.1 连接Cassandra](IV. Spring Boot features/30.7.1 Connecting to Cassandra.md) - * [30.7.2 Spring Data Cassandra仓库](IV. Spring Boot features/30.7.2 Spring Data Cassandra Repositories.md) - * [30.8 Couchbase](IV. Spring Boot features/30.8 Couchbase.md) - * [30.8.1 连接Couchbase](IV. Spring Boot features/30.8.1 Connecting to Couchbase.md) - * [30.8.2 Spring Data Couchbase仓库](IV. Spring Boot features/30.8.2 Spring Data Couchbase Repositories.md) - * [30.9 LDAP](IV. Spring Boot features/30.9 LDAP.md) - * [30.9.1 连接LDAP服务器](IV. Spring Boot features/30.9.1 Connecting to an LDAP Server.md) - * [30.9.2 Spring Data LDAP仓库](IV. Spring Boot features/30.9.2 Spring Data LDAP Repositories.md) - * [30.9.3 嵌入式内存中LDAP服务器](IV. Spring Boot features/30.9.3 Embedded In-memory LDAP Server.md) - * [30.10 InfluxDB](IV. Spring Boot features/30.10 InfluxDB.md) - * [30.10.1 连接InfluxDB](IV. Spring Boot features/30.10.1 Connecting to InfluxDB.md) - * [31. 缓存](IV. Spring Boot features/31. Caching.md) - * [31.1 支持的缓存提供商](IV. Spring Boot features/31.1 Supported Cache Providers.md) - * [31.1.1 Generic](IV. Spring Boot features/31.1.1 Generic.md) - * [31.1.2 JCache (JSR-107)](IV. Spring Boot features/31.1.2 JCache(JSR-107).md) - * [31.1.3 EhCache 2.x](IV. Spring Boot features/31.1.3 EhCache 2.x.md) - * [31.1.4 Hazelcast](IV. Spring Boot features/31.1.4 Hazelcast.md) - * [31.1.5 Infinispan](IV. Spring Boot features/31.1.5 Infinispan.md) - * [31.1.6 Couchbase](IV. Spring Boot features/31.1.6 Couchbase.md) - * [31.1.7 Redis](IV. Spring Boot features/31.1.7 Redis.md) - * [31.1.8 Caffeine](IV. Spring Boot features/31.1.8 Caffeine.md) - * [31.1.9 Simple](IV. Spring Boot features/31.1.9 Simple.md) - * [31.1.10 None](IV. Spring Boot features/31.1.10 None.md) - * [32. 消息](IV. Spring Boot features/32. Messaging.md) - * [32.1. JMS](IV. Spring Boot features/32.1. JMS.md) - * [32.1.1 ActiveQ支持](IV. Spring Boot features/32.1.1 ActiveMQ Support.md) - * [32.1.2 Artemis支持](IV. Spring Boot features/32.1.2 Artemis Support.md) - * [32.1.3 使用JNDI ConnectionFactory](IV. Spring Boot features/32.1.3 Using a JNDI ConnectionFactory.md) - * [32.1.4 发送消息](IV. Spring Boot features/32.1.4 Sending a Message.md) - * [32.1.5 接收消息](IV. Spring Boot features/32.1.5 Receiving a Message.md) - * [32.2 AMQP](IV. Spring Boot features/32.2 AMQP.md) - * [32.2.1 RabbitMQ支持](IV. Spring Boot features/32.2.1 RabbitMQ support.md) - * [32.2.2 发送消息](IV. Spring Boot features/32.2.2 Sending a Message.md) - * [32.2.3 接收消息](IV. Spring Boot features/32.2.3 Receiving a Message.md) - * [32.3 Apache Kafka支持](IV. Spring Boot features/32.3 Apache Kafka Support.md) - * [32.3.1 发送消息](IV. Spring Boot features/32.3.1 Sending a Message.md) - * [32.3.2 接收消息](IV. Spring Boot features/32.3.2 Receiving a Message.md) - * [32.3.3 其它的Kafka属性](IV. Spring Boot features/32.3.3 Additional Kafka Properties.md) - * [33. 使用RestTemplate调用REST服务](IV. Spring Boot features/33. Calling REST Services with RestTemplate.md) - * [33.1 自定义RestTemplate](IV. Spring Boot features/33.1 RestTemplate Customization.md) - * [34. 使用WebClient调用REST服务](IV. Spring Boot features/34. Calling REST Services with WebClient.md) - * [34.1 自定义WebClient](IV. Spring Boot features/34.1 WebClient Customization.md) - * [35. 验证](IV. Spring Boot features/35. Validation.md) - * [36. 发送邮件](IV. Spring Boot features/36. Sending Email.md) - * [37. 使用JTA处理分布式事务](IV. Spring Boot features/37. Distributed Transactions with JTA.md) - * [37.1 使用Atomikos事务管理器](IV. Spring Boot features/37.1 Using an Atomikos Transaction Manager.md) - * [37.2 使用Bitronix事务管理器](IV. Spring Boot features/37.2 Using a Bitronix Transaction Manager.md) - * [37.3 使用Narayana事务管理器](IV. Spring Boot features/37.3 Using a Narayana Transaction Manager.md) - * [37.4 使用J2EE管理的事务管理器](IV. Spring Boot features/37.4 Using a Java EE Managed Transaction Manager.md) - * [37.5 混合XA和non-XA的JMS连接](IV. Spring Boot features/37.5 Mixing XA and Non-XA JMS Connections.md) - * [37.6 支持可替代的内嵌事务管理器](IV. Spring Boot features/37.6 Supporting an Alternative Embedded Transaction Manager.md) - * [38. Hazelcast](IV. Spring Boot features/38. Hazelcast.md) - * [39. Quartz调度器](IV. Spring Boot features/39. Quartz Scheduler.md) - * [40. Spring集成](IV. Spring Boot features/40. Spring Integration.md) - * [41. Spring Session](IV. Spring Boot features/41. Spring Session.md) - * [42. 基于JMX的监控和管理](IV. Spring Boot features/42. Monitoring and Management over JMX.md) - * [43. 测试](IV. Spring Boot features/43. Testing.md) - * [43.1 测试作用域依赖](IV. Spring Boot features/43.1 Test Scope Dependencies.md) - * [43.2 测试Spring应用](IV. Spring Boot features/43.2 Testing Spring Applications.md) - * [43.3 测试Spring Boot应用](IV. Spring Boot features/43.3 Testing Spring Boot Applications.md) - * [43.3.1 检测网络应用类型](IV. Spring Boot features/43.3.1 Detecting Web Application Type.md) - * [43.3.2 检测测试配置](IV. Spring Boot features/43.3.2 Detecting Test Configuration.md) - * [43.3.3 排除测试配置](IV. Spring Boot features/43.3.3 Excluding Test Configuration.md) - * [43.3.4 使用运行的服务器测试](IV. Spring Boot features/43.3.4 Testing with a running server.md) - * [43.3.5 模拟和监视bean](IV. Spring Boot features/43.3.5 Mocking and Spying Beans.md) - * [43.3.6 自动配置测试](IV. Spring Boot features/43.3.6 Auto-configured Tests.md) - * [43.3.7 自动配置的JSON测试](IV. Spring Boot features/43.3.7 Auto-configured JSON Tests.md) - * [43.3.8 自动配置的Spring MVC测试](IV. Spring Boot features/43.3.8 Auto-configured Spring MVC Tests.md) - * [43.3.9 自动配置的Spring WebFlux测试](IV. Spring Boot features/43.3.9 Auto-configured Spring WebFlux Tests.md) - * [43.3.10 自动配置的Data JPA测试](IV. Spring Boot features/43.3.10 Auto-configured Data JPA Tests.md) - * [43.3.11 自动配置的JDBC测试](IV. Spring Boot features/43.3.11 Auto-configured JDBC Tests.md) - * [43.3.12 自动配置的jOOQ测试](IV. Spring Boot features/43.3.12 Auto-configured jOOQ Tests.md) - * [43.3.13 自动配置的Data MongoDB测试](IV. Spring Boot features/43.3.13 Auto-configured Data MongoDB Tests.md) - * [43.3.14 自动配置的Data Neo4j测试](IV. Spring Boot features/43.3.14 Auto-configured Data Neo4j Tests.md) - * [43.3.15 自动配置的Data Redis测试](IV. Spring Boot features/43.3.15 Auto-configured Data Redis Tests.md) - * [43.3.16 自动配置的Data LDAP测试](IV. Spring Boot features/43.3.16 Auto-configured Data LDAP Tests.md) - * [43.3.17 自动配置的REST客户端](IV. Spring Boot features/43.3.17 Auto-configured REST Clients.md) - * [43.3.18 自动配置的Spring REST Docs测试](IV. Spring Boot features/43.3.18 Auto-configured Spring REST Docs Tests.md) - * [43.3.19 用户配置与切片](IV. Spring Boot features/43.3.19 User Configuration and Slicing.md) - * [43.3.20 使用Spock测试Spring Boot应用](IV. Spring Boot features/43.3.20 Using Spock to Test Spring Boot Applications.md) - * [43.4 测试工具类](IV. Spring Boot features/43.4 Test Utilities.md) - * [43.4.1 ConfigFileApplicationContextInitializer](IV. Spring Boot features/43.4.1 ConfigFileApplicationContextInitializer.md) - * [43.4.2 EnvironmentTestUtils](IV. Spring Boot features/43.4.2 EnvironmentTestUtils.md) - * [43.4.3 OutputCapture](IV. Spring Boot features/43.4.3 OutputCapture.md) - * [43.4.4 TestRestTemplate](IV. Spring Boot features/43.4.4 TestRestTemplate.md) - * [44. WebSockets](IV. Spring Boot features/44. WebSockets.md) - * [45. Web Services](IV. Spring Boot features/45. Web Services.md) - * [46. 创建自己的自动配置](IV. Spring Boot features/46. Creating Your Own Auto-configuration.md) - * [46.1 理解自动配置的bean](IV. Spring Boot features/46.1 Understanding Auto-configured Beans.md) - * [46.2 定位自动配置候选者](IV. Spring Boot features/46.2 Locating Auto-configuration Candidates.md) - * [46.3 条件注解](IV. Spring Boot features/46.3 Condition Annotations.md) - * [46.3.1 Class条件](IV. Spring Boot features/46.3.1 Class Conditions.md) - * [46.3.2 Bean条件](IV. Spring Boot features/46.3.2 Bean Conditions.md) - * [46.3.3 Property条件](IV. Spring Boot features/46.3.3 Property Conditions.md) - * [46.3.4 Resource条件](IV. Spring Boot features/46.3.4 Resource Conditions.md) - * [46.3.5 Web Application条件](IV. Spring Boot features/46.3.5 Web Application Conditions.md) - * [46.3.6 SpEL表达式条件](IV. Spring Boot features/46.3.6 SpEL Expression Conditions.md) - * [46.4 测试你的自动配置](IV. Spring Boot features/46.4 Testing your Auto-configuration.md) - * [46.4.1 模拟网络上下文](IV. Spring Boot features/46.4.1 Simulating a Web Context.md) - * [46.4.2 覆盖类路径](IV. Spring Boot features/46.4.2 Overriding the Classpath.md) - * [46.5 创建自己的starter](IV. Spring Boot features/46.5 Creating Your Own Starter.md) - * [46.5.1 命名](IV. Spring Boot features/46.5.1 Naming.md) - * [46.5.2 自动配置模块](IV. Spring Boot features/46.5.2 Autoconfigure Module.md) - * [46.5.3 Starter模块](IV. Spring Boot features/46.5.3 Starter Module.md) - * [47. Kotlin支持](IV. Spring Boot features/47. Kotlin support.md) - * [47.1 要求](IV. Spring Boot features/47.1 Requirements.md) - * [47.2 空安全](IV. Spring Boot features/47.2 Null-safety.md) - * 47.3 Kotlin API - * [47.3.1 runApplication](IV. Spring Boot features/47.3.1 runApplication.md) - * [47.3.2 扩展](IV. Spring Boot features/47.3.2 Extensions.md) - * [47.4 依赖管理](IV. Spring Boot features/47.4 Dependency management.md) - * [47.5 @ConfigurationProperties](IV. Spring Boot features/47.5 @ConfigurationProperties.md) - * [47.6 测试](IV. Spring Boot features/47.6 Testing.md) - * 47.7 资源 - * [47.7.1 延伸阅读](IV. Spring Boot features/47.7.1 Further reading.md) - * [47.7.2 示例](IV. Spring Boot features/47.7.2 Examples.md) - * [48. 接下来阅读什么](IV. Spring Boot features/48. What to Read Next.md) -* [V. Spring Boot执行器:用于生产环境的特性](V. Spring Boot Actuator/README.md) - * [49. 开启用于生产环境的特性](V. Spring Boot Actuator/49. Enabling Production-ready Features.md) - * [50. 端点](V. Spring Boot Actuator/50. Endpoints.md) - * [50.1 启用端点](V. Spring Boot Actuator/50.1 Enabling Endpoints.md) - * [50.2 暴露端点](V. Spring Boot Actuator/50.2 Exposing Endpoints.md) - * [50.3 加密HTTP端点](V. Spring Boot Actuator/50.3 Securing HTTP Endpoints.md) - * [50.4 配置端点](V. Spring Boot Actuator/50.4 Configuring Endpoints.md) - * [50.5 执行器网络端点的超媒体支持](V. Spring Boot Actuator/50.5 Hypermedia for Actuator Web Endpoints.md) - * [50.6 执行器网络端点路径](V. Spring Boot Actuator/50.6 Actuator Web Endpoint Paths.md) - * [50.7 CORS支持](V. Spring Boot Actuator/50.7 CORS Support.md) - * [50.8 实现自定义端点](V. Spring Boot Actuator/50.8 Implementing Custom Endpoints.md) - * [50.8.1 接收输入](V. Spring Boot Actuator/50.8.1 Receiving Input.md) - * [50.8.2 自定义网络端点](V. Spring Boot Actuator/50.8.2 Custom Web Endpoints.md) - * [50.8.3 Servlet端点](V. Spring Boot Actuator/50.8.3 Servlet endpoints.md) - * [50.8.4 Controller端点](V. Spring Boot Actuator/50.8.4 Controller endpoints.md) - * [50.9 健康信息](V. Spring Boot Actuator/50.9 Health Information.md) - * [50.9.1 自动配置的HealthIndicator](V. Spring Boot Actuator/50.9.1 Auto-configured HealthIndicators.md) - * [50.9.2 编写自定义HealthIndicator](V. Spring Boot Actuator/50.9.2 Writing Custom HealthIndicators.md) - * [50.9.3 响应式的健康指示器](V. Spring Boot Actuator/50.9.3 Reactive Health Indicators.md) - * [50.9.4 自动配置的ReactiveHealthIndicators](V. Spring Boot Actuator/50.9.4 Auto-configured ReactiveHealthIndicators.md) - * [50.10 应用信息](V. Spring Boot Actuator/50.10 Application Information.md) - * [50.10.1 自动配置的InfoContributors](V. Spring Boot Actuator/50.10.1 Auto-configured InfoContributors.md) - * [50.10.2 自定义应用信息](V. Spring Boot Actuator/50.10.2 Custom Application Information.md) - * [50.10.3 Git提交信息](V. Spring Boot Actuator/50.10.3 Git Commit Information.md) - * [50.10.4 构建信息](V. Spring Boot Actuator/50.10.4 Build Information.md) - * [50.10.5 编写自定义的InfoContributor](V. Spring Boot Actuator/50.10.5 Writing Custom InfoContributors.md) - * [51. 基于HTTP的监控和管理](V. Spring Boot Actuator/51. Monitoring and Management over HTTP.md) - * [51.1 自定义管理端点路径](V. Spring Boot Actuator/51.1 Customizing the Management Endpoint Paths.md) - * [51.2 自定义管理服务器端口](V. Spring Boot Actuator/51.2 Customizing the Management Server Port.md) - * [51.3 配置管理相关的SSL](V. Spring Boot Actuator/51.3 Configuring Management-specific SSL.md) - * [51.4 自定义管理服务器地址](V. Spring Boot Actuator/51.4 Customizing the Management Server Address.md) - * [51.5 禁用HTTP端点](V. Spring Boot Actuator/51.5 Disabling HTTP Endpoints.md) - * [52. 基于JMX的监控和管理](V. Spring Boot Actuator/52. Monitoring and Management over JMX.md) - * [52.1 自定义MBean名称](V. Spring Boot Actuator/52.1 Customizing MBean Names.md) - * [52.2 禁用JMX端点](V. Spring Boot Actuator/52.2 Disabling JMX Endpoints.md) - * [52.3 使用Jolokia通过HTTP实现JMX远程管理](V. Spring Boot Actuator/52.3 Using Jolokia for JMX over HTTP.md) - * [52.3.1 自定义Jolokia](V. Spring Boot Actuator/52.3.1 Customizing Jolokia.md) - * [52.3.2 禁用Jolokia](V. Spring Boot Actuator/52.3.2 Disabling Jolokia.md) - * [53. 记录器](V. Spring Boot Actuator/53. Loggers.md) - * [53.1 配置记录器](V. Spring Boot Actuator/53.1 Configure a Logger.md) - * [54. 度量指标](V. Spring Boot Actuator/54. Metrics.md) - * [54.1 入门指南](V. Spring Boot Actuator/54.1 Getting started.md) - * 54.2 支持的监控系统 - * [54.2.1 Atlas](V. Spring Boot Actuator/54.2.1 Atlas.md) - * [54.2.2 Datadog](V. Spring Boot Actuator/54.2.2 Datadog.md) - * [54.2.3 Ganglia](V. Spring Boot Actuator/54.2.3 Ganglia.md) - * [54.2.4 Graphite](V. Spring Boot Actuator/54.2.4 Graphite.md) - * [54.2.5 Influx](V. Spring Boot Actuator/54.2.5 Influx.md) - * [54.2.6 JMX](V. Spring Boot Actuator/54.2.6 JMX.md) - * [54.2.7 New Relic](V. Spring Boot Actuator/54.2.7 New Relic.md) - * [54.2.8 Prometheus](V. Spring Boot Actuator/54.2.8 Prometheus.md) - * [54.2.9 SignalFx](V. Spring Boot Actuator/54.2.9 SignalFx.md) - * [54.2.10 Simple](V. Spring Boot Actuator/54.2.10 Simple.md) - * [54.2.11 StatsD](V. Spring Boot Actuator/54.2.11 StatsD.md) - * [54.2.12 Wavefront](V. Spring Boot Actuator/54.2.12 Wavefront.md) - * [54.3 支持的指标](V. Spring Boot Actuator/54.3 Supported Metrics.md) - * [54.3.1 Spring MVC指标](V. Spring Boot Actuator/54.3.1 Spring MVC Metrics.md) - * [54.3.2 Spring WebFlux指标](V. Spring Boot Actuator/54.3.2 Spring WebFlux Metrics.md) - * [54.3.3 RestTemplate指标](V. Spring Boot Actuator/54.3.3 RestTemplate Metrics.md) - * [54.3.4 Spring集成指标](V. Spring Boot Actuator/54.3.4 Spring Integration metrics.md) - * [54.3.5 缓存指标](V. Spring Boot Actuator/54.3.5 Cache Metrics.md) - * [54.3.6 数据源指标](V. Spring Boot Actuator/54.3.6 DataSource Metrics.md) - * [54.3.7 RabbitMQ指标](V. Spring Boot Actuator/54.3.7 RabbitMQ Metrics.md) - * [54.4 注册自定义指标](V. Spring Boot Actuator/54.4 Registering custom metrics.md) - * [54.5 自定义单个指标](V. Spring Boot Actuator/54.5 Customizing individual metrics.md) - * [54.5.1 Per-meter属性](V. Spring Boot Actuator/54.5.1 Per-meter properties.md) - * [54.6 度量端点](V. Spring Boot Actuator/54.6 Metrics endpoint.md) - * [55. 审计](V. Spring Boot Actuator/55. Auditing.md) - * [56. HTTP追踪](V. Spring Boot Actuator/56. HTTP Tracing.md) - * [56.1 自定义HTTP追踪](V. Spring Boot Actuator/56.1 Custom HTTP tracing.md) - * [57. 进程监控](V. Spring Boot Actuator/57. Process Monitoring.md) - * [57.1 扩展配置](V. Spring Boot Actuator/57.1 Extend Configuration.md) - * [57.2 以编程方式](V. Spring Boot Actuator/57.2 Programmatically.md) - * [58. Cloud Foundry支持](V. Spring Boot Actuator/58. Cloud Foundry Support.md) - * [58.1 禁用扩展的Cloud Foundry执行器支持](V. Spring Boot Actuator/58.1 Disabling Extended Cloud Foundry Actuator Support.md) - * [58.2 Cloud Foundry自签名证书](V. Spring Boot Actuator/58.2 Cloud Foundry Self-signed Certificates.md) - * [58.3 自定义上下文路径](V. Spring Boot Actuator/58.3 Custom context path.md) - * [59. 接下来阅读什么](V. Spring Boot Actuator/59. What to Read Next.md) -* [VI. 部署到云端](VI. Deploying Spring Boot Applications/README.md) - * [60. 部署到云端](VI. Deploying Spring Boot Applications/60. Deploying to the Cloud.md) - * [60.1 Cloud Foundry](VI. Deploying Spring Boot Applications/60.1 Cloud Foundry.md) - * [60.1.1 绑定服务](VI. Deploying Spring Boot Applications/60.1.1 Binding to Services.md) - * [60.2 Heroku](VI. Deploying Spring Boot Applications/60.2 Heroku.md) - * [60.3 Openshift](VI. Deploying Spring Boot Applications/60.3 Openshift.md) - * [60.4 亚马逊网络服务(AWS)](VI. Deploying Spring Boot Applications/60.4 Amazon Web Services(AWS).md) - * [60.4.1 AWS Elastic Beanstalk](VI. Deploying Spring Boot Applications/60.4.1 AWS Elastic Beanstalk.md) - * [60.4.2 总结](VI. Deploying Spring Boot Applications/60.4.2 Summary.md) - * [60.5 Boxfuse和亚马逊网络服务](VI. Deploying Spring Boot Applications/60.5 Boxfuse and Amazon Web Services.md) - * [60.6 Google Cloud](VI. Deploying Spring Boot Applications/60.6 Google Cloud.md) - * [61. 安装Spring Boot应用](VI. Deploying Spring Boot Applications/61. Installing Spring Boot Applications.md) - * [61.1 支持的操作系统](VI. Deploying Spring Boot Applications/61.1 Supported Operating Systems.md) - * [61.2 Unix/Linux服务](VI. Deploying Spring Boot Applications/61.2 Unix&Linux Services.md) - * [61.2.1 安装为init.d服务(System V)](VI. Deploying Spring Boot Applications/61.2.1 Installation as an init.d Service(System V).md) - * [61.2.2 安装为Systemd服务](VI. Deploying Spring Boot Applications/61.2.2 Installation as a systemd Service.md) - * [61.2.3 自定义启动脚本](VI. Deploying Spring Boot Applications/61.2.3 Customizing the Startup Script.md) - * [61.3 Microsoft Windows服务](VI. Deploying Spring Boot Applications/61.3 Microsoft Windows Services.md) - * [62. 接下来阅读什么](VI. Deploying Spring Boot Applications/62. What to Read Next.md) -* [VII. Spring Boot CLI](VII. Spring Boot CLI/README.md) - * [63. 安装CLI](VII. Spring Boot CLI/63. Installing the CLI.md) - * [64. 使用CLI](VII. Spring Boot CLI/64. Using the CLI.md) - * [64.1 使用CLI运行应用](VII. Spring Boot CLI/64.1. Running Applications with the CLI.md) - * [64.1.1 推断"grab"依赖](VII. Spring Boot CLI/64.1.1 Deduced “grab” Dependencies.md) - * [64.1.2 推断"grab"坐标](VII. Spring Boot CLI/64.1.2 Deduced “grab” Coordinates.md) - * [64.1.3 默认import语句](VII. Spring Boot CLI/64.1.3 Default Import Statements.md) - * [64.1.4 自动创建main方法](VII. Spring Boot CLI/64.1.4 Automatic Main Method.md) - * [64.1.5 自定义依赖管理](VII. Spring Boot CLI/64.1.5 Custom Dependency Management.md) - * [64.2 多源文件应用](VII. Spring Boot CLI/64.2 Applications with Multiple Source Files.md) - * [64.3 应用打包](VII. Spring Boot CLI/64.3 Packaging Your Application.md) - * [64.4 初始化新工程](VII. Spring Boot CLI/64.4 Initialize a New Project.md) - * [64.5 使用内嵌shell](VII. Spring Boot CLI/64.5 Using the Embedded Shell.md) - * [64.6 为CLI添加扩展](VII. Spring Boot CLI/64.6 Adding Extensions to the CLI.md) - * [65. 使用Groovy beans DSL开发应用](VII. Spring Boot CLI/65. Developing Application with the Groovy Beans DSL.md) - * [66. 使用settings.xml配置CLI](VII. Spring Boot CLI/66. Configuring the CLI with settings.xml.md) - * [67. 接下来阅读什么](VII. Spring Boot CLI/67. What to Read Next.md) -* [VIII. 构建工具插件](VIII. Build tool plugins/README.md) - * [68. Spring Boot Maven插件](VIII. Build tool plugins/68. Spring Boot Maven Plugin.md) - * [68.1 包含该插件](VIII. Build tool plugins/68.1 Including the Plugin.md) - * [68.2 打包可执行jar和war文件](VIII. Build tool plugins/68.2 Packaging Executable Jar and War Files.md) - * [69. Spring Boot Gradle插件](VIII. Build tool plugins/69. Spring Boot Gradle Plugin.md) - * [70. Spring Boot AntLib模块](VIII. Build tool plugins/70. Spring Boot AntLib Module.md) - * [70.1. Spring Boot Ant任务](VIII. Build tool plugins/70.1. Spring Boot Ant Tasks.md) - * [70.1.1. spring-boot:exejar](VIII. Build tool plugins/70.1.1. spring-boot:exejar.md) - * [70.1.2. 示例](VIII. Build tool plugins/70.1.2. Examples.md) - * [70.2. spring-boot:findmainclass](VIII. Build tool plugins/70.2. spring-boot:findmainclass.md) - * [70.2.1. 示例](VIII. Build tool plugins/70.2.1. Examples.md) -   * [71. 对其他构建系统的支持](VIII. Build tool plugins/71. Supporting Other Build Systems.md) - * [71.1. 重新打包存档](VIII. Build tool plugins/71.1. Repackaging Archives.md) - * [71.2. 内嵌库](VIII. Build tool plugins/71.2. Nested Libraries.md) - * [71.3. 查找main类](VIII. Build tool plugins/71.3. Finding a Main Class.md) - * [71.4. repackage实现示例](VIII. Build tool plugins/71.4. Example Repackage Implementation.md) - * [72. 接下来阅读什么](VIII. Build tool plugins/72. What to Read Next.md) -* [IX. How-to指南](IX. ‘How-to’ guides/README.md) - * [73. Spring Boot应用](IX. ‘How-to’ guides/73. Spring Boot Application.md) - * [73.1 创建自己的FailureAnalyzer](IX. ‘How-to’ guides/73.1 Create Your Own FailureAnalyzer.md) - * [73.2 解决自动配置问题](IX. ‘How-to’ guides/73.2 Troubleshoot Auto-configuration.md) - * [73.3 启动前自定义Environment或ApplicationContext](IX. ‘How-to’ guides/73.3 Customize the Environment or ApplicationContext Before It Starts.md) - * [73.4 构建ApplicationContext层次结构](IX. ‘How-to’ guides/73.4 Build an ApplicationContext Hierarchy(Adding a Parent or Root Context).md) - * [73.5 创建no-web应用](IX. ‘How-to’ guides/73.5 Create a Non-web Application.md) - * [74. 属性与配置](IX. ‘How-to’ guides/74. Properties and Configuration.md) - * [74.1. 运行时暴露属性](IX. ‘How-to’ guides/74.1. Automatically Expand Properties at Build Time.md) - * [74.1.1. 使用Maven自动暴露属性](IX. ‘How-to’ guides/74.1.1. Automatic Property Expansion Using Maven.md) - * [74.1.2. 使用Gradle自动暴露属性](IX. ‘How-to’ guides/74.1.2. Automatic Property Expansion Using Gradle.md) - * [74.2. 外部化SpringApplication配置](IX. ‘How-to’ guides/74.2. Externalize the Configuration of SpringApplication.md) - * [74.3 改变应用程序外部配置文件的位置](IX. ‘How-to’ guides/74.3 Change the Location of External Properties of an Application.md) - * [74.4 使用“短”命令行参数](IX. ‘How-to’ guides/74.4 Use ‘Short’ Command Line Arguments.md) - * [74.5 使用YAML配置外部属性](IX. ‘How-to’ guides/74.5 Use YAML for External Properties.md) - * [74.6 设置生效的Spring profiles](IX. ‘How-to’ guides/74.6 Set the Active Spring Profiles.md) - * [74.7 根据环境改变配置](IX. ‘How-to’ guides/74.7 Change Configuration Depending on the Environment.md) - * [74.8 发现外部属性的内置选项](IX. ‘How-to’ guides/74.8 Discover Built-in Options for External Properties.md) - * [75. 内嵌网络服务器](IX. ‘How-to’ guides/75. Embedded Web Servers.md) - * [75.1 使用另外的网络服务器](IX. ‘How-to’ guides/75.1 Use Another Web Server.md) - * [75.2 配置Jetty](IX. ‘How-to’ guides/75.2 Configure Jetty.md) - * [75.3 为应用添加Servlet、Filter或Listener](IX. ‘How-to’ guides/75.3 Add a Servlet, Filter, or Listener to an Application.md) - * [75.3.1 使用Spring bean添加Servlet、Filter或Listener](IX. ‘How-to’ guides/75.3.1 Add a Servlet, Filter, or Listener by Using a Spring Bean.md) - * [75.3.2 使用类路径扫描添加Servlet、Filter和Listener](IX. ‘How-to’ guides/75.3.2 Add Servlets, Filters, and Listeners by Using Classpath Scanning.md) - * [75.4 改变HTTP端口](IX. ‘How-to’ guides/75.4 Change the HTTP Port.md) - * [75.5 使用随机未分配的HTTP端口](IX. ‘How-to’ guides/75.5 Use a Random Unassigned HTTP Port.md) - * [75.6 在运行时发现HTTP端口](IX. ‘How-to’ guides/75.6 Discover the HTTP Port at Runtime.md) - * [75.7 配置SSL](IX. ‘How-to’ guides/75.7 Configure SSL.md) - * [75.8 配置HTTP/2](IX. ‘How-to’ guides/75.8 Configure HTTP2.md) - * [75.8.1 HTTP/2与Undertow](IX. ‘How-to’ guides/75.8.1 HTTP2 with Undertow.md) - * [75.8.2 HTTP/2与Jetty](IX. ‘How-to’ guides/75.8.2 HTTP2 with Jetty.md) - * [75.8.3 HTTP/2与Tomcat](IX. ‘How-to’ guides/75.8.3 HTTP2 with Tomcat.md) - * [73.6 配置访问日志](IX. ‘How-to’ guides/73.6 Configure Access Logging.md) - * [73.7 在前端代理服务器后使用](IX. ‘How-to’ guides/73.7 Use behind a front-end proxy server.md) - * [73.7.1 自定义Tomcat代理配置](IX. ‘How-to’ guides/73.7.1 Customize Tomcat’s proxy configuration.md) - * [73.8 配置Tomcat](IX. ‘How-to’ guides/73.8 Configure Tomcat.md) - * [73.9 启用Tomcat的多连接器](IX. ‘How-to’ guides/73.9 Enable Multiple Connectors with Tomcat.md) - * [73.10 使用Tomcat的LegacyCookieProcessor](IX. ‘How-to’ guides/73.10 Use Tomcat’s LegacyCookieProcessor.md) - * [73.11 使用Jetty替代Tomcat](IX. ‘How-to’ guides/73.11 Use Jetty instead of Tomcat.md) - * [73.12 配置Jetty](IX. ‘How-to’ guides/73.12 Configure Jetty.md) - * [73.13 使用Undertow替代Tomcat](IX. ‘How-to’ guides/73.13 Use Undertow instead of Tomcat.md) - * [73.14 配置Undertow](IX. ‘How-to’ guides/73.14 Configure Undertow.md) - * [73.15 启用Undertow的多监听器](IX. ‘How-to’ guides/73.15 Enable Multiple Listeners with Undertow.md) - * [73.16 使用@ServerEndpoint创建WebSocket端点](IX. ‘How-to’ guides/73.16 Create WebSocket endpoints using @ServerEndpoint.md) - * [73.17 启用HTTP响应压缩](IX. ‘How-to’ guides/73.17 Enable HTTP response compression.md) - * [74. Spring MVC](IX. ‘How-to’ guides/74. Spring MVC.md) - * [74.1 编写JSON REST服务](IX. ‘How-to’ guides/74.1 Write a JSON REST service.md) - * [74.2 编写XML REST服务](IX. ‘How-to’ guides/74.2 Write an XML REST service.md) - * [74.3 自定义Jackson ObjectMapper](IX. ‘How-to’ guides/74.3 Customize the Jackson ObjectMapper.md) - * [74.4 自定义@ResponseBody渲染](IX. ‘How-to’ guides/74.4 Customize the @ResponseBody rendering.md) - * [74.5 处理Multipart文件上传](IX. ‘How-to’ guides/74.5 Handling Multipart File Uploads.md) - * [74.6 关闭Spring MVC DispatcherServlet](IX. ‘How-to’ guides/74.6 Switch off the Spring MVC DispatcherServlet.md) - * [74.7 关闭默认的MVC配置](IX. ‘How-to’ guides/74.7 Switch off the Default MVC configuration.md) - * [74.8 自定义ViewResolvers](IX. ‘How-to’ guides/74.8 Customize ViewResolvers.md) - * [75. HTTP客户端](IX. ‘How-to’ guides/75. HTTP clients.md) - * [75.1 配置RestTemplate使用代理](IX. ‘How-to’ guides/75.1 Configure RestTemplate to use a proxy.md) - * [76. 日志](IX. ‘How-to’ guides/76. Logging.md) - * [76.1 配置Logback](IX. ‘How-to’ guides/76.1 Configure Logback for logging.md) - * [76.1.1 配置logback只输出到文件](IX. ‘How-to’ guides/76.1.1 Configure logback for file only output.md) - * [76.2 配置Log4j](IX. ‘How-to’ guides/76.2 Configure Log4j for logging.md) - * [76.2.1 使用YAML或JSON配置Log4j2](IX. ‘How-to’ guides/76.2.1 Use YAML or JSON to configure Log4j 2.md) - * [77. 数据访问](IX. ‘How-to’ guides/77. Data Access.md) - * [77.1 配置自定义的数据源](IX. ‘How-to’ guides/77.1 Configure a custom DataSource.md) - * [77.2 配置两个数据源](IX. ‘How-to’ guides/77.2 Configure Two DataSources.md) - * [77.3 使用Spring Data仓库](IX. ‘How-to’ guides/77.3 Use Spring Data repositories.md) - * [77.4 从Spring配置分离@Entity定义](IX. ‘How-to’ guides/77.4 Separate @Entity definitions from Spring configuration.md) - * [77.5 配置JPA属性](IX. ‘How-to’ guides/77.5 Configure JPA properties.md) - * [77.6 配置Hibernate命名策略](IX. ‘How-to’ guides/77.6 Configure Hibernate Naming Strategy.md) - * [77.7 使用自定义EntityManagerFactory](IX. ‘How-to’ guides/77.7 Use a custom EntityManagerFactory.md) - * [77.8 使用两个EntityManagers](IX. ‘How-to’ guides/77.8 Use Two EntityManagers.md) - * [77.9 使用普通的persistence.xml](IX. ‘How-to’ guides/77.9 Use a traditional persistence.xml.md) - * [77.10 使用Spring Data JPA和Mongo仓库](IX. ‘How-to’ guides/77.10 Use Spring Data JPA and Mongo repositories.md) - * [77.11 将Spring Data仓库暴露为REST端点](IX. ‘How-to’ guides/77.11 Expose Spring Data repositories as REST endpoint.md) - * [77.12 配置JPA使用的组件](IX. ‘How-to’ guides/77.12 Configure a component that is used by JPA.md) - * [78. 数据库初始化](IX. ‘How-to’ guides/78. Database initialization.md) - * [78.1 使用JPA初始化数据库](IX. ‘How-to’ guides/78.1 Initialize a database using JPA.md) - * [78.2 使用Hibernate初始化数据库](IX. ‘How-to’ guides/78.2 Initialize a database using Hibernate.md) - * [78.3 使用Spring JDBC初始化数据库](IX. ‘How-to’ guides/78.3 Initialize a database using Spring JDBC.md) - * [78.4 初始化Spring Batch数据库](IX. ‘How-to’ guides/78.4 Initialize a Spring Batch database.md) - * [78.5 使用高级数据迁移工具](IX. ‘How-to’ guides/78.5 Use a higher level database migration tool.md) - * [78.5.1 启动时执行Flyway数据库迁移](IX. ‘How-to’ guides/78.5.1 Execute Flyway database migrations on startup.md) - * [78.5.2 启动时执行Liquibase数据库迁移](IX. ‘How-to’ guides/78.5.2 Execute Liquibase database migrations on startup.md) - * [79. 消息传送](IX. ‘How-to’ guides/79. Messaging.md) - * [79.1 禁用事务JMS会话](IX. ‘How-to’ guides/79.1 Disable transacted JMS session.md) - * [80. 批处理应用](IX. ‘How-to’ guides/80. Batch applications.md) - * [80.1 在启动时执行Spring Batch作业](IX. ‘How-to’ guides/80.1 Execute Spring Batch jobs on startup.md) - * [81. 执行器](IX. ‘How-to’ guides/81. Actuator.md) - * [81.1 改变HTTP端口或执行器端点的地址](IX. ‘How-to’ guides/81.1 Change the HTTP port or address of the actuator endpoints.md) - * [81.2 自定义WhiteLabel错误页面](IX. ‘How-to’ guides/81.2 Customize the ‘whitelabel’ error page.md) - * [81.3 Actuator和Jersey](IX. ‘How-to’ guides/81.3 Actuator and Jersey.md) - * [82. 安全](IX. ‘How-to’ guides/82. Security.md) - * [82.1 关闭Spring Boot安全配置](IX. ‘How-to’ guides/82.1 Switch off the Spring Boot security configuration.md) - * [82.2 改变AuthenticationManager并添加用户账号](IX. ‘How-to’ guides/82.2 Change the AuthenticationManager and add user accounts.md) - * [82.3 当前端使用代理服务器时启用HTTPS](IX. ‘How-to’ guides/82.3 Enable HTTPS when running behind a proxy server.md) - * [83. 热交换](IX. ‘How-to’ guides/83. Hot swapping.md) - * [83.1 重新加载静态内容](IX. ‘How-to’ guides/83.1 Reload static content.md) - * [83.2. 在不重启容器的情况下重新加载模板](IX. ‘How-to’ guides/83.2. Reload templates without restarting the container.md) - * [83.2.1 Thymeleaf模板](IX. ‘How-to’ guides/83.2.1 Thymeleaf templates.md) - * [83.2.2 FreeMarker模板](IX. ‘How-to’ guides/83.2.2 FreeMarker templates.md) - * [83.2.3 Groovy模板](IX. ‘How-to’ guides/83.2.3 Groovy templates.md) - * [83.3 应用快速重启](IX. ‘How-to’ guides/83.3 Fast application restarts.md) - * [83.4 在不重启容器的情况下重新加载Java类](IX. ‘How-to’ guides/83.4 Reload Java classes without restarting the container.md) - * [84. 构建](IX. ‘How-to’ guides/84. Build.md) - * [84.1 生成构建信息](IX. ‘How-to’ guides/84.1 Generate build information.md) - * [84.2 生成Git信息](IX. ‘How-to’ guides/84.2 Generate git information.md) - * [84.3 自定义依赖版本](IX. ‘How-to’ guides/84.3 Customize dependency versions.md) - * [84.4 使用Maven创建可执行JAR](IX. ‘How-to’ guides/84.4 Create an executable JAR with Maven.md) - * [84.5 将Spring Boot应用作为依赖](IX. ‘How-to’ guides/84.5 Use a Spring Boot application as a dependency.md) - * [84.6 在可执行jar运行时提取特定的版本](IX. ‘How-to’ guides/84.6 Extract specific libraries when an executable jar runs.md) - * [84.7 使用排除创建不可执行的JAR](IX. ‘How-to’ guides/84.7 Create a non-executable JAR with exclusions.md) - * [84.8 远程调试使用Maven启动的Spring Boot项目](IX. ‘How-to’ guides/84.8 Remote debug a Spring Boot application started with Maven.md) - * [84.9 使用Ant构建可执行存档(不使用spring-boot-antlib)](IX. ‘How-to’ guides/84.9 Build an executable archive from Ant without using spring-boot-antlib.md) - * [85. 传统部署](IX. ‘How-to’ guides/85. Traditional deployment.md) - * [85.1 创建可部署的war文件](IX. ‘How-to’ guides/85.1 Create a deployable war file.md) - * [85.2 为老的servlet容器创建可部署的war文件](IX. ‘How-to’ guides/85.2 Create a deployable war file for older servlet containers.md) - * [85.3 将现有的应用转换为Spring Boot](IX. ‘How-to’ guides/85.3 Convert an existing application to Spring Boot.md) - * [85.4 部署WAR到Weblogic](IX. ‘How-to’ guides/85.4 Deploying a WAR to Weblogic.md) - * [85.5 部署WAR到老的(Servlet2.5)容器](IX. ‘How-to’ guides/85.5 Deploying a WAR in an Old(Servlet 2.5)Container.md) - * [85.6 使用Lettuce来代替Jedis](IX. ‘How-to’ guides/85.6 Use Lettuce instead of Jedis.md) -* [X.附录](X. Appendices/README.md) - * [附录A. 常见应用属性](X. Appendices/A. Common application properties.md) - * [附录B. 配置元数据](X. Appendices/B. Configuration meta-data.md) - * [附录B.1. 元数据格式](X. Appendices/B.1. Meta-data format.md) - * [附录B.1.1. Group属性](X. Appendices/B.1.1. Group Attributes.md) - * [附录B.1.2. Property属性](X. Appendices/B.1.2. Property Attributes.md) - * [附录B.1.3. Hint属性](X. Appendices/B.1.3 Hint Attributes.md) - * [附录B.1.4. 可重复的元数据节点](X. Appendices/B.1.4. Repeated meta-data items.md) - * [附录B.2. 提供人工提示](X. Appendices/B.2 Providing manual hints.md) - * [附录 B.2.1 值提示](X. Appendices/B.2.1 Value hint.md) - * [附录 B.2.2 值提供者](X. Appendices/B.2.2 Value provider.md) - * [附录B.3. 使用注解处理器产生自己的元数据](X. Appendices/B.3. Generating your own meta-data using the annotation processor.md) - * [附录 B.3.1. 内嵌属性](X. Appendices/B.3.1. Nested properties.md) - * [附录 B.3.2. 添加其他的元数据](X. Appendices/B.3.2. Adding additional meta-data.md) - * [附录C. 自动配置类](X. Appendices/C. Auto-configuration classes.md) - * [附录 C.1. 来自spring-boot-autoconfigure模块](X. Appendices/C.1. From the “spring-boot-autoconfigure” module.md) - * [附录C.2. 来自spring-boot-actuator模块](X. Appendices/C.2. From the “spring-boot-actuator” module.md) - * [附录D. 测试自动配置的标注](X. Appendices/D. Test auto-configuration annotations.md) - * [附录E. 可执行jar格式](X. Appendices/E. The executable jar format.md) - * [附录E.1. 内嵌JARs](X. Appendices/E.1. Nested JARs.md) - * [附录E.1.1. 可执行jar文件结构](X. Appendices/E.1.1. The executable jar file structure.md) - * [附录E.1.2. 可执行war文件结构](X. Appendices/E.1.2. The executable war file structure.md) - * [附录E.2. Spring Boot的"JarFile"类](X. Appendices/E.2. Spring Boot’s “JarFile” class.md) - * [附录E.2.1. 对标准Java "JarFile"的兼容性](X. Appendices/E.2.1. Compatibility with the standard Java “JarFile”.md) - * [附录E.3. 启动可执行jars](X. Appendices/E.3. Launching executable jars.md) - * [附录E.3.1 Launcher manifest](X. Appendices/E.3.1. Launcher manifest.md) - * [附录E.3.2. 暴露的存档](X. Appendices/E.3.2. Exploded archives.md) - * [附录E.4. PropertiesLauncher特性](X. Appendices/E.4. PropertiesLauncher Features.md) - * [附录E.5. 可执行jar的限制](X. Appendices/E.5. Executable jar restrictions.md) - * [附录E.5.1. Zip实体压缩](X. Appendices/E.5.1. Zip entry compression.md) - * [附录E.5.2. 系统ClassLoader](X. Appendices/E.5.2. System ClassLoader.md) - * [附录E.6. 可替代的单一jar解决方案](X. Appendices/E.6. Alternative single jar solutions.md) - * [附录F. 依赖版本](X. Appendices/F. Dependency versions.md) +# Summary + +* [I. Spring Boot文档](I. Spring Boot Documentation/README.md) + * [1. 关于本文档](I. Spring Boot Documentation/1. About the Documentation.md) + * [2. 获取帮助](I. Spring Boot Documentation/2. Getting Help.md) + * [3. 第一步](I. Spring Boot Documentation/3. First Steps.md) + * [4. 使用Spring Boot](I. Spring Boot Documentation/4. Working with Spring Boot.md) + * [5. 了解Spring Boot特性](I. Spring Boot Documentation/5. Learning about Spring Boot Features.md) + * [6. 迁移到生产环境](I. Spring Boot Documentation/6. Moving to Production.md) + * [7. 高级主题](I. Spring Boot Documentation/7. Advanced Topics.md) +* [II. 开始](II. Getting Started/README.md) + * [8. Spring Boot介绍](II. Getting Started/8. Introducing Spring Boot.md) + * [9. 系统要求](II. Getting Started/9. System Requirements.md) + * [9.1. Servlet容器](II. Getting Started/9.1. Servlet Containers.md) + * [10. Spring Boot安装](II. Getting Started/10. Installing Spring Boot.md) + * [10.1. 为Java开发者准备的安装指南](II. Getting Started/10.1. Installation Instructions for the Java Developer.md) + * [10.1.1. Maven安装](II. Getting Started/10.1.1. Maven Installation.md) + * [10.1.2. Gradle安装](II. Getting Started/10.1.2. Gradle Installation.md) + * [10.2. Spring Boot CLI安装](II. Getting Started/10.2. Installing the Spring Boot CLI.md) + * [10.2.1. 手动安装](II. Getting Started/10.2.1. Manual Installation.md) + * [10.2.2. 使用SDKMAN进行安装](II. Getting Started/10.2.2. Installation with SDKMAN.md) + * [10.2.3. 使用OSX Homebrew进行安装](II. Getting Started/10.2.3. OSX Homebrew Installation.md) + * [10.2.4. 使用MacPorts进行安装](II. Getting Started/10.2.4. MacPorts Installation.md) + * [10.2.5. 命令行实现](II. Getting Started/10.2.5. Command-line Completion.md) + * [10.2.6. Spring CLI示例快速入门](II. Getting Started/10.2.6. Quick-start Spring CLI Example.md) + * [10.3. 从Spring Boot早期版本升级](II. Getting Started/10.3. Upgrading from an Earlier Version of Spring Boot.md) + * [11. 开发你的第一个Spring Boot应用](II. Getting Started/11. Developing Your First Spring Boot Application.md) + * [11.1. 创建POM](II. Getting Started/11.1. Creating the POM.md) + * [11.2. 添加classpath依赖](II. Getting Started/11.2. Adding Classpath Dependencies.md) + * [11.3. 编写代码](II. Getting Started/11.3. Writing the Code.md) + * [11.3.1. @RestController和@RequestMapping注解](II. Getting Started/11.3.1. The @RestController and @RequestMapping Annotations.md) + * [11.3.2. @EnableAutoConfiguration注解](II. Getting Started/11.3.2. The @EnableAutoConfiguration Annotation.md) + * [11.3.3. main方法](II. Getting Started/11.3.3. The “main” Method.md) + * [11.4. 运行示例](II. Getting Started/11.4. Running the Example.md) + * [11.5. 创建一个可执行jar](II. Getting Started/11.5. Creating an Executable Jar.md) + * [12. 接下来阅读什么](II. Getting Started/12. What to Read Next.md) +* [III. 使用Spring Boot](III. Using Spring Boot/README.md) + * [13. 构建系统](III. Using Spring Boot/13. Build Systems.md) + * [13.1. 依赖管理](III. Using Spring Boot/13.1. Dependency Management.md) + * [13.2. Maven](III. Using Spring Boot/13.2. Maven.md) + * [13.2.1. 继承starter parent](III. Using Spring Boot/13.2.1. Inheriting the Starter Parent.md) + * [13.2.2. 在不使用parent POM的情况下玩转Spring Boot](III. Using Spring Boot/13.2.2. Using Spring Boot without the Parent POM.md) + * [13.2.3. 使用Spring Boot Maven插件](III. Using Spring Boot/13.2.3. Using the Spring Boot Maven Plugin.md) + * [13.3. Gradle](III. Using Spring Boot/13.3. Gradle.md) + * [13.4. Ant](III. Using Spring Boot/13.4. Ant.md) + * [13.5. Starters](III. Using Spring Boot/13.5. Starters.md) + * [14. 组织你的代码](III. Using Spring Boot/14. Structuring Your Code.md) + * [14.1. 使用"default"包](III. Using Spring Boot/14.1. Using the “default” Package.md) + * [14.2. 放置应用的main类](III. Using Spring Boot/14.2. Locating the Main Application Class.md) +   * [15. 配置类](III. Using Spring Boot/15. Configuration Classes.md) + * [15.1. 导入其他配置类](III. Using Spring Boot/15.1. Importing Additional Configuration Classes.md) + * [15.2. 导入XML配置](III. Using Spring Boot/15.2. Importing XML Configuration.md) + * [16. 自动配置](III. Using Spring Boot/16. Auto-configuration.md) + * [16.1. 逐步替换自动配置](III. Using Spring Boot/16.1. Gradually Replacing Auto-configuration.md) +      * [16.2. 禁用特定的自动配置类](III. Using Spring Boot/16.2. Disabling Specific Auto-configuration Classes.md) +   * [17. Spring Beans和依赖注入](III. Using Spring Boot/17. Spring Beans and Dependency Injection.md) + * [18. 使用@SpringBootApplication注解](III. Using Spring Boot/18. Using the @SpringBootApplication Annotation.md) + * [19. 运行应用程序](III. Using Spring Boot/19. Running Your Application.md) + * [19.1. 从IDE中运行](III. Using Spring Boot/19.1. Running from an IDE.md) + * [19.2. 作为一个打包后的应用运行](III. Using Spring Boot/19.2. Running as a Packaged Application.md) + * [19.3. 使用Maven插件运行](III. Using Spring Boot/19.3. Using the Maven Plugin.md) + * [19.4. 使用Gradle插件运行](III. Using Spring Boot/19.4. Using the Gradle Plugin.md) + * [19.5. 热交换](III. Using Spring Boot/19.5. Hot Swapping.md) + * [20. 开发者工具](III. Using Spring Boot/20. Developer Tools.md) + * [20.1. 默认属性](III. Using Spring Boot/20.1. Property Defaults.md) + * [20.2. 自动重启](III. Using Spring Boot/20.2. Automatic Restart.md) + * [20.2.1. 在状况评估里记录更改](III. Using Spring Boot/20.2.1. Logging changes in condition evaluation.md) + * [20.2.2. 排除资源](III. Using Spring Boot/20.2.2. Excluding Resources.md) + * [20.2.3. 查看其他路径](III. Using Spring Boot/20.2.3. Watching Additional Paths.md) + * [20.2.4. 禁用重启](III. Using Spring Boot/20.2.4. Disabling Restart.md) + * [20.2.5. 使用触发器文件](III. Using Spring Boot/20.2.5. Using a Trigger File.md) + * [20.2.6. 自定义restart类加载器](III. Using Spring Boot/20.2.6. Customizing the Restart Classloader.md) + * [20.2.7. 已知限制](III. Using Spring Boot/20.2.7. Known Limitations.md) + * [20.3. LiveReload](III. Using Spring Boot/20.3. LiveReload.md) +      * [20.4. 全局设置](III. Using Spring Boot/20.4. Global Settings.md) + * [20.5. 远程应用](III. Using Spring Boot/20.5. Remote Applications.md) + * [20.5.1. 运行远程客户端应用](III. Using Spring Boot/20.5.1. Running the Remote Client Application.md) +         * [20.5.2. 远程更新](III. Using Spring Boot/20.5.2. Remote Update.md) + * [21. 打包用于生产的应用](III. Using Spring Boot/21. Packaging Your Application for Production.md) + * [22. 接下来阅读什么](III. Using Spring Boot/22. What to Read Next.md) +* [IV. Spring Boot特性](IV. Spring Boot features/README.md) + * [23. SpringApplication](IV. Spring Boot features/23. SpringApplication.md) + * [23.1. 启动失败](IV. Spring Boot features/23.1. Startup Failure.md) + * [23.2. 自定义Banner](IV. Spring Boot features/23.2. Customizing the Banner.md) + * [23.3. 自定义SpringApplication](IV. Spring Boot features/23.3. Customizing SpringApplication.md) + * [23.4. 流式构建API](IV. Spring Boot features/23.4. Fluent Builder API.md) + * [23.5. 应用事件和监听器](IV. Spring Boot features/23.5. Application Events and Listeners.md) +      * [23.6. Web环境](IV. Spring Boot features/23.6. Web Environment.md) + * [23.7. 访问应用参数](IV. Spring Boot features/23.7. Accessing Application Arguments.md) + * [23.8. 使用ApplicationRunner或CommandLineRunner](IV. Spring Boot features/23.8. Using the ApplicationRunner or CommandLineRunner.md) +      * [23.9. 应用退出](IV. Spring Boot features/23.9. Application Exit.md) + * [23.10. Admin特性](IV. Spring Boot features/23.10. Admin Features.md) + * [24.外化配置](IV. Spring Boot features/24. Externalized Configuration.md) +      * [24.1. 配置随机值](IV. Spring Boot features/24.1. Configuring Random Values.md) + * [24.2. 访问命令行属性](IV. Spring Boot features/24.2. Accessing Command Line Properties.md) + * [24.3. 应用属性文件](IV. Spring Boot features/24.3. Application Property Files.md) + * [24.4. Profile-specific属性](IV. Spring Boot features/24.4. Profile-specific Properties.md) + * [24.5. 属性占位符](IV. Spring Boot features/24.5. Placeholders in Properties.md) +      * [24.6. 使用YAML代替Properties](IV. Spring Boot features/24.6. Using YAML Instead of Properties.md) + * [24.6.1. 加载YAML](IV. Spring Boot features/24.6.1. Loading YAML.md) + * [24.6.2. 在Spring环境中使用YAML暴露属性](IV. Spring Boot features/24.6.2. Exposing YAML as Properties in the Spring Environment.md) +         * [24.6.3. Multi-profile YAML文档](IV. Spring Boot features/24.6.3. Multi-profile YAML Documents.md) +         * [24.6.4. YAML缺点](IV. Spring Boot features/24.6.4. YAML Shortcomings.md) +         * [24.6.5. 合并YAML列表](IV. Spring Boot features/24.6.5. Merging YAML Lists.md) + * [24.7. 类型安全的配置属性](IV. Spring Boot features/24.7. Type-safe Configuration Properties.md) +         * [24.7.1. 第三方配置](IV. Spring Boot features/24.7.1. Third-party Configuration.md) +         * [24.7.2. Relaxed绑定](IV. Spring Boot features/24.7.2. Relaxed Binding.md) +         * [24.7.3. 属性转换](IV. Spring Boot features/24.7.3. Properties Conversion.md) + * [24.7.4. @ConfigurationProperties校验](IV. Spring Boot features/24.7.4. @ConfigurationProperties Validation.md) + * [24.7.5. @ConfigurationProperties vs @Value](IV. Spring Boot features/24.7.5. @ConfigurationProperties vs. @Value.md) + * [25. Profiles](IV. Spring Boot features/25. Profiles.md) + * [25.1. 添加激活的profiles](IV. Spring Boot features/25.1. Adding Active Profiles.md) + * [25.2.以编程方式设置profiles](IV. Spring Boot features/25.2. Programmatically Setting Profiles.md) + * [25.3. Profile-specific配置文件](IV. Spring Boot features/25.3. Profile-specific Configuration Files.md) + * [26. 日志](IV. Spring Boot features/26. Logging.md) + * [26.1. 日志格式](IV. Spring Boot features/26.1. Log Format.md) + * [26.2. 控制台输出](IV. Spring Boot features/26.2. Console Output.md) + * [26.2.1. Color-coded输出](IV. Spring Boot features/26.2.1. Color-coded Output.md) + * [26.3. 文件输出](IV. Spring Boot features/26.3. File Output.md) + * [26.4. 日志级别](IV. Spring Boot features/26.4. Log Levels.md) + * [26.5. 自定义日志配置](IV. Spring Boot features/26.5. Custom Log Configuration.md) + * [26.6. Logback扩展](IV. Spring Boot features/26.6. Logback Extensions.md) + * [26.6.1. Profile-specific配置](IV. Spring Boot features/26.6.1. Profile-specific Configuration.md) + * [26.6.2. Environment属性](IV. Spring Boot features/26.6.2. Environment Properties.md) + * [27. 开发Web应用](IV. Spring Boot features/27. Developing Web Applications.md) + * [27.1. Spring Web MVC框架](IV. Spring Boot features/27.1. The “Spring Web MVC Framework”.md) + * [27.1.1. Spring MVC自动配置](IV. Spring Boot features/27.1.1. Spring MVC Auto-configuration.md) + * [27.1.2. HttpMessageConverters](IV. Spring Boot features/27.1.2. HttpMessageConverters.md) + * [27.1.3. 自定义JSON序列化器和反序列化器](IV. Spring Boot features/27.1.3. Custom JSON Serializers and Deserializers.md) + * [27.1.4. MessageCodesResolver](IV. Spring Boot features/27.1.4. MessageCodesResolver.md) + * [27.1.5. 静态内容](IV. Spring Boot features/27.1.5. Static Content.md) + * [27.1.6. 欢迎页](IV. Spring Boot features/27.1.6. Welcome Page.md) + * [27.1.7. 定制网站图标](IV. Spring Boot features/27.1.7. Custom Favicon.md) + * [27.1.8. 路径匹配与内容协商](IV. Spring Boot features/27.1.8. Path Matching and Content Negotiation.md) + * [27.1.9. ConfigurableWebBindingInitializer](IV. Spring Boot features/27.1.9. ConfigurableWebBindingInitializer.md) + * [27.1.10. 模板引擎](IV. Spring Boot features/27.1.10. Template Engines.md) + * [27.1.11. 错误处理](IV. Spring Boot features/27.1.11. Error Handling.md) + * [27.1.12. Spring HATEOAS](IV. Spring Boot features/27.1.12. Spring HATEOAS.md) + * [27.1.13. CORS支持](IV. Spring Boot features/27.1.13. CORS support.md) + * [27.2 Spring WebFlux框架](IV. Spring Boot features/27.2 The “Spring WebFlux Framework”.md) + * [27.2.1 Spring WebFlux自动配置](IV. Spring Boot features/27.2.1 Spring WebFlux Auto-configuration.md) + * [27.2.2 HTTP编解码器——HttpMessageReaders与HttpMessageWriters](IV. Spring Boot features/27.2.2 HTTP Codecs with HttpMessageReaders and HttpMessageWriters.md) + * [27.2.3 静态内容](IV. Spring Boot features/27.2.3 Static Content.md) + * [27.2.4 模板引擎](IV. Spring Boot features/27.2.4 Template Engines.md) + * [27.2.5 错误处理](IV. Spring Boot features/27.2.5 Error Handling.md) + * [27.2.6 网络过滤器](IV. Spring Boot features/27.2.6 Web Filters.md) + * [27.3. JAX-RS和Jersey](IV. Spring Boot features/27.3. JAX-RS and Jersey.md) + * [27.4 内嵌servlet容器支持](IV. Spring Boot features/27.4 Embedded Servlet Container Support.md) + * [27.4.1 Servlets、Filters和listeners](IV. Spring Boot features/27.4.1 Servlets, Filters, and listeners.md) + * [27.4.2 Servlet上下文初始化](IV. Spring Boot features/27.4.2 Servlet Context Initialization.md) + * [27.4.3 ServletWebServerApplicationContext](IV. Spring Boot features/27.4.3 The ServletWebServerApplicationContext.md) + * [27.4.4 自定义内嵌servlet容器](IV. Spring Boot features/27.4.4 Customizing Embedded Servlet Containers.md) + * [27.4.5 JSP的限制](IV. Spring Boot features/27.4.5 JSP Limitations.md) + * [28. 安全](IV. Spring Boot features/28. Security.md) + * [28.1 MVC安全](IV. Spring Boot features/28.1 MVC Security.md) + * [28.2 WebFlux安全](IV. Spring Boot features/28.2 WebFlux Security.md) + * [28.3 OAuth2](IV. Spring Boot features/28.3 OAuth2.md) + * [28.3.1 客户端](IV. Spring Boot features/28.3.1 Client.md) + * [28.4 执行器安全](IV. Spring Boot features/28.4 Actuator Security.md) + * [28.4.1 跨站请求伪造保护](IV. Spring Boot features/28.4.1 Cross Site Request Forgery Protection.md) + * [29. 使用SQL数据库](IV. Spring Boot features/29. Working with SQL Databases.md) + * [29.1. 配置DataSource](IV. Spring Boot features/29.1. Configure a DataSource.md) + * [29.1.1. 对内嵌数据库的支持](IV. Spring Boot features/29.1.1. Embedded Database Support.md) + * [29.1.2. 连接生产环境数据库](IV. Spring Boot features/29.1.2. Connection to a Production Database.md) + * [29.1.3. 连接JNDI数据库](IV. Spring Boot features/29.1.3. Connection to a JNDI DataSource.md) + * [29.2. 使用JdbcTemplate](IV. Spring Boot features/29.2. Using JdbcTemplate.md) + * [29.3. JPA和Spring Data](IV. Spring Boot features/29.3. JPA and Spring Data.md) + * [29.3.1. 实体类](IV. Spring Boot features/29.3.1. Entity Classes.md) + * [29.3.2. Spring Data JPA仓库](IV. Spring Boot features/29.3.2. Spring Data JPA Repositories.md) + * [29.3.3. 创建和删除JPA数据库](IV. Spring Boot features/29.3.3. Creating and Dropping JPA Databases.md) + * [29.3.4. 在视图中打开实体管理器](IV. Spring Boot features/29.3.4. Open EntityManager in View.md) + * [29.4 使用H2的web控制台](IV. Spring Boot features/29.4 Using H2’s Web Console.md) + * [29.4.1 改变H2控制台路径](IV. Spring Boot features/29.4.1 Changing the H2 Console’s Path.md) + * [29.5 使用jOOQ](IV. Spring Boot features/29.5 Using jOOQ.md) + * [29.5.1 代码生成](IV. Spring Boot features/29.5.1 Code Generation.md) + * [29.5.2 使用DSLContext](IV. Spring Boot features/29.5.2 Using DSLContext.md) + * [29.5.3 jOOQ SQL方言](IV. Spring Boot features/29.5.3 jOOQ SQL Dialect.md) + * [29.5.4 自定义jOOQ](IV. Spring Boot features/29.5.4 Customizing jOOQ.md) + * [30. 使用NoSQL技术](IV. Spring Boot features/30. Working with NoSQL Technologies.md) + * [30.1. Redis](IV. Spring Boot features/30.1. Redis.md) + * [30.1.1. 连接Redis](IV. Spring Boot features/30.1.1. Connecting to Redis.md) + * [30.2. MongoDB](IV. Spring Boot features/30.2. MongoDB.md) + * [30.2.1. 连接MongoDB数据库](IV. Spring Boot features/30.2.1. Connecting to a MongoDB Database.md) + * [30.2.2. MongoDBTemplate](IV. Spring Boot features/30.2.2. MongoTemplate.md) + * [30.2.3. Spring Data MongoDB仓库](IV. Spring Boot features/30.2.3. Spring Data MongoDB Repositories.md) + * [30.2.4 内嵌的Mongo](IV. Spring Boot features/30.2.4 Embedded Mongo.md) + * [30.3 Neo4j](IV. Spring Boot features/30.3 Neo4j.md) + * [30.3.1 连接Neo4j数据库](IV. Spring Boot features/30.3.1 Connecting to a Neo4j Database.md) + * [30.3.2 使用内嵌模式](IV. Spring Boot features/30.3.2 Using the Embedded Mode.md) + * [30.3.3 Neo4jSession](IV. Spring Boot features/30.3.3 Neo4jSession.md) + * [30.3.4 Spring Data Neo4j仓库](IV. Spring Boot features/30.3.4 Spring Data Neo4j Repositories.md) + * [30.3.5 仓库示例](IV. Spring Boot features/30.3.5 Repository Example.md) + * [30.4 Gemfire](IV. Spring Boot features/30.4 Gemfire.md) + * [30.5 Solr](IV. Spring Boot features/30.5 Solr.md) + * [30.5.1 连接Solr](IV. Spring Boot features/30.5.1 Connecting to Solr.md) + * [30.5.2 Spring Data Solr仓库](IV. Spring Boot features/30.5.2 Spring Data Solr Repositories.md) + * [30.6 Elasticsearch](IV. Spring Boot features/30.6 Elasticsearch.md) + * [30.6.1 使用Jest连接Elasticsearch](IV. Spring Boot features/30.6.1 Connecting to Elasticsearch by Using Jest.md) + * [30.6.2 使用Spring Data连接Elasticsearch](IV. Spring Boot features/30.6.2 Connecting to Elasticsearch by Using Spring Data.md) + * [30.6.3 Spring Data Elasticseach仓库](IV. Spring Boot features/30.6.3 Spring Data Elasticsearch Repositories.md) + * [30.7 Cassandra](IV. Spring Boot features/30.7 Cassandra.md) + * [30.7.1 连接Cassandra](IV. Spring Boot features/30.7.1 Connecting to Cassandra.md) + * [30.7.2 Spring Data Cassandra仓库](IV. Spring Boot features/30.7.2 Spring Data Cassandra Repositories.md) + * [30.8 Couchbase](IV. Spring Boot features/30.8 Couchbase.md) + * [30.8.1 连接Couchbase](IV. Spring Boot features/30.8.1 Connecting to Couchbase.md) + * [30.8.2 Spring Data Couchbase仓库](IV. Spring Boot features/30.8.2 Spring Data Couchbase Repositories.md) + * [30.9 LDAP](IV. Spring Boot features/30.9 LDAP.md) + * [30.9.1 连接LDAP服务器](IV. Spring Boot features/30.9.1 Connecting to an LDAP Server.md) + * [30.9.2 Spring Data LDAP仓库](IV. Spring Boot features/30.9.2 Spring Data LDAP Repositories.md) + * [30.9.3 嵌入式内存中LDAP服务器](IV. Spring Boot features/30.9.3 Embedded In-memory LDAP Server.md) + * [30.10 InfluxDB](IV. Spring Boot features/30.10 InfluxDB.md) + * [30.10.1 连接InfluxDB](IV. Spring Boot features/30.10.1 Connecting to InfluxDB.md) + * [31. 缓存](IV. Spring Boot features/31. Caching.md) + * [31.1 支持的缓存提供商](IV. Spring Boot features/31.1 Supported Cache Providers.md) + * [31.1.1 Generic](IV. Spring Boot features/31.1.1 Generic.md) + * [31.1.2 JCache (JSR-107)](IV. Spring Boot features/31.1.2 JCache(JSR-107).md) + * [31.1.3 EhCache 2.x](IV. Spring Boot features/31.1.3 EhCache 2.x.md) + * [31.1.4 Hazelcast](IV. Spring Boot features/31.1.4 Hazelcast.md) + * [31.1.5 Infinispan](IV. Spring Boot features/31.1.5 Infinispan.md) + * [31.1.6 Couchbase](IV. Spring Boot features/31.1.6 Couchbase.md) + * [31.1.7 Redis](IV. Spring Boot features/31.1.7 Redis.md) + * [31.1.8 Caffeine](IV. Spring Boot features/31.1.8 Caffeine.md) + * [31.1.9 Simple](IV. Spring Boot features/31.1.9 Simple.md) + * [31.1.10 None](IV. Spring Boot features/31.1.10 None.md) + * [32. 消息](IV. Spring Boot features/32. Messaging.md) + * [32.1. JMS](IV. Spring Boot features/32.1. JMS.md) + * [32.1.1 ActiveQ支持](IV. Spring Boot features/32.1.1 ActiveMQ Support.md) + * [32.1.2 Artemis支持](IV. Spring Boot features/32.1.2 Artemis Support.md) + * [32.1.3 使用JNDI ConnectionFactory](IV. Spring Boot features/32.1.3 Using a JNDI ConnectionFactory.md) + * [32.1.4 发送消息](IV. Spring Boot features/32.1.4 Sending a Message.md) + * [32.1.5 接收消息](IV. Spring Boot features/32.1.5 Receiving a Message.md) + * [32.2 AMQP](IV. Spring Boot features/32.2 AMQP.md) + * [32.2.1 RabbitMQ支持](IV. Spring Boot features/32.2.1 RabbitMQ support.md) + * [32.2.2 发送消息](IV. Spring Boot features/32.2.2 Sending a Message.md) + * [32.2.3 接收消息](IV. Spring Boot features/32.2.3 Receiving a Message.md) + * [32.3 Apache Kafka支持](IV. Spring Boot features/32.3 Apache Kafka Support.md) + * [32.3.1 发送消息](IV. Spring Boot features/32.3.1 Sending a Message.md) + * [32.3.2 接收消息](IV. Spring Boot features/32.3.2 Receiving a Message.md) + * [32.3.3 其它的Kafka属性](IV. Spring Boot features/32.3.3 Additional Kafka Properties.md) + * [33. 使用RestTemplate调用REST服务](IV. Spring Boot features/33. Calling REST Services with RestTemplate.md) + * [33.1 自定义RestTemplate](IV. Spring Boot features/33.1 RestTemplate Customization.md) + * [34. 使用WebClient调用REST服务](IV. Spring Boot features/34. Calling REST Services with WebClient.md) + * [34.1 自定义WebClient](IV. Spring Boot features/34.1 WebClient Customization.md) + * [35. 验证](IV. Spring Boot features/35. Validation.md) + * [36. 发送邮件](IV. Spring Boot features/36. Sending Email.md) + * [37. 使用JTA处理分布式事务](IV. Spring Boot features/37. Distributed Transactions with JTA.md) + * [37.1 使用Atomikos事务管理器](IV. Spring Boot features/37.1 Using an Atomikos Transaction Manager.md) + * [37.2 使用Bitronix事务管理器](IV. Spring Boot features/37.2 Using a Bitronix Transaction Manager.md) + * [37.3 使用Narayana事务管理器](IV. Spring Boot features/37.3 Using a Narayana Transaction Manager.md) + * [37.4 使用J2EE管理的事务管理器](IV. Spring Boot features/37.4 Using a Java EE Managed Transaction Manager.md) + * [37.5 混合XA和non-XA的JMS连接](IV. Spring Boot features/37.5 Mixing XA and Non-XA JMS Connections.md) + * [37.6 支持可替代的内嵌事务管理器](IV. Spring Boot features/37.6 Supporting an Alternative Embedded Transaction Manager.md) + * [38. Hazelcast](IV. Spring Boot features/38. Hazelcast.md) + * [39. Quartz调度器](IV. Spring Boot features/39. Quartz Scheduler.md) + * [40. Spring集成](IV. Spring Boot features/40. Spring Integration.md) + * [41. Spring Session](IV. Spring Boot features/41. Spring Session.md) + * [42. 基于JMX的监控和管理](IV. Spring Boot features/42. Monitoring and Management over JMX.md) + * [43. 测试](IV. Spring Boot features/43. Testing.md) + * [43.1 测试作用域依赖](IV. Spring Boot features/43.1 Test Scope Dependencies.md) + * [43.2 测试Spring应用](IV. Spring Boot features/43.2 Testing Spring Applications.md) + * [43.3 测试Spring Boot应用](IV. Spring Boot features/43.3 Testing Spring Boot Applications.md) + * [43.3.1 检测网络应用类型](IV. Spring Boot features/43.3.1 Detecting Web Application Type.md) + * [43.3.2 检测测试配置](IV. Spring Boot features/43.3.2 Detecting Test Configuration.md) + * [43.3.3 排除测试配置](IV. Spring Boot features/43.3.3 Excluding Test Configuration.md) + * [43.3.4 使用运行的服务器测试](IV. Spring Boot features/43.3.4 Testing with a running server.md) + * [43.3.5 模拟和监视bean](IV. Spring Boot features/43.3.5 Mocking and Spying Beans.md) + * [43.3.6 自动配置测试](IV. Spring Boot features/43.3.6 Auto-configured Tests.md) + * [43.3.7 自动配置的JSON测试](IV. Spring Boot features/43.3.7 Auto-configured JSON Tests.md) + * [43.3.8 自动配置的Spring MVC测试](IV. Spring Boot features/43.3.8 Auto-configured Spring MVC Tests.md) + * [43.3.9 自动配置的Spring WebFlux测试](IV. Spring Boot features/43.3.9 Auto-configured Spring WebFlux Tests.md) + * [43.3.10 自动配置的Data JPA测试](IV. Spring Boot features/43.3.10 Auto-configured Data JPA Tests.md) + * [43.3.11 自动配置的JDBC测试](IV. Spring Boot features/43.3.11 Auto-configured JDBC Tests.md) + * [43.3.12 自动配置的jOOQ测试](IV. Spring Boot features/43.3.12 Auto-configured jOOQ Tests.md) + * [43.3.13 自动配置的Data MongoDB测试](IV. Spring Boot features/43.3.13 Auto-configured Data MongoDB Tests.md) + * [43.3.14 自动配置的Data Neo4j测试](IV. Spring Boot features/43.3.14 Auto-configured Data Neo4j Tests.md) + * [43.3.15 自动配置的Data Redis测试](IV. Spring Boot features/43.3.15 Auto-configured Data Redis Tests.md) + * [43.3.16 自动配置的Data LDAP测试](IV. Spring Boot features/43.3.16 Auto-configured Data LDAP Tests.md) + * [43.3.17 自动配置的REST客户端](IV. Spring Boot features/43.3.17 Auto-configured REST Clients.md) + * [43.3.18 自动配置的Spring REST Docs测试](IV. Spring Boot features/43.3.18 Auto-configured Spring REST Docs Tests.md) + * [43.3.19 用户配置与切片](IV. Spring Boot features/43.3.19 User Configuration and Slicing.md) + * [43.3.20 使用Spock测试Spring Boot应用](IV. Spring Boot features/43.3.20 Using Spock to Test Spring Boot Applications.md) + * [43.4 测试工具类](IV. Spring Boot features/43.4 Test Utilities.md) + * [43.4.1 ConfigFileApplicationContextInitializer](IV. Spring Boot features/43.4.1 ConfigFileApplicationContextInitializer.md) + * [43.4.2 EnvironmentTestUtils](IV. Spring Boot features/43.4.2 EnvironmentTestUtils.md) + * [43.4.3 OutputCapture](IV. Spring Boot features/43.4.3 OutputCapture.md) + * [43.4.4 TestRestTemplate](IV. Spring Boot features/43.4.4 TestRestTemplate.md) + * [44. WebSockets](IV. Spring Boot features/44. WebSockets.md) + * [45. Web Services](IV. Spring Boot features/45. Web Services.md) + * [46. 创建自己的自动配置](IV. Spring Boot features/46. Creating Your Own Auto-configuration.md) + * [46.1 理解自动配置的bean](IV. Spring Boot features/46.1 Understanding Auto-configured Beans.md) + * [46.2 定位自动配置候选者](IV. Spring Boot features/46.2 Locating Auto-configuration Candidates.md) + * [46.3 条件注解](IV. Spring Boot features/46.3 Condition Annotations.md) + * [46.3.1 Class条件](IV. Spring Boot features/46.3.1 Class Conditions.md) + * [46.3.2 Bean条件](IV. Spring Boot features/46.3.2 Bean Conditions.md) + * [46.3.3 Property条件](IV. Spring Boot features/46.3.3 Property Conditions.md) + * [46.3.4 Resource条件](IV. Spring Boot features/46.3.4 Resource Conditions.md) + * [46.3.5 Web Application条件](IV. Spring Boot features/46.3.5 Web Application Conditions.md) + * [46.3.6 SpEL表达式条件](IV. Spring Boot features/46.3.6 SpEL Expression Conditions.md) + * [46.4 测试你的自动配置](IV. Spring Boot features/46.4 Testing your Auto-configuration.md) + * [46.4.1 模拟网络上下文](IV. Spring Boot features/46.4.1 Simulating a Web Context.md) + * [46.4.2 覆盖类路径](IV. Spring Boot features/46.4.2 Overriding the Classpath.md) + * [46.5 创建自己的starter](IV. Spring Boot features/46.5 Creating Your Own Starter.md) + * [46.5.1 命名](IV. Spring Boot features/46.5.1 Naming.md) + * [46.5.2 自动配置模块](IV. Spring Boot features/46.5.2 Autoconfigure Module.md) + * [46.5.3 Starter模块](IV. Spring Boot features/46.5.3 Starter Module.md) + * [47. Kotlin支持](IV. Spring Boot features/47. Kotlin support.md) + * [47.1 要求](IV. Spring Boot features/47.1 Requirements.md) + * [47.2 空安全](IV. Spring Boot features/47.2 Null-safety.md) + * 47.3 Kotlin API + * [47.3.1 runApplication](IV. Spring Boot features/47.3.1 runApplication.md) + * [47.3.2 扩展](IV. Spring Boot features/47.3.2 Extensions.md) + * [47.4 依赖管理](IV. Spring Boot features/47.4 Dependency management.md) + * [47.5 @ConfigurationProperties](IV. Spring Boot features/47.5 @ConfigurationProperties.md) + * [47.6 测试](IV. Spring Boot features/47.6 Testing.md) + * 47.7 资源 + * [47.7.1 延伸阅读](IV. Spring Boot features/47.7.1 Further reading.md) + * [47.7.2 示例](IV. Spring Boot features/47.7.2 Examples.md) + * [48. 接下来阅读什么](IV. Spring Boot features/48. What to Read Next.md) +* [V. Spring Boot执行器:用于生产环境的特性](V. Spring Boot Actuator/README.md) + * [49. 开启用于生产环境的特性](V. Spring Boot Actuator/49. Enabling Production-ready Features.md) + * [50. 端点](V. Spring Boot Actuator/50. Endpoints.md) + * [50.1 启用端点](V. Spring Boot Actuator/50.1 Enabling Endpoints.md) + * [50.2 暴露端点](V. Spring Boot Actuator/50.2 Exposing Endpoints.md) + * [50.3 加密HTTP端点](V. Spring Boot Actuator/50.3 Securing HTTP Endpoints.md) + * [50.4 配置端点](V. Spring Boot Actuator/50.4 Configuring Endpoints.md) + * [50.5 执行器网络端点的超媒体支持](V. Spring Boot Actuator/50.5 Hypermedia for Actuator Web Endpoints.md) + * [50.6 执行器网络端点路径](V. Spring Boot Actuator/50.6 Actuator Web Endpoint Paths.md) + * [50.7 CORS支持](V. Spring Boot Actuator/50.7 CORS Support.md) + * [50.8 实现自定义端点](V. Spring Boot Actuator/50.8 Implementing Custom Endpoints.md) + * [50.8.1 接收输入](V. Spring Boot Actuator/50.8.1 Receiving Input.md) + * [50.8.2 自定义网络端点](V. Spring Boot Actuator/50.8.2 Custom Web Endpoints.md) + * [50.8.3 Servlet端点](V. Spring Boot Actuator/50.8.3 Servlet endpoints.md) + * [50.8.4 Controller端点](V. Spring Boot Actuator/50.8.4 Controller endpoints.md) + * [50.9 健康信息](V. Spring Boot Actuator/50.9 Health Information.md) + * [50.9.1 自动配置的HealthIndicator](V. Spring Boot Actuator/50.9.1 Auto-configured HealthIndicators.md) + * [50.9.2 编写自定义HealthIndicator](V. Spring Boot Actuator/50.9.2 Writing Custom HealthIndicators.md) + * [50.9.3 响应式的健康指示器](V. Spring Boot Actuator/50.9.3 Reactive Health Indicators.md) + * [50.9.4 自动配置的ReactiveHealthIndicators](V. Spring Boot Actuator/50.9.4 Auto-configured ReactiveHealthIndicators.md) + * [50.10 应用信息](V. Spring Boot Actuator/50.10 Application Information.md) + * [50.10.1 自动配置的InfoContributors](V. Spring Boot Actuator/50.10.1 Auto-configured InfoContributors.md) + * [50.10.2 自定义应用信息](V. Spring Boot Actuator/50.10.2 Custom Application Information.md) + * [50.10.3 Git提交信息](V. Spring Boot Actuator/50.10.3 Git Commit Information.md) + * [50.10.4 构建信息](V. Spring Boot Actuator/50.10.4 Build Information.md) + * [50.10.5 编写自定义的InfoContributor](V. Spring Boot Actuator/50.10.5 Writing Custom InfoContributors.md) + * [51. 基于HTTP的监控和管理](V. Spring Boot Actuator/51. Monitoring and Management over HTTP.md) + * [51.1 自定义管理端点路径](V. Spring Boot Actuator/51.1 Customizing the Management Endpoint Paths.md) + * [51.2 自定义管理服务器端口](V. Spring Boot Actuator/51.2 Customizing the Management Server Port.md) + * [51.3 配置管理相关的SSL](V. Spring Boot Actuator/51.3 Configuring Management-specific SSL.md) + * [51.4 自定义管理服务器地址](V. Spring Boot Actuator/51.4 Customizing the Management Server Address.md) + * [51.5 禁用HTTP端点](V. Spring Boot Actuator/51.5 Disabling HTTP Endpoints.md) + * [52. 基于JMX的监控和管理](V. Spring Boot Actuator/52. Monitoring and Management over JMX.md) + * [52.1 自定义MBean名称](V. Spring Boot Actuator/52.1 Customizing MBean Names.md) + * [52.2 禁用JMX端点](V. Spring Boot Actuator/52.2 Disabling JMX Endpoints.md) + * [52.3 使用Jolokia通过HTTP实现JMX远程管理](V. Spring Boot Actuator/52.3 Using Jolokia for JMX over HTTP.md) + * [52.3.1 自定义Jolokia](V. Spring Boot Actuator/52.3.1 Customizing Jolokia.md) + * [52.3.2 禁用Jolokia](V. Spring Boot Actuator/52.3.2 Disabling Jolokia.md) + * [53. 记录器](V. Spring Boot Actuator/53. Loggers.md) + * [53.1 配置记录器](V. Spring Boot Actuator/53.1 Configure a Logger.md) + * [54. 度量指标](V. Spring Boot Actuator/54. Metrics.md) + * [54.1 入门指南](V. Spring Boot Actuator/54.1 Getting started.md) + * 54.2 支持的监控系统 + * [54.2.1 Atlas](V. Spring Boot Actuator/54.2.1 Atlas.md) + * [54.2.2 Datadog](V. Spring Boot Actuator/54.2.2 Datadog.md) + * [54.2.3 Ganglia](V. Spring Boot Actuator/54.2.3 Ganglia.md) + * [54.2.4 Graphite](V. Spring Boot Actuator/54.2.4 Graphite.md) + * [54.2.5 Influx](V. Spring Boot Actuator/54.2.5 Influx.md) + * [54.2.6 JMX](V. Spring Boot Actuator/54.2.6 JMX.md) + * [54.2.7 New Relic](V. Spring Boot Actuator/54.2.7 New Relic.md) + * [54.2.8 Prometheus](V. Spring Boot Actuator/54.2.8 Prometheus.md) + * [54.2.9 SignalFx](V. Spring Boot Actuator/54.2.9 SignalFx.md) + * [54.2.10 Simple](V. Spring Boot Actuator/54.2.10 Simple.md) + * [54.2.11 StatsD](V. Spring Boot Actuator/54.2.11 StatsD.md) + * [54.2.12 Wavefront](V. Spring Boot Actuator/54.2.12 Wavefront.md) + * [54.3 支持的指标](V. Spring Boot Actuator/54.3 Supported Metrics.md) + * [54.3.1 Spring MVC指标](V. Spring Boot Actuator/54.3.1 Spring MVC Metrics.md) + * [54.3.2 Spring WebFlux指标](V. Spring Boot Actuator/54.3.2 Spring WebFlux Metrics.md) + * [54.3.3 RestTemplate指标](V. Spring Boot Actuator/54.3.3 RestTemplate Metrics.md) + * [54.3.4 Spring集成指标](V. Spring Boot Actuator/54.3.4 Spring Integration metrics.md) + * [54.3.5 缓存指标](V. Spring Boot Actuator/54.3.5 Cache Metrics.md) + * [54.3.6 数据源指标](V. Spring Boot Actuator/54.3.6 DataSource Metrics.md) + * [54.3.7 RabbitMQ指标](V. Spring Boot Actuator/54.3.7 RabbitMQ Metrics.md) + * [54.4 注册自定义指标](V. Spring Boot Actuator/54.4 Registering custom metrics.md) + * [54.5 自定义单个指标](V. Spring Boot Actuator/54.5 Customizing individual metrics.md) + * [54.5.1 Per-meter属性](V. Spring Boot Actuator/54.5.1 Per-meter properties.md) + * [54.6 度量端点](V. Spring Boot Actuator/54.6 Metrics endpoint.md) + * [55. 审计](V. Spring Boot Actuator/55. Auditing.md) + * [56. HTTP追踪](V. Spring Boot Actuator/56. HTTP Tracing.md) + * [56.1 自定义HTTP追踪](V. Spring Boot Actuator/56.1 Custom HTTP tracing.md) + * [57. 进程监控](V. Spring Boot Actuator/57. Process Monitoring.md) + * [57.1 扩展配置](V. Spring Boot Actuator/57.1 Extend Configuration.md) + * [57.2 以编程方式](V. Spring Boot Actuator/57.2 Programmatically.md) + * [58. Cloud Foundry支持](V. Spring Boot Actuator/58. Cloud Foundry Support.md) + * [58.1 禁用扩展的Cloud Foundry执行器支持](V. Spring Boot Actuator/58.1 Disabling Extended Cloud Foundry Actuator Support.md) + * [58.2 Cloud Foundry自签名证书](V. Spring Boot Actuator/58.2 Cloud Foundry Self-signed Certificates.md) + * [58.3 自定义上下文路径](V. Spring Boot Actuator/58.3 Custom context path.md) + * [59. 接下来阅读什么](V. Spring Boot Actuator/59. What to Read Next.md) +* [VI. 部署到云端](VI. Deploying Spring Boot Applications/README.md) + * [60. 部署到云端](VI. Deploying Spring Boot Applications/60. Deploying to the Cloud.md) + * [60.1 Cloud Foundry](VI. Deploying Spring Boot Applications/60.1 Cloud Foundry.md) + * [60.1.1 绑定服务](VI. Deploying Spring Boot Applications/60.1.1 Binding to Services.md) + * [60.2 Heroku](VI. Deploying Spring Boot Applications/60.2 Heroku.md) + * [60.3 Openshift](VI. Deploying Spring Boot Applications/60.3 Openshift.md) + * [60.4 亚马逊网络服务(AWS)](VI. Deploying Spring Boot Applications/60.4 Amazon Web Services(AWS).md) + * [60.4.1 AWS Elastic Beanstalk](VI. Deploying Spring Boot Applications/60.4.1 AWS Elastic Beanstalk.md) + * [60.4.2 总结](VI. Deploying Spring Boot Applications/60.4.2 Summary.md) + * [60.5 Boxfuse和亚马逊网络服务](VI. Deploying Spring Boot Applications/60.5 Boxfuse and Amazon Web Services.md) + * [60.6 Google Cloud](VI. Deploying Spring Boot Applications/60.6 Google Cloud.md) + * [61. 安装Spring Boot应用](VI. Deploying Spring Boot Applications/61. Installing Spring Boot Applications.md) + * [61.1 支持的操作系统](VI. Deploying Spring Boot Applications/61.1 Supported Operating Systems.md) + * [61.2 Unix/Linux服务](VI. Deploying Spring Boot Applications/61.2 Unix&Linux Services.md) + * [61.2.1 安装为init.d服务(System V)](VI. Deploying Spring Boot Applications/61.2.1 Installation as an init.d Service(System V).md) + * [61.2.2 安装为Systemd服务](VI. Deploying Spring Boot Applications/61.2.2 Installation as a systemd Service.md) + * [61.2.3 自定义启动脚本](VI. Deploying Spring Boot Applications/61.2.3 Customizing the Startup Script.md) + * [61.3 Microsoft Windows服务](VI. Deploying Spring Boot Applications/61.3 Microsoft Windows Services.md) + * [62. 接下来阅读什么](VI. Deploying Spring Boot Applications/62. What to Read Next.md) +* [VII. Spring Boot CLI](VII. Spring Boot CLI/README.md) + * [63. 安装CLI](VII. Spring Boot CLI/63. Installing the CLI.md) + * [64. 使用CLI](VII. Spring Boot CLI/64. Using the CLI.md) + * [64.1 使用CLI运行应用](VII. Spring Boot CLI/64.1. Running Applications with the CLI.md) + * [64.1.1 推断"grab"依赖](VII. Spring Boot CLI/64.1.1 Deduced “grab” Dependencies.md) + * [64.1.2 推断"grab"坐标](VII. Spring Boot CLI/64.1.2 Deduced “grab” Coordinates.md) + * [64.1.3 默认import语句](VII. Spring Boot CLI/64.1.3 Default Import Statements.md) + * [64.1.4 自动创建main方法](VII. Spring Boot CLI/64.1.4 Automatic Main Method.md) + * [64.1.5 自定义依赖管理](VII. Spring Boot CLI/64.1.5 Custom Dependency Management.md) + * [64.2 多源文件应用](VII. Spring Boot CLI/64.2 Applications with Multiple Source Files.md) + * [64.3 应用打包](VII. Spring Boot CLI/64.3 Packaging Your Application.md) + * [64.4 初始化新工程](VII. Spring Boot CLI/64.4 Initialize a New Project.md) + * [64.5 使用内嵌shell](VII. Spring Boot CLI/64.5 Using the Embedded Shell.md) + * [64.6 为CLI添加扩展](VII. Spring Boot CLI/64.6 Adding Extensions to the CLI.md) + * [65. 使用Groovy beans DSL开发应用](VII. Spring Boot CLI/65. Developing Application with the Groovy Beans DSL.md) + * [66. 使用settings.xml配置CLI](VII. Spring Boot CLI/66. Configuring the CLI with settings.xml.md) + * [67. 接下来阅读什么](VII. Spring Boot CLI/67. What to Read Next.md) +* [VIII. 构建工具插件](VIII. Build tool plugins/README.md) + * [68. Spring Boot Maven插件](VIII. Build tool plugins/68. Spring Boot Maven Plugin.md) + * [68.1 包含该插件](VIII. Build tool plugins/68.1 Including the Plugin.md) + * [68.2 打包可执行jar和war文件](VIII. Build tool plugins/68.2 Packaging Executable Jar and War Files.md) + * [69. Spring Boot Gradle插件](VIII. Build tool plugins/69. Spring Boot Gradle Plugin.md) + * [70. Spring Boot AntLib模块](VIII. Build tool plugins/70. Spring Boot AntLib Module.md) + * [70.1. Spring Boot Ant任务](VIII. Build tool plugins/70.1. Spring Boot Ant Tasks.md) + * [70.1.1. spring-boot:exejar](VIII. Build tool plugins/70.1.1. spring-boot:exejar.md) + * [70.1.2. 示例](VIII. Build tool plugins/70.1.2. Examples.md) + * [70.2. spring-boot:findmainclass](VIII. Build tool plugins/70.2. spring-boot:findmainclass.md) + * [70.2.1. 示例](VIII. Build tool plugins/70.2.1. Examples.md) +   * [71. 对其他构建系统的支持](VIII. Build tool plugins/71. Supporting Other Build Systems.md) + * [71.1. 重新打包存档](VIII. Build tool plugins/71.1. Repackaging Archives.md) + * [71.2. 内嵌库](VIII. Build tool plugins/71.2. Nested Libraries.md) + * [71.3. 查找main类](VIII. Build tool plugins/71.3. Finding a Main Class.md) + * [71.4. repackage实现示例](VIII. Build tool plugins/71.4. Example Repackage Implementation.md) + * [72. 接下来阅读什么](VIII. Build tool plugins/72. What to Read Next.md) +* [IX. How-to指南](IX. ‘How-to’ guides/README.md) + * [73. Spring Boot应用](IX. ‘How-to’ guides/73. Spring Boot Application.md) + * [73.1 创建自己的FailureAnalyzer](IX. ‘How-to’ guides/73.1 Create Your Own FailureAnalyzer.md) + * [73.2 解决自动配置问题](IX. ‘How-to’ guides/73.2 Troubleshoot Auto-configuration.md) + * [73.3 启动前自定义Environment或ApplicationContext](IX. ‘How-to’ guides/73.3 Customize the Environment or ApplicationContext Before It Starts.md) + * [73.4 构建ApplicationContext层次结构](IX. ‘How-to’ guides/73.4 Build an ApplicationContext Hierarchy(Adding a Parent or Root Context).md) + * [73.5 创建no-web应用](IX. ‘How-to’ guides/73.5 Create a Non-web Application.md) + * [74. 属性与配置](IX. ‘How-to’ guides/74. Properties and Configuration.md) + * [74.1. 运行时暴露属性](IX. ‘How-to’ guides/74.1. Automatically Expand Properties at Build Time.md) + * [74.1.1. 使用Maven自动暴露属性](IX. ‘How-to’ guides/74.1.1. Automatic Property Expansion Using Maven.md) + * [74.1.2. 使用Gradle自动暴露属性](IX. ‘How-to’ guides/74.1.2. Automatic Property Expansion Using Gradle.md) + * [74.2. 外部化SpringApplication配置](IX. ‘How-to’ guides/74.2. Externalize the Configuration of SpringApplication.md) + * [74.3 改变应用程序外部配置文件的位置](IX. ‘How-to’ guides/74.3 Change the Location of External Properties of an Application.md) + * [74.4 使用“短”命令行参数](IX. ‘How-to’ guides/74.4 Use ‘Short’ Command Line Arguments.md) + * [74.5 使用YAML配置外部属性](IX. ‘How-to’ guides/74.5 Use YAML for External Properties.md) + * [74.6 设置生效的Spring profiles](IX. ‘How-to’ guides/74.6 Set the Active Spring Profiles.md) + * [74.7 根据环境改变配置](IX. ‘How-to’ guides/74.7 Change Configuration Depending on the Environment.md) + * [74.8 发现外部属性的内置选项](IX. ‘How-to’ guides/74.8 Discover Built-in Options for External Properties.md) + * [75. 内嵌网络服务器](IX. ‘How-to’ guides/75. Embedded Web Servers.md) + * [75.1 使用另外的网络服务器](IX. ‘How-to’ guides/75.1 Use Another Web Server.md) + * [75.2 配置Jetty](IX. ‘How-to’ guides/75.2 Configure Jetty.md) + * [75.3 为应用添加Servlet、Filter或Listener](IX. ‘How-to’ guides/75.3 Add a Servlet, Filter, or Listener to an Application.md) + * [75.3.1 使用Spring bean添加Servlet、Filter或Listener](IX. ‘How-to’ guides/75.3.1 Add a Servlet, Filter, or Listener by Using a Spring Bean.md) + * [75.3.2 使用类路径扫描添加Servlet、Filter和Listener](IX. ‘How-to’ guides/75.3.2 Add Servlets, Filters, and Listeners by Using Classpath Scanning.md) + * [75.4 改变HTTP端口](IX. ‘How-to’ guides/75.4 Change the HTTP Port.md) + * [75.5 使用随机未分配的HTTP端口](IX. ‘How-to’ guides/75.5 Use a Random Unassigned HTTP Port.md) + * [75.6 在运行时发现HTTP端口](IX. ‘How-to’ guides/75.6 Discover the HTTP Port at Runtime.md) + * [75.7 配置SSL](IX. ‘How-to’ guides/75.7 Configure SSL.md) + * [75.8 配置HTTP/2](IX. ‘How-to’ guides/75.8 Configure HTTP2.md) + * [75.8.1 HTTP/2与Undertow](IX. ‘How-to’ guides/75.8.1 HTTP2 with Undertow.md) + * [75.8.2 HTTP/2与Jetty](IX. ‘How-to’ guides/75.8.2 HTTP2 with Jetty.md) + * [75.8.3 HTTP/2与Tomcat](IX. ‘How-to’ guides/75.8.3 HTTP2 with Tomcat.md) + * [75.9 配置访问日志](IX. ‘How-to’ guides/75.9 Configure Access Logging.md) + * [75.10 在前端代理服务器后运行](IX. ‘How-to’ guides/75.10 Running Behind a Front-end Proxy Server.md) + * [75.10.1 自定义Tomcat代理配置](IX. ‘How-to’ guides/75.10.1 Customize Tomcat’s Proxy Configuration.md) + * [73.8 配置Tomcat](IX. ‘How-to’ guides/73.8 Configure Tomcat.md) + * [73.9 启用Tomcat的多连接器](IX. ‘How-to’ guides/73.9 Enable Multiple Connectors with Tomcat.md) + * [73.10 使用Tomcat的LegacyCookieProcessor](IX. ‘How-to’ guides/73.10 Use Tomcat’s LegacyCookieProcessor.md) + * [73.11 使用Jetty替代Tomcat](IX. ‘How-to’ guides/73.11 Use Jetty instead of Tomcat.md) + * [73.12 配置Jetty](IX. ‘How-to’ guides/73.12 Configure Jetty.md) + * [73.13 使用Undertow替代Tomcat](IX. ‘How-to’ guides/73.13 Use Undertow instead of Tomcat.md) + * [73.14 配置Undertow](IX. ‘How-to’ guides/73.14 Configure Undertow.md) + * [73.15 启用Undertow的多监听器](IX. ‘How-to’ guides/73.15 Enable Multiple Listeners with Undertow.md) + * [73.16 使用@ServerEndpoint创建WebSocket端点](IX. ‘How-to’ guides/73.16 Create WebSocket endpoints using @ServerEndpoint.md) + * [73.17 启用HTTP响应压缩](IX. ‘How-to’ guides/73.17 Enable HTTP response compression.md) + * [74. Spring MVC](IX. ‘How-to’ guides/74. Spring MVC.md) + * [74.1 编写JSON REST服务](IX. ‘How-to’ guides/74.1 Write a JSON REST service.md) + * [74.2 编写XML REST服务](IX. ‘How-to’ guides/74.2 Write an XML REST service.md) + * [74.3 自定义Jackson ObjectMapper](IX. ‘How-to’ guides/74.3 Customize the Jackson ObjectMapper.md) + * [74.4 自定义@ResponseBody渲染](IX. ‘How-to’ guides/74.4 Customize the @ResponseBody rendering.md) + * [74.5 处理Multipart文件上传](IX. ‘How-to’ guides/74.5 Handling Multipart File Uploads.md) + * [74.6 关闭Spring MVC DispatcherServlet](IX. ‘How-to’ guides/74.6 Switch off the Spring MVC DispatcherServlet.md) + * [74.7 关闭默认的MVC配置](IX. ‘How-to’ guides/74.7 Switch off the Default MVC configuration.md) + * [74.8 自定义ViewResolvers](IX. ‘How-to’ guides/74.8 Customize ViewResolvers.md) + * [75. HTTP客户端](IX. ‘How-to’ guides/75. HTTP clients.md) + * [75.1 配置RestTemplate使用代理](IX. ‘How-to’ guides/75.1 Configure RestTemplate to use a proxy.md) + * [76. 日志](IX. ‘How-to’ guides/76. Logging.md) + * [76.1 配置Logback](IX. ‘How-to’ guides/76.1 Configure Logback for logging.md) + * [76.1.1 配置logback只输出到文件](IX. ‘How-to’ guides/76.1.1 Configure logback for file only output.md) + * [76.2 配置Log4j](IX. ‘How-to’ guides/76.2 Configure Log4j for logging.md) + * [76.2.1 使用YAML或JSON配置Log4j2](IX. ‘How-to’ guides/76.2.1 Use YAML or JSON to configure Log4j 2.md) + * [77. 数据访问](IX. ‘How-to’ guides/77. Data Access.md) + * [77.1 配置自定义的数据源](IX. ‘How-to’ guides/77.1 Configure a custom DataSource.md) + * [77.2 配置两个数据源](IX. ‘How-to’ guides/77.2 Configure Two DataSources.md) + * [77.3 使用Spring Data仓库](IX. ‘How-to’ guides/77.3 Use Spring Data repositories.md) + * [77.4 从Spring配置分离@Entity定义](IX. ‘How-to’ guides/77.4 Separate @Entity definitions from Spring configuration.md) + * [77.5 配置JPA属性](IX. ‘How-to’ guides/77.5 Configure JPA properties.md) + * [77.6 配置Hibernate命名策略](IX. ‘How-to’ guides/77.6 Configure Hibernate Naming Strategy.md) + * [77.7 使用自定义EntityManagerFactory](IX. ‘How-to’ guides/77.7 Use a custom EntityManagerFactory.md) + * [77.8 使用两个EntityManagers](IX. ‘How-to’ guides/77.8 Use Two EntityManagers.md) + * [77.9 使用普通的persistence.xml](IX. ‘How-to’ guides/77.9 Use a traditional persistence.xml.md) + * [77.10 使用Spring Data JPA和Mongo仓库](IX. ‘How-to’ guides/77.10 Use Spring Data JPA and Mongo repositories.md) + * [77.11 将Spring Data仓库暴露为REST端点](IX. ‘How-to’ guides/77.11 Expose Spring Data repositories as REST endpoint.md) + * [77.12 配置JPA使用的组件](IX. ‘How-to’ guides/77.12 Configure a component that is used by JPA.md) + * [78. 数据库初始化](IX. ‘How-to’ guides/78. Database initialization.md) + * [78.1 使用JPA初始化数据库](IX. ‘How-to’ guides/78.1 Initialize a database using JPA.md) + * [78.2 使用Hibernate初始化数据库](IX. ‘How-to’ guides/78.2 Initialize a database using Hibernate.md) + * [78.3 使用Spring JDBC初始化数据库](IX. ‘How-to’ guides/78.3 Initialize a database using Spring JDBC.md) + * [78.4 初始化Spring Batch数据库](IX. ‘How-to’ guides/78.4 Initialize a Spring Batch database.md) + * [78.5 使用高级数据迁移工具](IX. ‘How-to’ guides/78.5 Use a higher level database migration tool.md) + * [78.5.1 启动时执行Flyway数据库迁移](IX. ‘How-to’ guides/78.5.1 Execute Flyway database migrations on startup.md) + * [78.5.2 启动时执行Liquibase数据库迁移](IX. ‘How-to’ guides/78.5.2 Execute Liquibase database migrations on startup.md) + * [79. 消息传送](IX. ‘How-to’ guides/79. Messaging.md) + * [79.1 禁用事务JMS会话](IX. ‘How-to’ guides/79.1 Disable transacted JMS session.md) + * [80. 批处理应用](IX. ‘How-to’ guides/80. Batch applications.md) + * [80.1 在启动时执行Spring Batch作业](IX. ‘How-to’ guides/80.1 Execute Spring Batch jobs on startup.md) + * [81. 执行器](IX. ‘How-to’ guides/81. Actuator.md) + * [81.1 改变HTTP端口或执行器端点的地址](IX. ‘How-to’ guides/81.1 Change the HTTP port or address of the actuator endpoints.md) + * [81.2 自定义WhiteLabel错误页面](IX. ‘How-to’ guides/81.2 Customize the ‘whitelabel’ error page.md) + * [81.3 Actuator和Jersey](IX. ‘How-to’ guides/81.3 Actuator and Jersey.md) + * [82. 安全](IX. ‘How-to’ guides/82. Security.md) + * [82.1 关闭Spring Boot安全配置](IX. ‘How-to’ guides/82.1 Switch off the Spring Boot security configuration.md) + * [82.2 改变AuthenticationManager并添加用户账号](IX. ‘How-to’ guides/82.2 Change the AuthenticationManager and add user accounts.md) + * [82.3 当前端使用代理服务器时启用HTTPS](IX. ‘How-to’ guides/82.3 Enable HTTPS when running behind a proxy server.md) + * [83. 热交换](IX. ‘How-to’ guides/83. Hot swapping.md) + * [83.1 重新加载静态内容](IX. ‘How-to’ guides/83.1 Reload static content.md) + * [83.2. 在不重启容器的情况下重新加载模板](IX. ‘How-to’ guides/83.2. Reload templates without restarting the container.md) + * [83.2.1 Thymeleaf模板](IX. ‘How-to’ guides/83.2.1 Thymeleaf templates.md) + * [83.2.2 FreeMarker模板](IX. ‘How-to’ guides/83.2.2 FreeMarker templates.md) + * [83.2.3 Groovy模板](IX. ‘How-to’ guides/83.2.3 Groovy templates.md) + * [83.3 应用快速重启](IX. ‘How-to’ guides/83.3 Fast application restarts.md) + * [83.4 在不重启容器的情况下重新加载Java类](IX. ‘How-to’ guides/83.4 Reload Java classes without restarting the container.md) + * [84. 构建](IX. ‘How-to’ guides/84. Build.md) + * [84.1 生成构建信息](IX. ‘How-to’ guides/84.1 Generate build information.md) + * [84.2 生成Git信息](IX. ‘How-to’ guides/84.2 Generate git information.md) + * [84.3 自定义依赖版本](IX. ‘How-to’ guides/84.3 Customize dependency versions.md) + * [84.4 使用Maven创建可执行JAR](IX. ‘How-to’ guides/84.4 Create an executable JAR with Maven.md) + * [84.5 将Spring Boot应用作为依赖](IX. ‘How-to’ guides/84.5 Use a Spring Boot application as a dependency.md) + * [84.6 在可执行jar运行时提取特定的版本](IX. ‘How-to’ guides/84.6 Extract specific libraries when an executable jar runs.md) + * [84.7 使用排除创建不可执行的JAR](IX. ‘How-to’ guides/84.7 Create a non-executable JAR with exclusions.md) + * [84.8 远程调试使用Maven启动的Spring Boot项目](IX. ‘How-to’ guides/84.8 Remote debug a Spring Boot application started with Maven.md) + * [84.9 使用Ant构建可执行存档(不使用spring-boot-antlib)](IX. ‘How-to’ guides/84.9 Build an executable archive from Ant without using spring-boot-antlib.md) + * [85. 传统部署](IX. ‘How-to’ guides/85. Traditional deployment.md) + * [85.1 创建可部署的war文件](IX. ‘How-to’ guides/85.1 Create a deployable war file.md) + * [85.2 为老的servlet容器创建可部署的war文件](IX. ‘How-to’ guides/85.2 Create a deployable war file for older servlet containers.md) + * [85.3 将现有的应用转换为Spring Boot](IX. ‘How-to’ guides/85.3 Convert an existing application to Spring Boot.md) + * [85.4 部署WAR到Weblogic](IX. ‘How-to’ guides/85.4 Deploying a WAR to Weblogic.md) + * [85.5 部署WAR到老的(Servlet2.5)容器](IX. ‘How-to’ guides/85.5 Deploying a WAR in an Old(Servlet 2.5)Container.md) + * [85.6 使用Lettuce来代替Jedis](IX. ‘How-to’ guides/85.6 Use Lettuce instead of Jedis.md) +* [X.附录](X. Appendices/README.md) + * [附录A. 常见应用属性](X. Appendices/A. Common application properties.md) + * [附录B. 配置元数据](X. Appendices/B. Configuration meta-data.md) + * [附录B.1. 元数据格式](X. Appendices/B.1. Meta-data format.md) + * [附录B.1.1. Group属性](X. Appendices/B.1.1. Group Attributes.md) + * [附录B.1.2. Property属性](X. Appendices/B.1.2. Property Attributes.md) + * [附录B.1.3. Hint属性](X. Appendices/B.1.3 Hint Attributes.md) + * [附录B.1.4. 可重复的元数据节点](X. Appendices/B.1.4. Repeated meta-data items.md) + * [附录B.2. 提供人工提示](X. Appendices/B.2 Providing manual hints.md) + * [附录 B.2.1 值提示](X. Appendices/B.2.1 Value hint.md) + * [附录 B.2.2 值提供者](X. Appendices/B.2.2 Value provider.md) + * [附录B.3. 使用注解处理器产生自己的元数据](X. Appendices/B.3. Generating your own meta-data using the annotation processor.md) + * [附录 B.3.1. 内嵌属性](X. Appendices/B.3.1. Nested properties.md) + * [附录 B.3.2. 添加其他的元数据](X. Appendices/B.3.2. Adding additional meta-data.md) + * [附录C. 自动配置类](X. Appendices/C. Auto-configuration classes.md) + * [附录 C.1. 来自spring-boot-autoconfigure模块](X. Appendices/C.1. From the “spring-boot-autoconfigure” module.md) + * [附录C.2. 来自spring-boot-actuator模块](X. Appendices/C.2. From the “spring-boot-actuator” module.md) + * [附录D. 测试自动配置的标注](X. Appendices/D. Test auto-configuration annotations.md) + * [附录E. 可执行jar格式](X. Appendices/E. The executable jar format.md) + * [附录E.1. 内嵌JARs](X. Appendices/E.1. Nested JARs.md) + * [附录E.1.1. 可执行jar文件结构](X. Appendices/E.1.1. The executable jar file structure.md) + * [附录E.1.2. 可执行war文件结构](X. Appendices/E.1.2. The executable war file structure.md) + * [附录E.2. Spring Boot的"JarFile"类](X. Appendices/E.2. Spring Boot’s “JarFile” class.md) + * [附录E.2.1. 对标准Java "JarFile"的兼容性](X. Appendices/E.2.1. Compatibility with the standard Java “JarFile”.md) + * [附录E.3. 启动可执行jars](X. Appendices/E.3. Launching executable jars.md) + * [附录E.3.1 Launcher manifest](X. Appendices/E.3.1. Launcher manifest.md) + * [附录E.3.2. 暴露的存档](X. Appendices/E.3.2. Exploded archives.md) + * [附录E.4. PropertiesLauncher特性](X. Appendices/E.4. PropertiesLauncher Features.md) + * [附录E.5. 可执行jar的限制](X. Appendices/E.5. Executable jar restrictions.md) + * [附录E.5.1. Zip实体压缩](X. Appendices/E.5.1. Zip entry compression.md) + * [附录E.5.2. 系统ClassLoader](X. Appendices/E.5.2. System ClassLoader.md) + * [附录E.6. 可替代的单一jar解决方案](X. Appendices/E.6. Alternative single jar solutions.md) + * [附录F. 依赖版本](X. Appendices/F. Dependency versions.md) From e00dcfc0b26c9d3cb0d49cae54369fef36fad9a4 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E7=83=AD=E5=BF=83=E5=B8=82=E6=B0=91=E9=92=9F=E5=B0=8F?= =?UTF-8?q?=E5=BC=BA?= Date: Sun, 22 Dec 2019 20:00:42 +0800 Subject: [PATCH 715/865] Update SUMMARY.md --- SUMMARY.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/SUMMARY.md b/SUMMARY.md index 53482c9e..e1c73d4c 100644 --- a/SUMMARY.md +++ b/SUMMARY.md @@ -482,7 +482,7 @@ * [75.9 配置访问日志](IX. ‘How-to’ guides/75.9 Configure Access Logging.md) * [75.10 在前端代理服务器后运行](IX. ‘How-to’ guides/75.10 Running Behind a Front-end Proxy Server.md) * [75.10.1 自定义Tomcat代理配置](IX. ‘How-to’ guides/75.10.1 Customize Tomcat’s Proxy Configuration.md) - * [73.8 配置Tomcat](IX. ‘How-to’ guides/73.8 Configure Tomcat.md) + * [75.11 配置Tomcat](IX. ‘How-to’ guides/75.11 Configure Tomcat.md) * [73.9 启用Tomcat的多连接器](IX. ‘How-to’ guides/73.9 Enable Multiple Connectors with Tomcat.md) * [73.10 使用Tomcat的LegacyCookieProcessor](IX. ‘How-to’ guides/73.10 Use Tomcat’s LegacyCookieProcessor.md) * [73.11 使用Jetty替代Tomcat](IX. ‘How-to’ guides/73.11 Use Jetty instead of Tomcat.md) From a2d1b28fde41f5a969d2e7becd197ce734d47c45 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E7=83=AD=E5=BF=83=E5=B8=82=E6=B0=91=E9=92=9F=E5=B0=8F?= =?UTF-8?q?=E5=BC=BA?= Date: Sun, 22 Dec 2019 20:11:30 +0800 Subject: [PATCH 716/865] Update and rename 73.8 Configure Tomcat.md to 75.11 Configure Tomcat.md --- .../73.8 Configure Tomcat.md" | 5 ----- .../75.11 Configure Tomcat.md" | 5 +++++ 2 files changed, 5 insertions(+), 5 deletions(-) delete mode 100644 "IX. \342\200\230How-to\342\200\231 guides/73.8 Configure Tomcat.md" create mode 100644 "IX. \342\200\230How-to\342\200\231 guides/75.11 Configure Tomcat.md" diff --git "a/IX. \342\200\230How-to\342\200\231 guides/73.8 Configure Tomcat.md" "b/IX. \342\200\230How-to\342\200\231 guides/73.8 Configure Tomcat.md" deleted file mode 100644 index 35fd2c66..00000000 --- "a/IX. \342\200\230How-to\342\200\231 guides/73.8 Configure Tomcat.md" +++ /dev/null @@ -1,5 +0,0 @@ -### 73.8 配置Tomcat - -通常你可以遵循[Section 72.8, “Discover built-in options for external properties”](./72.8 Discover built-in options for external properties.md)关于`@ConfigurationProperties`(这里主要的是`ServerProperties`)的建议,但也看下`ServletWebServerFactoryCustomizer`和各种你可以添加的Tomcat-specific的`*Customizers`。 - -Tomcat APIs相当丰富,一旦获取到`TomcatServletWebServerFactory`,你就能够以多种方式修改它,或更彻底地就是添加你自己的`TomcatServletWebServerFactory`。 diff --git "a/IX. \342\200\230How-to\342\200\231 guides/75.11 Configure Tomcat.md" "b/IX. \342\200\230How-to\342\200\231 guides/75.11 Configure Tomcat.md" new file mode 100644 index 00000000..3439eb03 --- /dev/null +++ "b/IX. \342\200\230How-to\342\200\231 guides/75.11 Configure Tomcat.md" @@ -0,0 +1,5 @@ +### 75.11 配置Tomcat + +通常你可以遵循[74.8 发现外部属性的内置选项](https://docs.spring.io/spring-boot/docs/2.0.0.RELEASE/reference/htmlsingle/#howto-discover-build-in-options-for-external-properties)关于`@ConfigurationProperties`(这里主要的是`ServerProperties`)的建议,但也看下`WebServerFactoryCustomizer`和各种你可以添加的Tomcat特定的`*Customizers`。 + +Tomcat APIs相当丰富,一旦获取到`TomcatServletWebServerFactory`,你就能够以多种方式修改它,或更彻底地就是添加你自己的`TomcatServletWebServerFactory`。 From 04cbfc83ec46a2627afa6f9e1360397b9b221fe9 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E7=83=AD=E5=BF=83=E5=B8=82=E6=B0=91=E9=92=9F=E5=B0=8F?= =?UTF-8?q?=E5=BC=BA?= Date: Mon, 23 Dec 2019 19:29:33 +0800 Subject: [PATCH 717/865] Update SUMMARY.md --- SUMMARY.md | 9 +++------ 1 file changed, 3 insertions(+), 6 deletions(-) diff --git a/SUMMARY.md b/SUMMARY.md index e1c73d4c..ae6faf3f 100644 --- a/SUMMARY.md +++ b/SUMMARY.md @@ -483,12 +483,9 @@ * [75.10 在前端代理服务器后运行](IX. ‘How-to’ guides/75.10 Running Behind a Front-end Proxy Server.md) * [75.10.1 自定义Tomcat代理配置](IX. ‘How-to’ guides/75.10.1 Customize Tomcat’s Proxy Configuration.md) * [75.11 配置Tomcat](IX. ‘How-to’ guides/75.11 Configure Tomcat.md) - * [73.9 启用Tomcat的多连接器](IX. ‘How-to’ guides/73.9 Enable Multiple Connectors with Tomcat.md) - * [73.10 使用Tomcat的LegacyCookieProcessor](IX. ‘How-to’ guides/73.10 Use Tomcat’s LegacyCookieProcessor.md) - * [73.11 使用Jetty替代Tomcat](IX. ‘How-to’ guides/73.11 Use Jetty instead of Tomcat.md) - * [73.12 配置Jetty](IX. ‘How-to’ guides/73.12 Configure Jetty.md) - * [73.13 使用Undertow替代Tomcat](IX. ‘How-to’ guides/73.13 Use Undertow instead of Tomcat.md) - * [73.14 配置Undertow](IX. ‘How-to’ guides/73.14 Configure Undertow.md) + * [75.12 启用Tomcat的多连接器](IX. ‘How-to’ guides/75.12 Enable Multiple Connectors with Tomcat.md) + * [75.13 使用Tomcat的LegacyCookieProcessor](IX. ‘How-to’ guides/75.13 Use Tomcat’s LegacyCookieProcessor.md) + * [75.14 配置Undertow](IX. ‘How-to’ guides/75.14 Configure Undertow.md) * [73.15 启用Undertow的多监听器](IX. ‘How-to’ guides/73.15 Enable Multiple Listeners with Undertow.md) * [73.16 使用@ServerEndpoint创建WebSocket端点](IX. ‘How-to’ guides/73.16 Create WebSocket endpoints using @ServerEndpoint.md) * [73.17 启用HTTP响应压缩](IX. ‘How-to’ guides/73.17 Enable HTTP response compression.md) From e5029828b9ef574aecdd458899cfb5770de38b5a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E7=83=AD=E5=BF=83=E5=B8=82=E6=B0=91=E9=92=9F=E5=B0=8F?= =?UTF-8?q?=E5=BC=BA?= Date: Mon, 23 Dec 2019 19:31:33 +0800 Subject: [PATCH 718/865] Delete 73.11 Use Jetty instead of Tomcat.md --- .../73.11 Use Jetty instead of Tomcat.md" | 33 ------------------- 1 file changed, 33 deletions(-) delete mode 100644 "IX. \342\200\230How-to\342\200\231 guides/73.11 Use Jetty instead of Tomcat.md" diff --git "a/IX. \342\200\230How-to\342\200\231 guides/73.11 Use Jetty instead of Tomcat.md" "b/IX. \342\200\230How-to\342\200\231 guides/73.11 Use Jetty instead of Tomcat.md" deleted file mode 100644 index e794e25d..00000000 --- "a/IX. \342\200\230How-to\342\200\231 guides/73.11 Use Jetty instead of Tomcat.md" +++ /dev/null @@ -1,33 +0,0 @@ -### 73.11 使用Jetty替代Tomcat - -Spring Boot starters(特别是`spring-boot-starter-web`)默认都使用Tomcat作为内嵌容器。想使用Jetty替代Tomcat,你需要排除那些Tomcat的依赖并包含Jetty的依赖。为了简化这种事情的处理,Spring Boot将Tomcat和Jetty的依赖捆绑在一起,然后提供了单独的starters。 - -Maven示例: -```xml - - org.springframework.boot - spring-boot-starter-web - - - org.springframework.boot - spring-boot-starter-tomcat - - - - - org.springframework.boot - spring-boot-starter-jetty - -``` -Gradle示例: -```gradle -configurations { - compile.exclude module: 'spring-boot-starter-tomcat' -} - -dependencies { - compile 'org.springframework.boot:spring-boot-starter-web' - compile 'org.springframework.boot:spring-boot-starter-jetty' - // ... -} -``` From 6311fe9b20105fa9493536d5834b2c3e1123bd10 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E7=83=AD=E5=BF=83=E5=B8=82=E6=B0=91=E9=92=9F=E5=B0=8F?= =?UTF-8?q?=E5=BC=BA?= Date: Mon, 23 Dec 2019 19:31:56 +0800 Subject: [PATCH 719/865] Delete 73.12 Configure Jetty.md --- .../73.12 Configure Jetty.md" | 3 --- 1 file changed, 3 deletions(-) delete mode 100644 "IX. \342\200\230How-to\342\200\231 guides/73.12 Configure Jetty.md" diff --git "a/IX. \342\200\230How-to\342\200\231 guides/73.12 Configure Jetty.md" "b/IX. \342\200\230How-to\342\200\231 guides/73.12 Configure Jetty.md" deleted file mode 100644 index f83b389b..00000000 --- "a/IX. \342\200\230How-to\342\200\231 guides/73.12 Configure Jetty.md" +++ /dev/null @@ -1,3 +0,0 @@ -### 73.12 配置Jetty - -通常你可以遵循[Section 72.8, “Discover built-in options for external properties”](./72.8 Discover built-in options for external properties.md)关于`@ConfigurationProperties`(此处主要是`ServerProperties`)的建议,但也要看下`ServletWebServerFactoryCustomizer`。Jetty API相当丰富,一旦获取到`JettyServletWebServerFactory`,你就可以使用很多方式修改它,或更彻底地就是添加你自己的`JettyServletWebServerFactory`。 From fcfb44819394e4d9e32a9605ac3f0200723d80cd Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E7=83=AD=E5=BF=83=E5=B8=82=E6=B0=91=E9=92=9F=E5=B0=8F?= =?UTF-8?q?=E5=BC=BA?= Date: Mon, 23 Dec 2019 19:32:18 +0800 Subject: [PATCH 720/865] Delete 73.13 Use Undertow instead of Tomcat.md --- .../73.13 Use Undertow instead of Tomcat.md" | 33 ------------------- 1 file changed, 33 deletions(-) delete mode 100644 "IX. \342\200\230How-to\342\200\231 guides/73.13 Use Undertow instead of Tomcat.md" diff --git "a/IX. \342\200\230How-to\342\200\231 guides/73.13 Use Undertow instead of Tomcat.md" "b/IX. \342\200\230How-to\342\200\231 guides/73.13 Use Undertow instead of Tomcat.md" deleted file mode 100644 index 27435708..00000000 --- "a/IX. \342\200\230How-to\342\200\231 guides/73.13 Use Undertow instead of Tomcat.md" +++ /dev/null @@ -1,33 +0,0 @@ -### 73.13 使用Undertow替代Tomcat - -使用Undertow替代Tomcat和[使用Jetty替代Tomcat](./70.11 Use Jetty instead of Tomcat.md)非常类似。你需要排除Tomat依赖,并包含Undertow starter。 - -Maven示例: -```xml - - org.springframework.boot - spring-boot-starter-web - - - org.springframework.boot - spring-boot-starter-tomcat - - - - - org.springframework.boot - spring-boot-starter-undertow - -``` -Gradle示例: -```gradle -configurations { - compile.exclude module: 'spring-boot-starter-tomcat' -} - -dependencies { - compile 'org.springframework.boot:spring-boot-starter-web' - compile 'org.springframework.boot:spring-boot-starter-undertow' - // ... -} -``` From 3a8e0f50ef5561a6bd8a522bb60e16be25b3b087 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E7=83=AD=E5=BF=83=E5=B8=82=E6=B0=91=E9=92=9F=E5=B0=8F?= =?UTF-8?q?=E5=BC=BA?= Date: Mon, 23 Dec 2019 19:36:29 +0800 Subject: [PATCH 721/865] Update and rename 73.9 Enable Multiple Connectors with Tomcat.md to 75.12 Enable Multiple Connectors with Tomcat.md --- .../75.12 Enable Multiple Connectors with Tomcat.md" | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) rename "IX. \342\200\230How-to\342\200\231 guides/73.9 Enable Multiple Connectors with Tomcat.md" => "IX. \342\200\230How-to\342\200\231 guides/75.12 Enable Multiple Connectors with Tomcat.md" (95%) diff --git "a/IX. \342\200\230How-to\342\200\231 guides/73.9 Enable Multiple Connectors with Tomcat.md" "b/IX. \342\200\230How-to\342\200\231 guides/75.12 Enable Multiple Connectors with Tomcat.md" similarity index 95% rename from "IX. \342\200\230How-to\342\200\231 guides/73.9 Enable Multiple Connectors with Tomcat.md" rename to "IX. \342\200\230How-to\342\200\231 guides/75.12 Enable Multiple Connectors with Tomcat.md" index a48b6e79..0951a023 100644 --- "a/IX. \342\200\230How-to\342\200\231 guides/73.9 Enable Multiple Connectors with Tomcat.md" +++ "b/IX. \342\200\230How-to\342\200\231 guides/75.12 Enable Multiple Connectors with Tomcat.md" @@ -1,4 +1,4 @@ -### 73.9 启用Tomcat的多连接器 +### 75.12 启用Tomcat的多连接器 你可以将`org.apache.catalina.connector.Connector`添加到`TomcatServletWebServerFactory`,这就能够允许多连接器,比如HTTP和HTTPS连接器: ```java From 515095c9b76ff242b8d384d8143d803fbe5bd3d4 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E7=83=AD=E5=BF=83=E5=B8=82=E6=B0=91=E9=92=9F=E5=B0=8F?= =?UTF-8?q?=E5=BC=BA?= Date: Mon, 23 Dec 2019 19:39:23 +0800 Subject: [PATCH 722/865] =?UTF-8?q?Update=20and=20rename=2073.10=20Use=20T?= =?UTF-8?q?omcat=E2=80=99s=20LegacyCookieProcessor.md=20to=2075.13=20Use?= =?UTF-8?q?=20Tomcat=E2=80=99s=20LegacyCookieProcessor.md?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- ...e Tomcat\342\200\231s LegacyCookieProcessor.md" | 14 -------------- ...e Tomcat\342\200\231s LegacyCookieProcessor.md" | 14 ++++++++++++++ 2 files changed, 14 insertions(+), 14 deletions(-) delete mode 100644 "IX. \342\200\230How-to\342\200\231 guides/73.10 Use Tomcat\342\200\231s LegacyCookieProcessor.md" create mode 100644 "IX. \342\200\230How-to\342\200\231 guides/75.13 Use Tomcat\342\200\231s LegacyCookieProcessor.md" diff --git "a/IX. \342\200\230How-to\342\200\231 guides/73.10 Use Tomcat\342\200\231s LegacyCookieProcessor.md" "b/IX. \342\200\230How-to\342\200\231 guides/73.10 Use Tomcat\342\200\231s LegacyCookieProcessor.md" deleted file mode 100644 index 622431f1..00000000 --- "a/IX. \342\200\230How-to\342\200\231 guides/73.10 Use Tomcat\342\200\231s LegacyCookieProcessor.md" +++ /dev/null @@ -1,14 +0,0 @@ -###73.10 使用Tomcat的LegacyCookieProcessor - -Spring Boot使用的内嵌Tomcat不能开箱即用的支持`Version 0`的Cookie格式,你可能会看到以下错误: -```java -java.lang.IllegalArgumentException: An invalid character [32] was present in the Cookie value -``` -可以的话,你需要考虑将代码升级到只存储遵从最新版Cookie定义的值。如果不能改变写入的cookie,你可以配置Tomcat使用`LegacyCookieProcessor`。通过向`ServletWebServerFactoryCustomizer`bean添加一个`TomcatContextCustomizer`可以开启`LegacyCookieProcessor`: -```java -@Bean -public WebServerFactoryCustomizer cookieProcessorCustomizer() { - return (serverFactory) -> serverFactory.addContextCustomizers( - (context) -> context.setCookieProcessor(new LegacyCookieProcessor())); -} -``` diff --git "a/IX. \342\200\230How-to\342\200\231 guides/75.13 Use Tomcat\342\200\231s LegacyCookieProcessor.md" "b/IX. \342\200\230How-to\342\200\231 guides/75.13 Use Tomcat\342\200\231s LegacyCookieProcessor.md" new file mode 100644 index 00000000..411c814f --- /dev/null +++ "b/IX. \342\200\230How-to\342\200\231 guides/75.13 Use Tomcat\342\200\231s LegacyCookieProcessor.md" @@ -0,0 +1,14 @@ +### 75.13 使用Tomcat的LegacyCookieProcessor + +默认的,Spring Boot使用的内嵌Tomcat不能支持`Version 0`的Cookie格式,你可能会看到以下错误: +```java +java.lang.IllegalArgumentException: An invalid character [32] was present in the Cookie value +``` +可以的话,你需要考虑将代码升级到只存储遵从最新版Cookie定义的值。如果不能改变写入的cookie,你可以配置Tomcat使用`LegacyCookieProcessor`。通过向`WebServerFactoryCustomizer`bean添加一个`TomcatContextCustomizer`可以开启`LegacyCookieProcessor`: +```java +@Bean +public WebServerFactoryCustomizer cookieProcessorCustomizer() { + return (factory) -> factory.addContextCustomizers( + (context) -> context.setCookieProcessor(new LegacyCookieProcessor())); +} +``` From e42fbc5f7a767f02000e17d1f4f51e41d422e9d8 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E7=83=AD=E5=BF=83=E5=B8=82=E6=B0=91=E9=92=9F=E5=B0=8F?= =?UTF-8?q?=E5=BC=BA?= Date: Mon, 23 Dec 2019 19:46:49 +0800 Subject: [PATCH 723/865] Update and rename 73.14 Configure Undertow.md to 75.14 Configure Undertow.md --- .../73.14 Configure Undertow.md" | 3 --- .../75.14 Configure Undertow.md" | 3 +++ 2 files changed, 3 insertions(+), 3 deletions(-) delete mode 100644 "IX. \342\200\230How-to\342\200\231 guides/73.14 Configure Undertow.md" create mode 100644 "IX. \342\200\230How-to\342\200\231 guides/75.14 Configure Undertow.md" diff --git "a/IX. \342\200\230How-to\342\200\231 guides/73.14 Configure Undertow.md" "b/IX. \342\200\230How-to\342\200\231 guides/73.14 Configure Undertow.md" deleted file mode 100644 index ba99fbe5..00000000 --- "a/IX. \342\200\230How-to\342\200\231 guides/73.14 Configure Undertow.md" +++ /dev/null @@ -1,3 +0,0 @@ -### 73.14 配置Undertow - -通常你可以遵循[Section 72.8, “Discover built-in options for external properties”](./72.8 Discover built-in options for external properties.md)关于`@ConfigurationProperties`(此处主要是`ServerProperties`和`ServerProperties.Undertow`),但也要看下`ServletWebServerFactoryCustomizer`。一旦获取到`UndertowServletWebServerFactory`,你就可以使用`UndertowBuilderCustomizer`修改Undertow的配置以满足你的需求,或更彻底地就是添加你自己的`UndertowServletWebServerFactory`。 diff --git "a/IX. \342\200\230How-to\342\200\231 guides/75.14 Configure Undertow.md" "b/IX. \342\200\230How-to\342\200\231 guides/75.14 Configure Undertow.md" new file mode 100644 index 00000000..67e653d5 --- /dev/null +++ "b/IX. \342\200\230How-to\342\200\231 guides/75.14 Configure Undertow.md" @@ -0,0 +1,3 @@ +### 75.14 配置Undertow + +通常你可以遵循[74.8 发现外部属性的内置选项](https://docs.spring.io/spring-boot/docs/2.0.0.RELEASE/reference/htmlsingle/#howto-discover-build-in-options-for-external-properties)关于`@ConfigurationProperties`(此处主要是`ServerProperties`和`ServerProperties.Undertow`),但也要看下`WebServerFactoryCustomizer`。一旦获取到`UndertowServletWebServerFactory`,你就可以使用`UndertowBuilderCustomizer`修改Undertow的配置以满足你的需求,或更彻底地就是添加你自己的`UndertowServletWebServerFactory`。 From 000009a256ba45c26e72d03009e9070f62c3de69 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E7=83=AD=E5=BF=83=E5=B8=82=E6=B0=91=E9=92=9F=E5=B0=8F?= =?UTF-8?q?=E5=BC=BA?= Date: Mon, 13 Jan 2020 12:24:09 +0800 Subject: [PATCH 724/865] Update SUMMARY.md --- SUMMARY.md | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/SUMMARY.md b/SUMMARY.md index ae6faf3f..0456c59e 100644 --- a/SUMMARY.md +++ b/SUMMARY.md @@ -486,9 +486,9 @@ * [75.12 启用Tomcat的多连接器](IX. ‘How-to’ guides/75.12 Enable Multiple Connectors with Tomcat.md) * [75.13 使用Tomcat的LegacyCookieProcessor](IX. ‘How-to’ guides/75.13 Use Tomcat’s LegacyCookieProcessor.md) * [75.14 配置Undertow](IX. ‘How-to’ guides/75.14 Configure Undertow.md) - * [73.15 启用Undertow的多监听器](IX. ‘How-to’ guides/73.15 Enable Multiple Listeners with Undertow.md) - * [73.16 使用@ServerEndpoint创建WebSocket端点](IX. ‘How-to’ guides/73.16 Create WebSocket endpoints using @ServerEndpoint.md) - * [73.17 启用HTTP响应压缩](IX. ‘How-to’ guides/73.17 Enable HTTP response compression.md) + * [75.15 启用Undertow的多监听器](IX. ‘How-to’ guides/75.15 Enable Multiple Listeners with Undertow.md) + * [75.16 使用@ServerEndpoint创建WebSocket端点](IX. ‘How-to’ guides/75.16 Create WebSocket Endpoints Using @ServerEndpoint.md) + * [75.17 启用HTTP响应压缩](IX. ‘How-to’ guides/75.17 Enable HTTP Response Compression.md) * [74. Spring MVC](IX. ‘How-to’ guides/74. Spring MVC.md) * [74.1 编写JSON REST服务](IX. ‘How-to’ guides/74.1 Write a JSON REST service.md) * [74.2 编写XML REST服务](IX. ‘How-to’ guides/74.2 Write an XML REST service.md) From f869d546c8dbc0b3132f3977686d53d55476b39b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E7=83=AD=E5=BF=83=E5=B8=82=E6=B0=91=E9=92=9F=E5=B0=8F?= =?UTF-8?q?=E5=BC=BA?= Date: Mon, 13 Jan 2020 12:27:26 +0800 Subject: [PATCH 725/865] Update and rename 73.15 Enable Multiple Listeners with Undertow.md to 75.15 Enable Multiple Listeners with Undertow.md --- .../75.15 Enable Multiple Listeners with Undertow.md" | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) rename "IX. \342\200\230How-to\342\200\231 guides/73.15 Enable Multiple Listeners with Undertow.md" => "IX. \342\200\230How-to\342\200\231 guides/75.15 Enable Multiple Listeners with Undertow.md" (90%) diff --git "a/IX. \342\200\230How-to\342\200\231 guides/73.15 Enable Multiple Listeners with Undertow.md" "b/IX. \342\200\230How-to\342\200\231 guides/75.15 Enable Multiple Listeners with Undertow.md" similarity index 90% rename from "IX. \342\200\230How-to\342\200\231 guides/73.15 Enable Multiple Listeners with Undertow.md" rename to "IX. \342\200\230How-to\342\200\231 guides/75.15 Enable Multiple Listeners with Undertow.md" index a2ccfaad..8ee7168c 100644 --- "a/IX. \342\200\230How-to\342\200\231 guides/73.15 Enable Multiple Listeners with Undertow.md" +++ "b/IX. \342\200\230How-to\342\200\231 guides/75.15 Enable Multiple Listeners with Undertow.md" @@ -1,4 +1,4 @@ -### 73.15 启用Undertow的多监听器 +### 75.15 启用Undertow的多监听器 将`UndertowBuilderCustomizer`添加到`UndertowServletWebServerFactory`,然后使用`Builder`添加一个listener: ```java From f678b79611ad0364ea4c721b0d41d07f1328611e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E7=83=AD=E5=BF=83=E5=B8=82=E6=B0=91=E9=92=9F=E5=B0=8F?= =?UTF-8?q?=E5=BC=BA?= Date: Mon, 13 Jan 2020 12:28:52 +0800 Subject: [PATCH 726/865] Update and rename 73.16 Create WebSocket endpoints using @ServerEndpoint.md to 75.16 Create WebSocket Endpoints Using @ServerEndpoint.md --- .../75.16 Create WebSocket Endpoints Using @ServerEndpoint.md" | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) rename "IX. \342\200\230How-to\342\200\231 guides/73.16 Create WebSocket endpoints using @ServerEndpoint.md" => "IX. \342\200\230How-to\342\200\231 guides/75.16 Create WebSocket Endpoints Using @ServerEndpoint.md" (88%) diff --git "a/IX. \342\200\230How-to\342\200\231 guides/73.16 Create WebSocket endpoints using @ServerEndpoint.md" "b/IX. \342\200\230How-to\342\200\231 guides/75.16 Create WebSocket Endpoints Using @ServerEndpoint.md" similarity index 88% rename from "IX. \342\200\230How-to\342\200\231 guides/73.16 Create WebSocket endpoints using @ServerEndpoint.md" rename to "IX. \342\200\230How-to\342\200\231 guides/75.16 Create WebSocket Endpoints Using @ServerEndpoint.md" index 5551cdef..58f13d01 100644 --- "a/IX. \342\200\230How-to\342\200\231 guides/73.16 Create WebSocket endpoints using @ServerEndpoint.md" +++ "b/IX. \342\200\230How-to\342\200\231 guides/75.16 Create WebSocket Endpoints Using @ServerEndpoint.md" @@ -1,4 +1,4 @@ -### 73.16 使用@ServerEndpoint创建WebSocket端点 +### 75.16 使用@ServerEndpoint创建WebSocket端点 如果想在使用内嵌容器的Spring Boot应用中使用`@ServerEndpoint`,你需要声明一个单独的`ServerEndpointExporter` `@Bean`: ```java From 629a79bf28bb99ac9d1664f132bf0475361db818 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E7=83=AD=E5=BF=83=E5=B8=82=E6=B0=91=E9=92=9F=E5=B0=8F?= =?UTF-8?q?=E5=BC=BA?= Date: Mon, 13 Jan 2020 12:30:47 +0800 Subject: [PATCH 727/865] Update and rename 73.17 Enable HTTP response compression.md to 75.17 Enable HTTP Response Compression.md --- .../75.17 Enable HTTP Response Compression.md" | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) rename "IX. \342\200\230How-to\342\200\231 guides/73.17 Enable HTTP response compression.md" => "IX. \342\200\230How-to\342\200\231 guides/75.17 Enable HTTP Response Compression.md" (91%) diff --git "a/IX. \342\200\230How-to\342\200\231 guides/73.17 Enable HTTP response compression.md" "b/IX. \342\200\230How-to\342\200\231 guides/75.17 Enable HTTP Response Compression.md" similarity index 91% rename from "IX. \342\200\230How-to\342\200\231 guides/73.17 Enable HTTP response compression.md" rename to "IX. \342\200\230How-to\342\200\231 guides/75.17 Enable HTTP Response Compression.md" index 4942d038..79252801 100644 --- "a/IX. \342\200\230How-to\342\200\231 guides/73.17 Enable HTTP response compression.md" +++ "b/IX. \342\200\230How-to\342\200\231 guides/75.17 Enable HTTP Response Compression.md" @@ -1,4 +1,4 @@ -### 73.17 启用HTTP响应压缩 +### 75.17 启用HTTP响应压缩 Jetty,Tomcat和Undertow支持HTTP响应压缩,你可以通过设置`server.compression.enabled`启用它: ```properties From 1df57ff3ad139e5e1c4c733b1a75aa940e591af6 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E7=83=AD=E5=BF=83=E5=B8=82=E6=B0=91=E9=92=9F=E5=B0=8F?= =?UTF-8?q?=E5=BC=BA?= Date: Tue, 14 Jan 2020 18:09:58 +0800 Subject: [PATCH 728/865] Update SUMMARY.md --- SUMMARY.md | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/SUMMARY.md b/SUMMARY.md index 0456c59e..0a4126f7 100644 --- a/SUMMARY.md +++ b/SUMMARY.md @@ -489,15 +489,15 @@ * [75.15 启用Undertow的多监听器](IX. ‘How-to’ guides/75.15 Enable Multiple Listeners with Undertow.md) * [75.16 使用@ServerEndpoint创建WebSocket端点](IX. ‘How-to’ guides/75.16 Create WebSocket Endpoints Using @ServerEndpoint.md) * [75.17 启用HTTP响应压缩](IX. ‘How-to’ guides/75.17 Enable HTTP Response Compression.md) - * [74. Spring MVC](IX. ‘How-to’ guides/74. Spring MVC.md) - * [74.1 编写JSON REST服务](IX. ‘How-to’ guides/74.1 Write a JSON REST service.md) - * [74.2 编写XML REST服务](IX. ‘How-to’ guides/74.2 Write an XML REST service.md) - * [74.3 自定义Jackson ObjectMapper](IX. ‘How-to’ guides/74.3 Customize the Jackson ObjectMapper.md) - * [74.4 自定义@ResponseBody渲染](IX. ‘How-to’ guides/74.4 Customize the @ResponseBody rendering.md) - * [74.5 处理Multipart文件上传](IX. ‘How-to’ guides/74.5 Handling Multipart File Uploads.md) - * [74.6 关闭Spring MVC DispatcherServlet](IX. ‘How-to’ guides/74.6 Switch off the Spring MVC DispatcherServlet.md) - * [74.7 关闭默认的MVC配置](IX. ‘How-to’ guides/74.7 Switch off the Default MVC configuration.md) - * [74.8 自定义ViewResolvers](IX. ‘How-to’ guides/74.8 Customize ViewResolvers.md) + * [76. Spring MVC](IX. ‘How-to’ guides/76. Spring MVC.md) + * [76.1 编写JSON REST服务](IX. ‘How-to’ guides/76.1 Write a JSON REST Service.md) + * [76.2 编写XML REST服务](IX. ‘How-to’ guides/76.2 Write an XML REST Service.md) + * [76.3 自定义Jackson ObjectMapper](IX. ‘How-to’ guides/76.3 Customize the Jackson ObjectMapper.md) + * [76.4 自定义@ResponseBody渲染](IX. ‘How-to’ guides/76.4 Customize the @ResponseBody Rendering.md) + * [76.5 处理Multipart文件上传](IX. ‘How-to’ guides/76.5 Handling Multipart File Uploads.md) + * [76.6 关闭Spring MVC DispatcherServlet](IX. ‘How-to’ guides/76.6 Switch Off the Spring MVC DispatcherServlet.md) + * [76.7 关闭默认的MVC配置](IX. ‘How-to’ guides/76.7 Switch off the Default MVC Configuration.md) + * [76.8 自定义ViewResolvers](IX. ‘How-to’ guides/76.8 Customize ViewResolvers.md) * [75. HTTP客户端](IX. ‘How-to’ guides/75. HTTP clients.md) * [75.1 配置RestTemplate使用代理](IX. ‘How-to’ guides/75.1 Configure RestTemplate to use a proxy.md) * [76. 日志](IX. ‘How-to’ guides/76. Logging.md) From 55347673c5133f3be9584e8140dbd344a51fb280 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E7=83=AD=E5=BF=83=E5=B8=82=E6=B0=91=E9=92=9F=E5=B0=8F?= =?UTF-8?q?=E5=BC=BA?= Date: Tue, 14 Jan 2020 18:12:31 +0800 Subject: [PATCH 729/865] Update and rename 74. Spring MVC.md to 76. Spring MVC.md --- "IX. \342\200\230How-to\342\200\231 guides/74. Spring MVC.md" | 1 - "IX. \342\200\230How-to\342\200\231 guides/76. Spring MVC.md" | 3 +++ 2 files changed, 3 insertions(+), 1 deletion(-) delete mode 100644 "IX. \342\200\230How-to\342\200\231 guides/74. Spring MVC.md" create mode 100644 "IX. \342\200\230How-to\342\200\231 guides/76. Spring MVC.md" diff --git "a/IX. \342\200\230How-to\342\200\231 guides/74. Spring MVC.md" "b/IX. \342\200\230How-to\342\200\231 guides/74. Spring MVC.md" deleted file mode 100644 index 4ca17beb..00000000 --- "a/IX. \342\200\230How-to\342\200\231 guides/74. Spring MVC.md" +++ /dev/null @@ -1 +0,0 @@ -### 74. Spring MVC diff --git "a/IX. \342\200\230How-to\342\200\231 guides/76. Spring MVC.md" "b/IX. \342\200\230How-to\342\200\231 guides/76. Spring MVC.md" new file mode 100644 index 00000000..b03d0e94 --- /dev/null +++ "b/IX. \342\200\230How-to\342\200\231 guides/76. Spring MVC.md" @@ -0,0 +1,3 @@ +### 76. Spring MVC + +Spring Boot有许多starter,包括Spring MVC。注意,一些starter包含了对Spring MVC的依赖,而不是直接包含它。本节回答有关Spring MVC和Spring Boot的常见问题。 From 10093a07e4dcd0cdc1027fc0c900437d7c833b8c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E7=83=AD=E5=BF=83=E5=B8=82=E6=B0=91=E9=92=9F=E5=B0=8F?= =?UTF-8?q?=E5=BC=BA?= Date: Tue, 14 Jan 2020 18:14:54 +0800 Subject: [PATCH 730/865] Update and rename 74.1 Write a JSON REST service.md to 76.1 Write a JSON REST Service.md --- .../76.1 Write a JSON REST Service.md" | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) rename "IX. \342\200\230How-to\342\200\231 guides/74.1 Write a JSON REST service.md" => "IX. \342\200\230How-to\342\200\231 guides/76.1 Write a JSON REST Service.md" (92%) diff --git "a/IX. \342\200\230How-to\342\200\231 guides/74.1 Write a JSON REST service.md" "b/IX. \342\200\230How-to\342\200\231 guides/76.1 Write a JSON REST Service.md" similarity index 92% rename from "IX. \342\200\230How-to\342\200\231 guides/74.1 Write a JSON REST service.md" rename to "IX. \342\200\230How-to\342\200\231 guides/76.1 Write a JSON REST Service.md" index 1ada940b..9e76abd5 100644 --- "a/IX. \342\200\230How-to\342\200\231 guides/74.1 Write a JSON REST service.md" +++ "b/IX. \342\200\230How-to\342\200\231 guides/76.1 Write a JSON REST Service.md" @@ -1,4 +1,4 @@ -### 74.1 编写JSON REST服务 +### 76.1 编写JSON REST服务 只要添加的有Jackson2依赖,Spring Boot应用中的任何`@RestController`默认都会渲染为JSON响应,例如: ```java From 2510a4c09bb91df16cea58f40982f76b5a7826a9 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E7=83=AD=E5=BF=83=E5=B8=82=E6=B0=91=E9=92=9F=E5=B0=8F?= =?UTF-8?q?=E5=BC=BA?= Date: Tue, 14 Jan 2020 18:18:17 +0800 Subject: [PATCH 731/865] Update and rename 74.2 Write an XML REST service.md to 76.2 Write an XML REST Service.md --- .../76.2 Write an XML REST Service.md" | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) rename "IX. \342\200\230How-to\342\200\231 guides/74.2 Write an XML REST service.md" => "IX. \342\200\230How-to\342\200\231 guides/76.2 Write an XML REST Service.md" (86%) diff --git "a/IX. \342\200\230How-to\342\200\231 guides/74.2 Write an XML REST service.md" "b/IX. \342\200\230How-to\342\200\231 guides/76.2 Write an XML REST Service.md" similarity index 86% rename from "IX. \342\200\230How-to\342\200\231 guides/74.2 Write an XML REST service.md" rename to "IX. \342\200\230How-to\342\200\231 guides/76.2 Write an XML REST Service.md" index d660616b..40d33034 100644 --- "a/IX. \342\200\230How-to\342\200\231 guides/74.2 Write an XML REST service.md" +++ "b/IX. \342\200\230How-to\342\200\231 guides/76.2 Write an XML REST Service.md" @@ -1,6 +1,6 @@ -### 74.2 编写XML REST服务 +### 76.2 编写XML REST服务 -如果classpath下存在Jackson XML扩展(`jackson-dataformat-xml`),它会被用来渲染XML响应,示例和JSON的非常相似。想要使用它,只需为你的项目添加以下依赖: +如果classpath下存在Jackson XML扩展(`jackson-dataformat-xml`),它会被用来渲染XML响应,示例和JSON的非常相似。想要使用Jackson XML渲染器,只需为你的项目添加以下依赖: ```xml com.fasterxml.jackson.dataformat From 1988965b34357d76692fa46d1a8872db32386c56 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E7=83=AD=E5=BF=83=E5=B8=82=E6=B0=91=E9=92=9F=E5=B0=8F?= =?UTF-8?q?=E5=BC=BA?= Date: Tue, 14 Jan 2020 18:32:11 +0800 Subject: [PATCH 732/865] Update and rename 74.3 Customize the Jackson ObjectMapper.md to 76.3 Customize the Jackson ObjectMapper.md --- .../76.3 Customize the Jackson ObjectMapper.md" | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) rename "IX. \342\200\230How-to\342\200\231 guides/74.3 Customize the Jackson ObjectMapper.md" => "IX. \342\200\230How-to\342\200\231 guides/76.3 Customize the Jackson ObjectMapper.md" (75%) diff --git "a/IX. \342\200\230How-to\342\200\231 guides/74.3 Customize the Jackson ObjectMapper.md" "b/IX. \342\200\230How-to\342\200\231 guides/76.3 Customize the Jackson ObjectMapper.md" similarity index 75% rename from "IX. \342\200\230How-to\342\200\231 guides/74.3 Customize the Jackson ObjectMapper.md" rename to "IX. \342\200\230How-to\342\200\231 guides/76.3 Customize the Jackson ObjectMapper.md" index c56c36c9..f4de4ba4 100644 --- "a/IX. \342\200\230How-to\342\200\231 guides/74.3 Customize the Jackson ObjectMapper.md" +++ "b/IX. \342\200\230How-to\342\200\231 guides/76.3 Customize the Jackson ObjectMapper.md" @@ -1,4 +1,4 @@ -### 74.3 自定义Jackson ObjectMapper +### 76.3 自定义Jackson ObjectMapper 在一个HTTP交互中,Spring MVC(客户端和服务端)使用`HttpMessageConverters`协商内容转换。如果classpath下存在Jackson,你就获取到`Jackson2ObjectMapperBuilder`提供的默认转换器,这是Spring Boot为你自动配置的实例。 @@ -6,6 +6,7 @@ - `MapperFeature.DEFAULT_VIEW_INCLUSION`,默认是禁用的 - `DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES`,默认是禁用的 +- `SerializationFeature.WRITE_DATES_AS_TIMESTAMPS`,默认是禁用的 Spring Boot也有一些用于简化自定义该行为的特性。 @@ -20,14 +21,14 @@ Spring Boot也有一些用于简化自定义该行为的特性。 |`com.fasterxml.jackson.databind.SerializationFeature`|`spring.jackson.serialization.=true|false`| |`com.fasterxml.jackson.annotation.JsonInclude.Include`|`spring.jackson.serialization-inclusion=always|non_null|non_absent|non_default|non_empty`| -例如,设置`spring.jackson.serialization.indent_output=true`可以美化打印输出(pretty print)。注意,由于[松散绑定](../IV. Spring Boot features/24.7.2. Relaxed binding.md)的使用,`indent_output`不必匹配对应的枚举常量`INDENT_OUTPUT`。 +例如,设置`spring.jackson.serialization.indent_output=true`可以美化打印输出(pretty print)。注意,由于[松散绑定](https://docs.spring.io/spring-boot/docs/2.0.0.RELEASE/reference/htmlsingle/#boot-features-external-config-relaxed-binding)的使用,`indent_output`不必匹配对应的枚举常量`INDENT_OUTPUT`。 基于environment的配置会应用到自动配置的`Jackson2ObjectMapperBuilder` bean,然后应用到通过该builder创建的mappers,包括自动配置的`ObjectMapper` bean。 -`ApplicationContext`中的`Jackson2ObjectMapperBuilder`可以通过`Jackson2ObjectMapperBuilderCustomizer` bean自定义。这些customizer beans可以排序,Spring Boot自己的customizer序号为0,其他自定义可以应用到Spring Boot自定义之前或之后。 +`ApplicationContext`中的`Jackson2ObjectMapperBuilder`可以通过`Jackson2ObjectMapperBuilderCustomizer` bean自定义。这些customizer beans可以排序(Spring Boot自己的customizer序号为0)。其他自定义可以应用到Spring Boot自定义之前或之后。 所有类型为`com.fasterxml.jackson.databind.Module`的beans都会自动注册到自动配置的`Jackson2ObjectMapperBuilder`,并应用到它创建的任何`ObjectMapper`实例。这提供了一种全局机制,用于在为应用添加新特性时贡献自定义模块。 如果想完全替换默认的`ObjectMapper`,你既可以定义该类型的`@Bean`并注解`@Primary`,也可以定义`Jackson2ObjectMapperBuilder` `@Bean`,通过builder构建。注意不管哪种方式都会禁用所有的自动配置`ObjectMapper`。 -如果你提供`MappingJackson2HttpMessageConverter`类型的`@Bean`,它们将替换MVC配置中的默认值。Spring Boot也提供了一个`HttpMessageConverters`类型的便利bean(如果你使用MVC默认配置,那它就总是可用的),它提供了一些有用的方法来获取默认和用户增强的消息转换器(message converters)。具体详情可参考[Section 74.4, “Customize the @ResponseBody rendering”](./74.4 Customize the @ResponseBody rendering.md)及[WebMvcAutoConfiguration](https://github.com/spring-projects/spring-boot/tree/v2.0.0.RELEASE/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/web/servlet/WebMvcAutoConfiguration.java)源码。 +如果你提供`MappingJackson2HttpMessageConverter`类型的`@Bean`,它们将替换MVC配置中的默认值。Spring Boot也提供了一个`HttpMessageConverters`类型的便利bean(如果你使用MVC默认配置,那它就总是可用的),它提供了一些有用的方法来获取默认和用户增强的消息转换器(message converters)。具体详情可参考[76.4 自定义@ResponseBody渲染](https://docs.spring.io/spring-boot/docs/2.0.0.RELEASE/reference/htmlsingle/#howto-customize-the-responsebody-rendering)及[WebMvcAutoConfiguration](https://github.com/spring-projects/spring-boot/tree/v2.0.0.RELEASE/spring-boot-project/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/web/servlet/WebMvcAutoConfiguration.java)源码。 From 764ffc25ef3af76ef5cae99bab2cc873a44ae150 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E7=83=AD=E5=BF=83=E5=B8=82=E6=B0=91=E9=92=9F=E5=B0=8F?= =?UTF-8?q?=E5=BC=BA?= Date: Tue, 14 Jan 2020 18:35:12 +0800 Subject: [PATCH 733/865] Update and rename 74.4 Customize the @ResponseBody rendering.md to 76.4 Customize the @ResponseBody Rendering.md --- .../74.4 Customize the @ResponseBody rendering.md" | 7 ------- .../76.4 Customize the @ResponseBody Rendering.md" | 7 +++++++ 2 files changed, 7 insertions(+), 7 deletions(-) delete mode 100644 "IX. \342\200\230How-to\342\200\231 guides/74.4 Customize the @ResponseBody rendering.md" create mode 100644 "IX. \342\200\230How-to\342\200\231 guides/76.4 Customize the @ResponseBody Rendering.md" diff --git "a/IX. \342\200\230How-to\342\200\231 guides/74.4 Customize the @ResponseBody rendering.md" "b/IX. \342\200\230How-to\342\200\231 guides/74.4 Customize the @ResponseBody rendering.md" deleted file mode 100644 index 789a0bcd..00000000 --- "a/IX. \342\200\230How-to\342\200\231 guides/74.4 Customize the @ResponseBody rendering.md" +++ /dev/null @@ -1,7 +0,0 @@ -### 74.4 自定义@ResponseBody渲染 - -Spring使用`HttpMessageConverters`渲染`@ResponseBody`(或来自`@RestController`的响应),你可以通过在Spring Boot上下文中添加该类型的beans来贡献其他的转换器。如果你添加的bean类型默认已经包含了(像用于JSON转换的`MappingJackson2HttpMessageConverter`),那它将替换默认的。Spring Boot提供一个方便的`HttpMessageConverters`类型的bean,它有一些有用的方法可以访问默认的和用户增强的message转换器(比如你想要手动将它们注入到一个自定义的`RestTemplate`时就很有用)。 - -在通常的MVC用例中,任何你提供的`WebMvcConfigurerAdapter` beans通过覆盖`configureMessageConverters`方法也能贡献转换器,但不同于通常的MVC,你可以只提供你需要的转换器(因为Spring Boot使用相同的机制来贡献它默认的转换器)。最终,如果你通过提供自己的` @EnableWebMvc`注解覆盖Spring Boot默认的MVC配置,那你就可以完全控制,并使用来自`WebMvcConfigurationSupport`的`getMessageConverters`手动做任何事。 - -更多详情可参考[WebMvcAutoConfiguration](https://github.com/spring-projects/spring-boot/tree/v2.0.0.RELEASE/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/web/servlet/WebMvcAutoConfiguration.java)源码。 diff --git "a/IX. \342\200\230How-to\342\200\231 guides/76.4 Customize the @ResponseBody Rendering.md" "b/IX. \342\200\230How-to\342\200\231 guides/76.4 Customize the @ResponseBody Rendering.md" new file mode 100644 index 00000000..54c3250f --- /dev/null +++ "b/IX. \342\200\230How-to\342\200\231 guides/76.4 Customize the @ResponseBody Rendering.md" @@ -0,0 +1,7 @@ +### 76.4 自定义@ResponseBody渲染 + +Spring使用`HttpMessageConverters`渲染`@ResponseBody`(或来自`@RestController`的响应)。你可以通过在Spring Boot上下文中添加该类型的beans来贡献其他的转换器。如果你添加的bean类型默认已经包含了(像用于JSON转换的`MappingJackson2HttpMessageConverter`),那它将替换默认的。Spring Boot提供一个`HttpMessageConverters`类型的bean,它有一些有用的方法可以访问默认的和用户增强的message转换器(比如你想要手动将它们注入到一个自定义的`RestTemplate`时就很有用)。 + +在通常的MVC用例中,任何你提供的`WebMvcConfigurer` beans通过覆盖`configureMessageConverters`方法也能贡献转换器,但不同于通常的MVC,你可以只提供你需要的转换器(因为Spring Boot使用相同的机制来贡献它默认的转换器)。最终,如果你通过提供自己的` @EnableWebMvc`注解覆盖Spring Boot默认的MVC配置,那你就可以完全控制,并使用来自`WebMvcConfigurationSupport`的`getMessageConverters`手动做任何事。 + +更多详情可参考[WebMvcAutoConfiguration](https://github.com/spring-projects/spring-boot/tree/v2.0.0.RELEASE/spring-boot-project/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/web/servlet/WebMvcAutoConfiguration.java)源码。 From b3b2d5d58b02af5cac057260f8957b1adafa0fd0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E7=83=AD=E5=BF=83=E5=B8=82=E6=B0=91=E9=92=9F=E5=B0=8F?= =?UTF-8?q?=E5=BC=BA?= Date: Tue, 14 Jan 2020 18:36:56 +0800 Subject: [PATCH 734/865] Update and rename 74.5 Handling Multipart File Uploads.md to 76.5 Handling Multipart File Uploads.md --- .../76.5 Handling Multipart File Uploads.md" | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) rename "IX. \342\200\230How-to\342\200\231 guides/74.5 Handling Multipart File Uploads.md" => "IX. \342\200\230How-to\342\200\231 guides/76.5 Handling Multipart File Uploads.md" (82%) diff --git "a/IX. \342\200\230How-to\342\200\231 guides/74.5 Handling Multipart File Uploads.md" "b/IX. \342\200\230How-to\342\200\231 guides/76.5 Handling Multipart File Uploads.md" similarity index 82% rename from "IX. \342\200\230How-to\342\200\231 guides/74.5 Handling Multipart File Uploads.md" rename to "IX. \342\200\230How-to\342\200\231 guides/76.5 Handling Multipart File Uploads.md" index 45b44d76..3327edba 100644 --- "a/IX. \342\200\230How-to\342\200\231 guides/74.5 Handling Multipart File Uploads.md" +++ "b/IX. \342\200\230How-to\342\200\231 guides/76.5 Handling Multipart File Uploads.md" @@ -1,7 +1,7 @@ -### 74.5 处理Multipart文件上传 +### 76.5 处理Multipart文件上传 Spring Boot采用Servlet 3 `javax.servlet.http.Part` API来支持文件上传。默认情况下,Spring Boot配置Spring MVC在单个请求中只处理每个文件最大1MB,最多10MB的文件数据。你可以覆盖那些值,也可以设置临时文件存储的位置(比如,存储到`/tmp`文件夹下)及传递数据刷新到磁盘的阀值(通过使用`MultipartProperties`类暴露的属性)。如果你需要设置文件不受限制,可以设置`spring.servlet.multipart.max-file-size`属性值为`-1`。 当你想要接收multipart编码文件数据作为Spring MVC控制器(controller)处理方法中被`@RequestParam`注解的`MultipartFile`类型的参数时,multipart支持就非常有用了。 -更多详情可参考[MultipartAutoConfiguration](https://github.com/spring-projects/spring-boot/tree/v2.0.0.RELEASE/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/web/servlet/MultipartAutoConfiguration.java)源码。 +更多详情可参考[MultipartAutoConfiguration](https://github.com/spring-projects/spring-boot/tree/v2.0.0.RELEASE/spring-boot-project/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/web/servlet/MultipartAutoConfiguration.java)源码。 From b4d817a44943f567fb3473e35b42395da0f2919e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E7=83=AD=E5=BF=83=E5=B8=82=E6=B0=91=E9=92=9F=E5=B0=8F?= =?UTF-8?q?=E5=BC=BA?= Date: Tue, 14 Jan 2020 18:41:30 +0800 Subject: [PATCH 735/865] Update and rename 74.6 Switch off the Spring MVC DispatcherServlet.md to 76.6 Switch Off the Spring MVC DispatcherServlet.md --- .../74.6 Switch off the Spring MVC DispatcherServlet.md" | 3 --- .../76.6 Switch Off the Spring MVC DispatcherServlet.md" | 3 +++ 2 files changed, 3 insertions(+), 3 deletions(-) delete mode 100644 "IX. \342\200\230How-to\342\200\231 guides/74.6 Switch off the Spring MVC DispatcherServlet.md" create mode 100644 "IX. \342\200\230How-to\342\200\231 guides/76.6 Switch Off the Spring MVC DispatcherServlet.md" diff --git "a/IX. \342\200\230How-to\342\200\231 guides/74.6 Switch off the Spring MVC DispatcherServlet.md" "b/IX. \342\200\230How-to\342\200\231 guides/74.6 Switch off the Spring MVC DispatcherServlet.md" deleted file mode 100644 index eaa22778..00000000 --- "a/IX. \342\200\230How-to\342\200\231 guides/74.6 Switch off the Spring MVC DispatcherServlet.md" +++ /dev/null @@ -1,3 +0,0 @@ -### 74.6 关闭Spring MVC DispatcherServlet - -Spring Boot想要服务来自应用程序root `/`下的所有内容。如果你想将自己的servlet映射到该目录下也是可以的,但当然你可能失去一些Spring Boot MVC特性。为了添加你自己的servlet,并将它映射到root资源,你只需声明一个`Servlet`类型的`@Bean`,并给它特定的bean名称`dispatcherServlet`(如果只想关闭但不替换它,你可以使用该名称创建不同类型的bean)。 diff --git "a/IX. \342\200\230How-to\342\200\231 guides/76.6 Switch Off the Spring MVC DispatcherServlet.md" "b/IX. \342\200\230How-to\342\200\231 guides/76.6 Switch Off the Spring MVC DispatcherServlet.md" new file mode 100644 index 00000000..3bfb2f21 --- /dev/null +++ "b/IX. \342\200\230How-to\342\200\231 guides/76.6 Switch Off the Spring MVC DispatcherServlet.md" @@ -0,0 +1,3 @@ +### 76.6 关闭Spring MVC DispatcherServlet + +Spring Boot想要服务来自应用程序root(`/`)下的所有内容。如果你想将自己的servlet映射到该目录下也是可以的,但当然你可能失去一些Spring Boot MVC特性。为了添加你自己的servlet,并将它映射到root资源,你只需声明一个`Servlet`类型的`@Bean`,并给它特定的bean名称`dispatcherServlet`(如果只想关闭但不替换它,你可以使用该名称创建不同类型的bean)。 From e8ffd13db60bd36edd6fe99996036667659519a1 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E7=83=AD=E5=BF=83=E5=B8=82=E6=B0=91=E9=92=9F=E5=B0=8F?= =?UTF-8?q?=E5=BC=BA?= Date: Tue, 14 Jan 2020 18:42:45 +0800 Subject: [PATCH 736/865] Update and rename 74.7 Switch off the Default MVC configuration.md to 76.7 Switch off the Default MVC Configuration.md --- .../76.7 Switch off the Default MVC Configuration.md" | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) rename "IX. \342\200\230How-to\342\200\231 guides/74.7 Switch off the Default MVC configuration.md" => "IX. \342\200\230How-to\342\200\231 guides/76.7 Switch off the Default MVC Configuration.md" (81%) diff --git "a/IX. \342\200\230How-to\342\200\231 guides/74.7 Switch off the Default MVC configuration.md" "b/IX. \342\200\230How-to\342\200\231 guides/76.7 Switch off the Default MVC Configuration.md" similarity index 81% rename from "IX. \342\200\230How-to\342\200\231 guides/74.7 Switch off the Default MVC configuration.md" rename to "IX. \342\200\230How-to\342\200\231 guides/76.7 Switch off the Default MVC Configuration.md" index 543efd34..184de21f 100644 --- "a/IX. \342\200\230How-to\342\200\231 guides/74.7 Switch off the Default MVC configuration.md" +++ "b/IX. \342\200\230How-to\342\200\231 guides/76.7 Switch off the Default MVC Configuration.md" @@ -1,3 +1,3 @@ -### 74.7 关闭默认的MVC配置 +### 76.7 关闭默认的MVC配置 完全控制MVC配置的最简单方式是提供你自己的被`@EnableWebMvc`注解的`@Configuration`,这样所有的MVC配置都逃不出你的掌心。 From 46afc1c92edd5cc4839b98116b0aa9213efeeb69 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E7=83=AD=E5=BF=83=E5=B8=82=E6=B0=91=E9=92=9F=E5=B0=8F?= =?UTF-8?q?=E5=BC=BA?= Date: Tue, 14 Jan 2020 19:07:36 +0800 Subject: [PATCH 737/865] Update and rename 74.8 Customize ViewResolvers.md to 76.8 Customize ViewResolvers.md --- .../74.8 Customize ViewResolvers.md" | 15 --------------- .../76.8 Customize ViewResolvers.md" | 19 +++++++++++++++++++ 2 files changed, 19 insertions(+), 15 deletions(-) delete mode 100644 "IX. \342\200\230How-to\342\200\231 guides/74.8 Customize ViewResolvers.md" create mode 100644 "IX. \342\200\230How-to\342\200\231 guides/76.8 Customize ViewResolvers.md" diff --git "a/IX. \342\200\230How-to\342\200\231 guides/74.8 Customize ViewResolvers.md" "b/IX. \342\200\230How-to\342\200\231 guides/74.8 Customize ViewResolvers.md" deleted file mode 100644 index 7781b1c4..00000000 --- "a/IX. \342\200\230How-to\342\200\231 guides/74.8 Customize ViewResolvers.md" +++ /dev/null @@ -1,15 +0,0 @@ -### 74.8 自定义ViewResolvers - -`ViewResolver`是Spring MVC的核心组件,它负责转换`@Controller`中的视图名称到实际的`View`实现。注意`ViewResolvers`主要用在UI应用中,而不是REST风格的服务(`View`不是用来渲染`@ResponseBody`的)。Spring有很多你可以选择的`ViewResolver`实现,并且Spring自己对如何选择相应实现也没发表意见。另一方面,Spring Boot会根据classpath上的依赖和应用上下文为你安装一或两个`ViewResolver`实现。`DispatcherServlet`使用所有在应用上下文中找到的解析器(resolvers),并依次尝试每一个直到它获取到结果,所以如果你正在添加自己的解析器,那就要小心顺序和你的解析器添加的位置。 - -`WebMvcAutoConfiguration`将会为你的上下文添加以下`ViewResolvers`: - -- bean id为`defaultViewResolver`的`InternalResourceViewResolver`,它会定位可以使用`DefaultServlet`渲染的物理资源(比如静态资源和JSP页面)。它在视图名上应用了一个前缀和后缀(默认都为空,但你可以通过`spring.view.prefix`和`spring.view.suffix`设置),然后查找在servlet上下文中具有该路径的物理资源,可以通过提供相同类型的bean覆盖它。 -- id为`beanNameViewResolver`的`BeanNameViewResolver`,它是视图解析器链的一个非常有用的成员,可以在`View`解析时收集任何具有相同名称的beans,没必要覆盖或替换它。 -- id为`viewResolver`的`ContentNegotiatingViewResolver`,它只会在实际`View`类型的beans出现时添加。这是一个'master'解析器,它的职责会代理给其他解析器,它会尝试找到客户端发送的一个匹配'Accept'的HTTP头部。这有一篇关于[ContentNegotiatingViewResolver](https://spring.io/blog/2013/06/03/content-negotiation-using-views)的博客,你也可以也查看下源码。通过定义一个名叫'viewResolver'的bean,你可以关闭自动配置的`ContentNegotiatingViewResolver`。 -- 如果使用Thymeleaf,你将有一个id为`thymeleafViewResolver`的`ThymeleafViewResolver`,它会通过加前缀和后缀的视图名来查找资源(外部配置为`spring.thymeleaf.prefix`和`spring.thymeleaf.suffix`,对应的默认为'classpath:/templates/'和'.html')。你可以通过提供相同名称的bean来覆盖它。 -- 如果使用FreeMarker,你将有一个id为`freeMarkerViewResolver`的`FreeMarkerViewResolver`,它会使用加前缀和后缀(外部配置为`spring.freemarker.prefix`和`spring.freemarker.suffix`,对应的默认值为空和'.ftl')的视图名从加载路径(外部配置为`spring.freemarker.templateLoaderPath`,默认为'classpath:/templates/')下查找资源。你可以通过提供相同名称的bean来覆盖它。 -- 如果使用Groovy模板(实际上只要你把groovy-templates添加到classpath下),你将有一个id为`groovyTemplateViewResolver`的`Groovy TemplateViewResolver`,它会使用加前缀和后缀(外部属性为`spring.groovy.template.prefix`和`spring.groovy.template.suffix`,对应的默认值为'classpath:/templates/'和'.tpl')的视图名从加载路径下查找资源。你可以通过提供相同名称的bean来覆盖它。 -- 如果使用Velocity,你将有一个id为`velocityViewResolver`的`VelocityViewResolver`,它会使用加前缀和后缀(外部属性为`spring.velocity.prefix`和`spring.velocity.suffix`,对应的默认值为空和'.vm')的视图名从加载路径(外部属性为`spring.velocity.resourceLoaderPath`,默认为'classpath:/templates/')下查找资源。你可以通过提供相同名称的bean来覆盖它。 - -更多详情可查看源码:  [WebMvcAutoConfiguration](https://github.com/spring-projects/spring-boot/tree/v2.0.0.RELEASE/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/web/servlet/WebMvcAutoConfiguration.java),[ThymeleafAutoConfiguration](https://github.com/spring-projects/spring-boot/tree/v2.0.0.RELEASE/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/thymeleaf/ThymeleafAutoConfiguration.java),[FreeMarkerAutoConfiguration](https://github.com/spring-projects/spring-boot/tree/v2.0.0.RELEASE/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/freemarker/FreeMarkerAutoConfiguration.java),[GroovyTemplateAutoConfiguration](https://github.com/spring-projects/spring-boot/tree/v2.0.0.RELEASE/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/groovy/template/GroovyTemplateAutoConfiguration.java)。 diff --git "a/IX. \342\200\230How-to\342\200\231 guides/76.8 Customize ViewResolvers.md" "b/IX. \342\200\230How-to\342\200\231 guides/76.8 Customize ViewResolvers.md" new file mode 100644 index 00000000..34239d13 --- /dev/null +++ "b/IX. \342\200\230How-to\342\200\231 guides/76.8 Customize ViewResolvers.md" @@ -0,0 +1,19 @@ +### 76.8 自定义ViewResolvers + +`ViewResolver`是Spring MVC的核心组件,它负责转换`@Controller`中的视图名称到实际的`View`实现。注意`ViewResolvers`主要用在UI应用中,而不是REST风格的服务(`View`不是用来渲染`@ResponseBody`的)。Spring有很多你可以选择的`ViewResolver`实现,并且Spring自己对如何选择相应实现也没发表意见。另一方面,Spring Boot会根据classpath上的依赖和应用上下文为你安装一或两个`ViewResolver`实现。`DispatcherServlet`使用所有在应用上下文中找到的解析器(resolvers),并依次尝试每一个直到它获取到结果,所以如果你正在添加自己的解析器,那就要小心顺序和你的解析器添加的位置。 + +`WebMvcAutoConfiguration`将会为你的上下文添加以下`ViewResolvers`: + +- 名为`defaultViewResolver`的`InternalResourceViewResolver`,它会定位可以使用`DefaultServlet`渲染的物理资源(比如静态资源和JSP页面)。它在视图名上应用了一个前缀和后缀(默认都为空,但你可以通过`spring.view.prefix`和`spring.view.suffix`设置),然后查找在servlet上下文中具有该路径的物理资源,可以通过提供相同类型的bean覆盖它。 +- 名为`beanNameViewResolver`的`BeanNameViewResolver`,它是视图解析器链的一个非常有用的成员,可以在`View`解析时收集任何具有相同名称的beans,没必要覆盖或替换它。 +- 名为`viewResolver`的`ContentNegotiatingViewResolver`,它只会在实际`View`类型的beans出现时添加。这是一个'master'解析器,它的职责会代理给其他解析器,它会尝试找到客户端发送的一个匹配'Accept'的HTTP头部。这有一篇关于[ContentNegotiatingViewResolver](https://spring.io/blog/2013/06/03/content-negotiation-using-views)的博客,你也可以也查看下源码。通过定义一个名叫'viewResolver'的bean,你可以关闭自动配置的`ContentNegotiatingViewResolver`。 +- 如果使用Thymeleaf,你将有一个id为`thymeleafViewResolver`的`ThymeleafViewResolver`,它会通过加前缀和后缀的视图名来查找资源(外部配置为`spring.thymeleaf.prefix`和`spring.thymeleaf.suffix`,对应的默认为'classpath:/templates/'和'.html')。你可以通过提供相同名称的bean来覆盖它。 +- 如果使用FreeMarker,你将有一个名为`freeMarkerViewResolver`的`FreeMarkerViewResolver`,它会使用加前缀和后缀。它通过在视图名周围加上前缀和后缀来查找加载器路径中的资源(加载器路径外化为`spring.freemarker.templateLoaderPath`,默认值为`classpath:/templates/`)。前缀外部化为`spring.freemarker.prefix`,后缀外部化为`spring.freemarker.suffix`。前缀和后缀的默认值为空和`.ftl`。你可以通过提供同名的bean来覆盖`FreeMarkerViewResolver`。 +- 如果使用Groovy模板(实际上只要你把groovy-templates添加到classpath下),你将有一个名为`groovyTemplateViewResolver`的`Groovy TemplateViewResolver`。它会使用加前缀和后缀(外部属性为`spring.groovy.template.prefix`和`spring.groovy.template.suffix`,对应的默认值为`classpath:/templates/`和`.tpl`)的视图名从加载路径下查找资源。你可以通过提供同名的bean来覆盖它。 +- 如果使用Velocity,你将有一个id为`velocityViewResolver`的`VelocityViewResolver`,它会使用加前缀和后缀(外部属性为`spring.velocity.prefix`和`spring.velocity.suffix`,对应的默认值为空和'.vm')的视图名从加载路径(外部属性为`spring.velocity.resourceLoaderPath`,默认为'classpath:/templates/')下查找资源。你可以通过提供相同名称的bean来覆盖它。 + +更多详情,可查看下列章节: +- [WebMvcAutoConfiguration](https://github.com/spring-projects/spring-boot/tree/v2.0.0.RELEASE/spring-boot-project/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/web/servlet/WebMvcAutoConfiguration.java) +- [ThymeleafAutoConfiguration](https://github.com/spring-projects/spring-boot/tree/v2.0.0.RELEASE/spring-boot-project/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/thymeleaf/ThymeleafAutoConfiguration.java) +- [FreeMarkerAutoConfiguration](https://github.com/spring-projects/spring-boot/tree/v2.0.0.RELEASE/spring-boot-project/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/freemarker/FreeMarkerAutoConfiguration.java) +- [GroovyTemplateAutoConfiguration](https://github.com/spring-projects/spring-boot/tree/v2.0.0.RELEASE/spring-boot-project/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/groovy/template/GroovyTemplateAutoConfiguration.java)。 From 9c7776972489ea14b8c064b8e097a05000c582e3 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E7=83=AD=E5=BF=83=E5=B8=82=E6=B0=91=E9=92=9F=E5=B0=8F?= =?UTF-8?q?=E5=BC=BA?= Date: Tue, 14 Jan 2020 19:08:01 +0800 Subject: [PATCH 738/865] Update 76.8 Customize ViewResolvers.md --- .../76.8 Customize ViewResolvers.md" | 1 - 1 file changed, 1 deletion(-) diff --git "a/IX. \342\200\230How-to\342\200\231 guides/76.8 Customize ViewResolvers.md" "b/IX. \342\200\230How-to\342\200\231 guides/76.8 Customize ViewResolvers.md" index 34239d13..7314c3a8 100644 --- "a/IX. \342\200\230How-to\342\200\231 guides/76.8 Customize ViewResolvers.md" +++ "b/IX. \342\200\230How-to\342\200\231 guides/76.8 Customize ViewResolvers.md" @@ -10,7 +10,6 @@ - 如果使用Thymeleaf,你将有一个id为`thymeleafViewResolver`的`ThymeleafViewResolver`,它会通过加前缀和后缀的视图名来查找资源(外部配置为`spring.thymeleaf.prefix`和`spring.thymeleaf.suffix`,对应的默认为'classpath:/templates/'和'.html')。你可以通过提供相同名称的bean来覆盖它。 - 如果使用FreeMarker,你将有一个名为`freeMarkerViewResolver`的`FreeMarkerViewResolver`,它会使用加前缀和后缀。它通过在视图名周围加上前缀和后缀来查找加载器路径中的资源(加载器路径外化为`spring.freemarker.templateLoaderPath`,默认值为`classpath:/templates/`)。前缀外部化为`spring.freemarker.prefix`,后缀外部化为`spring.freemarker.suffix`。前缀和后缀的默认值为空和`.ftl`。你可以通过提供同名的bean来覆盖`FreeMarkerViewResolver`。 - 如果使用Groovy模板(实际上只要你把groovy-templates添加到classpath下),你将有一个名为`groovyTemplateViewResolver`的`Groovy TemplateViewResolver`。它会使用加前缀和后缀(外部属性为`spring.groovy.template.prefix`和`spring.groovy.template.suffix`,对应的默认值为`classpath:/templates/`和`.tpl`)的视图名从加载路径下查找资源。你可以通过提供同名的bean来覆盖它。 -- 如果使用Velocity,你将有一个id为`velocityViewResolver`的`VelocityViewResolver`,它会使用加前缀和后缀(外部属性为`spring.velocity.prefix`和`spring.velocity.suffix`,对应的默认值为空和'.vm')的视图名从加载路径(外部属性为`spring.velocity.resourceLoaderPath`,默认为'classpath:/templates/')下查找资源。你可以通过提供相同名称的bean来覆盖它。 更多详情,可查看下列章节: - [WebMvcAutoConfiguration](https://github.com/spring-projects/spring-boot/tree/v2.0.0.RELEASE/spring-boot-project/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/web/servlet/WebMvcAutoConfiguration.java) From a104ba0a80a5e509ccfb2aae28fa98615fe793e2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E7=83=AD=E5=BF=83=E5=B8=82=E6=B0=91=E9=92=9F=E5=B0=8F?= =?UTF-8?q?=E5=BC=BA?= Date: Fri, 17 Jan 2020 16:56:54 +0800 Subject: [PATCH 739/865] Update SUMMARY.md --- SUMMARY.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/SUMMARY.md b/SUMMARY.md index 0a4126f7..48b3f50b 100644 --- a/SUMMARY.md +++ b/SUMMARY.md @@ -498,8 +498,8 @@ * [76.6 关闭Spring MVC DispatcherServlet](IX. ‘How-to’ guides/76.6 Switch Off the Spring MVC DispatcherServlet.md) * [76.7 关闭默认的MVC配置](IX. ‘How-to’ guides/76.7 Switch off the Default MVC Configuration.md) * [76.8 自定义ViewResolvers](IX. ‘How-to’ guides/76.8 Customize ViewResolvers.md) - * [75. HTTP客户端](IX. ‘How-to’ guides/75. HTTP clients.md) - * [75.1 配置RestTemplate使用代理](IX. ‘How-to’ guides/75.1 Configure RestTemplate to use a proxy.md) + * [77. HTTP客户端](IX. ‘How-to’ guides/77. HTTP Clients.md) + * [77.1 配置RestTemplate使用代理](IX. ‘How-to’ guides/77.1 Configure RestTemplate to Use a Proxy.md) * [76. 日志](IX. ‘How-to’ guides/76. Logging.md) * [76.1 配置Logback](IX. ‘How-to’ guides/76.1 Configure Logback for logging.md) * [76.1.1 配置logback只输出到文件](IX. ‘How-to’ guides/76.1.1 Configure logback for file only output.md) From 29443c40a1b3a505084442f77f325539e7c2780f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E7=83=AD=E5=BF=83=E5=B8=82=E6=B0=91=E9=92=9F=E5=B0=8F?= =?UTF-8?q?=E5=BC=BA?= Date: Fri, 17 Jan 2020 17:00:11 +0800 Subject: [PATCH 740/865] Update and rename 75. HTTP clients.md to 77. HTTP Clients.md --- .../75. HTTP clients.md" | 1 - .../77. HTTP Clients.md" | 3 +++ 2 files changed, 3 insertions(+), 1 deletion(-) delete mode 100644 "IX. \342\200\230How-to\342\200\231 guides/75. HTTP clients.md" create mode 100644 "IX. \342\200\230How-to\342\200\231 guides/77. HTTP Clients.md" diff --git "a/IX. \342\200\230How-to\342\200\231 guides/75. HTTP clients.md" "b/IX. \342\200\230How-to\342\200\231 guides/75. HTTP clients.md" deleted file mode 100644 index b5d4cfd2..00000000 --- "a/IX. \342\200\230How-to\342\200\231 guides/75. HTTP clients.md" +++ /dev/null @@ -1 +0,0 @@ -###75. HTTP客户端 diff --git "a/IX. \342\200\230How-to\342\200\231 guides/77. HTTP Clients.md" "b/IX. \342\200\230How-to\342\200\231 guides/77. HTTP Clients.md" new file mode 100644 index 00000000..aa2dcae5 --- /dev/null +++ "b/IX. \342\200\230How-to\342\200\231 guides/77. HTTP Clients.md" @@ -0,0 +1,3 @@ +### 77. HTTP客户端 + +Spring Boot提供了许多使用HTTP客户端的starter。本节回答与使用它们相关的问题。 From 8f822923379832fb01514bac9907132298f87dd6 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E7=83=AD=E5=BF=83=E5=B8=82=E6=B0=91=E9=92=9F=E5=B0=8F?= =?UTF-8?q?=E5=BC=BA?= Date: Fri, 17 Jan 2020 17:03:54 +0800 Subject: [PATCH 741/865] Update and rename 75.1 Configure RestTemplate to use a proxy.md to 77.1 Configure RestTemplate to Use a Proxy.md --- .../77.1 Configure RestTemplate to Use a Proxy.md" | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) rename "IX. \342\200\230How-to\342\200\231 guides/75.1 Configure RestTemplate to use a proxy.md" => "IX. \342\200\230How-to\342\200\231 guides/77.1 Configure RestTemplate to Use a Proxy.md" (75%) diff --git "a/IX. \342\200\230How-to\342\200\231 guides/75.1 Configure RestTemplate to use a proxy.md" "b/IX. \342\200\230How-to\342\200\231 guides/77.1 Configure RestTemplate to Use a Proxy.md" similarity index 75% rename from "IX. \342\200\230How-to\342\200\231 guides/75.1 Configure RestTemplate to use a proxy.md" rename to "IX. \342\200\230How-to\342\200\231 guides/77.1 Configure RestTemplate to Use a Proxy.md" index ef559c95..17790f00 100644 --- "a/IX. \342\200\230How-to\342\200\231 guides/75.1 Configure RestTemplate to use a proxy.md" +++ "b/IX. \342\200\230How-to\342\200\231 guides/77.1 Configure RestTemplate to Use a Proxy.md" @@ -1,5 +1,6 @@ -###75.1 配置RestTemplate使用代理 -正如[Section 33.1, “RestTemplate customization”](../IV. Spring Boot features/33.1 RestTemplate customization.md)描述的那样,你可以使用`RestTemplateCustomizer`和`RestTemplateBuilder`构建一个自定义的`RestTemplate`,这是创建使用代理的`RestTemplate`的推荐方式。 +### 77.1 配置RestTemplate使用代理 + +正如[33.1 自定义RestTemplate](https://docs.spring.io/spring-boot/docs/2.0.0.RELEASE/reference/htmlsingle/#boot-features-resttemplate-customization)描述的那样,你可以使用`RestTemplateCustomizer`和`RestTemplateBuilder`构建一个自定义的`RestTemplate`。这是创建使用代理的`RestTemplate`的推荐方式。 代理配置的确切细节取决于底层使用的客户端请求factory,这里有个示例演示`HttpClient`配置的`HttpComponentsClientRequestFactory`对所有hosts都使用代理,除了`192.168.0.5`。 ```java From a2cd11db1b9c53da4b5dd18d536c06c6638bd6b9 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E7=83=AD=E5=BF=83=E5=B8=82=E6=B0=91=E9=92=9F=E5=B0=8F?= =?UTF-8?q?=E5=BC=BA?= Date: Fri, 17 Jan 2020 17:14:29 +0800 Subject: [PATCH 742/865] Update SUMMARY.md --- SUMMARY.md | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/SUMMARY.md b/SUMMARY.md index 48b3f50b..b30ee221 100644 --- a/SUMMARY.md +++ b/SUMMARY.md @@ -500,11 +500,11 @@ * [76.8 自定义ViewResolvers](IX. ‘How-to’ guides/76.8 Customize ViewResolvers.md) * [77. HTTP客户端](IX. ‘How-to’ guides/77. HTTP Clients.md) * [77.1 配置RestTemplate使用代理](IX. ‘How-to’ guides/77.1 Configure RestTemplate to Use a Proxy.md) - * [76. 日志](IX. ‘How-to’ guides/76. Logging.md) - * [76.1 配置Logback](IX. ‘How-to’ guides/76.1 Configure Logback for logging.md) - * [76.1.1 配置logback只输出到文件](IX. ‘How-to’ guides/76.1.1 Configure logback for file only output.md) - * [76.2 配置Log4j](IX. ‘How-to’ guides/76.2 Configure Log4j for logging.md) - * [76.2.1 使用YAML或JSON配置Log4j2](IX. ‘How-to’ guides/76.2.1 Use YAML or JSON to configure Log4j 2.md) + * [78. 日志](IX. ‘How-to’ guides/78. Logging.md) + * [78.1 配置Logback](IX. ‘How-to’ guides/78.1 Configure Logback for Logging.md) + * [78.1.1 配置logback只输出到文件](IX. ‘How-to’ guides/78.1.1 Configure Logback for File-only Output.md) + * [78.2 配置Log4j](IX. ‘How-to’ guides/78.2 Configure Log4j for Logging.md) + * [78.2.1 使用YAML或JSON配置Log4j2](IX. ‘How-to’ guides/78.2.1 Use YAML or JSON to Configure Log4j 2.md) * [77. 数据访问](IX. ‘How-to’ guides/77. Data Access.md) * [77.1 配置自定义的数据源](IX. ‘How-to’ guides/77.1 Configure a custom DataSource.md) * [77.2 配置两个数据源](IX. ‘How-to’ guides/77.2 Configure Two DataSources.md) From 170dc0c86740c70d9ac2a3db45be79bdd591910d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E7=83=AD=E5=BF=83=E5=B8=82=E6=B0=91=E9=92=9F=E5=B0=8F?= =?UTF-8?q?=E5=BC=BA?= Date: Fri, 17 Jan 2020 17:23:26 +0800 Subject: [PATCH 743/865] Update and rename 76. Logging.md to 78. Logging.md --- .../78. Logging.md" | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) rename "IX. \342\200\230How-to\342\200\231 guides/76. Logging.md" => "IX. \342\200\230How-to\342\200\231 guides/78. Logging.md" (65%) diff --git "a/IX. \342\200\230How-to\342\200\231 guides/76. Logging.md" "b/IX. \342\200\230How-to\342\200\231 guides/78. Logging.md" similarity index 65% rename from "IX. \342\200\230How-to\342\200\231 guides/76. Logging.md" rename to "IX. \342\200\230How-to\342\200\231 guides/78. Logging.md" index fdca95be..24f17a0f 100644 --- "a/IX. \342\200\230How-to\342\200\231 guides/76. Logging.md" +++ "b/IX. \342\200\230How-to\342\200\231 guides/78. Logging.md" @@ -1,12 +1,13 @@ -### 76. 日志 +### 78. 日志 -Spring Boot除了`commons-logging`API外没有其他强制性的日志依赖,你有很多可选的日志实现。想要使用[Logback](http://logback.qos.ch/),你需要包含它及`jcl-over-slf4j`(它实现了Commons Logging API)。最简单的方式是通过依赖`spring-boot-starter-logging`的starters。对于一个web应用程序,你只需添加`spring-boot-starter-web`依赖,因为它依赖于logging starter。例如,使用Maven: +除了通常由Spring框架的`spring-jcl`模块提供的Commons Logging API,Spring Boot没有强制的日志依赖关系。想要使用[Logback](http://logback.qos.ch/),你需要包含它及`spring-jcl`。最简单的方式是通过依赖`spring-boot-starter-logging`的starter。对于一个web应用程序,你只需添加`spring-boot-starter-web`依赖,因为它依赖于logging starter。例如,使用Maven: ```xml org.springframework.boot spring-boot-starter-web ``` + Spring Boot有一个`LoggingSystem`抽象,用于尝试通过classpath上下文配置日志系统。如果Logback可用,则首选它。如果你唯一需要做的就是设置不同日志级别,那可以通过在`application.properties`中使用`logging.level`前缀实现,比如: ```java logging.level.org.springframework.web=DEBUG From 01e547b18d952c5a088c9819dc7c37c252ce8830 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E7=83=AD=E5=BF=83=E5=B8=82=E6=B0=91=E9=92=9F=E5=B0=8F?= =?UTF-8?q?=E5=BC=BA?= Date: Fri, 17 Jan 2020 17:32:17 +0800 Subject: [PATCH 744/865] Update and rename 76.1 Configure Logback for logging.md to 78.1 Configure Logback for Logging.md --- .../78.1 Configure Logback for Logging.md" | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) rename "IX. \342\200\230How-to\342\200\231 guides/76.1 Configure Logback for logging.md" => "IX. \342\200\230How-to\342\200\231 guides/78.1 Configure Logback for Logging.md" (65%) diff --git "a/IX. \342\200\230How-to\342\200\231 guides/76.1 Configure Logback for logging.md" "b/IX. \342\200\230How-to\342\200\231 guides/78.1 Configure Logback for Logging.md" similarity index 65% rename from "IX. \342\200\230How-to\342\200\231 guides/76.1 Configure Logback for logging.md" rename to "IX. \342\200\230How-to\342\200\231 guides/78.1 Configure Logback for Logging.md" index 1faa746e..1dd7af05 100644 --- "a/IX. \342\200\230How-to\342\200\231 guides/76.1 Configure Logback for logging.md" +++ "b/IX. \342\200\230How-to\342\200\231 guides/78.1 Configure Logback for Logging.md" @@ -1,4 +1,4 @@ -### 76.1 配置Logback +### 78.1 配置Logback 如果你将`logback.xml`放到classpath根目录下,那它将会被从这加载(或`logback-spring.xml`充分利用Boot提供的模板特性)。Spring Boot提供一个默认的基本配置,如果你只是设置日志级别,那你可以包含它,比如: ```xml @@ -9,11 +9,11 @@ ``` 如果查看spring-boot jar中的`base.xml`,你将会看到`LoggingSystem`为你创建的很多有用的系统属性,比如: -- `${PID}`,当前进程id。 -- `${LOG_FILE}`,如果在Boot外部配置中设置了`logging.file`。 -- `${LOG_PATH}`,如果设置了`logging.path`(表示日志文件产生的目录)。 -- `${LOG_EXCEPTION_CONVERSION_WORD}`,如果在Boot外部配置中设置了`logging.exception-conversion-word`。 +- `${PID}`:当前进程ID。 +- `${LOG_FILE}`:是否在Boot外部配置中设置了`logging.file`。 +- `${LOG_PATH}`:是否设置了`logging.path`(表示日志文件产生的目录)。 +- `${LOG_EXCEPTION_CONVERSION_WORD}`:是否在外部配置中设置了`logging.exception-conversion-word`。 Spring Boot也提供使用自定义的Logback转换器在控制台上输出一些漂亮的彩色ANSI日志信息(不是日志文件),具体参考默认的`base.xml`配置。 -如果Groovy在classpath下,你也可以使用`logback.groovy`配置Logback。 +如果Groovy在类路径下,你也可以使用`logback.groovy`配置Logback。如果存在,则优先考虑此设置。 From f6ba5230dd69a1d0bc1dcf18067a5f81fdb898eb Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E7=83=AD=E5=BF=83=E5=B8=82=E6=B0=91=E9=92=9F=E5=B0=8F?= =?UTF-8?q?=E5=BC=BA?= Date: Fri, 17 Jan 2020 17:35:23 +0800 Subject: [PATCH 745/865] Update and rename 76.1.1 Configure logback for file only output.md to 78.1.1 Configure Logback for File-only Output.md --- .../78.1.1 Configure Logback for File-only Output.md" | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) rename "IX. \342\200\230How-to\342\200\231 guides/76.1.1 Configure logback for file only output.md" => "IX. \342\200\230How-to\342\200\231 guides/78.1.1 Configure Logback for File-only Output.md" (94%) diff --git "a/IX. \342\200\230How-to\342\200\231 guides/76.1.1 Configure logback for file only output.md" "b/IX. \342\200\230How-to\342\200\231 guides/78.1.1 Configure Logback for File-only Output.md" similarity index 94% rename from "IX. \342\200\230How-to\342\200\231 guides/76.1.1 Configure logback for file only output.md" rename to "IX. \342\200\230How-to\342\200\231 guides/78.1.1 Configure Logback for File-only Output.md" index c23e4913..2cf160e4 100644 --- "a/IX. \342\200\230How-to\342\200\231 guides/76.1.1 Configure logback for file only output.md" +++ "b/IX. \342\200\230How-to\342\200\231 guides/78.1.1 Configure Logback for File-only Output.md" @@ -1,4 +1,4 @@ -###76.1.1 配置logback只输出到文件 +### 78.1.1 配置logback只输出到文件 如果想禁用控制台日志记录,只将输出写入文件中,你需要一个只导入`file-appender.xml`而不是`console-appender.xml`的自定义`logback-spring.xml`: ```xml From c564f751a7420aeadb1dc142ab529e1c26780c1d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E7=83=AD=E5=BF=83=E5=B8=82=E6=B0=91=E9=92=9F=E5=B0=8F?= =?UTF-8?q?=E5=BC=BA?= Date: Fri, 17 Jan 2020 17:46:41 +0800 Subject: [PATCH 746/865] Update and rename 76.2 Configure Log4j for logging.md to 78.2 Configure Log4j for Logging.md --- .../76.2 Configure Log4j for logging.md" | 27 ----------------- .../78.2 Configure Log4j for Logging.md" | 29 +++++++++++++++++++ 2 files changed, 29 insertions(+), 27 deletions(-) delete mode 100644 "IX. \342\200\230How-to\342\200\231 guides/76.2 Configure Log4j for logging.md" create mode 100644 "IX. \342\200\230How-to\342\200\231 guides/78.2 Configure Log4j for Logging.md" diff --git "a/IX. \342\200\230How-to\342\200\231 guides/76.2 Configure Log4j for logging.md" "b/IX. \342\200\230How-to\342\200\231 guides/76.2 Configure Log4j for logging.md" deleted file mode 100644 index 50ae8040..00000000 --- "a/IX. \342\200\230How-to\342\200\231 guides/76.2 Configure Log4j for logging.md" +++ /dev/null @@ -1,27 +0,0 @@ -### 76.2 配置Log4j - -如果[Log4j 2](http://logging.apache.org/log4j/2.x)出现在classpath下,Spring Boot会将其作为日志配置。如果你正在使用starters进行依赖装配,这意味着你需要排除Logback,然后包含log4j 2。如果不使用starters,除了添加Log4j 2,你还需要提供`jcl-over-slf4j`依赖(至少)。 - -最简单的方式可能就是通过starters,尽管它需要排除一些依赖,比如,在Maven中: -```xml - - org.springframework.boot - spring-boot-starter-web - - - org.springframework.boot - spring-boot-starter - - - org.springframework.boot - spring-boot-starter-logging - - - - - org.springframework.boot - spring-boot-starter-log4j2 - -``` - -**注** Log4j starters会收集好依赖以满足普通日志记录的需求(比如,Tomcat中使用`java.util.logging`,但使用Log4j 2作为输出),具体查看Actuator Log4j 2的示例,了解如何将它用于实战。 diff --git "a/IX. \342\200\230How-to\342\200\231 guides/78.2 Configure Log4j for Logging.md" "b/IX. \342\200\230How-to\342\200\231 guides/78.2 Configure Log4j for Logging.md" new file mode 100644 index 00000000..6cabf767 --- /dev/null +++ "b/IX. \342\200\230How-to\342\200\231 guides/78.2 Configure Log4j for Logging.md" @@ -0,0 +1,29 @@ +### 78.2 配置Log4j + +如果[Log4j 2](https://logging.apache.org/log4j/2.x)出现在类路径下,Spring Boot会将其作为日志配置。如果你正在使用starter进行依赖装配,这意味着你需要排除Logback,然后包含log4j 2。如果不使用starters,除了添加Log4j 2,你还需要提供`spring-jcl`依赖(至少)。 + +最简单的方式可能就是通过starter,尽管它需要排除一些依赖,比如,在Maven中: +```xml + + org.springframework.boot + spring-boot-starter-web + + + org.springframework.boot + spring-boot-starter + + + org.springframework.boot + spring-boot-starter-logging + + + + + org.springframework.boot + spring-boot-starter-log4j2 + +``` + +**注** Log4j starters会收集好依赖以满足普通日志记录的需求(比如,Tomcat中使用`java.util.logging`,但使用Log4j 2作为输出)。具体查看[Actuator Log4j 2](https://github.com/spring-projects/spring-boot/tree/v2.0.0.RELEASE/spring-boot-samples/spring-boot-sample-actuator-log4j2)的示例,了解如何将它用于实战。 + +**注** 通过设置`java.util.logging.manager`系统属性为`org.apache.logging.log4j.jul.LogManager`,来配置它的[JDK日志适配器](https://logging.apache.org/log4j/2.0/log4j-jul/index.html),确保使用`java.util.logging`执行的调试日志被路由到Log4j 2。 From e2c04f642541fa98c203fda16e3795ac419b1ed3 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E7=83=AD=E5=BF=83=E5=B8=82=E6=B0=91=E9=92=9F=E5=B0=8F?= =?UTF-8?q?=E5=BC=BA?= Date: Fri, 17 Jan 2020 17:48:16 +0800 Subject: [PATCH 747/865] Update and rename 76.2.1 Use YAML or JSON to configure Log4j 2.md to 78.2.1 Use YAML or JSON to Configure Log4j 2.md --- .../78.2.1 Use YAML or JSON to Configure Log4j 2.md" | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) rename "IX. \342\200\230How-to\342\200\231 guides/76.2.1 Use YAML or JSON to configure Log4j 2.md" => "IX. \342\200\230How-to\342\200\231 guides/78.2.1 Use YAML or JSON to Configure Log4j 2.md" (90%) diff --git "a/IX. \342\200\230How-to\342\200\231 guides/76.2.1 Use YAML or JSON to configure Log4j 2.md" "b/IX. \342\200\230How-to\342\200\231 guides/78.2.1 Use YAML or JSON to Configure Log4j 2.md" similarity index 90% rename from "IX. \342\200\230How-to\342\200\231 guides/76.2.1 Use YAML or JSON to configure Log4j 2.md" rename to "IX. \342\200\230How-to\342\200\231 guides/78.2.1 Use YAML or JSON to Configure Log4j 2.md" index 3fbafb87..90157380 100644 --- "a/IX. \342\200\230How-to\342\200\231 guides/76.2.1 Use YAML or JSON to configure Log4j 2.md" +++ "b/IX. \342\200\230How-to\342\200\231 guides/78.2.1 Use YAML or JSON to Configure Log4j 2.md" @@ -1,4 +1,4 @@ -### 76.2.1 使用YAML或JSON配置Log4j2 +### 78.2.1 使用YAML或JSON配置Log4j2 除了它的默认XML配置格式,Log4j 2也支持YAML和JSON配置文件。想使用其他配置文件格式配置Log4j 2,你需要添加合适的依赖到classpath,并以匹配所选格式的方式命名配置文件: From 6008ed5762e0f25392483b734b491db70305ed7d Mon Sep 17 00:00:00 2001 From: Zhong Zengqiang Date: Sat, 18 Jan 2020 14:41:41 +0800 Subject: [PATCH 748/865] Update SUMMARY.md --- SUMMARY.md | 27 ++++++++++++++------------- 1 file changed, 14 insertions(+), 13 deletions(-) diff --git a/SUMMARY.md b/SUMMARY.md index b30ee221..2acd9e05 100644 --- a/SUMMARY.md +++ b/SUMMARY.md @@ -505,19 +505,20 @@ * [78.1.1 配置logback只输出到文件](IX. ‘How-to’ guides/78.1.1 Configure Logback for File-only Output.md) * [78.2 配置Log4j](IX. ‘How-to’ guides/78.2 Configure Log4j for Logging.md) * [78.2.1 使用YAML或JSON配置Log4j2](IX. ‘How-to’ guides/78.2.1 Use YAML or JSON to Configure Log4j 2.md) - * [77. 数据访问](IX. ‘How-to’ guides/77. Data Access.md) - * [77.1 配置自定义的数据源](IX. ‘How-to’ guides/77.1 Configure a custom DataSource.md) - * [77.2 配置两个数据源](IX. ‘How-to’ guides/77.2 Configure Two DataSources.md) - * [77.3 使用Spring Data仓库](IX. ‘How-to’ guides/77.3 Use Spring Data repositories.md) - * [77.4 从Spring配置分离@Entity定义](IX. ‘How-to’ guides/77.4 Separate @Entity definitions from Spring configuration.md) - * [77.5 配置JPA属性](IX. ‘How-to’ guides/77.5 Configure JPA properties.md) - * [77.6 配置Hibernate命名策略](IX. ‘How-to’ guides/77.6 Configure Hibernate Naming Strategy.md) - * [77.7 使用自定义EntityManagerFactory](IX. ‘How-to’ guides/77.7 Use a custom EntityManagerFactory.md) - * [77.8 使用两个EntityManagers](IX. ‘How-to’ guides/77.8 Use Two EntityManagers.md) - * [77.9 使用普通的persistence.xml](IX. ‘How-to’ guides/77.9 Use a traditional persistence.xml.md) - * [77.10 使用Spring Data JPA和Mongo仓库](IX. ‘How-to’ guides/77.10 Use Spring Data JPA and Mongo repositories.md) - * [77.11 将Spring Data仓库暴露为REST端点](IX. ‘How-to’ guides/77.11 Expose Spring Data repositories as REST endpoint.md) - * [77.12 配置JPA使用的组件](IX. ‘How-to’ guides/77.12 Configure a component that is used by JPA.md) + * [79. 数据访问](IX. ‘How-to’ guides/79. Data Access.md) + * [79.1 配置自定义的数据源](IX. ‘How-to’ guides/79.1 Configure a Custom DataSource.md) + * [79.2 配置两个数据源](IX. ‘How-to’ guides/79.2 Configure Two DataSources.md) + * [79.3 使用Spring Data仓库](IX. ‘How-to’ guides/79.3 Use Spring Data Repositories.md) + * [79.4 从Spring配置分离@Entity定义](IX. ‘How-to’ guides/79.4 Separate @Entity Definitions from Spring Configuration.md) + * [79.5 配置JPA属性](IX. ‘How-to’ guides/79.5 Configure JPA Properties.md) + * [79.6 配置Hibernate命名策略](IX. ‘How-to’ guides/79.6 Configure Hibernate Naming Strategy.md) + * [79.7 使用自定义EntityManagerFactory](IX. ‘How-to’ guides/79.7 Use a Custom EntityManagerFactory.md) + * [79.8 使用两个EntityManagers](IX. ‘How-to’ guides/79.8 Use Two EntityManagers.md) + * [79.9 使用普通的persistence.xml文件](IX. ‘How-to’ guides/79.9 Use a Traditional persistence.xml File.md) + * [79.10 使用Spring Data JPA和Mongo仓库](IX. ‘How-to’ guides/79.10 Use Spring Data JPA and Mongo Repositories.md) + * [79.11 将Spring Data仓库暴露为REST端点](IX. ‘How-to’ guides/79.11 Expose Spring Data Repositories as REST Endpoint.md) + * [79.12 配置JPA使用的组件](IX. ‘How-to’ guides/79.12 Configure a Component that is Used by JPA.md) + * [79.13 使用两个数据源配置jOOQ](IX. ‘How-to’ guides/79.13. Configure jOOQ with Two DataSources.md) * [78. 数据库初始化](IX. ‘How-to’ guides/78. Database initialization.md) * [78.1 使用JPA初始化数据库](IX. ‘How-to’ guides/78.1 Initialize a database using JPA.md) * [78.2 使用Hibernate初始化数据库](IX. ‘How-to’ guides/78.2 Initialize a database using Hibernate.md) From 5834c1d1c6f583a5761fe51c487edfd6b4682240 Mon Sep 17 00:00:00 2001 From: Zhong Zengqiang Date: Mon, 20 Jan 2020 16:06:42 +0800 Subject: [PATCH 749/865] update Data Access --- .../29.1. Configure a DataSource.md | 10 +- .../77. Data Access.md" | 1 - .../77.2 Configure Two DataSources.md" | 69 ------- .../79. Data Access.md" | 3 + .../79.1 Configure a Custom DataSource.md" | 180 ++++++++++-------- .../79.2 Configure Two DataSources.md" | 69 +++++++ 6 files changed, 173 insertions(+), 159 deletions(-) delete mode 100644 "IX. \342\200\230How-to\342\200\231 guides/77. Data Access.md" delete mode 100644 "IX. \342\200\230How-to\342\200\231 guides/77.2 Configure Two DataSources.md" create mode 100644 "IX. \342\200\230How-to\342\200\231 guides/79. Data Access.md" rename "IX. \342\200\230How-to\342\200\231 guides/77.1 Configure a custom DataSource.md" => "IX. \342\200\230How-to\342\200\231 guides/79.1 Configure a Custom DataSource.md" (70%) create mode 100644 "IX. \342\200\230How-to\342\200\231 guides/79.2 Configure Two DataSources.md" diff --git a/IV. Spring Boot features/29.1. Configure a DataSource.md b/IV. Spring Boot features/29.1. Configure a DataSource.md index 86ac32d8..0a028706 100644 --- a/IV. Spring Boot features/29.1. Configure a DataSource.md +++ b/IV. Spring Boot features/29.1. Configure a DataSource.md @@ -1,5 +1,5 @@ -### 29.1. 配置DataSource - -Java的`javax.sql.DataSource`接口提供了一个标准的使用数据库连接的方法。通常,DataSource使用`URL`和相应的凭证去初始化数据库连接。 - -**提示** 查看[How-to章节](https://docs.spring.io/spring-boot/docs/2.0.0.RELEASE/reference/htmlsingle/#howto-configure-a-datasource),获取更多的高级示例,典型地完全控制DataSource的配置。 +### 29.1. 配置数据源 + +Java的`javax.sql.DataSource`接口提供了一个标准的使用数据库连接的方法。通常,DataSource使用`URL`和相应的凭证去初始化数据库连接。 + +**提示** 查看[How-to章节](https://docs.spring.io/spring-boot/docs/2.0.0.RELEASE/reference/htmlsingle/#howto-configure-a-datasource),获取更多的高级示例,典型地完全控制DataSource的配置。 diff --git "a/IX. \342\200\230How-to\342\200\231 guides/77. Data Access.md" "b/IX. \342\200\230How-to\342\200\231 guides/77. Data Access.md" deleted file mode 100644 index cf1c449c..00000000 --- "a/IX. \342\200\230How-to\342\200\231 guides/77. Data Access.md" +++ /dev/null @@ -1 +0,0 @@ -### 77. 数据访问 diff --git "a/IX. \342\200\230How-to\342\200\231 guides/77.2 Configure Two DataSources.md" "b/IX. \342\200\230How-to\342\200\231 guides/77.2 Configure Two DataSources.md" deleted file mode 100644 index e6a045b4..00000000 --- "a/IX. \342\200\230How-to\342\200\231 guides/77.2 Configure Two DataSources.md" +++ /dev/null @@ -1,69 +0,0 @@ -### 77.2 配置两个数据源 - -如果你需要配置多个数据源,你可以应用上一节描述的技巧。但是,你必须把其中的一个`数据源`标注为`@Primary`,因为之后有各种不同的自动配置,至少需要通过类型得到一个。 - -如果你创建了你自己的`数据源`,自动配置将会后退。在下面的例子中,我们提供完全相同的特性,而不是自动配置提供的主要的数据源: -```java -@Bean -@Primary -@ConfigurationProperties("app.datasource.foo") -public DataSourceProperties fooDataSourceProperties() { - return new DataSourceProperties(); -} - -@Bean -@Primary -@ConfigurationProperties("app.datasource.foo") -public DataSource fooDataSource() { - return fooDataSourceProperties().initializeDataSourceBuilder().build(); -} - -@Bean -@ConfigurationProperties("app.datasource.bar") -public BasicDataSource barDataSource() { - return (BasicDataSource) DataSourceBuilder.create() - .type(BasicDataSource.class).build(); -} -``` - -**提示** `fooDataSourceProperties`必须被标记为`@Primary`。这样,数据库初始化器特性会使用你的拷贝(你应当使用它)。 - -两个数据源也都绑定到了高级的自定义。例如你应当如下配置它们: -```properties -app.datasource.foo.type=com.zaxxer.hikari.HikariDataSource -app.datasource.foo.maximum-pool-size=30 - -app.datasource.bar.url=jdbc:mysql://localhost/test -app.datasource.bar.username=dbuser -app.datasource.bar.password=dbpass -app.datasource.bar.max-total=30 -``` -当然,你也可以应用相同的观念到第二个`数据源`: -```java -@Bean -@Primary -@ConfigurationProperties("app.datasource.foo") -public DataSourceProperties fooDataSourceProperties() { - return new DataSourceProperties(); -} - -@Bean -@Primary -@ConfigurationProperties("app.datasource.foo") -public DataSource fooDataSource() { - return fooDataSourceProperties().initializeDataSourceBuilder().build(); -} - -@Bean -@ConfigurationProperties("app.datasource.bar") -public DataSourceProperties barDataSourceProperties() { - return new DataSourceProperties(); -} - -@Bean -@ConfigurationProperties("app.datasource.bar") -public DataSource barDataSource() { - return barDataSourceProperties().initializeDataSourceBuilder().build(); -} -``` -这个最后的例子用相同的逻辑,在自定义的命名空间配置了两个数据源,而没有使用Spring Boot的自动配置。 diff --git "a/IX. \342\200\230How-to\342\200\231 guides/79. Data Access.md" "b/IX. \342\200\230How-to\342\200\231 guides/79. Data Access.md" new file mode 100644 index 00000000..514b5378 --- /dev/null +++ "b/IX. \342\200\230How-to\342\200\231 guides/79. Data Access.md" @@ -0,0 +1,3 @@ +### 79. 数据访问 + +Spring Boot包含许多用于处理数据源的starter。本节回答与此相关的问题。 \ No newline at end of file diff --git "a/IX. \342\200\230How-to\342\200\231 guides/77.1 Configure a custom DataSource.md" "b/IX. \342\200\230How-to\342\200\231 guides/79.1 Configure a Custom DataSource.md" similarity index 70% rename from "IX. \342\200\230How-to\342\200\231 guides/77.1 Configure a custom DataSource.md" rename to "IX. \342\200\230How-to\342\200\231 guides/79.1 Configure a Custom DataSource.md" index 819aa766..342a2249 100644 --- "a/IX. \342\200\230How-to\342\200\231 guides/77.1 Configure a custom DataSource.md" +++ "b/IX. \342\200\230How-to\342\200\231 guides/79.1 Configure a Custom DataSource.md" @@ -1,84 +1,96 @@ -### 77.1 配置自定义的数据源 - -在你的配置中自定义那种类型的`@Bean`来配置你自己的`数据源`。需要的时候,Spring Boot将会重复使用你的`数据源`,包括数据库的初始化。如果你需要具体化一些配置,你可以轻松的将你的`数据源`跟环境绑定([查看24.7.1章节,“第三方配置”](../IV. Spring Boot features/24.7.1. Third-party configuration.md))。 -```java -@Bean -@ConfigurationProperties(prefix="app.datasource") -public DataSource dataSource() { - return new FancyDataSource(); -} -``` -```properties -app.datasource.url=jdbc:h2:mem:mydb -app.datasource.username=sa -app.datasource.pool-size=30 -``` -假设对于这个URL,你的`FancyDataSource`有一个常规的JavaBean属性。用户名和池的大小,这些设置将会在`数据源`对其它组件可用之前,被自动绑定。常规的[数据库初始化](https://docs.spring.io/spring-boot/docs/2.0.0.RELEASE/reference/htmlsingle/#howto-initialize-a-database-using-spring-jdbc)也将会发生(这样,相关的`spring.datasource.*`的子集仍旧可以在你的自定义配置中使用)。 - -如果你正在配置一个自定义的JNDI`数据源`,你可以应用相同的原则: -```java -@Bean(destroyMethod="") -@ConfigurationProperties(prefix="app.datasource") -public DataSource dataSource() throws Exception { - JndiDataSourceLookup dataSourceLookup = new JndiDataSourceLookup(); - return dataSourceLookup.getDataSource("java:comp/env/jdbc/YourDS"); -} -``` -Spring Boot也提供了一个工具生成器类`DataSourceBuilder`,可以被用于生成标准的数据源(如果它在类路径上)。在类路径上哪个可用,生成器就会用哪个。它也会基于JDBC url自动探测驱动。 -```java -@Bean -@ConfigurationProperties("app.datasource") -public DataSource dataSource() { - return DataSourceBuilder.create().build(); -} -``` -运行一个带有那个`数据源`的应用,只需要连接信息。也可以提供指定池的设置。检查将要在运行时使用的实现,来获取更多细节。 -```properties -app.datasource.url=jdbc:mysql://localhost/test -app.datasource.username=dbuser -app.datasource.password=dbpass -app.datasource.pool-size=30 -``` -然而,这里有一个陷阱。因为连接池的实际类型没有被暴露,对于你自定义的`数据源`,在元数据中没有键值生成。同时,在你的IDE中也没有补全的方法(数据源接口没有暴露任何属性)。如果你的类路径里存在Hikari,基本的设置将不会生效,因为Hikari没有`url`参数(但有一个`jdbcUrl`参数)。你将不得不如下重写你的配置: -```properties -app.datasource.jdbc-url=jdbc:mysql://localhost/test -app.datasource.username=dbuser -app.datasource.password=dbpass -app.datasource.maximum-pool-size=30 -``` -你可以通过强制连接池使用和返回一个专用的实现而不是`数据源`来处理。你将无法在运行时改变实现,但是选项的列表将会明确。 -```java -@Bean -@ConfigurationProperties("app.datasource") -public HikariDataSource dataSource() { - return (HikariDataSource) DataSourceBuilder.create() - .type(HikariDataSource.class).build(); -} -``` -通过利用`DataSourceProperties`,你可以走得更远。如果没有url(带有可感测的用户名和密码)被提供,它提供一个默认的内嵌的数据库。你可以从任何`DataSourceProperties`的状态,轻松地初始化一个`DataSourceBuilder`。这样,你幸好可以注入Spring Boot自动创建的那个。可是,那将会把你的配置分离为两个命名空间:`spring.datasource`上的url,用户名,密码,类型和驱动,以及在你自定义的命名空间(`app.datasource`)上的剩余部分。为了避免这种情况,你可以在你自定义的命名空间,重新定义一个自定义的`DataSourceProperties`: -```java -@Bean -@Primary -@ConfigurationProperties("app.datasource") -public DataSourceProperties dataSourceProperties() { - return new DataSourceProperties(); -} - -@Bean -@ConfigurationProperties("app.datasource") -public HikariDataSource dataSource(DataSourceProperties properties) { - return (HikariDataSource) properties.initializeDataSourceBuilder() - .type(HikariDataSource.class).build(); -} -``` -这项设置与Spring Boot默认为你做的刚好是一对,除了一个专用的连接池被选择(在代码里),同时它的设置被暴露在相同的命名空间。因为`DataSourceProperties`会为你处理`url`或者`jdbcUrl`的翻译,你可以像这样配置它: -```properties -app.datasource.url=jdbc:mysql://localhost/test -app.datasource.username=dbuser -app.datasource.password=dbpass -app.datasource.maximum-pool-size=30 -``` - -**注** 因为你自定义的配置选择使用Hikari,`app.datasource.type`将会失效。实际上,生成器将会被任何你设置在那儿的值初始化,然后被`.type()`的调用重写。 - -具体详情可参考'Spring Boot特性'章节中的[Section 29.1, “Configure a DataSource”](../IV. Spring Boot features/29.1. Configure a DataSource.md)和[`DataSourceAutoConfiguration`](https://github.com/spring-projects/spring-boot/tree/v2.0.0.RELEASE/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/jdbc/DataSourceAutoConfiguration.java)类源码。 +### 79.1 配置自定义的数据源 + +在你的配置中自定义那种类型的`@Bean`来配置你自己的`数据源`。需要的时候,Spring Boot将会重复使用你的`数据源`,包括数据库的初始化。如果你需要具体化一些配置,你可以轻松的将你的`数据源`跟环境绑定([24.7.1. 第三方配置](https://docs.spring.io/spring-boot/docs/2.0.0.RELEASE/reference/htmlsingle/#boot-features-external-config-3rd-party-configuration))。 + +下面的例子演示了如何在bean中定义数据源: +```java +@Bean +@ConfigurationProperties(prefix="app.datasource") +public DataSource dataSource() { + return new FancyDataSource(); +} +``` + +下面的例子展示了如何通过设置属性来定义一个数据源: +```properties +app.datasource.url=jdbc:h2:mem:mydb +app.datasource.username=sa +app.datasource.pool-size=30 +``` +假设对于这个URL,你的`FancyDataSource`有一个常规的JavaBean属性。用户名和池的大小,这些设置将会在`数据源`对其它组件可用之前,被自动绑定。常规的[数据库初始化](https://docs.spring.io/spring-boot/docs/2.0.0.RELEASE/reference/htmlsingle/#howto-initialize-a-database-using-spring-jdbc)也将会发生(这样,相关的`spring.datasource.*`的子集仍旧可以在你的自定义配置中使用)。 + +如果你正在配置一个自定义的JNDI`数据源`,你可以应用相同的原则: +```java +@Bean(destroyMethod="") +@ConfigurationProperties(prefix="app.datasource") +public DataSource dataSource() throws Exception { + JndiDataSourceLookup dataSourceLookup = new JndiDataSourceLookup(); + return dataSourceLookup.getDataSource("java:comp/env/jdbc/YourDS"); +} +``` + +Spring Boot也提供了一个工具生成器类`DataSourceBuilder`,可以被用于生成标准的数据源(如果它在类路径上)。在类路径上哪个可用,生成器就会用哪个。它也会基于JDBC URL自动探测驱动。 + +下面的示例演示如何使用`DataSourceBuilder`创建数据源: +```java +@Bean +@ConfigurationProperties("app.datasource") +public DataSource dataSource() { + return DataSourceBuilder.create().build(); +} +``` +运行一个带有那个`数据源`的应用,只需要连接信息。也可以提供指定池的设置。检查将要在运行时使用的实现,来获取更多细节。 + +下面的例子展示了如何通过设置属性来定义JDBC数据源: +```properties +app.datasource.url=jdbc:mysql://localhost/test +app.datasource.username=dbuser +app.datasource.password=dbpass +app.datasource.pool-size=30 +``` +然而,这里有一个陷阱。因为连接池的实际类型没有被暴露,对于你自定义的`数据源`,在元数据中没有键值生成。同时,在你的IDE中也没有补全的方法(数据源接口没有暴露任何属性)。如果你的类路径里存在Hikari,基本的设置将不会生效,因为Hikari没有`url`参数(但有一个`jdbcUrl`参数)。你将不得不如下重写你的配置: +```properties +app.datasource.jdbc-url=jdbc:mysql://localhost/test +app.datasource.username=dbuser +app.datasource.password=dbpass +app.datasource.maximum-pool-size=30 +``` + +你可以通过强制连接池使用和返回一个专用的实现而不是`数据源`来处理。你将无法在运行时改变实现,但是选项的列表将会明确。 + +下面的示例演示如何使用`DataSourceBuilder`创建`HikariDataSource`: +```java +@Bean +@ConfigurationProperties("app.datasource") +public HikariDataSource dataSource() { + return DataSourceBuilder.create().type(HikariDataSource.class).build(); +} +``` + +通过利用`DataSourceProperties`,你可以走得更远。如果没有URL(带有可感测的用户名和密码)被提供,它提供一个默认的内嵌的数据库。你可以从任何`DataSourceProperties`的状态,轻松地初始化一个`DataSourceBuilder`。这样,你幸好可以注入Spring Boot自动创建的数据源。可是,那将会把你的配置分离为两个命名空间:`spring.datasource`上的url,用户名,密码,类型和驱动,以及在你自定义的命名空间(`app.datasource`)上的剩余部分。为了避免这种情况,你可以在你自定义的命名空间,重新定义一个自定义的`DataSourceProperties`: +```java +@Bean +@Primary +@ConfigurationProperties("app.datasource") +public DataSourceProperties dataSourceProperties() { + return new DataSourceProperties(); +} + +@Bean +@ConfigurationProperties("app.datasource") +public HikariDataSource dataSource(DataSourceProperties properties) { + return properties.initializeDataSourceBuilder().type(HikariDataSource.class) + .build(); +} +``` +这项设置与Spring Boot默认为你做的刚好是一对,除了一个专用的连接池被选择(在代码里),同时它的设置被暴露在相同的命名空间。因为`DataSourceProperties`会为你处理`url`或者`jdbcUrl`的翻译,你可以像这样配置它: +```properties +app.datasource.url=jdbc:mysql://localhost/test +app.datasource.username=dbuser +app.datasource.password=dbpass +app.datasource.maximum-pool-size=30 +``` + +**注** 因为你自定义的配置选择使用Hikari,`app.datasource.type`将会失效。实际上,生成器将会被任何你设置在那儿的值初始化,然后被`.type()`的调用重写。 + +具体详情可参考“Spring Boot特性”章节中的[29.1. 配置数据源](https://docs.spring.io/spring-boot/docs/2.0.0.RELEASE/reference/htmlsingle/#boot-features-configure-datasource)和[`DataSourceAutoConfiguration`](https://github.com/spring-projects/spring-boot/tree/v2.0.0.RELEASE/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/jdbc/DataSourceAutoConfiguration.java)类源码。 diff --git "a/IX. \342\200\230How-to\342\200\231 guides/79.2 Configure Two DataSources.md" "b/IX. \342\200\230How-to\342\200\231 guides/79.2 Configure Two DataSources.md" new file mode 100644 index 00000000..39616377 --- /dev/null +++ "b/IX. \342\200\230How-to\342\200\231 guides/79.2 Configure Two DataSources.md" @@ -0,0 +1,69 @@ +### 79.2 配置两个数据源 + +如果你需要配置多个数据源,你可以应用上一节描述的技巧。但是,你必须把其中的一个`数据源`标注为`@Primary`,因为之后有各种不同的自动配置,至少需要通过类型得到一个。 + +如果你创建了你自己的`数据源`,自动配置将会后退。在下面的例子中,我们提供完全相同的特性,而不是自动配置提供的主要的数据源: +```java +@Bean +@Primary +@ConfigurationProperties("app.datasource.first") +public DataSourceProperties firstDataSourceProperties() { + return new DataSourceProperties(); +} + +@Bean +@Primary +@ConfigurationProperties("app.datasource.first") +public DataSource firstDataSource() { + return firstDataSourceProperties().initializeDataSourceBuilder().build(); +} + +@Bean +@ConfigurationProperties("app.datasource.second") +public BasicDataSource secondDataSource() { + return DataSourceBuilder.create().type(BasicDataSource.class).build(); +} +``` + +**提示** `firstDataSourceProperties`必须被标记为`@Primary`。这样,数据库初始化器特性会使用你的拷贝(如果你使用初始化器)。 + +两个数据源也都绑定到了高级的自定义。例如你应当如下配置它们: +```properties +app.datasource.first.type=com.zaxxer.hikari.HikariDataSource +app.datasource.first.maximum-pool-size=30 + +app.datasource.second.url=jdbc:mysql://localhost/test +app.datasource.second.username=dbuser +app.datasource.second.password=dbpass +app.datasource.second.max-total=30 +``` + +你也可以应用相同的观念到第二个`数据源`: +```java +@Bean +@Primary +@ConfigurationProperties("app.datasource.first") +public DataSourceProperties firstDataSourceProperties() { + return new DataSourceProperties(); +} + +@Bean +@Primary +@ConfigurationProperties("app.datasource.first") +public DataSource firstDataSource() { + return firstDataSourceProperties().initializeDataSourceBuilder().build(); +} + +@Bean +@ConfigurationProperties("app.datasource.second") +public DataSourceProperties secondDataSourceProperties() { + return new DataSourceProperties(); +} + +@Bean +@ConfigurationProperties("app.datasource.second") +public DataSource secondDataSource() { + return secondDataSourceProperties().initializeDataSourceBuilder().build(); +} +``` +这个最后的例子用相同的逻辑,在自定义的命名空间配置了两个数据源,而没有使用Spring Boot的自动配置。 From 024847e1038c71fee114e9ebf96f56dc6f62db80 Mon Sep 17 00:00:00 2001 From: Zhong Zengqiang Date: Mon, 20 Jan 2020 16:16:06 +0800 Subject: [PATCH 750/865] update Use Spring Data Repositories --- .../79.3 Use Spring Data Repositories.md" | 16 +++++++++------- SUMMARY.md | 2 +- 2 files changed, 10 insertions(+), 8 deletions(-) rename "IX. \342\200\230How-to\342\200\231 guides/77.3 Use Spring Data repositories.md" => "IX. \342\200\230How-to\342\200\231 guides/79.3 Use Spring Data Repositories.md" (58%) diff --git "a/IX. \342\200\230How-to\342\200\231 guides/77.3 Use Spring Data repositories.md" "b/IX. \342\200\230How-to\342\200\231 guides/79.3 Use Spring Data Repositories.md" similarity index 58% rename from "IX. \342\200\230How-to\342\200\231 guides/77.3 Use Spring Data repositories.md" rename to "IX. \342\200\230How-to\342\200\231 guides/79.3 Use Spring Data Repositories.md" index 3857dea9..8ff141eb 100644 --- "a/IX. \342\200\230How-to\342\200\231 guides/77.3 Use Spring Data repositories.md" +++ "b/IX. \342\200\230How-to\342\200\231 guides/79.3 Use Spring Data Repositories.md" @@ -1,7 +1,9 @@ -### 77.3 使用Spring Data仓库 - -Spring Data可以为你的`@Repository`接口创建各种风格的实现。Spring Boot会为你处理所有事情,只要那些`@Repositories`接口跟你的`@EnableAutoConfiguration`类处于相同的包(或子包)。 - -对于很多应用来说,你需要做的就是将正确的Spring Data依赖添加到classpath下(JPA对应`spring-boot-starter-data-jpa`,Mongodb对应`spring-boot-starter-data-mongodb`),创建一些repository接口来处理`@Entity`对象,相应示例可参考[JPA sample](https://github.com/spring-projects/spring-boot/tree/v2.0.0.RELEASE/spring-boot-samples/spring-boot-sample-data-jpa)或[Mongodb sample](https://github.com/spring-projects/spring-boot/tree/v2.0.0.RELEASE/spring-boot-samples/spring-boot-sample-data-mongodb)。 - -Spring Boot会基于它找到的`@EnableAutoConfiguration`来尝试猜测你的`@Repository`定义的位置。想要获取更多控制,可以使用`@EnableJpaRepositories`注解(来自Spring Data JPA)。 +### 79.3 使用Spring Data仓库 + +Spring Data可以为你的`@Repository`接口创建各种风格的实现。Spring Boot会为你处理所有事情,只要那些`@Repositories`接口跟你的`@EnableAutoConfiguration`类处于相同的包(或子包)。 + +对于很多应用来说,你需要做的就是将正确的Spring Data依赖添加到classpath下(JPA对应`spring-boot-starter-data-jpa`,Mongodb对应`spring-boot-starter-data-mongodb`),创建一些repository接口来处理`@Entity`对象。相应示例可参考[JPA样本](https://github.com/spring-projects/spring-boot/tree/v2.0.0.RELEASE/spring-boot-samples/spring-boot-sample-data-jpa)与[Mongodb样本](https://github.com/spring-projects/spring-boot/tree/v2.0.0.RELEASE/spring-boot-samples/spring-boot-sample-data-mongodb)。 + +Spring Boot会基于它找到的`@EnableAutoConfiguration`来尝试猜测你的`@Repository`定义的位置。想要获取更多控制,可以使用`@EnableJpaRepositories`注解(来自Spring Data JPA)。 + +有关Spring数据的更多信息,请参见Spring Data项目页面。 \ No newline at end of file diff --git a/SUMMARY.md b/SUMMARY.md index 2acd9e05..cfe69421 100644 --- a/SUMMARY.md +++ b/SUMMARY.md @@ -159,7 +159,7 @@ * [28.4 执行器安全](IV. Spring Boot features/28.4 Actuator Security.md) * [28.4.1 跨站请求伪造保护](IV. Spring Boot features/28.4.1 Cross Site Request Forgery Protection.md) * [29. 使用SQL数据库](IV. Spring Boot features/29. Working with SQL Databases.md) - * [29.1. 配置DataSource](IV. Spring Boot features/29.1. Configure a DataSource.md) + * [29.1. 配置数据源](IV. Spring Boot features/29.1. Configure a DataSource.md) * [29.1.1. 对内嵌数据库的支持](IV. Spring Boot features/29.1.1. Embedded Database Support.md) * [29.1.2. 连接生产环境数据库](IV. Spring Boot features/29.1.2. Connection to a Production Database.md) * [29.1.3. 连接JNDI数据库](IV. Spring Boot features/29.1.3. Connection to a JNDI DataSource.md) From e6ca623226bbdb8d20cc46b401b5641c0d6dec26 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E7=83=AD=E5=BF=83=E5=B8=82=E6=B0=91=E9=92=9F=E5=B0=8F?= =?UTF-8?q?=E5=BC=BA?= Date: Mon, 20 Jan 2020 16:17:38 +0800 Subject: [PATCH 751/865] Update 79.3 Use Spring Data Repositories.md --- .../79.3 Use Spring Data Repositories.md" | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git "a/IX. \342\200\230How-to\342\200\231 guides/79.3 Use Spring Data Repositories.md" "b/IX. \342\200\230How-to\342\200\231 guides/79.3 Use Spring Data Repositories.md" index 8ff141eb..e121e6c6 100644 --- "a/IX. \342\200\230How-to\342\200\231 guides/79.3 Use Spring Data Repositories.md" +++ "b/IX. \342\200\230How-to\342\200\231 guides/79.3 Use Spring Data Repositories.md" @@ -6,4 +6,4 @@ Spring Data可以为你的`@Repository`接口创建各种风格的实现。Sprin Spring Boot会基于它找到的`@EnableAutoConfiguration`来尝试猜测你的`@Repository`定义的位置。想要获取更多控制,可以使用`@EnableJpaRepositories`注解(来自Spring Data JPA)。 -有关Spring数据的更多信息,请参见Spring Data项目页面。 \ No newline at end of file +有关Spring数据的更多信息,请参见[Spring Data项目页面](https://projects.spring.io/spring-data/)。 From 282ae27662c389eed9e9e6cec034764f10b9426c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E7=83=AD=E5=BF=83=E5=B8=82=E6=B0=91=E9=92=9F=E5=B0=8F?= =?UTF-8?q?=E5=BC=BA?= Date: Wed, 22 Jan 2020 23:19:03 +0800 Subject: [PATCH 752/865] Update and rename 77.4 Separate @Entity definitions from Spring configuration.md to 79.4 Separate @Entity Definitions from Spring Configuration.md --- ...4 Separate @Entity Definitions from Spring Configuration.md" | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) rename "IX. \342\200\230How-to\342\200\231 guides/77.4 Separate @Entity definitions from Spring configuration.md" => "IX. \342\200\230How-to\342\200\231 guides/79.4 Separate @Entity Definitions from Spring Configuration.md" (83%) diff --git "a/IX. \342\200\230How-to\342\200\231 guides/77.4 Separate @Entity definitions from Spring configuration.md" "b/IX. \342\200\230How-to\342\200\231 guides/79.4 Separate @Entity Definitions from Spring Configuration.md" similarity index 83% rename from "IX. \342\200\230How-to\342\200\231 guides/77.4 Separate @Entity definitions from Spring configuration.md" rename to "IX. \342\200\230How-to\342\200\231 guides/79.4 Separate @Entity Definitions from Spring Configuration.md" index bbae22ea..0ad6d0aa 100644 --- "a/IX. \342\200\230How-to\342\200\231 guides/77.4 Separate @Entity definitions from Spring configuration.md" +++ "b/IX. \342\200\230How-to\342\200\231 guides/79.4 Separate @Entity Definitions from Spring Configuration.md" @@ -1,4 +1,4 @@ -### 77.4 从Spring配置分离`@Entity`定义 +### 79.4 从Spring配置分离`@Entity`定义 Spring Boot会基于它找到的`@EnableAutoConfiguration`来尝试猜测`@Entity`定义的位置,想要获取更多控制可以使用`@EntityScan`注解,比如: ```java From 7b24cfdbd5e75cca888c2d5720898264d327e1eb Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E7=83=AD=E5=BF=83=E5=B8=82=E6=B0=91=E9=92=9F=E5=B0=8F?= =?UTF-8?q?=E5=BC=BA?= Date: Wed, 22 Jan 2020 23:33:56 +0800 Subject: [PATCH 753/865] Update and rename 77.5 Configure JPA properties.md to 79.5 Configure JPA Properties.md --- .../77.5 Configure JPA properties.md" | 14 -------------- .../79.5 Configure JPA Properties.md" | 16 ++++++++++++++++ 2 files changed, 16 insertions(+), 14 deletions(-) delete mode 100644 "IX. \342\200\230How-to\342\200\231 guides/77.5 Configure JPA properties.md" create mode 100644 "IX. \342\200\230How-to\342\200\231 guides/79.5 Configure JPA Properties.md" diff --git "a/IX. \342\200\230How-to\342\200\231 guides/77.5 Configure JPA properties.md" "b/IX. \342\200\230How-to\342\200\231 guides/77.5 Configure JPA properties.md" deleted file mode 100644 index cc5b306d..00000000 --- "a/IX. \342\200\230How-to\342\200\231 guides/77.5 Configure JPA properties.md" +++ /dev/null @@ -1,14 +0,0 @@ -### 77.5 配置JPA属性 - -Spring Data JPA已经提供了一些独立的配置选项(比如,针对SQL日志),并且Spring Boot会暴露它们,针对hibernate的外部配置属性也更多些。它们中的一些会通过上下文,被自动探测到,所以你不需要设置它们。 - -`spring.jpa.hibernate.ddl-auto`比较特殊,因为它会根据你是(`create-drop`)否(`none`)正在使用一个内嵌的数据库,有不同的默认值。使用的方言也会基于目前的`数据源`被自动地探测到。但是如果你想要在启动时清楚明白,避开这种选择,你可以自己设置`spring.jpa.database`。 - -**提示** 🈯️定一个`数据库`是配置Hibernate方言的一种很好的方式。多个数据库有多种方言,这可能不符合你的需求。在那种情况下,你既可以把`spring.jpa.database`设置为`default`,来让Hibernate搞定一切,也可以使用`spring.jpa.database-platform`属性来设置方言。 - -最常见的选项如下: -```properties -spring.jpa.hibernate.naming.physical-strategy=com.example.MyPhysicalNamingStrategy -spring.jpa.show-sql=true -``` -此外,当本地的`EntityManagerFactory`被创建时,`spring.jpa.properties.*`里的所有属性会作为正常的JPA属性(前缀除去)被传递。 \ No newline at end of file diff --git "a/IX. \342\200\230How-to\342\200\231 guides/79.5 Configure JPA Properties.md" "b/IX. \342\200\230How-to\342\200\231 guides/79.5 Configure JPA Properties.md" new file mode 100644 index 00000000..321bb7fc --- /dev/null +++ "b/IX. \342\200\230How-to\342\200\231 guides/79.5 Configure JPA Properties.md" @@ -0,0 +1,16 @@ +### 79.5 配置JPA属性 + +Spring Data JPA已经提供了一些独立的配置选项(比如,针对SQL日志),并且Spring Boot会暴露它们,针对Hibernate的外部配置属性也更多些。它们中的一些会通过上下文,被自动探测到,所以你不需要设置它们。 + +`spring.jpa.hibernate.ddl-auto`比较特殊。因为根据运行条件的不同,它会有不同的默认值。如果使用嵌入式数据库,而没有模式管理器(如Liquibase或Flyway)处理`数据源`,则默认为`create-drop`。在所有其他情况下,它默认为`none`。使用的方言也会基于目前的`数据源`被自动地探测到。但是如果你想要在启动时清楚明白,避开这种选择,你可以自己设置`spring.jpa.database`。 + +**注** 指定一个`数据库`是配置Hibernate方言的一种很好的方式。多个数据库有多种方言,这可能不符合你的需求。在那种情况下,你既可以把`spring.jpa.database`设置为`default`,来让Hibernate搞定一切,也可以使用`spring.jpa.database-platform`属性来设置方言。 + +最常见的选项如下: +```properties +spring.jpa.hibernate.naming.physical-strategy=com.example.MyPhysicalNamingStrategy +spring.jpa.show-sql=true +``` +此外,当本地的`EntityManagerFactory`被创建时,`spring.jpa.properties.*`里的所有属性会作为正常的JPA属性(前缀除去)被传递。 + +**注** 如果需要对Hibernate属性应用高级定制,可以考虑注册一个`HibernatePropertiesCustomizer` bean。它将在创建`EntityManagerFactory`之前被调用。这优先于自动配置所应用的任何内容。 From e758ede3d73c35d08be83038e745b86d46e0da4d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E7=83=AD=E5=BF=83=E5=B8=82=E6=B0=91=E9=92=9F=E5=B0=8F?= =?UTF-8?q?=E5=BC=BA?= Date: Wed, 22 Jan 2020 23:45:37 +0800 Subject: [PATCH 754/865] Update and rename 77.6 Configure Hibernate Naming Strategy.md to 79.6 Configure Hibernate Naming Strategy.md --- ....6 Configure Hibernate Naming Strategy.md" | 9 -------- ....6 Configure Hibernate Naming Strategy.md" | 22 +++++++++++++++++++ 2 files changed, 22 insertions(+), 9 deletions(-) delete mode 100644 "IX. \342\200\230How-to\342\200\231 guides/77.6 Configure Hibernate Naming Strategy.md" create mode 100644 "IX. \342\200\230How-to\342\200\231 guides/79.6 Configure Hibernate Naming Strategy.md" diff --git "a/IX. \342\200\230How-to\342\200\231 guides/77.6 Configure Hibernate Naming Strategy.md" "b/IX. \342\200\230How-to\342\200\231 guides/77.6 Configure Hibernate Naming Strategy.md" deleted file mode 100644 index b88c57ed..00000000 --- "a/IX. \342\200\230How-to\342\200\231 guides/77.6 Configure Hibernate Naming Strategy.md" +++ /dev/null @@ -1,9 +0,0 @@ -### 77.6 配置Hibernate命名策略 - -Hibernate 5定义了一个`Physical`和`Implicit`命名策略。Spring Boot默认配置`SpringPhysicalNamingStrategy`,该实现提供跟Hibernate 4相同的表结构:all dots are replaced by underscores and camel cases are replaced by underscores as well. By default, all table names are generated in lower case but it is possible to override that flag if your schema requires it. -Concretely, a TelephoneNumber entity will be mapped to the telephone_number table. -如果你情愿使用Hibernate 5默认的,可以设置以下属性: -```properties -spring.jpa.hibernate.naming.physical-strategy=org.hibernate.boot.model.naming.PhysicalNamingStrategyStandardImpl -``` -具体详情可参考[HibernateJpaAutoConfiguration](https://github.com/spring-projects/spring-boot/tree/v2.0.0.RELEASE/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/orm/jpa/HibernateJpaAutoConfiguration.java)和[JpaBaseConfiguration](https://github.com/spring-projects/spring-boot/tree/v2.0.0.RELEASE/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/orm/jpa/JpaBaseConfiguration.java)。 \ No newline at end of file diff --git "a/IX. \342\200\230How-to\342\200\231 guides/79.6 Configure Hibernate Naming Strategy.md" "b/IX. \342\200\230How-to\342\200\231 guides/79.6 Configure Hibernate Naming Strategy.md" new file mode 100644 index 00000000..87df1652 --- /dev/null +++ "b/IX. \342\200\230How-to\342\200\231 guides/79.6 Configure Hibernate Naming Strategy.md" @@ -0,0 +1,22 @@ +### 79.6 配置Hibernate命名策略 + +Hibernate使用[两种不同的命名策略](https://docs.jboss.org/hibernate/orm/5.2/userguide/html_single/Hibernate_User_Guide.html#naming)将对象模型的名称映射到相应的数据库名称。可以通过设置`spring.jpa.hibernate.naming.physical-strategy`和`spring.jpa.hibernate.naming.implicit-strategy`属性来配置物理和隐式策略实现的完全限定类名。或者,如果应用程序上下文中有`ImplicitNamingStrategy`或`PhysicalNamingStrategy` bean可用,Hibernate将自动配置为使用它们。 + +默认情况下,Spring Boot使用`SpringPhysicalNamingStrategy`配置物理命名策略。这个实现提供了与Hibernate 4相同的表结构:所有的点都用下划线替换,驼峰式大小写也用下划线替换。默认情况下,所有表名都是用小写字母生成的,但是如果您的模式需要,可以覆盖该标志。 + +例如,`TelephoneNumber`实体映射到`telephone_number`表。 + +如果你更喜欢使用Hibernate 5的默认设置,设置如下属性: +```properties +spring.jpa.hibernate.naming.physical-strategy=org.hibernate.boot.model.naming.PhysicalNamingStrategyStandardImpl +``` + +或者,你可以配置以下bean: +```java +@Bean +public PhysicalNamingStrategy physicalNamingStrategy() { + return new PhysicalNamingStrategyStandardImpl(); +} +``` + +具体详情可参考[HibernateJpaAutoConfiguration](https://github.com/spring-projects/spring-boot/tree/v2.0.0.RELEASE/spring-boot-project/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/orm/jpa/HibernateJpaAutoConfiguration.java)和[JpaBaseConfiguration](https://github.com/spring-projects/spring-boot/tree/v2.0.0.RELEASE/spring-boot-project/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/orm/jpa/JpaBaseConfiguration.java)。 From db9d45173d3883dedb36eedf454dd925d1f54afa Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E7=83=AD=E5=BF=83=E5=B8=82=E6=B0=91=E9=92=9F=E5=B0=8F?= =?UTF-8?q?=E5=BC=BA?= Date: Tue, 28 Jan 2020 20:14:29 +0800 Subject: [PATCH 755/865] Update and rename 77.7 Use a custom EntityManagerFactory.md to 79.7 Use a Custom EntityManagerFactory.md --- .../79.7 Use a Custom EntityManagerFactory.md" | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) rename "IX. \342\200\230How-to\342\200\231 guides/77.7 Use a custom EntityManagerFactory.md" => "IX. \342\200\230How-to\342\200\231 guides/79.7 Use a Custom EntityManagerFactory.md" (59%) diff --git "a/IX. \342\200\230How-to\342\200\231 guides/77.7 Use a custom EntityManagerFactory.md" "b/IX. \342\200\230How-to\342\200\231 guides/79.7 Use a Custom EntityManagerFactory.md" similarity index 59% rename from "IX. \342\200\230How-to\342\200\231 guides/77.7 Use a custom EntityManagerFactory.md" rename to "IX. \342\200\230How-to\342\200\231 guides/79.7 Use a Custom EntityManagerFactory.md" index 63454797..6e872c9c 100644 --- "a/IX. \342\200\230How-to\342\200\231 guides/77.7 Use a custom EntityManagerFactory.md" +++ "b/IX. \342\200\230How-to\342\200\231 guides/79.7 Use a Custom EntityManagerFactory.md" @@ -1,3 +1,3 @@ -### 77.7 使用自定义EntityManagerFactory +### 79.7 使用自定义EntityManagerFactory -为了完全控制`EntityManagerFactory`的配置,你需要添加一个名为`entityManagerFactory`的`@Bean`,Spring Boot自动配置会根据是否存在该类型的bean来关闭它的实体管理器(entity manager)。 +为了完全控制`EntityManagerFactory`的配置,你需要添加一个名为`entityManagerFactory`的`@Bean`。Spring Boot自动配置会根据是否存在该类型的bean来关闭它的实体管理器(entity manager)。 From f6f99278c73904a96d27878c8ee6dbcb07cccdc9 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E7=83=AD=E5=BF=83=E5=B8=82=E6=B0=91=E9=92=9F=E5=B0=8F?= =?UTF-8?q?=E5=BC=BA?= Date: Tue, 28 Jan 2020 20:19:53 +0800 Subject: [PATCH 756/865] Update and rename 77.8 Use Two EntityManagers.md to 79.8 Use Two EntityManagers.md --- .../79.8 Use Two EntityManagers.md" | 34 +++++++++---------- 1 file changed, 17 insertions(+), 17 deletions(-) rename "IX. \342\200\230How-to\342\200\231 guides/77.8 Use Two EntityManagers.md" => "IX. \342\200\230How-to\342\200\231 guides/79.8 Use Two EntityManagers.md" (66%) diff --git "a/IX. \342\200\230How-to\342\200\231 guides/77.8 Use Two EntityManagers.md" "b/IX. \342\200\230How-to\342\200\231 guides/79.8 Use Two EntityManagers.md" similarity index 66% rename from "IX. \342\200\230How-to\342\200\231 guides/77.8 Use Two EntityManagers.md" rename to "IX. \342\200\230How-to\342\200\231 guides/79.8 Use Two EntityManagers.md" index 600d52f5..9690b8df 100644 --- "a/IX. \342\200\230How-to\342\200\231 guides/77.8 Use Two EntityManagers.md" +++ "b/IX. \342\200\230How-to\342\200\231 guides/79.8 Use Two EntityManagers.md" @@ -1,4 +1,4 @@ -### 77.8 使用两个EntityManagers +### 79.8 使用两个EntityManagers 即使默认的`EntityManagerFactory`工作的很好,你也需要定义一个新的`EntityManagerFactory`,因为一旦出现第二个该类型的bean,默认的将会被关闭。为了轻松的实现该操作,你可以使用Spring Boot提供的`EntityManagerBuilder`,或者如果你喜欢的话可以直接使用来自Spring ORM的`LocalContainerEntityManagerFactoryBean`。 @@ -8,22 +8,22 @@ @Bean public LocalContainerEntityManagerFactoryBean customerEntityManagerFactory( - EntityManagerFactoryBuilder builder) { - return builder - .dataSource(customerDataSource()) - .packages(Customer.class) - .persistenceUnit("customers") - .build(); + EntityManagerFactoryBuilder builder) { + return builder + .dataSource(customerDataSource()) + .packages(Customer.class) + .persistenceUnit("customers") + .build(); } @Bean public LocalContainerEntityManagerFactoryBean orderEntityManagerFactory( - EntityManagerFactoryBuilder builder) { - return builder - .dataSource(orderDataSource()) - .packages(Order.class) - .persistenceUnit("orders") - .build(); + EntityManagerFactoryBuilder builder) { + return builder + .dataSource(orderDataSource()) + .packages(Order.class) + .persistenceUnit("orders") + .build(); } ``` 上面的配置靠自己基本可以运行,想要完成作品你还需要为两个`EntityManagers`配置`TransactionManagers`。其中的一个会被Spring Boot默认的`JpaTransactionManager`获取,如果你将它标记为`@Primary`。另一个需要显式注入到一个新实例。或你可以使用一个JTA事物管理器生成它两个。 @@ -32,15 +32,15 @@ public LocalContainerEntityManagerFactoryBean orderEntityManagerFactory( ```java @Configuration @EnableJpaRepositories(basePackageClasses = Customer.class, - entityManagerFactoryRef = "customerEntityManagerFactory") + entityManagerFactoryRef = "customerEntityManagerFactory") public class CustomerConfiguration { - ... + ... } @Configuration @EnableJpaRepositories(basePackageClasses = Order.class, - entityManagerFactoryRef = "orderEntityManagerFactory") + entityManagerFactoryRef = "orderEntityManagerFactory") public class OrderConfiguration { - ... + ... } ``` From ec23b6a12d6377266daac036aa0ec567e89e4b83 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E7=83=AD=E5=BF=83=E5=B8=82=E6=B0=91=E9=92=9F=E5=B0=8F?= =?UTF-8?q?=E5=BC=BA?= Date: Tue, 28 Jan 2020 20:22:17 +0800 Subject: [PATCH 757/865] Update and rename 77.9 Use a traditional persistence.xml.md to 79.9 Use a Traditional persistence.xml File.md --- .../79.9 Use a Traditional persistence.xml File.md" | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) rename "IX. \342\200\230How-to\342\200\231 guides/77.9 Use a traditional persistence.xml.md" => "IX. \342\200\230How-to\342\200\231 guides/79.9 Use a Traditional persistence.xml File.md" (52%) diff --git "a/IX. \342\200\230How-to\342\200\231 guides/77.9 Use a traditional persistence.xml.md" "b/IX. \342\200\230How-to\342\200\231 guides/79.9 Use a Traditional persistence.xml File.md" similarity index 52% rename from "IX. \342\200\230How-to\342\200\231 guides/77.9 Use a traditional persistence.xml.md" rename to "IX. \342\200\230How-to\342\200\231 guides/79.9 Use a Traditional persistence.xml File.md" index 40c3bc70..73ff36ae 100644 --- "a/IX. \342\200\230How-to\342\200\231 guides/77.9 Use a traditional persistence.xml.md" +++ "b/IX. \342\200\230How-to\342\200\231 guides/79.9 Use a Traditional persistence.xml File.md" @@ -1,3 +1,3 @@ -### 77.9 使用普通的persistence.xml +### 79.9 使用传统的persistence.xml文件 -Spring不要求使用XML配置JPA提供者(provider),并且Spring Boot假定你想要充分利用该特性。如果你倾向于使用`persistence.xml`,那你需要定义你自己的id为`entityManagerFactory`的`LocalEntityManagerFactoryBean`类型的`@Bean`,并在那设置持久化单元的名称,默认设置可查看[JpaBaseConfiguration](https://github.com/spring-projects/spring-boot/blob/master/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/orm/jpa/JpaBaseConfiguration.java)。 +Spring不要求使用XML配置JPA提供者(provider),并且Spring Boot假定你想要充分利用该特性。如果你倾向于使用`persistence.xml`,那你需要定义你自己的ID为`entityManagerFactory`的`LocalEntityManagerFactoryBean`类型的`@Bean`,并在那设置持久化单元的名称,默认设置可查看[JpaBaseConfiguration](https://github.com/spring-projects/spring-boot/tree/v2.0.0.RELEASE/spring-boot-project/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/orm/jpa/JpaBaseConfiguration.java)。 From 142cbea1e9b0b375b071b83e5f9fc014185e570e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E7=83=AD=E5=BF=83=E5=B8=82=E6=B0=91=E9=92=9F=E5=B0=8F?= =?UTF-8?q?=E5=BC=BA?= Date: Tue, 28 Jan 2020 20:23:00 +0800 Subject: [PATCH 758/865] Update SUMMARY.md --- SUMMARY.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/SUMMARY.md b/SUMMARY.md index cfe69421..749d0819 100644 --- a/SUMMARY.md +++ b/SUMMARY.md @@ -514,7 +514,7 @@ * [79.6 配置Hibernate命名策略](IX. ‘How-to’ guides/79.6 Configure Hibernate Naming Strategy.md) * [79.7 使用自定义EntityManagerFactory](IX. ‘How-to’ guides/79.7 Use a Custom EntityManagerFactory.md) * [79.8 使用两个EntityManagers](IX. ‘How-to’ guides/79.8 Use Two EntityManagers.md) - * [79.9 使用普通的persistence.xml文件](IX. ‘How-to’ guides/79.9 Use a Traditional persistence.xml File.md) + * [79.9 使用传统的persistence.xml文件](IX. ‘How-to’ guides/79.9 Use a Traditional persistence.xml File.md) * [79.10 使用Spring Data JPA和Mongo仓库](IX. ‘How-to’ guides/79.10 Use Spring Data JPA and Mongo Repositories.md) * [79.11 将Spring Data仓库暴露为REST端点](IX. ‘How-to’ guides/79.11 Expose Spring Data Repositories as REST Endpoint.md) * [79.12 配置JPA使用的组件](IX. ‘How-to’ guides/79.12 Configure a Component that is Used by JPA.md) From f61af4f23fce3614db94a0d7c9efd632016d5be6 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E7=83=AD=E5=BF=83=E5=B8=82=E6=B0=91=E9=92=9F=E5=B0=8F?= =?UTF-8?q?=E5=BC=BA?= Date: Tue, 28 Jan 2020 20:33:24 +0800 Subject: [PATCH 759/865] Update and rename 77.10 Use Spring Data JPA and Mongo repositories.md to 79.10 Use Spring Data JPA and Mongo Repositories.md --- .../77.10 Use Spring Data JPA and Mongo repositories.md" | 7 ------- .../79.10 Use Spring Data JPA and Mongo Repositories.md" | 7 +++++++ 2 files changed, 7 insertions(+), 7 deletions(-) delete mode 100644 "IX. \342\200\230How-to\342\200\231 guides/77.10 Use Spring Data JPA and Mongo repositories.md" create mode 100644 "IX. \342\200\230How-to\342\200\231 guides/79.10 Use Spring Data JPA and Mongo Repositories.md" diff --git "a/IX. \342\200\230How-to\342\200\231 guides/77.10 Use Spring Data JPA and Mongo repositories.md" "b/IX. \342\200\230How-to\342\200\231 guides/77.10 Use Spring Data JPA and Mongo repositories.md" deleted file mode 100644 index bae5c48b..00000000 --- "a/IX. \342\200\230How-to\342\200\231 guides/77.10 Use Spring Data JPA and Mongo repositories.md" +++ /dev/null @@ -1,7 +0,0 @@ -### 77.10 使用Spring Data JPA和Mongo仓库 - -Spring Data JPA和Spring Data Mongo都能自动为你创建`Repository`实现。如果它们同时出现在classpath下,你可能需要添加额外的配置来告诉Spring Boot你想要哪个(或两个)为你创建仓库。最明确地方式是使用标准的Spring Data `@Enable*Repositories`,然后告诉它你的`Repository`接口的位置(此处`*`即可以是Jpa,也可以是Mongo,或者两者都是)。 - -这里也有`spring.data.*.repositories.enabled`标志,可用来在外部配置中开启或关闭仓库的自动配置,这在你想关闭Mongo仓库但仍使用自动配置的`MongoTemplate`时非常有用。 - -相同的障碍和特性也存在于其他自动配置的Spring Data仓库类型(Elasticsearch, Solr),只需要改变对应注解的名称和标志。 diff --git "a/IX. \342\200\230How-to\342\200\231 guides/79.10 Use Spring Data JPA and Mongo Repositories.md" "b/IX. \342\200\230How-to\342\200\231 guides/79.10 Use Spring Data JPA and Mongo Repositories.md" new file mode 100644 index 00000000..41c75cfa --- /dev/null +++ "b/IX. \342\200\230How-to\342\200\231 guides/79.10 Use Spring Data JPA and Mongo Repositories.md" @@ -0,0 +1,7 @@ +### 79.10 使用Spring Data JPA和Mongo仓库 + +Spring Data JPA和Spring Data Mongo都能自动为你创建`Repository`实现。如果它们同时出现在类路径下,你可能需要添加额外的配置来告诉Spring Boot你想要创建哪个仓库。最明确的方式是使用标准的Spring Data `@EnableJpaRepositories`与`@EnableMongoRepositories`,然后提供它你的`Repository`接口的位置。 + +这里也有`spring.data.*.repositories.enabled`与`spring.data.*.repositories.type`标志,可用来在外部配置中开启或关闭仓库的自动配置。这在你想关闭Mongo仓库但仍使用自动配置的`MongoTemplate`时非常有用。 + +相同的障碍和特性也存在于其他自动配置的Spring Data仓库类型(Elasticsearch、Solr等),只需要改变对应注解的名称和标志。 From ac38c8c65716c56e6eeb68203711ea1bf3f73ba3 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E7=83=AD=E5=BF=83=E5=B8=82=E6=B0=91=E9=92=9F=E5=B0=8F?= =?UTF-8?q?=E5=BC=BA?= Date: Tue, 28 Jan 2020 20:37:46 +0800 Subject: [PATCH 760/865] Update and rename 77.11 Expose Spring Data repositories as REST endpoint.md to 79.11 Expose Spring Data Repositories as REST Endpoint.md --- ...7.11 Expose Spring Data repositories as REST endpoint.md" | 5 ----- ...9.11 Expose Spring Data Repositories as REST Endpoint.md" | 5 +++++ 2 files changed, 5 insertions(+), 5 deletions(-) delete mode 100644 "IX. \342\200\230How-to\342\200\231 guides/77.11 Expose Spring Data repositories as REST endpoint.md" create mode 100644 "IX. \342\200\230How-to\342\200\231 guides/79.11 Expose Spring Data Repositories as REST Endpoint.md" diff --git "a/IX. \342\200\230How-to\342\200\231 guides/77.11 Expose Spring Data repositories as REST endpoint.md" "b/IX. \342\200\230How-to\342\200\231 guides/77.11 Expose Spring Data repositories as REST endpoint.md" deleted file mode 100644 index ccc1bde4..00000000 --- "a/IX. \342\200\230How-to\342\200\231 guides/77.11 Expose Spring Data repositories as REST endpoint.md" +++ /dev/null @@ -1,5 +0,0 @@ -### 77.11 将Spring Data仓库暴露为REST端点 - -Spring Data REST能够将`Repository`的实现暴露为REST端点,只要该应用启用Spring MVC。Spring Boot暴露一系列来自`spring.data.rest`命名空间的有用属性来定制化[`RepositoryRestConfiguration`](http://docs.spring.io/spring-data/rest/docs/current/api/org/springframework/data/rest/core/config/RepositoryRestConfiguration.html),你可以使用[`RepositoryRestConfigurer`](http://docs.spring.io/spring-data/rest/docs/current/api/org/springframework/data/rest/webmvc/config/RepositoryRestConfigurer.html)提供其他定制。 - -**注** 如果你不在你自定义的`RepositoryRestConfigurer`上指定顺序,它将会在Spring Boot内部使用的那个之后运行。如果你需要指定顺序,确保它比0高。 diff --git "a/IX. \342\200\230How-to\342\200\231 guides/79.11 Expose Spring Data Repositories as REST Endpoint.md" "b/IX. \342\200\230How-to\342\200\231 guides/79.11 Expose Spring Data Repositories as REST Endpoint.md" new file mode 100644 index 00000000..820bcc2a --- /dev/null +++ "b/IX. \342\200\230How-to\342\200\231 guides/79.11 Expose Spring Data Repositories as REST Endpoint.md" @@ -0,0 +1,5 @@ +### 79.11 将Spring Data仓库暴露为REST端点 + +Spring Data REST能够将`Repository`的实现暴露为REST端点,只要该应用启用Spring MVC。Spring Boot暴露一系列来自`spring.data.rest`命名空间的有用属性来定制化[`RepositoryRestConfiguration`](https://docs.spring.io/spring-data/rest/docs/current/api/org/springframework/data/rest/core/config/RepositoryRestConfiguration.html),你可以使用[`RepositoryRestConfigurer`](https://docs.spring.io/spring-data/rest/docs/current/api/org/springframework/data/rest/webmvc/config/RepositoryRestConfigurer.html)提供其他定制。 + +**注** 如果你不在你自定义的`RepositoryRestConfigurer`上指定顺序,它将会在Spring Boot内部使用的那个之后运行。如果你需要指定顺序,确保它比0高。 From aef6aa29ffc41b9d0cae5bf01d1d355abaf763c6 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E7=83=AD=E5=BF=83=E5=B8=82=E6=B0=91=E9=92=9F=E5=B0=8F?= =?UTF-8?q?=E5=BC=BA?= Date: Tue, 28 Jan 2020 20:45:09 +0800 Subject: [PATCH 761/865] Update and rename 77.12 Configure a component that is used by JPA.md to 79.12 Configure a Component that is Used by JPA.md --- ...79.12 Configure a Component that is Used by JPA.md" | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) rename "IX. \342\200\230How-to\342\200\231 guides/77.12 Configure a component that is used by JPA.md" => "IX. \342\200\230How-to\342\200\231 guides/79.12 Configure a Component that is Used by JPA.md" (81%) diff --git "a/IX. \342\200\230How-to\342\200\231 guides/77.12 Configure a component that is used by JPA.md" "b/IX. \342\200\230How-to\342\200\231 guides/79.12 Configure a Component that is Used by JPA.md" similarity index 81% rename from "IX. \342\200\230How-to\342\200\231 guides/77.12 Configure a component that is used by JPA.md" rename to "IX. \342\200\230How-to\342\200\231 guides/79.12 Configure a Component that is Used by JPA.md" index b2fe0547..f09004c8 100644 --- "a/IX. \342\200\230How-to\342\200\231 guides/77.12 Configure a component that is used by JPA.md" +++ "b/IX. \342\200\230How-to\342\200\231 guides/79.12 Configure a Component that is Used by JPA.md" @@ -1,4 +1,4 @@ -### 77.12 配置JPA使用的组件 +### 79.12 配置JPA使用的组件 如果想配置一个JPA使用的组件,你需要确保该组件在JPA之前初始化。组件如果是Spring Boot自动配置的,Spring Boot会为你处理。例如,Flyway是自动配置的,Hibernate依赖于Flyway,这样Hibernate有机会在使用数据库前对其进行初始化。 @@ -10,11 +10,11 @@ */ @Configuration static class ElasticsearchJpaDependencyConfiguration - extends EntityManagerFactoryDependsOnPostProcessor { + extends EntityManagerFactoryDependsOnPostProcessor { - ElasticsearchJpaDependencyConfiguration() { - super("elasticsearchClient"); - } + ElasticsearchJpaDependencyConfiguration() { + super("elasticsearchClient"); + } } ``` From d3c837ccda8ef45f8cadca6339388eb4290d4fc4 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E7=83=AD=E5=BF=83=E5=B8=82=E6=B0=91=E9=92=9F=E5=B0=8F?= =?UTF-8?q?=E5=BC=BA?= Date: Tue, 28 Jan 2020 20:50:37 +0800 Subject: [PATCH 762/865] Create 79.13 Configure jOOQ with Two DataSources.md --- .../79.13 Configure jOOQ with Two DataSources.md" | 5 +++++ 1 file changed, 5 insertions(+) create mode 100644 "IX. \342\200\230How-to\342\200\231 guides/79.13 Configure jOOQ with Two DataSources.md" diff --git "a/IX. \342\200\230How-to\342\200\231 guides/79.13 Configure jOOQ with Two DataSources.md" "b/IX. \342\200\230How-to\342\200\231 guides/79.13 Configure jOOQ with Two DataSources.md" new file mode 100644 index 00000000..682b0dc7 --- /dev/null +++ "b/IX. \342\200\230How-to\342\200\231 guides/79.13 Configure jOOQ with Two DataSources.md" @@ -0,0 +1,5 @@ +### 79.13 使用两个数据源配置jOOQ + +如果需要对多个数据源使用jOOQ,应该为每个数据源创建自己的`DSLContext`。更多细节请参考[JooqAutoConfiguration](https://github.com/spring-projects/spring-boot/tree/v2.0.0.RELEASE/spring-boot-project/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/jooq/JooqAutoConfiguration.java)。 + +**注** 特别是,可以重用`JooqExceptionTranslator`和`SpringTransactionProvider`来提供与单个`数据源`的自动配置类似的功能。 From 84dcd309cb6845177d8f060c6ce76583e2b1fb4a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E7=83=AD=E5=BF=83=E5=B8=82=E6=B0=91=E9=92=9F=E5=B0=8F?= =?UTF-8?q?=E5=BC=BA?= Date: Tue, 28 Jan 2020 21:11:59 +0800 Subject: [PATCH 763/865] Update SUMMARY.md --- SUMMARY.md | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/SUMMARY.md b/SUMMARY.md index 749d0819..fda60b0e 100644 --- a/SUMMARY.md +++ b/SUMMARY.md @@ -519,14 +519,14 @@ * [79.11 将Spring Data仓库暴露为REST端点](IX. ‘How-to’ guides/79.11 Expose Spring Data Repositories as REST Endpoint.md) * [79.12 配置JPA使用的组件](IX. ‘How-to’ guides/79.12 Configure a Component that is Used by JPA.md) * [79.13 使用两个数据源配置jOOQ](IX. ‘How-to’ guides/79.13. Configure jOOQ with Two DataSources.md) - * [78. 数据库初始化](IX. ‘How-to’ guides/78. Database initialization.md) - * [78.1 使用JPA初始化数据库](IX. ‘How-to’ guides/78.1 Initialize a database using JPA.md) - * [78.2 使用Hibernate初始化数据库](IX. ‘How-to’ guides/78.2 Initialize a database using Hibernate.md) - * [78.3 使用Spring JDBC初始化数据库](IX. ‘How-to’ guides/78.3 Initialize a database using Spring JDBC.md) - * [78.4 初始化Spring Batch数据库](IX. ‘How-to’ guides/78.4 Initialize a Spring Batch database.md) - * [78.5 使用高级数据迁移工具](IX. ‘How-to’ guides/78.5 Use a higher level database migration tool.md) - * [78.5.1 启动时执行Flyway数据库迁移](IX. ‘How-to’ guides/78.5.1 Execute Flyway database migrations on startup.md) - * [78.5.2 启动时执行Liquibase数据库迁移](IX. ‘How-to’ guides/78.5.2 Execute Liquibase database migrations on startup.md) + * [80. 数据库初始化](IX. ‘How-to’ guides/80. Database Initialization.md) + * [80.1 使用JPA初始化数据库](IX. ‘How-to’ guides/80.1 Initialize a Database Using JPA.md) + * [80.2 使用Hibernate初始化数据库](IX. ‘How-to’ guides/80.2 Initialize a Database Using Hibernate.md) + * [80.3 初始化数据库](IX. ‘How-to’ guides/80.3 Initialize a Database.md) + * [80.4 初始化Spring Batch数据库](IX. ‘How-to’ guides/80.4 Initialize a Spring Batch Database.md) + * [80.5 使用高级数据迁移工具](IX. ‘How-to’ guides/80.5 Use a Higher-level Database Migration Tool.md) + * [80.5.1 启动时执行Flyway数据库迁移](IX. ‘How-to’ guides/80.5.1 Execute Flyway Database Migrations on Startup.md) + * [80.5.2 启动时执行Liquibase数据库迁移](IX. ‘How-to’ guides/80.5.2 Execute Liquibase Database Migrations on Startup.md) * [79. 消息传送](IX. ‘How-to’ guides/79. Messaging.md) * [79.1 禁用事务JMS会话](IX. ‘How-to’ guides/79.1 Disable transacted JMS session.md) * [80. 批处理应用](IX. ‘How-to’ guides/80. Batch applications.md) From 2a8560d2bd88a3bdc82116eabd6fd6671193b652 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E7=83=AD=E5=BF=83=E5=B8=82=E6=B0=91=E9=92=9F=E5=B0=8F?= =?UTF-8?q?=E5=BC=BA?= Date: Tue, 28 Jan 2020 21:17:09 +0800 Subject: [PATCH 764/865] Update and rename 78. Database initialization.md to 80. Database Initialization.md --- .../78. Database initialization.md" | 3 --- .../80. Database Initialization.md" | 3 +++ 2 files changed, 3 insertions(+), 3 deletions(-) delete mode 100644 "IX. \342\200\230How-to\342\200\231 guides/78. Database initialization.md" create mode 100644 "IX. \342\200\230How-to\342\200\231 guides/80. Database Initialization.md" diff --git "a/IX. \342\200\230How-to\342\200\231 guides/78. Database initialization.md" "b/IX. \342\200\230How-to\342\200\231 guides/78. Database initialization.md" deleted file mode 100644 index b30eb3a1..00000000 --- "a/IX. \342\200\230How-to\342\200\231 guides/78. Database initialization.md" +++ /dev/null @@ -1,3 +0,0 @@ -### 78. 数据库初始化 - -一个数据库可以使用不同的方式进行初始化,这取决于你的技术栈。或者你可以手动完成该任务,只要数据库是单独的过程。 diff --git "a/IX. \342\200\230How-to\342\200\231 guides/80. Database Initialization.md" "b/IX. \342\200\230How-to\342\200\231 guides/80. Database Initialization.md" new file mode 100644 index 00000000..eaf5bf38 --- /dev/null +++ "b/IX. \342\200\230How-to\342\200\231 guides/80. Database Initialization.md" @@ -0,0 +1,3 @@ +### 80. 数据库初始化 + +一个数据库可以使用不同的方式进行初始化,这取决于你的技术栈。当然,你可以手动完成该任务,只要数据库是单独的过程。 From 08f792d82eb95c31daee1e2c144370bab981d2c0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E7=83=AD=E5=BF=83=E5=B8=82=E6=B0=91=E9=92=9F=E5=B0=8F?= =?UTF-8?q?=E5=BC=BA?= Date: Tue, 28 Jan 2020 21:22:42 +0800 Subject: [PATCH 765/865] Update SUMMARY.md --- SUMMARY.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/SUMMARY.md b/SUMMARY.md index fda60b0e..634e4f42 100644 --- a/SUMMARY.md +++ b/SUMMARY.md @@ -518,7 +518,7 @@ * [79.10 使用Spring Data JPA和Mongo仓库](IX. ‘How-to’ guides/79.10 Use Spring Data JPA and Mongo Repositories.md) * [79.11 将Spring Data仓库暴露为REST端点](IX. ‘How-to’ guides/79.11 Expose Spring Data Repositories as REST Endpoint.md) * [79.12 配置JPA使用的组件](IX. ‘How-to’ guides/79.12 Configure a Component that is Used by JPA.md) - * [79.13 使用两个数据源配置jOOQ](IX. ‘How-to’ guides/79.13. Configure jOOQ with Two DataSources.md) + * [79.13 使用两个数据源配置jOOQ](IX. ‘How-to’ guides/79.13 Configure jOOQ with Two DataSources.md) * [80. 数据库初始化](IX. ‘How-to’ guides/80. Database Initialization.md) * [80.1 使用JPA初始化数据库](IX. ‘How-to’ guides/80.1 Initialize a Database Using JPA.md) * [80.2 使用Hibernate初始化数据库](IX. ‘How-to’ guides/80.2 Initialize a Database Using Hibernate.md) From 7d522f930659c1802392442f434eead217bf7a1e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E7=83=AD=E5=BF=83=E5=B8=82=E6=B0=91=E9=92=9F=E5=B0=8F?= =?UTF-8?q?=E5=BC=BA?= Date: Wed, 29 Jan 2020 15:35:02 +0800 Subject: [PATCH 766/865] Update and rename 78.1 Initialize a database using JPA.md to 80.1 Initialize a Database Using JPA.md --- .../80.1 Initialize a Database Using JPA.md" | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) rename "IX. \342\200\230How-to\342\200\231 guides/78.1 Initialize a database using JPA.md" => "IX. \342\200\230How-to\342\200\231 guides/80.1 Initialize a Database Using JPA.md" (74%) diff --git "a/IX. \342\200\230How-to\342\200\231 guides/78.1 Initialize a database using JPA.md" "b/IX. \342\200\230How-to\342\200\231 guides/80.1 Initialize a Database Using JPA.md" similarity index 74% rename from "IX. \342\200\230How-to\342\200\231 guides/78.1 Initialize a database using JPA.md" rename to "IX. \342\200\230How-to\342\200\231 guides/80.1 Initialize a Database Using JPA.md" index 2ab671d8..b60c14b0 100644 --- "a/IX. \342\200\230How-to\342\200\231 guides/78.1 Initialize a database using JPA.md" +++ "b/IX. \342\200\230How-to\342\200\231 guides/80.1 Initialize a Database Using JPA.md" @@ -1,6 +1,6 @@ -### 78.1 使用JPA初始化数据库 +### 80.1 使用JPA初始化数据库 JPA有个生成DDL的特性,并且可以设置为在数据库启动时运行,这可以通过两个外部属性进行控制: - `spring.jpa.generate-ddl`(`boolean`)控制该特性的关闭和开启,跟实现者没关系。 -- `spring.jpa.hibernate.ddl-auto`(`enum`)是一个Hibernate特性,用于更细力度的控制该行为,更多详情参考以下内容。 +- `spring.jpa.hibernate.ddl-auto`(`enum`)是一个Hibernate特性,用于更细力度的控制该行为。更多详情参考以下内容。 From c20156cd064aa5847c1e237598f9e49eec359e8a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E7=83=AD=E5=BF=83=E5=B8=82=E6=B0=91=E9=92=9F=E5=B0=8F?= =?UTF-8?q?=E5=BC=BA?= Date: Wed, 29 Jan 2020 15:42:35 +0800 Subject: [PATCH 767/865] Update and rename 78.2 Initialize a database using Hibernate.md to 80.2 Initialize a Database Using Hibernate.md --- .../80.2 Initialize a Database Using Hibernate.md" | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) rename "IX. \342\200\230How-to\342\200\231 guides/78.2 Initialize a database using Hibernate.md" => "IX. \342\200\230How-to\342\200\231 guides/80.2 Initialize a Database Using Hibernate.md" (71%) diff --git "a/IX. \342\200\230How-to\342\200\231 guides/78.2 Initialize a database using Hibernate.md" "b/IX. \342\200\230How-to\342\200\231 guides/80.2 Initialize a Database Using Hibernate.md" similarity index 71% rename from "IX. \342\200\230How-to\342\200\231 guides/78.2 Initialize a database using Hibernate.md" rename to "IX. \342\200\230How-to\342\200\231 guides/80.2 Initialize a Database Using Hibernate.md" index 6f78bca2..42c0a967 100644 --- "a/IX. \342\200\230How-to\342\200\231 guides/78.2 Initialize a database using Hibernate.md" +++ "b/IX. \342\200\230How-to\342\200\231 guides/80.2 Initialize a Database Using Hibernate.md" @@ -1,6 +1,6 @@ -### 78.2 使用Hibernate初始化数据库 +### 80.2 使用Hibernate初始化数据库 -你可以显式设置`spring.jpa.hibernate.ddl-auto`,标准的Hibernate属性值有`none`,`validate`,`update`,`create`,`create-drop`。Spring Boot根据你的数据库是否为内嵌数据库来选择相应的默认值,如果是内嵌型的则默认值为`create-drop`,否则为`none`。通过查看`Connection`类型可以检查是否为内嵌型数据库,hsqldb,h2和derby是内嵌的,其他都不是。当从内存数据库迁移到一个真正的数据库时,你需要当心,在新的平台中不能对数据库表和数据是否存在进行臆断,你也需要显式设置`ddl-auto`,或使用其他机制初始化数据库。 +你可以显式设置`spring.jpa.hibernate.ddl-auto`。标准的Hibernate属性值有`none`、`validate`、`update`、`create`与`create-drop`。Spring Boot根据你的数据库是否为内嵌数据库来选择相应的默认值。如果是内嵌型的则默认值为`create-drop`,否则为`none`。通过查看`Connection`类型可以检查是否为内嵌型数据库。hsqldb、h2和derby是内嵌的,其他都不是。当从内存数据库迁移到一个真正的数据库时,你需要当心,在新的平台中不能对数据库表和数据是否存在进行臆断,你也需要显式设置`ddl-auto`,或使用其他机制初始化数据库。 **注** 通过启用`org.hibernate.SQL`记录器,你可以输出模式创建。如果你启用了[debug模式](https://docs.spring.io/spring-boot/docs/2.0.0.RELEASE/reference/htmlsingle/#boot-features-logging-console-output),这些会自动完成。 From 3c592a52770d299ea82d9c8a62e79ef3a9749e5d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E7=83=AD=E5=BF=83=E5=B8=82=E6=B0=91=E9=92=9F=E5=B0=8F?= =?UTF-8?q?=E5=BC=BA?= Date: Wed, 29 Jan 2020 20:50:01 +0800 Subject: [PATCH 768/865] Update and rename 78.3 Initialize a database using Spring JDBC.md to 80.3 Initialize a Database.md --- .../78.3 Initialize a database using Spring JDBC.md" | 7 ------- .../80.3 Initialize a Database.md" | 9 +++++++++ 2 files changed, 9 insertions(+), 7 deletions(-) delete mode 100644 "IX. \342\200\230How-to\342\200\231 guides/78.3 Initialize a database using Spring JDBC.md" create mode 100644 "IX. \342\200\230How-to\342\200\231 guides/80.3 Initialize a Database.md" diff --git "a/IX. \342\200\230How-to\342\200\231 guides/78.3 Initialize a database using Spring JDBC.md" "b/IX. \342\200\230How-to\342\200\231 guides/78.3 Initialize a database using Spring JDBC.md" deleted file mode 100644 index 323cf1a0..00000000 --- "a/IX. \342\200\230How-to\342\200\231 guides/78.3 Initialize a database using Spring JDBC.md" +++ /dev/null @@ -1,7 +0,0 @@ -### 78.3 使用Spring JDBC初始化数据库 - -Spring JDBC有一个初始化`DataSource`特性,Spring Boot默认启用该特性,并从标准的位置`schema.sql`和`data.sql`(位于classpath根目录)加载SQL。此外,Spring Boot将加载`schema-${platform}.sql`和`data-${platform}.sql`文件(如果存在),在这里`platform`是`spring.datasource.platform`的值,比如,你可以将它设置为数据库的供应商名称(`hsqldb`, `h2`, `oracle`, `mysql`, `postgresql`等)。Spring Boot默认启用Spring JDBC初始化快速失败特性,所以如果脚本导致异常产生,那应用程序将启动失败。脚本的位置可以通过设置`spring.datasource.schema`和`spring.datasource.data`来改变,如果设置`spring.datasource.initialize=false`则哪个位置都不会被处理。 - -你可以设置`spring.datasource.continue-on-error=true`禁用快速失败特性。一旦应用程序成熟并被部署了很多次,那该设置就很有用,因为脚本可以充当"可怜人的迁移"-例如,插入失败时意味着数据已经存在,也就没必要阻止应用继续运行。 - -如果你想要在一个JPA应用中使用`schema.sql`,那如果Hibernate试图创建相同的表,`ddl-auto=create-drop`将导致错误产生。为了避免那些错误,可以将`ddl-auto`设置为“”(推荐)或`none`。不管是否使用`ddl-auto=create-drop`,你总可以使用`data.sql`初始化新数据。 diff --git "a/IX. \342\200\230How-to\342\200\231 guides/80.3 Initialize a Database.md" "b/IX. \342\200\230How-to\342\200\231 guides/80.3 Initialize a Database.md" new file mode 100644 index 00000000..82301fbf --- /dev/null +++ "b/IX. \342\200\230How-to\342\200\231 guides/80.3 Initialize a Database.md" @@ -0,0 +1,9 @@ +### 80.3 初始化数据库 + +Spring Boot可以自动创建`数据源`的模式(DDL脚本)并初始化它(DML脚本)。它从标准的根类路径位置加载SQL(`schema.sql`与`data.sql`)。此外,Spring Boot处理`schema-${platform}.sql`和`data-${platform}.sql`文件(如果存在),其中`platform`是`spring.datasource.platform`的值。这允许你在必要时切换到特定于数据库的脚本。例如,你可以选择将其设置为数据库的供应商名称(`hsqldb`、`h2`、`oracle`、`mysql`、`postgresql`等)。 + +Spring Boot自动创建嵌入式`数据源`的模式。可以通过使用`spring.datasource.initialization-mode`属性定制此行为(也可以是`always`或`never`)。 + +默认情况下,Spring Boot支持Spring JDBC初始化器的故障快速特性。这意味着,如果脚本导致异常,应用程序将无法启动。你可以通过设置`spring.datasource.continue-on-error`来调整该行为。 + +**注** 在基于JPA的应用程序中,你可以选择让Hibernate创建模式或使用`schema.sql`。但你不能两者都做。如果使用`schema.sql`,请确保禁用`spring.jpa.hibernate.ddl-auto`。 From 3233a3197a194930a3616a42093c1ca536934642 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E7=83=AD=E5=BF=83=E5=B8=82=E6=B0=91=E9=92=9F=E5=B0=8F?= =?UTF-8?q?=E5=BC=BA?= Date: Wed, 29 Jan 2020 20:55:31 +0800 Subject: [PATCH 769/865] Update and rename 78.4 Initialize a Spring Batch database.md to 80.4 Initialize a Spring Batch Database.md --- .../78.4 Initialize a Spring Batch database.md" | 3 --- .../80.4 Initialize a Spring Batch Database.md" | 8 ++++++++ 2 files changed, 8 insertions(+), 3 deletions(-) delete mode 100644 "IX. \342\200\230How-to\342\200\231 guides/78.4 Initialize a Spring Batch database.md" create mode 100644 "IX. \342\200\230How-to\342\200\231 guides/80.4 Initialize a Spring Batch Database.md" diff --git "a/IX. \342\200\230How-to\342\200\231 guides/78.4 Initialize a Spring Batch database.md" "b/IX. \342\200\230How-to\342\200\231 guides/78.4 Initialize a Spring Batch database.md" deleted file mode 100644 index 15cbb25e..00000000 --- "a/IX. \342\200\230How-to\342\200\231 guides/78.4 Initialize a Spring Batch database.md" +++ /dev/null @@ -1,3 +0,0 @@ -### 78.4 初始化Spring Batch数据库 - -如果你正在使用Spring Batch,那么它会为大多数的流行数据库平台预装SQL初始化脚本。Spring Boot会检测你的数据库类型,并默认执行那些脚本,在这种情况下将关闭快速失败特性(错误被记录但不会阻止应用启动)。这是因为那些脚本是可信任的,通常不会包含bugs,所以错误会被忽略掉,并且对错误的忽略可以让脚本具有幂等性。你可以使用`spring.batch.initializer.enabled=false`显式关闭初始化功能。 diff --git "a/IX. \342\200\230How-to\342\200\231 guides/80.4 Initialize a Spring Batch Database.md" "b/IX. \342\200\230How-to\342\200\231 guides/80.4 Initialize a Spring Batch Database.md" new file mode 100644 index 00000000..6ea23dac --- /dev/null +++ "b/IX. \342\200\230How-to\342\200\231 guides/80.4 Initialize a Spring Batch Database.md" @@ -0,0 +1,8 @@ +### 80.4 初始化Spring Batch数据库 + +如果你使用Spring Batch,它会预先打包为大多数流行数据库平台的SQL初始化脚本。Spring Boot可以检测数据库类型,并在启动时执行这些脚本。如果使用嵌入式数据库,这是默认情况。你也可以为任何数据库类型启用它,如下所示: +```properties +spring.batch.initialize-schema=always +``` + +你还可以通过设置`spring.batch.initialize-schema=never`来显式地关闭初始化。 From db956417e0b3b00a3271831d8a17090a238d0621 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E7=83=AD=E5=BF=83=E5=B8=82=E6=B0=91=E9=92=9F=E5=B0=8F?= =?UTF-8?q?=E5=BC=BA?= Date: Wed, 29 Jan 2020 20:58:35 +0800 Subject: [PATCH 770/865] Update and rename 78.5 Use a higher level database migration tool.md to 80.5 Use a Higher-level Database Migration Tool.md --- .../78.5 Use a higher level database migration tool.md" | 3 --- .../80.5 Use a Higher-level Database Migration Tool.md" | 3 +++ 2 files changed, 3 insertions(+), 3 deletions(-) delete mode 100644 "IX. \342\200\230How-to\342\200\231 guides/78.5 Use a higher level database migration tool.md" create mode 100644 "IX. \342\200\230How-to\342\200\231 guides/80.5 Use a Higher-level Database Migration Tool.md" diff --git "a/IX. \342\200\230How-to\342\200\231 guides/78.5 Use a higher level database migration tool.md" "b/IX. \342\200\230How-to\342\200\231 guides/78.5 Use a higher level database migration tool.md" deleted file mode 100644 index 7ffa4a79..00000000 --- "a/IX. \342\200\230How-to\342\200\231 guides/78.5 Use a higher level database migration tool.md" +++ /dev/null @@ -1,3 +0,0 @@ -### 78.5 使用高级数据迁移工具 - -Spring Boot支持两种高级数据迁移工具[Flyway](http://flywaydb.org/)(基于SQL)和[Liquibase](http://www.liquibase.org/)(XML)。 diff --git "a/IX. \342\200\230How-to\342\200\231 guides/80.5 Use a Higher-level Database Migration Tool.md" "b/IX. \342\200\230How-to\342\200\231 guides/80.5 Use a Higher-level Database Migration Tool.md" new file mode 100644 index 00000000..2fbe185f --- /dev/null +++ "b/IX. \342\200\230How-to\342\200\231 guides/80.5 Use a Higher-level Database Migration Tool.md" @@ -0,0 +1,3 @@ +### 80.5 使用高级数据迁移工具 + +Spring Boot支持两种高级数据迁移工具[Flyway](https://flywaydb.org/)和[Liquibase](http://www.liquibase.org/)。 From c03196a925564375b901f1a8b1673740ea482250 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E7=83=AD=E5=BF=83=E5=B8=82=E6=B0=91=E9=92=9F=E5=B0=8F?= =?UTF-8?q?=E5=BC=BA?= Date: Wed, 29 Jan 2020 21:20:16 +0800 Subject: [PATCH 771/865] Update and rename 78.5.1 Execute Flyway database migrations on startup.md to 80.5.1 Execute Flyway Database Migrations on Startup.md --- ... Flyway database migrations on startup.md" | 19 --------------- ... Flyway Database Migrations on Startup.md" | 24 +++++++++++++++++++ 2 files changed, 24 insertions(+), 19 deletions(-) delete mode 100644 "IX. \342\200\230How-to\342\200\231 guides/78.5.1 Execute Flyway database migrations on startup.md" create mode 100644 "IX. \342\200\230How-to\342\200\231 guides/80.5.1 Execute Flyway Database Migrations on Startup.md" diff --git "a/IX. \342\200\230How-to\342\200\231 guides/78.5.1 Execute Flyway database migrations on startup.md" "b/IX. \342\200\230How-to\342\200\231 guides/78.5.1 Execute Flyway database migrations on startup.md" deleted file mode 100644 index 1ce670dd..00000000 --- "a/IX. \342\200\230How-to\342\200\231 guides/78.5.1 Execute Flyway database migrations on startup.md" +++ /dev/null @@ -1,19 +0,0 @@ -### 78.5.1 启动时执行Flyway数据库迁移 - -想要在启动时自动运行Flyway数据库迁移,需要将`org.flywaydb:flyway-core`添加到你的classpath下。 - -迁移是一些`V__.sql`格式的脚本(``是一个下划线分割的版本号,比如'1'或'2_1')。默认情况下,它们存放在`classpath:db/migration`文件夹中,但你可以使用`flyway.locations`改变它。你也可以添加一个特殊的`{vendor}`占位符,来使用特殊指定的脚本。假定如下: -```properties -flyway.locations=db/migration/{vendor} -``` -这项配置将会根据数据库的类型设置使用的文件夹(比如MySQL对应的是`db/migration/mysql`),而不是使用`db/migration`。支持的数据库的一览在[`DatabaseDriver`](https://github.com/spring-projects/spring-boot/tree/v2.0.0.RELEASE/spring-boot/src/main/java/org/springframework/boot/jdbc/DatabaseDriver.java). - -详情可参考flyway-core中的`Flyway`类,查看一些可用的配置,比如schemas。Spring Boot在[FlywayProperties](http://github.com/spring-projects/spring-boot/tree/master/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/flyway/FlywayProperties.java)中提供了一个小的属性集,可用于禁止迁移,或关闭位置检测。Spring Boot将调用`Flyway.migrate()`执行数据库迁移,如果想要更多控制可提供一个实现[FlywayMigrationStrategy](https://github.com/spring-projects/spring-boot/tree/v2.0.0.RELEASE/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/flyway/FlywayMigrationStrategy.java)的`@Bean`。 - -Flyway支持SQL和Java[回调](http://flywaydb.org/documentation/callbacks.html)。为了使用基于SQL的回调,在`classpath:db/migration`文件夹里放置回调脚本。为了使用基于Java的回调,创建一个或者更多的实现了`FlywayCallback`,或者最好是扩展了`BaseFlywayCallback`的bean。任何这样的bean会自动在`Flyway`注册。它们能够通过使用`@Order`或者实现`Ordered`来指定顺序。 - -默认情况下,Flyway将自动注入(`@Primary`)`DataSource`到你的上下文,并用它进行数据迁移。如果想使用不同的`DataSource`,你可以创建一个,并将它标记为`@FlywayDataSource`的`@Bean`-如果你这样做了,且想要两个数据源,记得创建另一个并将它标记为`@Primary`,或者你可以通过在外部配置文件中设置`flyway.[url,user,password]`来使用Flyway的原生`DataSource`。 - -这是一个[Flyway示例](http://github.com/spring-projects/spring-boot/tree/master/spring-boot-samples/spring-boot-sample-flyway),你可以作为参考。 - -你也可以使用Flyway来为特定的场景提供数据。例如,你可以在`src/test/resources`放置测试指定的迁移。它们只会在你的应用为测试启动时运行。如果你想要更加的精细,你可以使用profile指定的配置来自定义`flyway.locations`。这样,某些迁移将只会在特定profile激活的时候运行。比如,在`application-dev.properties`里,你可以把`flyway.locations`设置为`classpath:/db/migration, classpath:/dev/db/migration`,在`dev/db/migration`里的迁移将只会在`dev`profile激活的时候运行。 \ No newline at end of file diff --git "a/IX. \342\200\230How-to\342\200\231 guides/80.5.1 Execute Flyway Database Migrations on Startup.md" "b/IX. \342\200\230How-to\342\200\231 guides/80.5.1 Execute Flyway Database Migrations on Startup.md" new file mode 100644 index 00000000..71e1b6c3 --- /dev/null +++ "b/IX. \342\200\230How-to\342\200\231 guides/80.5.1 Execute Flyway Database Migrations on Startup.md" @@ -0,0 +1,24 @@ +### 80.5.1 启动时执行Flyway数据库迁移 + +想要在启动时自动运行Flyway数据库迁移,需要将`org.flywaydb:flyway-core`添加到你的classpath下。 + +迁移是一些`V__.sql`格式的脚本(``是一个下划线分割的版本号,比如'1'或'2_1')。默认情况下,它们存放在`classpath:db/migration`文件夹中,但你可以设置`spring.flyway.locations`改变它。你也可以添加一个特殊的`{vendor}`占位符,来使用特殊指定的脚本。假定如下: +```properties +spring.flyway.locations=db/migration/{vendor} +``` +这项配置将会根据数据库的类型设置使用的文件夹(比如MySQL对应的是`db/migration/mysql`),而不是使用`db/migration`。支持的数据库的一览在[`DatabaseDriver`](https://github.com/spring-projects/spring-boot/tree/v2.0.0.RELEASE/spring-boot-project/spring-boot/src/main/java/org/springframework/boot/jdbc/DatabaseDriver.java). + +详情可参考flyway-core中的`Flyway`类,查看一些可用的配置,比如schemas。Spring Boot在[FlywayProperties](https://github.com/spring-projects/spring-boot/tree/v2.0.0.RELEASE/spring-boot-project/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/flyway/FlywayProperties.java)中提供了一个小的属性集,可用于禁止迁移,或关闭位置检测。Spring Boot将调用`Flyway.migrate()`执行数据库迁移,如果想要更多控制可提供一个实现[FlywayMigrationStrategy](https://github.com/spring-projects/spring-boot/tree/v2.0.0.RELEASE/spring-boot-project/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/flyway/FlywayMigrationStrategy.java)的`@Bean`。 + +Flyway支持SQL和Java[回调](https://flywaydb.org/documentation/callbacks.html)。为了使用基于SQL的回调,在`classpath:db/migration`文件夹里放置回调脚本。为了使用基于Java的回调,创建一个或者更多的实现了`FlywayCallback`,或者最好是扩展了`BaseFlywayCallback`的bean。任何这样的bean会自动在`Flyway`注册。它们能够通过使用`@Order`或者实现`Ordered`来指定顺序。 + +默认情况下,Flyway将自动注入(`@Primary`)`DataSource`到你的上下文,并用它进行数据迁移。如果想使用不同的`DataSource`,你可以创建一个,并将它标记为`@FlywayDataSource`的`@Bean`。如果你这样做了,且想要两个数据源,记得创建另一个并将它标记为`@Primary`,或者你可以通过在外部配置文件中设置`spring.flyway.[url,user,password]`来使用Flyway的原生`数据源`。设置`spring.flyway.url`或`spring.flyway.user`足以导致Flyway使用自己的`数据源`。如果没有设置这三个属性中的任何一个,则将使用与其等效的`spring.datasource`属性的值。 + +这是一个[Flyway示例](https://github.com/spring-projects/spring-boot/tree/v2.0.0.RELEASE/spring-boot-samples/spring-boot-sample-flyway),你可以作为参考。 + +你也可以使用Flyway来为特定的场景提供数据。例如,你可以在`src/test/resources`放置测试指定的迁移。它们只会在你的应用为测试启动时运行。如果你想要更加的精细,你可以使用profile指定的配置来自定义`spring.flyway.locations`。这样,某些迁移将只会在特定profile激活的时候运行。比如,在`application-dev.properties`里,你可能指定了如下设置: +```properties +spring.flyway.locations=classpath:/db/migration,classpath:/dev/db/migration +``` + +这样配置了以后,在`dev/db/migration`里的迁移将只会在`dev` profile激活的时候运行。 From f45232faaf39f39d4e0141aa38d0d9e77d2a8888 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E7=83=AD=E5=BF=83=E5=B8=82=E6=B0=91=E9=92=9F=E5=B0=8F?= =?UTF-8?q?=E5=BC=BA?= Date: Wed, 29 Jan 2020 21:35:00 +0800 Subject: [PATCH 772/865] Update and rename 78.5.2 Execute Liquibase database migrations on startup.md to 80.5.2 Execute Liquibase Database Migrations on Startup.md --- ...ecute Liquibase database migrations on startup.md" | 11 ----------- ...ecute Liquibase Database Migrations on Startup.md" | 11 +++++++++++ 2 files changed, 11 insertions(+), 11 deletions(-) delete mode 100644 "IX. \342\200\230How-to\342\200\231 guides/78.5.2 Execute Liquibase database migrations on startup.md" create mode 100644 "IX. \342\200\230How-to\342\200\231 guides/80.5.2 Execute Liquibase Database Migrations on Startup.md" diff --git "a/IX. \342\200\230How-to\342\200\231 guides/78.5.2 Execute Liquibase database migrations on startup.md" "b/IX. \342\200\230How-to\342\200\231 guides/78.5.2 Execute Liquibase database migrations on startup.md" deleted file mode 100644 index 6887a1de..00000000 --- "a/IX. \342\200\230How-to\342\200\231 guides/78.5.2 Execute Liquibase database migrations on startup.md" +++ /dev/null @@ -1,11 +0,0 @@ -### 78.5.2 启动时执行Liquibase数据库迁移 - -想要在启动时自动运行Liquibase数据库迁移,你需要将`org.liquibase:liquibase-core`添加到classpath下。 - -你可以使用`liquibase.change-log`设置master变化日志位置,默认从`db/changelog/db.changelog-master.yaml`读取。除了YAML,Liquibase还支持JSON, XML和SQL改变日志格式。查看[LiquibaseProperties](https://github.com/spring-projects/spring-boot/tree/v2.0.0.RELEASE/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/liquibase/LiquibaseProperties.java)获取可用配置,比如上下文,默认schema等。 - -默认情况下Liquibase将会在你的上下文中自动装配(`@Primary`)`数据源`,并使用此数据源进行迁移。如果你想要使用一个不同的`数据源`,你可以创建一个并把它的`@Bean`作为`@LiquibaseDataSource`标记。如果你那样做了,并且你还想要创建两个数据源,记得创建另外一个,并把它标记为`@Primary`。或者你可以通过在外部属性里设置`liquibase.[url,user,password]`的办法,使用Liquibase的本地`数据源`。 - -更多的像上下文、默认的模式之类的细节,请查看[LiquibaseProperties](https://github.com/spring-projects/spring-boot/tree/v2.0.0.RELEASE/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/liquibase/LiquibaseProperties.java)。 - -这里有个[Liquibase示例](http://github.com/spring-projects/spring-boot/tree/master/spring-boot-samples/spring-boot-sample-liquibase)可作为参考。 diff --git "a/IX. \342\200\230How-to\342\200\231 guides/80.5.2 Execute Liquibase Database Migrations on Startup.md" "b/IX. \342\200\230How-to\342\200\231 guides/80.5.2 Execute Liquibase Database Migrations on Startup.md" new file mode 100644 index 00000000..74121afc --- /dev/null +++ "b/IX. \342\200\230How-to\342\200\231 guides/80.5.2 Execute Liquibase Database Migrations on Startup.md" @@ -0,0 +1,11 @@ +### 80.5.2 启动时执行Liquibase数据库迁移 + +想要在启动时自动运行Liquibase数据库迁移,你需要将`org.liquibase:liquibase-core`添加到classpath下。 + +默认从`db/changelog/db.changelog-master.yaml`读取master变化日志。你可以设置`spring.liquibase.change-log`改变位置。除了YAML,Liquibase还支持JSON、XML和SQL改变日志格式。 + +默认情况下Liquibase将会在你的上下文中自动装配(`@Primary`)`数据源`,并使用此数据源进行迁移。如果你想要使用一个不同的`数据源`,你可以创建一个并把它的`@Bean`作为`@LiquibaseDataSource`标记。如果你那样做了,并且你还想要创建两个数据源,记得创建另外一个,并把它标记为`@Primary`。或者你可以通过在外部属性里设置`spring.liquibase.[url,user,password]`,使用Liquibase的本地`数据源`。设置`spring.flyway.url`或`spring.flyway.user`足以导致Liquibase使用自己的`数据源`。如果没有设置这三个属性中的任何一个,则将使用与其等效的`spring.datasource`属性的值。 + +更多的像上下文、默认的模式之类的细节,请查看[LiquibaseProperties](https://github.com/spring-projects/spring-boot/tree/v2.0.0.RELEASE/spring-boot-project/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/liquibase/LiquibaseProperties.java)。 + +这里有个[Liquibase示例](https://github.com/spring-projects/spring-boot/tree/v2.0.0.RELEASE/spring-boot-samples/spring-boot-sample-liquibase)可作为参考。 From dd144f6fe20d0f6eb2caf68400b6d65f6bac83c4 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E7=83=AD=E5=BF=83=E5=B8=82=E6=B0=91=E9=92=9F=E5=B0=8F?= =?UTF-8?q?=E5=BC=BA?= Date: Thu, 30 Jan 2020 22:14:26 +0800 Subject: [PATCH 773/865] Update SUMMARY.md --- SUMMARY.md | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/SUMMARY.md b/SUMMARY.md index 634e4f42..8cf565f8 100644 --- a/SUMMARY.md +++ b/SUMMARY.md @@ -527,10 +527,10 @@ * [80.5 使用高级数据迁移工具](IX. ‘How-to’ guides/80.5 Use a Higher-level Database Migration Tool.md) * [80.5.1 启动时执行Flyway数据库迁移](IX. ‘How-to’ guides/80.5.1 Execute Flyway Database Migrations on Startup.md) * [80.5.2 启动时执行Liquibase数据库迁移](IX. ‘How-to’ guides/80.5.2 Execute Liquibase Database Migrations on Startup.md) - * [79. 消息传送](IX. ‘How-to’ guides/79. Messaging.md) - * [79.1 禁用事务JMS会话](IX. ‘How-to’ guides/79.1 Disable transacted JMS session.md) - * [80. 批处理应用](IX. ‘How-to’ guides/80. Batch applications.md) - * [80.1 在启动时执行Spring Batch作业](IX. ‘How-to’ guides/80.1 Execute Spring Batch jobs on startup.md) + * [81. 消息传送](IX. ‘How-to’ guides/81. Messaging.md) + * [81.1 禁用事务JMS会话](IX. ‘How-to’ guides/81.1 Disable Transacted JMS Session.md) + * [82. 批处理应用](IX. ‘How-to’ guides/82. Batch Applications.md) + * [82.1 在启动时执行Spring Batch作业](IX. ‘How-to’ guides/82.1 Execute Spring Batch Jobs on Startup.md) * [81. 执行器](IX. ‘How-to’ guides/81. Actuator.md) * [81.1 改变HTTP端口或执行器端点的地址](IX. ‘How-to’ guides/81.1 Change the HTTP port or address of the actuator endpoints.md) * [81.2 自定义WhiteLabel错误页面](IX. ‘How-to’ guides/81.2 Customize the ‘whitelabel’ error page.md) From cbe0ec0d76fbb063421da99156f6bbf39e828b09 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E7=83=AD=E5=BF=83=E5=B8=82=E6=B0=91=E9=92=9F=E5=B0=8F?= =?UTF-8?q?=E5=BC=BA?= Date: Thu, 30 Jan 2020 22:17:33 +0800 Subject: [PATCH 774/865] Update and rename 79. Messaging.md to 81. Messaging.md --- "IX. \342\200\230How-to\342\200\231 guides/79. Messaging.md" | 1 - "IX. \342\200\230How-to\342\200\231 guides/81. Messaging.md" | 3 +++ 2 files changed, 3 insertions(+), 1 deletion(-) delete mode 100644 "IX. \342\200\230How-to\342\200\231 guides/79. Messaging.md" create mode 100644 "IX. \342\200\230How-to\342\200\231 guides/81. Messaging.md" diff --git "a/IX. \342\200\230How-to\342\200\231 guides/79. Messaging.md" "b/IX. \342\200\230How-to\342\200\231 guides/79. Messaging.md" deleted file mode 100644 index e4e63038..00000000 --- "a/IX. \342\200\230How-to\342\200\231 guides/79. Messaging.md" +++ /dev/null @@ -1 +0,0 @@ -### 79. 消息传送 diff --git "a/IX. \342\200\230How-to\342\200\231 guides/81. Messaging.md" "b/IX. \342\200\230How-to\342\200\231 guides/81. Messaging.md" new file mode 100644 index 00000000..8bf8d108 --- /dev/null +++ "b/IX. \342\200\230How-to\342\200\231 guides/81. Messaging.md" @@ -0,0 +1,3 @@ +### 81. 消息传送 + +Spring Boot提供了许多starter,包括消息传递。本节回答在Spring Boot中使用消息传递时出现的问题。 From b6afbc1a15c3020c8f67a2f94ca8499247f26d55 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E7=83=AD=E5=BF=83=E5=B8=82=E6=B0=91=E9=92=9F=E5=B0=8F?= =?UTF-8?q?=E5=BC=BA?= Date: Thu, 30 Jan 2020 22:26:11 +0800 Subject: [PATCH 775/865] Update and rename 79.1 Disable transacted JMS session.md to 81.1 Disable Transacted JMS Session.md --- .../79.1 Disable transacted JMS session.md" | 16 ---------------- .../81.1 Disable Transacted JMS Session.md" | 17 +++++++++++++++++ 2 files changed, 17 insertions(+), 16 deletions(-) delete mode 100644 "IX. \342\200\230How-to\342\200\231 guides/79.1 Disable transacted JMS session.md" create mode 100644 "IX. \342\200\230How-to\342\200\231 guides/81.1 Disable Transacted JMS Session.md" diff --git "a/IX. \342\200\230How-to\342\200\231 guides/79.1 Disable transacted JMS session.md" "b/IX. \342\200\230How-to\342\200\231 guides/79.1 Disable transacted JMS session.md" deleted file mode 100644 index b86052e5..00000000 --- "a/IX. \342\200\230How-to\342\200\231 guides/79.1 Disable transacted JMS session.md" +++ /dev/null @@ -1,16 +0,0 @@ -### 79.1 禁用事务JMS会话 - -If your JMS broker does not support transacted session, you will have to disable the support of transactions altogether. If you create your own JmsListenerContainerFactory there is nothing to do since it won’t be transacted by default. If you want to use the DefaultJmsListenerContainerFactoryConfigurer to reuse Spring Boot’s default, you can disable transacted session as follows: - -@Bean -public DefaultJmsListenerContainerFactory jmsListenerContainerFactory( - ConnectionFactory connectionFactory, - DefaultJmsListenerContainerFactoryConfigurer configurer) { - DefaultJmsListenerContainerFactory listenerFactory = - new DefaultJmsListenerContainerFactory(); - configurer.configure(listenerFactory, connectionFactory); - listenerFactory.setTransactionManager(null); - listenerFactory.setSessionTransacted(false); - return listenerFactory; -} -This overrides the default factory and this should be applied to any other factory that your application defines, if any. diff --git "a/IX. \342\200\230How-to\342\200\231 guides/81.1 Disable Transacted JMS Session.md" "b/IX. \342\200\230How-to\342\200\231 guides/81.1 Disable Transacted JMS Session.md" new file mode 100644 index 00000000..142be48b --- /dev/null +++ "b/IX. \342\200\230How-to\342\200\231 guides/81.1 Disable Transacted JMS Session.md" @@ -0,0 +1,17 @@ +### 81.1 禁用事务JMS会话 + +如果你的JMS代理不支持事务会话,则必须完全禁用事务支持。如果你创建自己的`JmsListenerContainerFactory`,则不需要做任何事情,因为它在默认情况下不能进行事务处理。如果你想使用`DefaultJmsListenerContainerFactoryConfigurer`来重用Spring Boot的默认值,你可以禁用事务会话。如下所示: +```java +@Bean +public DefaultJmsListenerContainerFactory jmsListenerContainerFactory( + ConnectionFactory connectionFactory, + DefaultJmsListenerContainerFactoryConfigurer configurer) { + DefaultJmsListenerContainerFactory listenerFactory = + new DefaultJmsListenerContainerFactory(); + configurer.configure(listenerFactory, connectionFactory); + listenerFactory.setTransactionManager(null); + listenerFactory.setSessionTransacted(false); + return listenerFactory; +} +``` +前面的示例覆盖了默认工厂,如果应用程序定义了其它工厂,则应该将其应用于其它工厂。 From b062265ef6afefafc6a7771957ac567b0a6b55a7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E7=83=AD=E5=BF=83=E5=B8=82=E6=B0=91=E9=92=9F=E5=B0=8F?= =?UTF-8?q?=E5=BC=BA?= Date: Thu, 30 Jan 2020 22:34:17 +0800 Subject: [PATCH 776/865] Update and rename 80. Batch applications.md to 82. Batch Applications.md --- .../80. Batch applications.md" | 3 --- .../82. Batch Applications.md" | 7 +++++++ 2 files changed, 7 insertions(+), 3 deletions(-) delete mode 100644 "IX. \342\200\230How-to\342\200\231 guides/80. Batch applications.md" create mode 100644 "IX. \342\200\230How-to\342\200\231 guides/82. Batch Applications.md" diff --git "a/IX. \342\200\230How-to\342\200\231 guides/80. Batch applications.md" "b/IX. \342\200\230How-to\342\200\231 guides/80. Batch applications.md" deleted file mode 100644 index 533743dc..00000000 --- "a/IX. \342\200\230How-to\342\200\231 guides/80. Batch applications.md" +++ /dev/null @@ -1,3 +0,0 @@ -### 80. 批处理应用 - -默认的,批处理应用需要一个`数据源`来存储job细节。如果你想要脱离那个,你将会需要实现`BatchConfigurer`,查看[`@EnableBatchProcessing`的Javadoc](https://docs.spring.io/spring-batch/apidocs/org/springframework/batch/core/configuration/annotation/EnableBatchProcessing.html) 获取更多细节。 diff --git "a/IX. \342\200\230How-to\342\200\231 guides/82. Batch Applications.md" "b/IX. \342\200\230How-to\342\200\231 guides/82. Batch Applications.md" new file mode 100644 index 00000000..4f482415 --- /dev/null +++ "b/IX. \342\200\230How-to\342\200\231 guides/82. Batch Applications.md" @@ -0,0 +1,7 @@ +### 82. 批处理应用 + +本节回答在Spring Boot中使用Spring Batch时出现的问题。 + +**注** 默认的,批处理应用需要一个`数据源`来存储job细节。如果你想要脱离那个,你将会需要实现`BatchConfigurer`,查看[`@EnableBatchProcessing`的Javadoc](https://docs.spring.io/spring-batch/apidocs/org/springframework/batch/core/configuration/annotation/EnableBatchProcessing.html) 获取更多细节。 + +有关Spring Batch的更多信息,请参见[Spring Batch项目页面](https://projects.spring.io/spring-batch/)。 From 306251a8fe116e8f7e2b0fdb1906b5acd6149152 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E7=83=AD=E5=BF=83=E5=B8=82=E6=B0=91=E9=92=9F=E5=B0=8F?= =?UTF-8?q?=E5=BC=BA?= Date: Thu, 30 Jan 2020 22:40:42 +0800 Subject: [PATCH 777/865] Update and rename 80.1 Execute Spring Batch jobs on startup.md to 82.1 Execute Spring Batch Jobs on Startup.md --- .../80.1 Execute Spring Batch jobs on startup.md" | 9 --------- .../82.1 Execute Spring Batch Jobs on Startup.md" | 9 +++++++++ 2 files changed, 9 insertions(+), 9 deletions(-) delete mode 100644 "IX. \342\200\230How-to\342\200\231 guides/80.1 Execute Spring Batch jobs on startup.md" create mode 100644 "IX. \342\200\230How-to\342\200\231 guides/82.1 Execute Spring Batch Jobs on Startup.md" diff --git "a/IX. \342\200\230How-to\342\200\231 guides/80.1 Execute Spring Batch jobs on startup.md" "b/IX. \342\200\230How-to\342\200\231 guides/80.1 Execute Spring Batch jobs on startup.md" deleted file mode 100644 index d5574285..00000000 --- "a/IX. \342\200\230How-to\342\200\231 guides/80.1 Execute Spring Batch jobs on startup.md" +++ /dev/null @@ -1,9 +0,0 @@ -### 80.1 在启动时执行Spring Batch作业 - -你可以在上下文的某个地方添加`@EnableBatchProcessing`来启用Spring Batch的自动配置功能。 - -默认情况下,在启动时它会执行应用的所有作业(Jobs),具体查看[JobLauncherCommandLineRunner](http://github.com/spring-projects/spring-boot/tree/master/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/batch/JobLauncherCommandLineRunner.java)。你可以通过指定`spring.batch.job.names`(多个作业名以逗号分割)来缩小到一个特定的作业或多个作业。 - -如果应用上下文包含一个`JobRegistry`,那么处于`spring.batch.job.names`中的作业将会从registry中查找,而不是从上下文中自动装配。这是复杂系统中常见的一个模式,在这些系统中多个作业被定义在子上下文和注册中心。 - -详情可参考[BatchAutoConfiguration](http://github.com/spring-projects/spring-boot/tree/master/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/batch/BatchAutoConfiguration.java)和[@EnableBatchProcessing](https://github.com/spring-projects/spring-batch/blob/master/spring-batch-core/src/main/java/org/springframework/batch/core/configuration/annotation/EnableBatchProcessing.java)。 diff --git "a/IX. \342\200\230How-to\342\200\231 guides/82.1 Execute Spring Batch Jobs on Startup.md" "b/IX. \342\200\230How-to\342\200\231 guides/82.1 Execute Spring Batch Jobs on Startup.md" new file mode 100644 index 00000000..1a69c1a8 --- /dev/null +++ "b/IX. \342\200\230How-to\342\200\231 guides/82.1 Execute Spring Batch Jobs on Startup.md" @@ -0,0 +1,9 @@ +### 82.1 在启动时执行Spring Batch作业 + +你可以在上下文的某个地方添加`@EnableBatchProcessing`来启用Spring Batch的自动配置功能。 + +默认情况下,在启动时它会执行应用的所有作业(Jobs),具体查看[JobLauncherCommandLineRunner](https://github.com/spring-projects/spring-boot/tree/v2.0.0.RELEASE/spring-boot-project/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/batch/JobLauncherCommandLineRunner.java)。你可以通过指定`spring.batch.job.names`(多个作业名以逗号分割)来缩小到一个特定的作业或多个作业。 + +如果应用上下文包含一个`JobRegistry`,那么处于`spring.batch.job.names`中的作业将会从registry中查找,而不是从上下文中自动装配。这是复杂系统中常见的一个模式,在这些系统中多个作业被定义在子上下文和注册中心。 + +详情可参考[BatchAutoConfiguration](https://github.com/spring-projects/spring-boot/tree/v2.0.0.RELEASE/spring-boot-project/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/batch/BatchAutoConfiguration.java)和[@EnableBatchProcessing](https://github.com/spring-projects/spring-batch/blob/master/spring-batch-core/src/main/java/org/springframework/batch/core/configuration/annotation/EnableBatchProcessing.java)。 From 4b12d1bdcda9dac8fbce8b5192d2c37f67e76e82 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E7=83=AD=E5=BF=83=E5=B8=82=E6=B0=91=E9=92=9F=E5=B0=8F?= =?UTF-8?q?=E5=BC=BA?= Date: Fri, 31 Jan 2020 16:39:01 +0800 Subject: [PATCH 778/865] Update SUMMARY.md --- SUMMARY.md | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/SUMMARY.md b/SUMMARY.md index 8cf565f8..698f9740 100644 --- a/SUMMARY.md +++ b/SUMMARY.md @@ -531,10 +531,9 @@ * [81.1 禁用事务JMS会话](IX. ‘How-to’ guides/81.1 Disable Transacted JMS Session.md) * [82. 批处理应用](IX. ‘How-to’ guides/82. Batch Applications.md) * [82.1 在启动时执行Spring Batch作业](IX. ‘How-to’ guides/82.1 Execute Spring Batch Jobs on Startup.md) - * [81. 执行器](IX. ‘How-to’ guides/81. Actuator.md) - * [81.1 改变HTTP端口或执行器端点的地址](IX. ‘How-to’ guides/81.1 Change the HTTP port or address of the actuator endpoints.md) - * [81.2 自定义WhiteLabel错误页面](IX. ‘How-to’ guides/81.2 Customize the ‘whitelabel’ error page.md) - * [81.3 Actuator和Jersey](IX. ‘How-to’ guides/81.3 Actuator and Jersey.md) + * [83. 执行器](IX. ‘How-to’ guides/83. Actuator.md) + * [83.1 改变HTTP端口或执行器端点的地址](IX. ‘How-to’ guides/83.1 Change the HTTP Port or Address of the Actuator Endpoints.md) + * [83.2 自定义WhiteLabel错误页面](IX. ‘How-to’ guides/83.2 Customize the ‘whitelabel’ Error Page.md) * [82. 安全](IX. ‘How-to’ guides/82. Security.md) * [82.1 关闭Spring Boot安全配置](IX. ‘How-to’ guides/82.1 Switch off the Spring Boot security configuration.md) * [82.2 改变AuthenticationManager并添加用户账号](IX. ‘How-to’ guides/82.2 Change the AuthenticationManager and add user accounts.md) From e1943edd95cb3aa1c81b5b143ccc0f4b74def6d2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E7=83=AD=E5=BF=83=E5=B8=82=E6=B0=91=E9=92=9F=E5=B0=8F?= =?UTF-8?q?=E5=BC=BA?= Date: Fri, 31 Jan 2020 16:41:48 +0800 Subject: [PATCH 779/865] Update and rename 81. Actuator.md to 83. Actuator.md --- "IX. \342\200\230How-to\342\200\231 guides/81. Actuator.md" | 1 - "IX. \342\200\230How-to\342\200\231 guides/83. Actuator.md" | 3 +++ 2 files changed, 3 insertions(+), 1 deletion(-) delete mode 100644 "IX. \342\200\230How-to\342\200\231 guides/81. Actuator.md" create mode 100644 "IX. \342\200\230How-to\342\200\231 guides/83. Actuator.md" diff --git "a/IX. \342\200\230How-to\342\200\231 guides/81. Actuator.md" "b/IX. \342\200\230How-to\342\200\231 guides/81. Actuator.md" deleted file mode 100644 index 313cdfcb..00000000 --- "a/IX. \342\200\230How-to\342\200\231 guides/81. Actuator.md" +++ /dev/null @@ -1 +0,0 @@ -### 81. 执行器(Actuator) diff --git "a/IX. \342\200\230How-to\342\200\231 guides/83. Actuator.md" "b/IX. \342\200\230How-to\342\200\231 guides/83. Actuator.md" new file mode 100644 index 00000000..868d8f0e --- /dev/null +++ "b/IX. \342\200\230How-to\342\200\231 guides/83. Actuator.md" @@ -0,0 +1,3 @@ +### 83. 执行器(Actuator) + +Spring Boot包括Spring Boot Actuator。本节回答了在使用过程中经常出现的问题。 From 1e1690b20ff561dd6dfedd78e58ccaace721442b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E7=83=AD=E5=BF=83=E5=B8=82=E6=B0=91=E9=92=9F=E5=B0=8F?= =?UTF-8?q?=E5=BC=BA?= Date: Fri, 31 Jan 2020 16:49:44 +0800 Subject: [PATCH 780/865] Update and rename 81.1 Change the HTTP port or address of the actuator endpoints.md to 83.1 Change the HTTP Port or Address of the Actuator Endpoints.md --- ...ge the HTTP port or address of the actuator endpoints.md" | 5 ----- ...ge the HTTP Port or Address of the Actuator Endpoints.md" | 5 +++++ 2 files changed, 5 insertions(+), 5 deletions(-) delete mode 100644 "IX. \342\200\230How-to\342\200\231 guides/81.1 Change the HTTP port or address of the actuator endpoints.md" create mode 100644 "IX. \342\200\230How-to\342\200\231 guides/83.1 Change the HTTP Port or Address of the Actuator Endpoints.md" diff --git "a/IX. \342\200\230How-to\342\200\231 guides/81.1 Change the HTTP port or address of the actuator endpoints.md" "b/IX. \342\200\230How-to\342\200\231 guides/81.1 Change the HTTP port or address of the actuator endpoints.md" deleted file mode 100644 index 20a6abbc..00000000 --- "a/IX. \342\200\230How-to\342\200\231 guides/81.1 Change the HTTP port or address of the actuator endpoints.md" +++ /dev/null @@ -1,5 +0,0 @@ -### 81.1 改变HTTP端口或执行器端点的地址 - -在一个单独的应用中,执行器的HTTP端口默认和主HTTP端口相同。想要让应用监听不同的端口,你可以设置外部属性`management.port`。为了监听一个完全不同的网络地址(比如,你有一个用于管理的内部网络和一个用于用户应用程序的外部网络),你可以将`management.address`设置为一个可用的IP地址,然后将服务器绑定到该地址。 - -更多详情可查看[ManagementServerProperties](http://github.com/spring-projects/spring-boot/tree/master/spring-boot-actuator/src/main/java/org/springframework/boot/actuate/autoconfigure/ManagementServerProperties.java)源码和'Production-ready特性'章节中的[Section 49.3, “Customizing the management server port”](../V. Spring Boot Actuator/49.3 Customizing the management server port.md)。 diff --git "a/IX. \342\200\230How-to\342\200\231 guides/83.1 Change the HTTP Port or Address of the Actuator Endpoints.md" "b/IX. \342\200\230How-to\342\200\231 guides/83.1 Change the HTTP Port or Address of the Actuator Endpoints.md" new file mode 100644 index 00000000..3d980591 --- /dev/null +++ "b/IX. \342\200\230How-to\342\200\231 guides/83.1 Change the HTTP Port or Address of the Actuator Endpoints.md" @@ -0,0 +1,5 @@ +### 83.1 改变HTTP端口或执行器端点的地址 + +在一个单独的应用中,执行器的HTTP端口默认和主HTTP端口相同。想要让应用监听不同的端口,你可以设置外部属性`management.server.port`。为了监听一个完全不同的网络地址(比如,你有一个用于管理的内部网络和一个用于用户应用程序的外部网络),你可以将`management.server.address`设置为一个可用的IP地址,然后将服务器绑定到该地址。 + +更多详情可查看[ManagementServerProperties](https://github.com/spring-projects/spring-boot/tree/v2.0.0.RELEASE/spring-boot-project/spring-boot-actuator-autoconfigure/src/main/java/org/springframework/boot/actuate/autoconfigure/web/server/ManagementServerProperties.java)源码和'Production-ready特性'章节中的[51.2 自定义管理服务器端口](https://docs.spring.io/spring-boot/docs/2.0.0.RELEASE/reference/htmlsingle/#production-ready-customizing-management-server-port)。 From 233f764daf1c85b544f64b4d6425a0247cab3c35 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E7=83=AD=E5=BF=83=E5=B8=82=E6=B0=91=E9=92=9F=E5=B0=8F?= =?UTF-8?q?=E5=BC=BA?= Date: Fri, 31 Jan 2020 17:13:05 +0800 Subject: [PATCH 781/865] =?UTF-8?q?Update=20and=20rename=2081.2=20Customiz?= =?UTF-8?q?e=20the=20=E2=80=98whitelabel=E2=80=99=20error=20page.md=20to?= =?UTF-8?q?=2083.2=20Customize=20the=20=E2=80=98whitelabel=E2=80=99=20Erro?= =?UTF-8?q?r=20Page.md?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- ...ze the \342\200\230whitelabel\342\200\231 Error Page.md" | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) rename "IX. \342\200\230How-to\342\200\231 guides/81.2 Customize the \342\200\230whitelabel\342\200\231 error page.md" => "IX. \342\200\230How-to\342\200\231 guides/83.2 Customize the \342\200\230whitelabel\342\200\231 Error Page.md" (57%) diff --git "a/IX. \342\200\230How-to\342\200\231 guides/81.2 Customize the \342\200\230whitelabel\342\200\231 error page.md" "b/IX. \342\200\230How-to\342\200\231 guides/83.2 Customize the \342\200\230whitelabel\342\200\231 Error Page.md" similarity index 57% rename from "IX. \342\200\230How-to\342\200\231 guides/81.2 Customize the \342\200\230whitelabel\342\200\231 error page.md" rename to "IX. \342\200\230How-to\342\200\231 guides/83.2 Customize the \342\200\230whitelabel\342\200\231 Error Page.md" index 8004ba28..cf026b99 100644 --- "a/IX. \342\200\230How-to\342\200\231 guides/81.2 Customize the \342\200\230whitelabel\342\200\231 error page.md" +++ "b/IX. \342\200\230How-to\342\200\231 guides/83.2 Customize the \342\200\230whitelabel\342\200\231 Error Page.md" @@ -1,5 +1,5 @@ -### 81.2 自定义WhiteLabel错误页面 +### 83.2 自定义WhiteLabel错误页面 -Spring Boot安装了一个'whitelabel'错误页面,如果你遇到一个服务器错误(机器客户端消费的是JSON,其他媒体类型则会看到一个具有正确错误码的合乎情理的响应),那就能在客户端浏览器中看到该页面。你可以设置`error.whitelabel.enabled=false`来关闭该功能,但通常你想要添加自己的错误页面来取代whitelabel。确切地说,如何实现取决于你使用的模板技术。例如,你正在使用Thymeleaf,你将添加一个`error.html`模板。如果你正在使用FreeMarker,那你将添加一个`error.ftl`模板。通常,你需要的只是一个名称为`error`的`View`,或一个处理`/error`路径的`@Controller`。除非你替换了一些默认配置,否则你将在你的`ApplicationContext`中找到一个`BeanNameViewResolver`,所以一个id为`error`的`@Bean`可能是完成该操作的一个简单方式,详情可参考[ErrorMvcAutoConfiguration](http://github.com/spring-projects/spring-boot/tree/master/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/web/ErrorMvcAutoConfiguration.java)。 +Spring Boot安装了一个'whitelabel'错误页面,如果你遇到一个服务器错误(机器客户端消费的是JSON,其他媒体类型则会看到一个具有正确错误码的合乎情理的响应),那就能在客户端浏览器中看到该页面。你可以设置`error.whitelabel.enabled=false`来关闭该功能,但通常你想要添加自己的错误页面来取代whitelabel。确切地说,如何实现取决于你使用的模板技术。例如,你正在使用Thymeleaf,你将添加一个`error.html`模板。如果你正在使用FreeMarker,那你将添加一个`error.ftl`模板。通常,你需要的只是一个名称为`error`的`View`,或一个处理`/error`路径的`@Controller`。除非你替换了一些默认配置,否则你将在你的`ApplicationContext`中找到一个`BeanNameViewResolver`,所以一个名为`error`的`@Bean`可能是完成该操作的一个简单方式,详情可参考[ErrorMvcAutoConfiguration](https://github.com/spring-projects/spring-boot/tree/v2.0.0.RELEASE/spring-boot-project/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/web/servlet/error/ErrorMvcAutoConfiguration.java)。 -查看[Error Handling](../IV. Spring Boot features/27.1.8 Error Handling.md)章节,了解如何将处理器(handlers)注册到servlet容器中。 +查看[Error Handling](https://docs.spring.io/spring-boot/docs/2.0.0.RELEASE/reference/htmlsingle/#boot-features-error-handling)章节,了解如何将处理器(handlers)注册到servlet容器中。 From a09df07793e8b66d4e19f1fd2b0cb505f69da922 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E7=83=AD=E5=BF=83=E5=B8=82=E6=B0=91=E9=92=9F=E5=B0=8F?= =?UTF-8?q?=E5=BC=BA?= Date: Fri, 31 Jan 2020 17:15:38 +0800 Subject: [PATCH 782/865] Delete 81.3 Actuator and Jersey.md --- .../81.3 Actuator and Jersey.md" | 3 --- 1 file changed, 3 deletions(-) delete mode 100644 "IX. \342\200\230How-to\342\200\231 guides/81.3 Actuator and Jersey.md" diff --git "a/IX. \342\200\230How-to\342\200\231 guides/81.3 Actuator and Jersey.md" "b/IX. \342\200\230How-to\342\200\231 guides/81.3 Actuator and Jersey.md" deleted file mode 100644 index def46133..00000000 --- "a/IX. \342\200\230How-to\342\200\231 guides/81.3 Actuator and Jersey.md" +++ /dev/null @@ -1,3 +0,0 @@ -### 81.3 Actuator和Jersey - -执行器HTTP端点只有在基于Spring MVC的应用才可用,如果想使用Jersey和执行器,你需要启用Spring MVC(添加`spring-boot-starter-web`依赖)。默认情况下,Jersey和 Spring MVC分发器servlet被映射到相同路径(`/`)。你需要改变它们中的某个路径(Spring MVC可以配置`server.servlet.path`,Jersey可以配置`spring.jersey.application-path`)。例如,如果你在`application.properties`中添加`server.servlet.path=/system`,你将在`/system`访问执行器HTTP端点。 From 291ca629775b8f2ee718a2d644b0f6a92bf46489 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E7=83=AD=E5=BF=83=E5=B8=82=E6=B0=91=E9=92=9F=E5=B0=8F?= =?UTF-8?q?=E5=BC=BA?= Date: Sat, 8 Feb 2020 12:29:37 +0800 Subject: [PATCH 783/865] Update SUMMARY.md --- SUMMARY.md | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/SUMMARY.md b/SUMMARY.md index 698f9740..21f5d3ea 100644 --- a/SUMMARY.md +++ b/SUMMARY.md @@ -534,10 +534,10 @@ * [83. 执行器](IX. ‘How-to’ guides/83. Actuator.md) * [83.1 改变HTTP端口或执行器端点的地址](IX. ‘How-to’ guides/83.1 Change the HTTP Port or Address of the Actuator Endpoints.md) * [83.2 自定义WhiteLabel错误页面](IX. ‘How-to’ guides/83.2 Customize the ‘whitelabel’ Error Page.md) - * [82. 安全](IX. ‘How-to’ guides/82. Security.md) - * [82.1 关闭Spring Boot安全配置](IX. ‘How-to’ guides/82.1 Switch off the Spring Boot security configuration.md) - * [82.2 改变AuthenticationManager并添加用户账号](IX. ‘How-to’ guides/82.2 Change the AuthenticationManager and add user accounts.md) - * [82.3 当前端使用代理服务器时启用HTTPS](IX. ‘How-to’ guides/82.3 Enable HTTPS when running behind a proxy server.md) + * [84. 安全](IX. ‘How-to’ guides/84. Security.md) + * [84.1 关闭Spring Boot安全配置](IX. ‘How-to’ guides/84.1 Switch off the Spring Boot Security Configuration.md) + * [84.2 改变AuthenticationManager并添加用户账号](IX. ‘How-to’ guides/84.2 Change the AuthenticationManager and Add User Accounts.md) + * [84.3 当前端使用代理服务器时启用HTTPS](IX. ‘How-to’ guides/84.3 Enable HTTPS When Running behind a Proxy Server.md) * [83. 热交换](IX. ‘How-to’ guides/83. Hot swapping.md) * [83.1 重新加载静态内容](IX. ‘How-to’ guides/83.1 Reload static content.md) * [83.2. 在不重启容器的情况下重新加载模板](IX. ‘How-to’ guides/83.2. Reload templates without restarting the container.md) From 6d61e356a670b5aa87186329fb3628d07ba07dca Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E7=83=AD=E5=BF=83=E5=B8=82=E6=B0=91=E9=92=9F=E5=B0=8F?= =?UTF-8?q?=E5=BC=BA?= Date: Sat, 8 Feb 2020 12:32:34 +0800 Subject: [PATCH 784/865] Update and rename 82. Security.md to 84. Security.md --- "IX. \342\200\230How-to\342\200\231 guides/82. Security.md" | 1 - "IX. \342\200\230How-to\342\200\231 guides/84. Security.md" | 5 +++++ 2 files changed, 5 insertions(+), 1 deletion(-) delete mode 100644 "IX. \342\200\230How-to\342\200\231 guides/82. Security.md" create mode 100644 "IX. \342\200\230How-to\342\200\231 guides/84. Security.md" diff --git "a/IX. \342\200\230How-to\342\200\231 guides/82. Security.md" "b/IX. \342\200\230How-to\342\200\231 guides/82. Security.md" deleted file mode 100644 index adf45395..00000000 --- "a/IX. \342\200\230How-to\342\200\231 guides/82. Security.md" +++ /dev/null @@ -1 +0,0 @@ -### 82. 安全 diff --git "a/IX. \342\200\230How-to\342\200\231 guides/84. Security.md" "b/IX. \342\200\230How-to\342\200\231 guides/84. Security.md" new file mode 100644 index 00000000..f0b27527 --- /dev/null +++ "b/IX. \342\200\230How-to\342\200\231 guides/84. Security.md" @@ -0,0 +1,5 @@ +### 84. 安全 + +本节讨论在使用Spring Boot时有关安全性的问题,包括在Spring Boot中使用Spring Security时产生的问题。 + +有关Spring安全性的更多信息,请参见[Spring Security项目页面](https://projects.spring.io/spring-security/)。 From 235e6d15ab1a647e64ba47415c7b978b82a875eb Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E7=83=AD=E5=BF=83=E5=B8=82=E6=B0=91=E9=92=9F=E5=B0=8F?= =?UTF-8?q?=E5=BC=BA?= Date: Sat, 8 Feb 2020 12:39:11 +0800 Subject: [PATCH 785/865] Update and rename 82.1 Switch off the Spring Boot security configuration.md to 84.1 Switch off the Spring Boot Security Configuration.md --- .../82.1 Switch off the Spring Boot security configuration.md" | 3 --- .../84.1 Switch off the Spring Boot Security Configuration.md" | 3 +++ 2 files changed, 3 insertions(+), 3 deletions(-) delete mode 100644 "IX. \342\200\230How-to\342\200\231 guides/82.1 Switch off the Spring Boot security configuration.md" create mode 100644 "IX. \342\200\230How-to\342\200\231 guides/84.1 Switch off the Spring Boot Security Configuration.md" diff --git "a/IX. \342\200\230How-to\342\200\231 guides/82.1 Switch off the Spring Boot security configuration.md" "b/IX. \342\200\230How-to\342\200\231 guides/82.1 Switch off the Spring Boot security configuration.md" deleted file mode 100644 index e0aec8ef..00000000 --- "a/IX. \342\200\230How-to\342\200\231 guides/82.1 Switch off the Spring Boot security configuration.md" +++ /dev/null @@ -1,3 +0,0 @@ -### 82.1 关闭Spring Boot安全配置 - -不管你在应用的什么地方定义了一个使用`@EnableWebSecurity`注解的`@Configuration`,它都会关闭Spring Boot中的默认webapp安全设置。想要调整默认值,你可以尝试设置`security.*`属性(具体查看[SecurityProperties](http://github.com/spring-projects/spring-boot/tree/master/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/security/SecurityProperties.java)和[常见应用属性](http://docs.spring.io/spring-boot/docs/current-SNAPSHOT/reference/htmlsingle/#common-application-properties-security)的SECURITY章节)。 diff --git "a/IX. \342\200\230How-to\342\200\231 guides/84.1 Switch off the Spring Boot Security Configuration.md" "b/IX. \342\200\230How-to\342\200\231 guides/84.1 Switch off the Spring Boot Security Configuration.md" new file mode 100644 index 00000000..063f7636 --- /dev/null +++ "b/IX. \342\200\230How-to\342\200\231 guides/84.1 Switch off the Spring Boot Security Configuration.md" @@ -0,0 +1,3 @@ +### 84.1 关闭Spring Boot安全配置 + +如果你在应用里使用`WebSecurityConfigurerAdapter`定义了一个`@Configuration`,它都会关闭Spring Boot中的默认webapp安全设置。 From f7ca038a47ad387c27997c5b503b5ff0e7e83c66 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E7=83=AD=E5=BF=83=E5=B8=82=E6=B0=91=E9=92=9F=E5=B0=8F?= =?UTF-8?q?=E5=BC=BA?= Date: Sat, 8 Feb 2020 12:46:53 +0800 Subject: [PATCH 786/865] Update and rename 82.2 Change the AuthenticationManager and add user accounts.md to 84.2 Change the AuthenticationManager and Add User Accounts.md --- ...nticationManager and add user accounts.md" | 33 ------------------- ...nticationManager and Add User Accounts.md" | 5 +++ 2 files changed, 5 insertions(+), 33 deletions(-) delete mode 100644 "IX. \342\200\230How-to\342\200\231 guides/82.2 Change the AuthenticationManager and add user accounts.md" create mode 100644 "IX. \342\200\230How-to\342\200\231 guides/84.2 Change the AuthenticationManager and Add User Accounts.md" diff --git "a/IX. \342\200\230How-to\342\200\231 guides/82.2 Change the AuthenticationManager and add user accounts.md" "b/IX. \342\200\230How-to\342\200\231 guides/82.2 Change the AuthenticationManager and add user accounts.md" deleted file mode 100644 index 49eef0d0..00000000 --- "a/IX. \342\200\230How-to\342\200\231 guides/82.2 Change the AuthenticationManager and add user accounts.md" +++ /dev/null @@ -1,33 +0,0 @@ -### 82.2 改变AuthenticationManager并添加用户账号 - -如果你提供了一个`AuthenticationManager`类型的`@Bean`,那么默认的就不会被创建了,所以你可以获得Spring Security可用的全部特性(比如,[不同的认证选项](http://docs.spring.io/spring-security/site/docs/current/reference/htmlsingle/#jc-authentication))。 - -Spring Security也提供了一个方便的`AuthenticationManagerBuilder`,用于构建具有常见选项的`AuthenticationManager`。在一个webapp中,推荐将它注入到`WebSecurityConfigurerAdapter`的一个void方法中,比如: -```java -@Configuration -public class SecurityConfiguration extends WebSecurityConfigurerAdapter { - - @Autowired - public void configureGlobal(AuthenticationManagerBuilder auth) throws Exception { - auth.inMemoryAuthentication() - .withUser("barry").password("password").roles("USER"); // ... etc. - } - - // ... other stuff for application security -} -``` -如果把它放到一个内部类或一个单独的类中,你将得到最好的结果(也就是不跟很多其他`@Beans`混合在一起将允许你改变实例化的顺序)。[secure web sample](http://github.com/spring-projects/spring-boot/tree/master/spring-boot-samples/spring-boot-sample-web-secure)是一个有用的参考模板。 - -如果你遇到了实例化问题(比如,使用JDBC或JPA进行用户详细信息的存储),那将`AuthenticationManagerBuilder`回调提取到一个`GlobalAuthenticationConfigurerAdapter`(放到`init()`方法内以防其他地方也需要authentication manager)可能是个不错的选择,比如: -```java -@Configuration -public class AuthenticationManagerConfiguration extends - - GlobalAuthenticationConfigurerAdapter { - @Override - public void init(AuthenticationManagerBuilder auth) { - auth.inMemoryAuthentication() // ... etc. - } - -} -``` diff --git "a/IX. \342\200\230How-to\342\200\231 guides/84.2 Change the AuthenticationManager and Add User Accounts.md" "b/IX. \342\200\230How-to\342\200\231 guides/84.2 Change the AuthenticationManager and Add User Accounts.md" new file mode 100644 index 00000000..797458b5 --- /dev/null +++ "b/IX. \342\200\230How-to\342\200\231 guides/84.2 Change the AuthenticationManager and Add User Accounts.md" @@ -0,0 +1,5 @@ +### 84.2 改变AuthenticationManager并添加用户账号 + +如果你提供了一个`AuthenticationManager`、`AuthenticationProvider`、`UserDetailsService`类型的`@Bean`,那么默认的用于`InMemoryUserDetailsManager`的`@Bean`就不会被创建了,所以你可以获得Spring Security可用的全部特性(比如,[不同的认证选项](https://docs.spring.io/spring-security/site/docs/current/reference/htmlsingle/#jc-authentication))。 + +添加用户帐户的最简单方法是提供你自己的`UserDetailsService` bean。 From d6d7fc29caaf46f9bcb508e9e05dfbed3ee595b5 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E7=83=AD=E5=BF=83=E5=B8=82=E6=B0=91=E9=92=9F=E5=B0=8F?= =?UTF-8?q?=E5=BC=BA?= Date: Sat, 8 Feb 2020 12:55:19 +0800 Subject: [PATCH 787/865] Update and rename 82.3 Enable HTTPS when running behind a proxy server.md to 84.3 Enable HTTPS When Running behind a Proxy Server.md --- ...TPS when running behind a proxy server.md" | 12 ---------- ...TPS When Running behind a Proxy Server.md" | 22 +++++++++++++++++++ 2 files changed, 22 insertions(+), 12 deletions(-) delete mode 100644 "IX. \342\200\230How-to\342\200\231 guides/82.3 Enable HTTPS when running behind a proxy server.md" create mode 100644 "IX. \342\200\230How-to\342\200\231 guides/84.3 Enable HTTPS When Running behind a Proxy Server.md" diff --git "a/IX. \342\200\230How-to\342\200\231 guides/82.3 Enable HTTPS when running behind a proxy server.md" "b/IX. \342\200\230How-to\342\200\231 guides/82.3 Enable HTTPS when running behind a proxy server.md" deleted file mode 100644 index fa717552..00000000 --- "a/IX. \342\200\230How-to\342\200\231 guides/82.3 Enable HTTPS when running behind a proxy server.md" +++ /dev/null @@ -1,12 +0,0 @@ -### 82.3 当前端使用代理服务器时启用HTTPS - -对于任何应用来说,确保所有的主端点(URL)都只在HTTPS下可用是个重要的苦差事。如果你使用Tomcat作为servlet容器,那Spring Boot如果发现一些环境设置的话,它将自动添加Tomcat自己的`RemoteIpValve`,你也可以依赖于`HttpServletRequest`来报告是否请求是安全的(即使代理服务器的downstream处理真实的SSL终端)。这个标准行为取决于某些请求头是否出现(`x-forwarded-for`和`x-forwarded-proto`),这些请求头的名称都是约定好的,所以对于大多数前端和代理都是有效的。 - -你可以向`application.properties`添加以下设置开启该功能,比如: -```yml -server.tomcat.remote_ip_header=x-forwarded-for -server.tomcat.protocol_header=x-forwarded-proto -``` -(这些属性出现一个就会开启该功能,或者你可以通过添加一个`TomcatServletWebServerFactory` bean自己添加`RemoteIpValve`)。 - -Spring Security也可以配置成针对所有或某些请求需要一个安全渠道(channel)。想要在一个Spring Boot应用中开启它,你只需将`application.properties`中的`security.require_ssl`设置为`true`即可。 diff --git "a/IX. \342\200\230How-to\342\200\231 guides/84.3 Enable HTTPS When Running behind a Proxy Server.md" "b/IX. \342\200\230How-to\342\200\231 guides/84.3 Enable HTTPS When Running behind a Proxy Server.md" new file mode 100644 index 00000000..86281e78 --- /dev/null +++ "b/IX. \342\200\230How-to\342\200\231 guides/84.3 Enable HTTPS When Running behind a Proxy Server.md" @@ -0,0 +1,22 @@ +### 84.3 当前端使用代理服务器时启用HTTPS + +对于任何应用来说,确保所有的主端点(URL)都只在HTTPS下可用是个重要的苦差事。如果你使用Tomcat作为servlet容器,那Spring Boot如果发现一些环境设置的话,它将自动添加Tomcat自己的`RemoteIpValve`,你也可以依赖于`HttpServletRequest`来报告是否请求是安全的(即使代理服务器的downstream处理真实的SSL终端)。这个标准行为取决于某些请求头是否出现(`x-forwarded-for`和`x-forwarded-proto`),这些请求头的名称都是约定好的,所以对于大多数前端和代理都是有效的。你可以向`application.properties`添加以下设置开启该功能,比如: +```properties +server.tomcat.remote-ip-header=x-forwarded-for +server.tomcat.protocol-header=x-forwarded-proto +``` +(这些属性出现一个就会开启该功能,或者你可以通过添加一个`TomcatServletWebServerFactory` bean自己添加`RemoteIpValve`)。 + +要将Spring Security配置为所有(或部分)请求都需要一个安全通道,请考虑添加你自己的`WebSecurityConfigurerAdapter`,它将添加以下`HttpSecurity`配置: +``` +@Configuration +public class SslWebSecurityConfigurerAdapter extends WebSecurityConfigurerAdapter { + + @Override + protected void configure(HttpSecurity http) throws Exception { + // Customize the application security + http.requiresChannel().anyRequest().requiresSecure(); + } + +} +``` From 29cad5c2a7e1e13be1b6c57511ae9953905387b8 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E7=83=AD=E5=BF=83=E5=B8=82=E6=B0=91=E9=92=9F=E5=B0=8F?= =?UTF-8?q?=E5=BC=BA?= Date: Tue, 11 Feb 2020 22:46:58 +0800 Subject: [PATCH 788/865] Update SUMMARY.md --- SUMMARY.md | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/SUMMARY.md b/SUMMARY.md index 21f5d3ea..a3acab23 100644 --- a/SUMMARY.md +++ b/SUMMARY.md @@ -538,14 +538,14 @@ * [84.1 关闭Spring Boot安全配置](IX. ‘How-to’ guides/84.1 Switch off the Spring Boot Security Configuration.md) * [84.2 改变AuthenticationManager并添加用户账号](IX. ‘How-to’ guides/84.2 Change the AuthenticationManager and Add User Accounts.md) * [84.3 当前端使用代理服务器时启用HTTPS](IX. ‘How-to’ guides/84.3 Enable HTTPS When Running behind a Proxy Server.md) - * [83. 热交换](IX. ‘How-to’ guides/83. Hot swapping.md) - * [83.1 重新加载静态内容](IX. ‘How-to’ guides/83.1 Reload static content.md) - * [83.2. 在不重启容器的情况下重新加载模板](IX. ‘How-to’ guides/83.2. Reload templates without restarting the container.md) - * [83.2.1 Thymeleaf模板](IX. ‘How-to’ guides/83.2.1 Thymeleaf templates.md) - * [83.2.2 FreeMarker模板](IX. ‘How-to’ guides/83.2.2 FreeMarker templates.md) - * [83.2.3 Groovy模板](IX. ‘How-to’ guides/83.2.3 Groovy templates.md) - * [83.3 应用快速重启](IX. ‘How-to’ guides/83.3 Fast application restarts.md) - * [83.4 在不重启容器的情况下重新加载Java类](IX. ‘How-to’ guides/83.4 Reload Java classes without restarting the container.md) + * [85. 热交换](IX. ‘How-to’ guides/85. Hot Swapping.md) + * [85.1 重新加载静态内容](IX. ‘How-to’ guides/85.1 Reload Static Content.md) + * [85.2. 在不重启容器的情况下重新加载模板](IX. ‘How-to’ guides/85.2. Reload Templates without Restarting the Container.md) + * [85.2.1 Thymeleaf模板](IX. ‘How-to’ guides/85.2.1 Thymeleaf Templates.md) + * [85.2.2 FreeMarker模板](IX. ‘How-to’ guides/85.2.2 FreeMarker Templates.md) + * [85.2.3 Groovy模板](IX. ‘How-to’ guides/85.2.3 Groovy Templates.md) + * [85.3 应用快速重启](IX. ‘How-to’ guides/85.3 Fast Application Restarts.md) + * [85.4 在不重启容器的情况下重新加载Java类](IX. ‘How-to’ guides/85.4 Reload Java Classes without Restarting the Container.md) * [84. 构建](IX. ‘How-to’ guides/84. Build.md) * [84.1 生成构建信息](IX. ‘How-to’ guides/84.1 Generate build information.md) * [84.2 生成Git信息](IX. ‘How-to’ guides/84.2 Generate git information.md) From ea0b152bdee303f2e9390fbfcf6796df204a1e39 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E7=83=AD=E5=BF=83=E5=B8=82=E6=B0=91=E9=92=9F=E5=B0=8F?= =?UTF-8?q?=E5=BC=BA?= Date: Sat, 15 Feb 2020 13:28:02 +0800 Subject: [PATCH 789/865] Update and rename 83. Hot swapping.md to 85. Hot Swapping.md --- .../83. Hot swapping.md" | 1 - .../85. Hot Swapping.md" | 3 +++ 2 files changed, 3 insertions(+), 1 deletion(-) delete mode 100644 "IX. \342\200\230How-to\342\200\231 guides/83. Hot swapping.md" create mode 100644 "IX. \342\200\230How-to\342\200\231 guides/85. Hot Swapping.md" diff --git "a/IX. \342\200\230How-to\342\200\231 guides/83. Hot swapping.md" "b/IX. \342\200\230How-to\342\200\231 guides/83. Hot swapping.md" deleted file mode 100644 index 80b90468..00000000 --- "a/IX. \342\200\230How-to\342\200\231 guides/83. Hot swapping.md" +++ /dev/null @@ -1 +0,0 @@ -### 83. 热交换 diff --git "a/IX. \342\200\230How-to\342\200\231 guides/85. Hot Swapping.md" "b/IX. \342\200\230How-to\342\200\231 guides/85. Hot Swapping.md" new file mode 100644 index 00000000..ea952cd8 --- /dev/null +++ "b/IX. \342\200\230How-to\342\200\231 guides/85. Hot Swapping.md" @@ -0,0 +1,3 @@ +### 85. 热交换 + +Spring Boot支持热交换。本节回答关于它如何工作的问题。 From cf06bfe7215c5fd2823c289dbd788f9a2e6ecc93 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E7=83=AD=E5=BF=83=E5=B8=82=E6=B0=91=E9=92=9F=E5=B0=8F?= =?UTF-8?q?=E5=BC=BA?= Date: Sat, 15 Feb 2020 13:33:20 +0800 Subject: [PATCH 790/865] Update and rename 83.1 Reload static content.md to 85.1 Reload Static Content.md --- .../83.1 Reload static content.md" | 7 ------- .../85.1 Reload Static Content.md" | 7 +++++++ 2 files changed, 7 insertions(+), 7 deletions(-) delete mode 100644 "IX. \342\200\230How-to\342\200\231 guides/83.1 Reload static content.md" create mode 100644 "IX. \342\200\230How-to\342\200\231 guides/85.1 Reload Static Content.md" diff --git "a/IX. \342\200\230How-to\342\200\231 guides/83.1 Reload static content.md" "b/IX. \342\200\230How-to\342\200\231 guides/83.1 Reload static content.md" deleted file mode 100644 index 72b2543d..00000000 --- "a/IX. \342\200\230How-to\342\200\231 guides/83.1 Reload static content.md" +++ /dev/null @@ -1,7 +0,0 @@ -### 83.1 重新加载静态内容 - -Spring Boot有很多用于热加载的选项,不过推荐使用[spring-boot-devtools](../III. Using Spring Boot/20. Developer tools.md),因为它提供了其他开发时特性,比如快速应用重启和LiveReload,还有开发时敏感的配置加载(比如,模板缓存)。Devtools通过监控类路径上的变化工作。这意味着静态资源的改变必须“生成”才能生效。默认的,当你保存你的改变时,这在Eclipse里会自动发生。在IntelliJ IDEA里,生成项目将会触发必要的构建。由于[默认的重启排除](../III. Using Spring Boot/20.2.1. Excluding resources.md),静态资源的改变将不会触发应用的重启。但是,它们会触发LiveReload。 - -此外,使用IDE开发也是一个不错的方式,特别是需要调试的时候(所有的现代IDEs都允许重新加载静态资源,通常也支持对变更的Java类进行热交换)。 - -最后,[Maven和Gradle插件](../VIII. Build tool plugins/README.md)也支持命令行下的静态文件热加载。如果你使用其他高级工具编写css/js,并使用外部的css/js编译器,那你就可以充分利用该功能。 diff --git "a/IX. \342\200\230How-to\342\200\231 guides/85.1 Reload Static Content.md" "b/IX. \342\200\230How-to\342\200\231 guides/85.1 Reload Static Content.md" new file mode 100644 index 00000000..368f31a9 --- /dev/null +++ "b/IX. \342\200\230How-to\342\200\231 guides/85.1 Reload Static Content.md" @@ -0,0 +1,7 @@ +### 85.1 重新加载静态内容 + +Spring Boot有很多用于热加载的选项,不过推荐使用[spring-boot-devtools](https://docs.spring.io/spring-boot/docs/2.0.0.RELEASE/reference/htmlsingle/#using-boot-devtools),因为它提供了其他开发时特性,比如快速应用重启和LiveReload,还有开发时敏感的配置加载(比如,模板缓存)。Devtools通过监控类路径上的变化工作。这意味着静态资源的改变必须“生成”才能生效。默认的,当你保存你的改变时,这在Eclipse里会自动发生。在IntelliJ IDEA里,生成项目命令会触发必要的构建。由于[默认的重启排除](https://docs.spring.io/spring-boot/docs/2.0.0.RELEASE/reference/htmlsingle/#using-boot-devtools-restart-exclude),静态资源的改变将不会触发应用的重启。但是,它们会触发LiveReload。 + +此外,使用IDE开发也是一个不错的方式,特别是需要调试的时候(所有的现代IDEs都允许重新加载静态资源,通常也允许对变更的Java类进行热交换)。 + +最后,[Maven和Gradle插件](https://docs.spring.io/spring-boot/docs/2.0.0.RELEASE/reference/htmlsingle/#build-tool-plugins)也支持命令行下的静态文件热加载。如果你使用其他高级工具编写css/js,并使用外部的css/js编译器,那你就可以充分利用该功能。 From c8f3017e99aad859b23fd195f777bc213d2bc224 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E7=83=AD=E5=BF=83=E5=B8=82=E6=B0=91=E9=92=9F=E5=B0=8F?= =?UTF-8?q?=E5=BC=BA?= Date: Sat, 15 Feb 2020 13:36:06 +0800 Subject: [PATCH 791/865] Update and rename 83.2. Reload templates without restarting the container.md to 85.2. Reload Templates without Restarting the Container.md --- ...5.2. Reload Templates without Restarting the Container.md" | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) rename "IX. \342\200\230How-to\342\200\231 guides/83.2. Reload templates without restarting the container.md" => "IX. \342\200\230How-to\342\200\231 guides/85.2. Reload Templates without Restarting the Container.md" (51%) diff --git "a/IX. \342\200\230How-to\342\200\231 guides/83.2. Reload templates without restarting the container.md" "b/IX. \342\200\230How-to\342\200\231 guides/85.2. Reload Templates without Restarting the Container.md" similarity index 51% rename from "IX. \342\200\230How-to\342\200\231 guides/83.2. Reload templates without restarting the container.md" rename to "IX. \342\200\230How-to\342\200\231 guides/85.2. Reload Templates without Restarting the Container.md" index f69b81b4..6fa51d38 100644 --- "a/IX. \342\200\230How-to\342\200\231 guides/83.2. Reload templates without restarting the container.md" +++ "b/IX. \342\200\230How-to\342\200\231 guides/85.2. Reload Templates without Restarting the Container.md" @@ -1,3 +1,3 @@ -### 83.2. 在不重启容器的情况下重新加载模板 +### 85.2. 在不重启容器的情况下重新加载模板 -Spring Boot支持的大多数模板技术包含一个禁用缓存的配置选项,如果你正在使用`spring-boot-devtools`模块,Spring Boot在开发期间会自动为你[配置那些属性](../III. Using Spring Boot/20.1 Property defaults.md)。 +Spring Boot支持的大多数模板技术包含一个禁用缓存的配置选项,如果你正在使用`spring-boot-devtools`模块,Spring Boot在开发期间会自动为你[配置那些属性](https://docs.spring.io/spring-boot/docs/2.0.0.RELEASE/reference/htmlsingle/#using-boot-devtools-property-defaults)。 From 0478415e519c38fcb95313ee829ee55133b71c6d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E7=83=AD=E5=BF=83=E5=B8=82=E6=B0=91=E9=92=9F=E5=B0=8F?= =?UTF-8?q?=E5=BC=BA?= Date: Sat, 15 Feb 2020 13:39:04 +0800 Subject: [PATCH 792/865] Update and rename 83.2.1 Thymeleaf templates.md to 85.2.1 Thymeleaf Templates.md --- .../83.2.1 Thymeleaf templates.md" | 3 --- .../85.2.1 Thymeleaf Templates.md" | 3 +++ 2 files changed, 3 insertions(+), 3 deletions(-) delete mode 100644 "IX. \342\200\230How-to\342\200\231 guides/83.2.1 Thymeleaf templates.md" create mode 100644 "IX. \342\200\230How-to\342\200\231 guides/85.2.1 Thymeleaf Templates.md" diff --git "a/IX. \342\200\230How-to\342\200\231 guides/83.2.1 Thymeleaf templates.md" "b/IX. \342\200\230How-to\342\200\231 guides/83.2.1 Thymeleaf templates.md" deleted file mode 100644 index 73b3ea62..00000000 --- "a/IX. \342\200\230How-to\342\200\231 guides/83.2.1 Thymeleaf templates.md" +++ /dev/null @@ -1,3 +0,0 @@ -### 83.2.1 Thymeleaf模板 - -如果你正在使用Thymeleaf,那就将`spring.thymeleaf.cache`设置为`false`,查看[ThymeleafAutoConfiguration](http://github.com/spring-projects/spring-boot/tree/master/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/thymeleaf/ThymeleafAutoConfiguration.java)可以获取其他Thymeleaf自定义选项。 diff --git "a/IX. \342\200\230How-to\342\200\231 guides/85.2.1 Thymeleaf Templates.md" "b/IX. \342\200\230How-to\342\200\231 guides/85.2.1 Thymeleaf Templates.md" new file mode 100644 index 00000000..c467ee3b --- /dev/null +++ "b/IX. \342\200\230How-to\342\200\231 guides/85.2.1 Thymeleaf Templates.md" @@ -0,0 +1,3 @@ +### 85.2.1 Thymeleaf模板 + +如果你正在使用Thymeleaf,那就将`spring.thymeleaf.cache`设置为`false`,查看[ThymeleafAutoConfiguration](https://github.com/spring-projects/spring-boot/tree/v2.0.0.RELEASE/spring-boot-project/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/thymeleaf/ThymeleafAutoConfiguration.java)可以获取其他Thymeleaf自定义选项。 From 397f62d3b8b3d952c6e7e6dd905b3549995b8806 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E7=83=AD=E5=BF=83=E5=B8=82=E6=B0=91=E9=92=9F=E5=B0=8F?= =?UTF-8?q?=E5=BC=BA?= Date: Sat, 15 Feb 2020 13:40:33 +0800 Subject: [PATCH 793/865] Update and rename 83.2.2 FreeMarker templates.md to 85.2.2 FreeMarker Templates.md --- .../83.2.2 FreeMarker templates.md" | 3 --- .../85.2.2 FreeMarker Templates.md" | 3 +++ 2 files changed, 3 insertions(+), 3 deletions(-) delete mode 100644 "IX. \342\200\230How-to\342\200\231 guides/83.2.2 FreeMarker templates.md" create mode 100644 "IX. \342\200\230How-to\342\200\231 guides/85.2.2 FreeMarker Templates.md" diff --git "a/IX. \342\200\230How-to\342\200\231 guides/83.2.2 FreeMarker templates.md" "b/IX. \342\200\230How-to\342\200\231 guides/83.2.2 FreeMarker templates.md" deleted file mode 100644 index f2485eab..00000000 --- "a/IX. \342\200\230How-to\342\200\231 guides/83.2.2 FreeMarker templates.md" +++ /dev/null @@ -1,3 +0,0 @@ -### 83.2.2 FreeMarker模板 - -如果你正在使用FreeMarker,那就将`spring.freemarker.cache`设置为`false`,查看[FreeMarkerAutoConfiguration ](http://github.com/spring-projects/spring-boot/tree/master/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/freemarker/FreeMarkerAutoConfiguration.java)可以获取其他FreeMarker自定义选项。 diff --git "a/IX. \342\200\230How-to\342\200\231 guides/85.2.2 FreeMarker Templates.md" "b/IX. \342\200\230How-to\342\200\231 guides/85.2.2 FreeMarker Templates.md" new file mode 100644 index 00000000..ab30bd51 --- /dev/null +++ "b/IX. \342\200\230How-to\342\200\231 guides/85.2.2 FreeMarker Templates.md" @@ -0,0 +1,3 @@ +### 85.2.2 FreeMarker模板 + +如果你正在使用FreeMarker,那就将`spring.freemarker.cache`设置为`false`,查看[FreeMarkerAutoConfiguration ](https://github.com/spring-projects/spring-boot/tree/v2.0.0.RELEASE/spring-boot-project/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/freemarker/FreeMarkerAutoConfiguration.java)可以获取其他FreeMarker自定义选项。 From 08b36645962db6b8bbe76dadac2df64e6d4d8ec9 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E7=83=AD=E5=BF=83=E5=B8=82=E6=B0=91=E9=92=9F=E5=B0=8F?= =?UTF-8?q?=E5=BC=BA?= Date: Sat, 15 Feb 2020 13:41:42 +0800 Subject: [PATCH 794/865] Update and rename 83.2.3 Groovy templates.md to 85.2.3 Groovy Templates.md --- .../83.2.3 Groovy templates.md" | 3 --- .../85.2.3 Groovy Templates.md" | 3 +++ 2 files changed, 3 insertions(+), 3 deletions(-) delete mode 100644 "IX. \342\200\230How-to\342\200\231 guides/83.2.3 Groovy templates.md" create mode 100644 "IX. \342\200\230How-to\342\200\231 guides/85.2.3 Groovy Templates.md" diff --git "a/IX. \342\200\230How-to\342\200\231 guides/83.2.3 Groovy templates.md" "b/IX. \342\200\230How-to\342\200\231 guides/83.2.3 Groovy templates.md" deleted file mode 100644 index 3e80cbce..00000000 --- "a/IX. \342\200\230How-to\342\200\231 guides/83.2.3 Groovy templates.md" +++ /dev/null @@ -1,3 +0,0 @@ -### 83.2.3 Groovy模板 - -如果你正在使用Groovy模板,那就将`spring.groovy.template.cache`设置为`false`,查看[GroovyTemplateAutoConfiguration](http://github.com/spring-projects/spring-boot/tree/master/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/groovy/template/GroovyTemplateAutoConfiguration.java)可以获取其他Groovy自定义选项。 diff --git "a/IX. \342\200\230How-to\342\200\231 guides/85.2.3 Groovy Templates.md" "b/IX. \342\200\230How-to\342\200\231 guides/85.2.3 Groovy Templates.md" new file mode 100644 index 00000000..5b374323 --- /dev/null +++ "b/IX. \342\200\230How-to\342\200\231 guides/85.2.3 Groovy Templates.md" @@ -0,0 +1,3 @@ +### 85.2.3 Groovy模板 + +如果你正在使用Groovy模板,那就将`spring.groovy.template.cache`设置为`false`,查看[https://github.com/spring-projects/spring-boot/tree/v2.0.0.RELEASE/spring-boot-project/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/groovy/template/GroovyTemplateAutoConfiguration.java)可以获取其他Groovy自定义选项。 From e982708f18d811852843f5d4a20ecb74477d7963 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E7=83=AD=E5=BF=83=E5=B8=82=E6=B0=91=E9=92=9F=E5=B0=8F?= =?UTF-8?q?=E5=BC=BA?= Date: Sat, 15 Feb 2020 13:50:57 +0800 Subject: [PATCH 795/865] Update 85.2.3 Groovy Templates.md --- .../85.2.3 Groovy Templates.md" | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git "a/IX. \342\200\230How-to\342\200\231 guides/85.2.3 Groovy Templates.md" "b/IX. \342\200\230How-to\342\200\231 guides/85.2.3 Groovy Templates.md" index 5b374323..ebf8b3f3 100644 --- "a/IX. \342\200\230How-to\342\200\231 guides/85.2.3 Groovy Templates.md" +++ "b/IX. \342\200\230How-to\342\200\231 guides/85.2.3 Groovy Templates.md" @@ -1,3 +1,3 @@ ### 85.2.3 Groovy模板 -如果你正在使用Groovy模板,那就将`spring.groovy.template.cache`设置为`false`,查看[https://github.com/spring-projects/spring-boot/tree/v2.0.0.RELEASE/spring-boot-project/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/groovy/template/GroovyTemplateAutoConfiguration.java)可以获取其他Groovy自定义选项。 +如果你正在使用Groovy模板,那就将`spring.groovy.template.cache`设置为`false`,查看[GroovyTemplateAutoConfiguration](https://github.com/spring-projects/spring-boot/tree/v2.0.0.RELEASE/spring-boot-project/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/groovy/template/GroovyTemplateAutoConfiguration.java)可以获取其他Groovy自定义选项。 From 5e7846459f7f587af14f15d942fbe9f808dc51e0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E7=83=AD=E5=BF=83=E5=B8=82=E6=B0=91=E9=92=9F=E5=B0=8F?= =?UTF-8?q?=E5=BC=BA?= Date: Sat, 15 Feb 2020 13:56:53 +0800 Subject: [PATCH 796/865] Update 20. Developer Tools.md --- III. Using Spring Boot/20. Developer Tools.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/III. Using Spring Boot/20. Developer Tools.md b/III. Using Spring Boot/20. Developer Tools.md index 19b5040f..28ad3c7b 100644 --- a/III. Using Spring Boot/20. Developer Tools.md +++ b/III. Using Spring Boot/20. Developer Tools.md @@ -1,4 +1,4 @@ -###20. 开发者工具 +### 20. 开发者工具 Spring Boot包含了一些额外的工具集,用于提升Spring Boot应用的开发体验。`spring-boot-devtools`模块可以included到任何模块中,以提供development-time特性,你只需将该模块的依赖添加到构建中: From ee9c477e015853b59fb0ad3796233c24bba3ec91 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E7=83=AD=E5=BF=83=E5=B8=82=E6=B0=91=E9=92=9F=E5=B0=8F?= =?UTF-8?q?=E5=BC=BA?= Date: Sat, 15 Feb 2020 13:58:25 +0800 Subject: [PATCH 797/865] Update and rename 83.3 Fast application restarts.md to 85.3 Fast Application Restarts.md --- .../83.3 Fast application restarts.md" | 3 --- .../85.3 Fast Application Restarts.md" | 5 +++++ 2 files changed, 5 insertions(+), 3 deletions(-) delete mode 100644 "IX. \342\200\230How-to\342\200\231 guides/83.3 Fast application restarts.md" create mode 100644 "IX. \342\200\230How-to\342\200\231 guides/85.3 Fast Application Restarts.md" diff --git "a/IX. \342\200\230How-to\342\200\231 guides/83.3 Fast application restarts.md" "b/IX. \342\200\230How-to\342\200\231 guides/83.3 Fast application restarts.md" deleted file mode 100644 index 4721d565..00000000 --- "a/IX. \342\200\230How-to\342\200\231 guides/83.3 Fast application restarts.md" +++ /dev/null @@ -1,3 +0,0 @@ -### 83.3 应用快速重启 - -`spring-boot-devtools`模块包括应用自动重启支持,虽然没有其他技术快,比如[JRebel](http://zeroturnaround.com/software/jrebel/),但比"冷启动"快。在研究其他复杂重启选项时,你最好自己先试下,更多详情可参考[Chapter 20, Developer tools](../III. Using Spring Boot/20. Developer tools.md)章节。 diff --git "a/IX. \342\200\230How-to\342\200\231 guides/85.3 Fast Application Restarts.md" "b/IX. \342\200\230How-to\342\200\231 guides/85.3 Fast Application Restarts.md" new file mode 100644 index 00000000..4d989a77 --- /dev/null +++ "b/IX. \342\200\230How-to\342\200\231 guides/85.3 Fast Application Restarts.md" @@ -0,0 +1,5 @@ +### 85.3 应用快速重启 + +`spring-boot-devtools`模块包括应用自动重启支持,虽然没有其他技术快,比如[JRebel](http://zeroturnaround.com/software/jrebel/),但比"冷启动"快。在研究其他复杂重启选项时,你最好自己先试下。 + +更多详情可参考[20. 开发者工具](https://docs.spring.io/spring-boot/docs/2.0.0.RELEASE/reference/htmlsingle/#using-boot-devtools)。 From 0714c5c71f2d294736264cd068c6e84e1ec174d7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E7=83=AD=E5=BF=83=E5=B8=82=E6=B0=91=E9=92=9F=E5=B0=8F?= =?UTF-8?q?=E5=BC=BA?= Date: Sat, 15 Feb 2020 14:03:24 +0800 Subject: [PATCH 798/865] Update and rename 83.4 Reload Java classes without restarting the container.md to 85.4 Reload Java Classes without Restarting the Container.md --- ....4 Reload Java classes without restarting the container.md" | 3 --- ....4 Reload Java Classes without Restarting the Container.md" | 3 +++ 2 files changed, 3 insertions(+), 3 deletions(-) delete mode 100644 "IX. \342\200\230How-to\342\200\231 guides/83.4 Reload Java classes without restarting the container.md" create mode 100644 "IX. \342\200\230How-to\342\200\231 guides/85.4 Reload Java Classes without Restarting the Container.md" diff --git "a/IX. \342\200\230How-to\342\200\231 guides/83.4 Reload Java classes without restarting the container.md" "b/IX. \342\200\230How-to\342\200\231 guides/83.4 Reload Java classes without restarting the container.md" deleted file mode 100644 index 2b978736..00000000 --- "a/IX. \342\200\230How-to\342\200\231 guides/83.4 Reload Java classes without restarting the container.md" +++ /dev/null @@ -1,3 +0,0 @@ -### 83.4 在不重启容器的情况下重新加载Java类 - -现代IDEs(Eclipse, IDEA等)都支持字节码的热交换,所以如果你做了一个没有影响类或方法签名的改变,它会利索地重新加载并没有任何影响。 diff --git "a/IX. \342\200\230How-to\342\200\231 guides/85.4 Reload Java Classes without Restarting the Container.md" "b/IX. \342\200\230How-to\342\200\231 guides/85.4 Reload Java Classes without Restarting the Container.md" new file mode 100644 index 00000000..86f30997 --- /dev/null +++ "b/IX. \342\200\230How-to\342\200\231 guides/85.4 Reload Java Classes without Restarting the Container.md" @@ -0,0 +1,3 @@ +### 85.4 在不重启容器的情况下重新加载Java类 + +许多现代IDE(Eclipse、IDEA等)都支持字节码的热交换。所以如果你做了一个没有影响类或方法签名的改变,它会利索地重新加载并没有任何影响。 From da001799cc9e052f8edc7ff9f8cb21e089d3e9ed Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E7=83=AD=E5=BF=83=E5=B8=82=E6=B0=91=E9=92=9F=E5=B0=8F?= =?UTF-8?q?=E5=BC=BA?= Date: Sat, 15 Feb 2020 14:30:11 +0800 Subject: [PATCH 799/865] Update SUMMARY.md --- SUMMARY.md | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) diff --git a/SUMMARY.md b/SUMMARY.md index a3acab23..2938ecf0 100644 --- a/SUMMARY.md +++ b/SUMMARY.md @@ -546,16 +546,16 @@ * [85.2.3 Groovy模板](IX. ‘How-to’ guides/85.2.3 Groovy Templates.md) * [85.3 应用快速重启](IX. ‘How-to’ guides/85.3 Fast Application Restarts.md) * [85.4 在不重启容器的情况下重新加载Java类](IX. ‘How-to’ guides/85.4 Reload Java Classes without Restarting the Container.md) - * [84. 构建](IX. ‘How-to’ guides/84. Build.md) - * [84.1 生成构建信息](IX. ‘How-to’ guides/84.1 Generate build information.md) - * [84.2 生成Git信息](IX. ‘How-to’ guides/84.2 Generate git information.md) - * [84.3 自定义依赖版本](IX. ‘How-to’ guides/84.3 Customize dependency versions.md) - * [84.4 使用Maven创建可执行JAR](IX. ‘How-to’ guides/84.4 Create an executable JAR with Maven.md) - * [84.5 将Spring Boot应用作为依赖](IX. ‘How-to’ guides/84.5 Use a Spring Boot application as a dependency.md) - * [84.6 在可执行jar运行时提取特定的版本](IX. ‘How-to’ guides/84.6 Extract specific libraries when an executable jar runs.md) - * [84.7 使用排除创建不可执行的JAR](IX. ‘How-to’ guides/84.7 Create a non-executable JAR with exclusions.md) - * [84.8 远程调试使用Maven启动的Spring Boot项目](IX. ‘How-to’ guides/84.8 Remote debug a Spring Boot application started with Maven.md) - * [84.9 使用Ant构建可执行存档(不使用spring-boot-antlib)](IX. ‘How-to’ guides/84.9 Build an executable archive from Ant without using spring-boot-antlib.md) + * [86. 构建](IX. ‘How-to’ guides/86. Build.md) + * [86.1 生成构建信息](IX. ‘How-to’ guides/86.1 Generate Build Information.md) + * [86.2 生成Git信息](IX. ‘How-to’ guides/86.2 Generate Git Information.md) + * [86.3 自定义依赖版本](IX. ‘How-to’ guides/86.3 Customize Dependency Versions.md) + * [86.4 使用Maven创建可执行JAR](IX. ‘How-to’ guides/86.4 Create an Executable JAR with Maven.md) + * [86.5 将Spring Boot应用作为依赖](IX. ‘How-to’ guides/86.5 Use a Spring Boot Application as a Dependency.md) + * [86.6 在可执行jar运行时提取特定的版本](IX. ‘How-to’ guides/86.6 Extract Specific Libraries When an Executable Jar Runs.md) + * [86.7 使用排除创建不可执行的JAR](IX. ‘How-to’ guides/86.7 Create a Non-executable JAR with Exclusions.md) + * [86.8 远程调试使用Maven启动的Spring Boot项目](IX. ‘How-to’ guides/86.8 Remote Debug a Spring Boot Application Started with Maven.md) + * [86.9 使用Ant构建可执行存档(不使用spring-boot-antlib)](IX. ‘How-to’ guides/86.9 Build an Executable Archive from Ant without Using spring-boot-antlib.md) * [85. 传统部署](IX. ‘How-to’ guides/85. Traditional deployment.md) * [85.1 创建可部署的war文件](IX. ‘How-to’ guides/85.1 Create a deployable war file.md) * [85.2 为老的servlet容器创建可部署的war文件](IX. ‘How-to’ guides/85.2 Create a deployable war file for older servlet containers.md) From 75a65261b4fb1c2b4468365dbe4bc0ef0022e4fb Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E7=83=AD=E5=BF=83=E5=B8=82=E6=B0=91=E9=92=9F=E5=B0=8F?= =?UTF-8?q?=E5=BC=BA?= Date: Thu, 20 Feb 2020 16:42:44 +0800 Subject: [PATCH 800/865] Delete 79.4.1 Configuring Spring Loaded for use with Maven.md --- ...iguring Spring Loaded for use with Maven.md" | 17 ----------------- 1 file changed, 17 deletions(-) delete mode 100644 "IX. \342\200\230How-to\342\200\231 guides/79.4.1 Configuring Spring Loaded for use with Maven.md" diff --git "a/IX. \342\200\230How-to\342\200\231 guides/79.4.1 Configuring Spring Loaded for use with Maven.md" "b/IX. \342\200\230How-to\342\200\231 guides/79.4.1 Configuring Spring Loaded for use with Maven.md" deleted file mode 100644 index 5628b90d..00000000 --- "a/IX. \342\200\230How-to\342\200\231 guides/79.4.1 Configuring Spring Loaded for use with Maven.md" +++ /dev/null @@ -1,17 +0,0 @@ -### 79.4.1 使用Maven配置Spring Loaded - -为了在Maven命令行下使用Spring Loaded,你只需将它作为依赖添加到Spring Boot插件声明中即可,比如: -```xml - - org.springframework.boot - spring-boot-maven-plugin - - - org.springframework - springloaded - 1.2.0.RELEASE - - - -``` -正常情况下,这在Eclipse和IntelliJ IDEA中工作的相当漂亮,只要它们有相应的,和Maven默认一致的构建配置(Eclipse m2e对此支持的更好,开箱即用)。 From 33b1cc81a1245265d7ef85759f5a4b5d6f6d999a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E7=83=AD=E5=BF=83=E5=B8=82=E6=B0=91=E9=92=9F=E5=B0=8F?= =?UTF-8?q?=E5=BC=BA?= Date: Thu, 20 Feb 2020 16:43:11 +0800 Subject: [PATCH 801/865] Delete 79.4.2 Configuring Spring Loaded for use with Gradle and IntelliJ.md --- ...oaded for use with Gradle and IntelliJ.md" | 28 ------------------- 1 file changed, 28 deletions(-) delete mode 100644 "IX. \342\200\230How-to\342\200\231 guides/79.4.2 Configuring Spring Loaded for use with Gradle and IntelliJ.md" diff --git "a/IX. \342\200\230How-to\342\200\231 guides/79.4.2 Configuring Spring Loaded for use with Gradle and IntelliJ.md" "b/IX. \342\200\230How-to\342\200\231 guides/79.4.2 Configuring Spring Loaded for use with Gradle and IntelliJ.md" deleted file mode 100644 index dab85c27..00000000 --- "a/IX. \342\200\230How-to\342\200\231 guides/79.4.2 Configuring Spring Loaded for use with Gradle and IntelliJ.md" +++ /dev/null @@ -1,28 +0,0 @@ -### 79.4.2 使用Gradle和IntelliJ IDEA配置Spring Loaded - -如果想将Spring Loaded和Gradle,IntelliJ IDEA结合起来,那你需要付出代价。默认情况下,IntelliJ IDEA将类编译到一个跟Gradle不同的位置,这会导致Spring Loaded监控失败。 - -为了正确配置IntelliJ IDEA,你可以使用`idea` Gradle插件: -```gradle -buildscript { - repositories { jcenter() } - dependencies { - classpath "org.springframework.boot:spring-boot-gradle-plugin:2.0.0.RELEASE" - classpath 'org.springframework:springloaded:1.2.0.RELEASE' - } -} - -apply plugin: 'idea' - -idea { - module { - inheritOutputDirs = false - outputDir = file("$buildDir/classes/main/") - } -} - -// ... -``` -**注** IntelliJ IDEA必须配置跟命令行Gradle任务相同的Java版本,并且`springloaded`必须作为一个`buildscript`依赖被包含进去。 - -此外,你也可以启用Intellij IDEA内部的`Make Project Automatically`,这样不管什么时候只要文件被保存都会自动编译。 From 16c1ed37c5ec8f2bada7904c715eca1ac8cc05ff Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E7=83=AD=E5=BF=83=E5=B8=82=E6=B0=91=E9=92=9F=E5=B0=8F?= =?UTF-8?q?=E5=BC=BA?= Date: Thu, 20 Feb 2020 16:45:20 +0800 Subject: [PATCH 802/865] Update and rename 84. Build.md to 86. Build.md --- "IX. \342\200\230How-to\342\200\231 guides/84. Build.md" | 1 - "IX. \342\200\230How-to\342\200\231 guides/86. Build.md" | 3 +++ 2 files changed, 3 insertions(+), 1 deletion(-) delete mode 100644 "IX. \342\200\230How-to\342\200\231 guides/84. Build.md" create mode 100644 "IX. \342\200\230How-to\342\200\231 guides/86. Build.md" diff --git "a/IX. \342\200\230How-to\342\200\231 guides/84. Build.md" "b/IX. \342\200\230How-to\342\200\231 guides/84. Build.md" deleted file mode 100644 index 9eeb85a5..00000000 --- "a/IX. \342\200\230How-to\342\200\231 guides/84. Build.md" +++ /dev/null @@ -1 +0,0 @@ -### 84. 构建 diff --git "a/IX. \342\200\230How-to\342\200\231 guides/86. Build.md" "b/IX. \342\200\230How-to\342\200\231 guides/86. Build.md" new file mode 100644 index 00000000..47189481 --- /dev/null +++ "b/IX. \342\200\230How-to\342\200\231 guides/86. Build.md" @@ -0,0 +1,3 @@ +### 86. 构建 + +Spring Boot包含Maven和Gradle的构建插件。本节回答关于这些插件的常见问题。 From 4e0f9a83719bcb94144c70f7103446bf5a08306e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E7=83=AD=E5=BF=83=E5=B8=82=E6=B0=91=E9=92=9F=E5=B0=8F?= =?UTF-8?q?=E5=BC=BA?= Date: Thu, 20 Feb 2020 21:47:07 +0800 Subject: [PATCH 803/865] Update and rename 84.1 Generate build information.md to 86.1 Generate Build Information.md --- .../84.1 Generate build information.md" | 41 ------------------- .../86.1 Generate Build Information.md" | 32 +++++++++++++++ 2 files changed, 32 insertions(+), 41 deletions(-) delete mode 100644 "IX. \342\200\230How-to\342\200\231 guides/84.1 Generate build information.md" create mode 100644 "IX. \342\200\230How-to\342\200\231 guides/86.1 Generate Build Information.md" diff --git "a/IX. \342\200\230How-to\342\200\231 guides/84.1 Generate build information.md" "b/IX. \342\200\230How-to\342\200\231 guides/84.1 Generate build information.md" deleted file mode 100644 index 59c1135e..00000000 --- "a/IX. \342\200\230How-to\342\200\231 guides/84.1 Generate build information.md" +++ /dev/null @@ -1,41 +0,0 @@ -### 84.1 生成构建信息 - -Maven和Gradle都支持产生包含项目版本,坐标,名称的构建信息,该插件可以通过配置添加其他属性。当这些文件出现时,Spring Boot自动配置一个`BuildProperties` bean。 - -为了让Maven生成构建信息,你需要为`build-info` goal添加一个execution: -```xml - - - - org.springframework.boot - spring-boot-maven-plugin - 2.0.0.RELEASE - - - - build-info - - - - - - -``` -**注** 更多详情查看[Spring Boot Maven插件文档](https://docs.spring.io/spring-boot/docs/2.0.0.RELEASE/maven-plugin/)。 - -使用Gradle实现同样效果: -```gradle -springBoot { - buildInfo() -} -``` -可以使用DSL添加其他属性: -```gradle -springBoot { - buildInfo { - additionalProperties = [ - 'foo': 'bar' - ] - } -} -``` diff --git "a/IX. \342\200\230How-to\342\200\231 guides/86.1 Generate Build Information.md" "b/IX. \342\200\230How-to\342\200\231 guides/86.1 Generate Build Information.md" new file mode 100644 index 00000000..e8c5234f --- /dev/null +++ "b/IX. \342\200\230How-to\342\200\231 guides/86.1 Generate Build Information.md" @@ -0,0 +1,32 @@ +### 86.1 生成构建信息 + +Maven插件和Gradle插件都支持产生包含项目版本、坐标、名称的构建信息。该插件可以通过配置添加其他属性。当这些文件出现时,Spring Boot自动配置一个`BuildProperties` bean。 + +为了让Maven生成构建信息,你需要为`build-info` goal添加一个execution: +```xml + + + + org.springframework.boot + spring-boot-maven-plugin + 2.0.0.RELEASE + + + + build-info + + + + + + +``` +**注** 更多详情查看[Spring Boot Maven插件文档](https://docs.spring.io/spring-boot/docs/2.0.0.RELEASE/maven-plugin)。 + +使用Gradle实现同样效果: +```gradle +springBoot { + buildInfo() +} +``` +**注** 更多详情查看[Spring Boot Gradle插件文档](https://docs.spring.io/spring-boot/docs/2.0.0.RELEASE/gradle-plugin/reference/html/#integrating-with-actuator-build-info)。 From 1c271a9635d966703fc3a18391548d6b0677f3a1 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E7=83=AD=E5=BF=83=E5=B8=82=E6=B0=91=E9=92=9F=E5=B0=8F?= =?UTF-8?q?=E5=BC=BA?= Date: Thu, 20 Feb 2020 21:58:06 +0800 Subject: [PATCH 804/865] Update and rename 84.2 Generate git information.md to 86.2 Generate Git Information.md --- .../86.2 Generate Git Information.md" | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) rename "IX. \342\200\230How-to\342\200\231 guides/84.2 Generate git information.md" => "IX. \342\200\230How-to\342\200\231 guides/86.2 Generate Git Information.md" (69%) diff --git "a/IX. \342\200\230How-to\342\200\231 guides/84.2 Generate git information.md" "b/IX. \342\200\230How-to\342\200\231 guides/86.2 Generate Git Information.md" similarity index 69% rename from "IX. \342\200\230How-to\342\200\231 guides/84.2 Generate git information.md" rename to "IX. \342\200\230How-to\342\200\231 guides/86.2 Generate Git Information.md" index 3399cfad..b848e1aa 100644 --- "a/IX. \342\200\230How-to\342\200\231 guides/84.2 Generate git information.md" +++ "b/IX. \342\200\230How-to\342\200\231 guides/86.2 Generate Git Information.md" @@ -1,4 +1,4 @@ -### 84.2 生成Git信息 +### 86.2 生成Git信息 Maven和Gradle都支持生成一个`git.properties`文件,该文件包含项目构建时`git`源码的仓库状态。对于Maven用户来说,`spring-boot-starter-parent` POM包含一个预配置的插件去产生一个`git.properties`文件,只需简单的将以下声明添加到POM中: ```xml @@ -17,3 +17,5 @@ plugins { id "com.gorylenko.gradle-git-properties" version "1.4.17" } ``` + +**注** `git.properties`中的提交时间需要符合以下格式:`yyyy-MM-dd’T’HH:mm:ssZ`。这是上面列出的两个插件的默认格式。使用这种格式可以将时间解析为`Date`,并将其格式序列化为JSON时,由Jackson的日期序列化配置设置控制。 From 337fd34692375dca3e7e21078c2f504d46d15d2b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E7=83=AD=E5=BF=83=E5=B8=82=E6=B0=91=E9=92=9F=E5=B0=8F?= =?UTF-8?q?=E5=BC=BA?= Date: Thu, 20 Feb 2020 22:01:27 +0800 Subject: [PATCH 805/865] Update and rename 84.3 Customize dependency versions.md to 86.3 Customize Dependency Versions.md --- .../86.3 Customize Dependency Versions.md" | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) rename "IX. \342\200\230How-to\342\200\231 guides/84.3 Customize dependency versions.md" => "IX. \342\200\230How-to\342\200\231 guides/86.3 Customize Dependency Versions.md" (70%) diff --git "a/IX. \342\200\230How-to\342\200\231 guides/84.3 Customize dependency versions.md" "b/IX. \342\200\230How-to\342\200\231 guides/86.3 Customize Dependency Versions.md" similarity index 70% rename from "IX. \342\200\230How-to\342\200\231 guides/84.3 Customize dependency versions.md" rename to "IX. \342\200\230How-to\342\200\231 guides/86.3 Customize Dependency Versions.md" index 0477727b..7384745d 100644 --- "a/IX. \342\200\230How-to\342\200\231 guides/84.3 Customize dependency versions.md" +++ "b/IX. \342\200\230How-to\342\200\231 guides/86.3 Customize Dependency Versions.md" @@ -1,6 +1,6 @@ -### 84.3 自定义依赖版本 +### 86.3 自定义依赖版本 -如果你使用Maven进行一个直接或间接继承`spring-boot-dependencies`(比如`spring-boot-starter-parent`)的构建,并想覆盖一个特定的第三方依赖,那你可以添加合适的``元素。浏览[spring-boot-dependencies](http://github.com/spring-projects/spring-boot/tree/master/spring-boot-dependencies/pom.xml) POM可以获取一个全面的属性列表。例如,想要选择一个不同的`slf4j`版本,你可以添加以下内容: +如果你使用Maven进行一个直接或间接继承`spring-boot-dependencies`(比如`spring-boot-starter-parent`)的构建,并想覆盖一个特定的第三方依赖,那你可以添加合适的``元素。浏览[spring-boot-dependencies](https://github.com/spring-projects/spring-boot/tree/v2.0.0.RELEASE/spring-boot-project/spring-boot-dependencies/pom.xml) POM可以获取一个全面的属性列表。例如,想要选择一个不同的`slf4j`版本,你可以添加以下内容: ```xml 1.7.5 @@ -8,4 +8,4 @@ ``` **注** 这只在你的Maven项目继承(直接或间接)自`spring-boot-dependencies`才有用。如果你使用`import`,将`spring-boot-dependencies`添加到自己的`dependencyManagement`片段,那你必须自己重新定义artifact而不是覆盖属性。 -**注** 每个Spring Boot发布都是基于一些特定的第三方依赖集进行设计和测试的,覆盖版本可能导致兼容性问题。 \ No newline at end of file +**注** 每个Spring Boot发布都是基于一些特定的第三方依赖集进行设计和测试的,覆盖版本可能导致兼容性问题。 From d8ab6d649d7b16203ba002a622629c8de3e7bb0e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E7=83=AD=E5=BF=83=E5=B8=82=E6=B0=91=E9=92=9F=E5=B0=8F?= =?UTF-8?q?=E5=BC=BA?= Date: Thu, 20 Feb 2020 22:08:48 +0800 Subject: [PATCH 806/865] Update and rename 84.4 Create an executable JAR with Maven.md to 86.4 Create an Executable JAR with Maven.md --- .../86.4 Create an Executable JAR with Maven.md" | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) rename "IX. \342\200\230How-to\342\200\231 guides/84.4 Create an executable JAR with Maven.md" => "IX. \342\200\230How-to\342\200\231 guides/86.4 Create an Executable JAR with Maven.md" (93%) diff --git "a/IX. \342\200\230How-to\342\200\231 guides/84.4 Create an executable JAR with Maven.md" "b/IX. \342\200\230How-to\342\200\231 guides/86.4 Create an Executable JAR with Maven.md" similarity index 93% rename from "IX. \342\200\230How-to\342\200\231 guides/84.4 Create an executable JAR with Maven.md" rename to "IX. \342\200\230How-to\342\200\231 guides/86.4 Create an Executable JAR with Maven.md" index 264700b4..c2813619 100644 --- "a/IX. \342\200\230How-to\342\200\231 guides/84.4 Create an executable JAR with Maven.md" +++ "b/IX. \342\200\230How-to\342\200\231 guides/86.4 Create an Executable JAR with Maven.md" @@ -1,4 +1,4 @@ -### 84.4 使用Maven创建可执行JAR +### 86.4 使用Maven创建可执行JAR `spring-boot-maven-plugin`能够用来创建可执行的'胖'JAR。如果正在使用`spring-boot-starter-parent` POM,你可以简单地声明该插件,然后你的jar将被重新打包: ```xml From 7293476d6fdb535ffc036374abbd97777a15dd34 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E7=83=AD=E5=BF=83=E5=B8=82=E6=B0=91=E9=92=9F=E5=B0=8F?= =?UTF-8?q?=E5=BC=BA?= Date: Thu, 20 Feb 2020 22:11:15 +0800 Subject: [PATCH 807/865] Update and rename 84.5 Use a Spring Boot application as a dependency.md to 86.5 Use a Spring Boot Application as a Dependency.md --- .../86.5 Use a Spring Boot Application as a Dependency.md" | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) rename "IX. \342\200\230How-to\342\200\231 guides/84.5 Use a Spring Boot application as a dependency.md" => "IX. \342\200\230How-to\342\200\231 guides/86.5 Use a Spring Boot Application as a Dependency.md" (96%) diff --git "a/IX. \342\200\230How-to\342\200\231 guides/84.5 Use a Spring Boot application as a dependency.md" "b/IX. \342\200\230How-to\342\200\231 guides/86.5 Use a Spring Boot Application as a Dependency.md" similarity index 96% rename from "IX. \342\200\230How-to\342\200\231 guides/84.5 Use a Spring Boot application as a dependency.md" rename to "IX. \342\200\230How-to\342\200\231 guides/86.5 Use a Spring Boot Application as a Dependency.md" index 3c9001cf..a02abf2a 100644 --- "a/IX. \342\200\230How-to\342\200\231 guides/84.5 Use a Spring Boot application as a dependency.md" +++ "b/IX. \342\200\230How-to\342\200\231 guides/86.5 Use a Spring Boot Application as a Dependency.md" @@ -1,4 +1,4 @@ -### 84.5 将Spring Boot应用作为依赖 +### 86.5 将Spring Boot应用作为依赖 跟war包一样,Spring Boot应用不是用来作为依赖的。如果你的应用包含需要跟其他项目共享的类,最好的方式是将代码放到单独的模块,然后其他项目及你的应用都可以依赖该模块。 From 96ef0646975e9e7db8e527f6e47b7b48eb08ac61 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E7=83=AD=E5=BF=83=E5=B8=82=E6=B0=91=E9=92=9F=E5=B0=8F?= =?UTF-8?q?=E5=BC=BA?= Date: Thu, 20 Feb 2020 22:20:04 +0800 Subject: [PATCH 808/865] Update and rename 84.6 Extract specific libraries when an executable jar runs.md to 86.6 Extract Specific Libraries When an Executable Jar Runs.md --- ...Extract Specific Libraries When an Executable Jar Runs.md" | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) rename "IX. \342\200\230How-to\342\200\231 guides/84.6 Extract specific libraries when an executable jar runs.md" => "IX. \342\200\230How-to\342\200\231 guides/86.6 Extract Specific Libraries When an Executable Jar Runs.md" (92%) diff --git "a/IX. \342\200\230How-to\342\200\231 guides/84.6 Extract specific libraries when an executable jar runs.md" "b/IX. \342\200\230How-to\342\200\231 guides/86.6 Extract Specific Libraries When an Executable Jar Runs.md" similarity index 92% rename from "IX. \342\200\230How-to\342\200\231 guides/84.6 Extract specific libraries when an executable jar runs.md" rename to "IX. \342\200\230How-to\342\200\231 guides/86.6 Extract Specific Libraries When an Executable Jar Runs.md" index 674effd9..9430397c 100644 --- "a/IX. \342\200\230How-to\342\200\231 guides/84.6 Extract specific libraries when an executable jar runs.md" +++ "b/IX. \342\200\230How-to\342\200\231 guides/86.6 Extract Specific Libraries When an Executable Jar Runs.md" @@ -1,4 +1,4 @@ -### 84.6 在可执行jar运行时提取特定的版本 +### 86.6 在可执行jar运行时提取特定的版本 在一个可执行jar中,为了运行,多数内嵌的库不需要拆包(unpacked),然而有一些库可能会遇到问题。例如,JRuby包含它自己的内嵌jar,它假定`jruby-complete.jar`本身总是能够直接作为文件访问的。 @@ -20,4 +20,4 @@ -``` \ No newline at end of file +``` From 1e7586024d8495d0e23ed760e11f926a9eedd272 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E7=83=AD=E5=BF=83=E5=B8=82=E6=B0=91=E9=92=9F=E5=B0=8F?= =?UTF-8?q?=E5=BC=BA?= Date: Thu, 20 Feb 2020 22:25:27 +0800 Subject: [PATCH 809/865] Update and rename 84.7 Create a non-executable JAR with exclusions.md to 86.7 Create a Non-executable JAR with Exclusions.md --- .../86.7 Create a Non-executable JAR with Exclusions.md" | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) rename "IX. \342\200\230How-to\342\200\231 guides/84.7 Create a non-executable JAR with exclusions.md" => "IX. \342\200\230How-to\342\200\231 guides/86.7 Create a Non-executable JAR with Exclusions.md" (55%) diff --git "a/IX. \342\200\230How-to\342\200\231 guides/84.7 Create a non-executable JAR with exclusions.md" "b/IX. \342\200\230How-to\342\200\231 guides/86.7 Create a Non-executable JAR with Exclusions.md" similarity index 55% rename from "IX. \342\200\230How-to\342\200\231 guides/84.7 Create a non-executable JAR with exclusions.md" rename to "IX. \342\200\230How-to\342\200\231 guides/86.7 Create a Non-executable JAR with Exclusions.md" index 0cc2190b..949ba469 100644 --- "a/IX. \342\200\230How-to\342\200\231 guides/84.7 Create a non-executable JAR with exclusions.md" +++ "b/IX. \342\200\230How-to\342\200\231 guides/86.7 Create a Non-executable JAR with Exclusions.md" @@ -1,8 +1,8 @@ -### 84.7 使用排除创建不可执行的JAR +### 86.7 使用排除创建不可执行的JAR -如果你构建的产物既有可执行的jar和非可执行的jar,那你常常需要为可执行的版本添加额外的配置文件,而这些文件在一个library jar中是不需要的。比如,`application.yml`配置文件可能需要从非可执行的JAR中排除。 +如果你构建的两个单独的产物既有可执行的jar和非可执行的jar,那你常常需要为可执行的版本添加额外的配置文件,而这些文件在一个library jar中是不需要的。比如,`application.yml`配置文件可能需要从非可执行的JAR中排除。 -`maven-jar-plugin`过去一直会暴露`forceCreation`属性。一旦`repackage`目标执行,就可以再一次创建jar。可以说,这就有些脆弱。因为它依靠plugin executions的顺序。在Maven里,可执行的jar必须是主要的artifact,并且你可以为类库加入一个分类的jar: +在Maven里,可执行的jar必须是主要的artifact,并且你可以为类库加入一个分类的jar: ```xml From 3c4f5cbe508f6f97d09116a3127f4231c1cf025c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E7=83=AD=E5=BF=83=E5=B8=82=E6=B0=91=E9=92=9F=E5=B0=8F?= =?UTF-8?q?=E5=BC=BA?= Date: Thu, 20 Feb 2020 22:29:00 +0800 Subject: [PATCH 810/865] Update and rename 84.8 Remote debug a Spring Boot application started with Maven.md to 86.8 Remote Debug a Spring Boot Application Started with Maven.md --- ...ote debug a Spring Boot application started with Maven.md" | 3 --- ...ote Debug a Spring Boot Application Started with Maven.md" | 4 ++++ 2 files changed, 4 insertions(+), 3 deletions(-) delete mode 100644 "IX. \342\200\230How-to\342\200\231 guides/84.8 Remote debug a Spring Boot application started with Maven.md" create mode 100644 "IX. \342\200\230How-to\342\200\231 guides/86.8 Remote Debug a Spring Boot Application Started with Maven.md" diff --git "a/IX. \342\200\230How-to\342\200\231 guides/84.8 Remote debug a Spring Boot application started with Maven.md" "b/IX. \342\200\230How-to\342\200\231 guides/84.8 Remote debug a Spring Boot application started with Maven.md" deleted file mode 100644 index 8c905609..00000000 --- "a/IX. \342\200\230How-to\342\200\231 guides/84.8 Remote debug a Spring Boot application started with Maven.md" +++ /dev/null @@ -1,3 +0,0 @@ -### 84.8 远程调试使用Maven启动的Spring Boot项目 - -想要为使用Maven启动的Spring Boot应用添加一个远程调试器,你可以使用[mave插件](https://docs.spring.io/spring-boot/docs/2.0.0.RELEASE/maven-plugin/)的jvmArguments属性,详情参考[示例](https://docs.spring.io/spring-boot/docs/2.0.0.RELEASE/maven-plugin/examples/run-debug.html)。 diff --git "a/IX. \342\200\230How-to\342\200\231 guides/86.8 Remote Debug a Spring Boot Application Started with Maven.md" "b/IX. \342\200\230How-to\342\200\231 guides/86.8 Remote Debug a Spring Boot Application Started with Maven.md" new file mode 100644 index 00000000..445a00c8 --- /dev/null +++ "b/IX. \342\200\230How-to\342\200\231 guides/86.8 Remote Debug a Spring Boot Application Started with Maven.md" @@ -0,0 +1,4 @@ +### 86.8 远程调试使用Maven启动的Spring Boot项目 + +想要为使用Maven启动的Spring Boot应用添加一个远程调试器,你可以使用[mave插件](https://docs.spring.io/spring-boot/docs/2.0.0.RELEASE/maven-plugin)的jvmArguments属性。 +详情参考[示例](https://docs.spring.io/spring-boot/docs/2.0.0.RELEASE/maven-plugin/examples/run-debug.html)。 From d5a9a619d696f754d051a9cdbe1552b38c8abb62 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E7=83=AD=E5=BF=83=E5=B8=82=E6=B0=91=E9=92=9F=E5=B0=8F?= =?UTF-8?q?=E5=BC=BA?= Date: Thu, 20 Feb 2020 22:35:06 +0800 Subject: [PATCH 811/865] Update and rename 84.9 Build an executable archive from Ant without using spring-boot-antlib.md to 86.9 Build an Executable Archive from Ant without Using spring-boot-antlib.md --- ...m Ant without Using spring-boot-antlib.md" | 42 +++++++++---------- 1 file changed, 21 insertions(+), 21 deletions(-) rename "IX. \342\200\230How-to\342\200\231 guides/84.9 Build an executable archive from Ant without using spring-boot-antlib.md" => "IX. \342\200\230How-to\342\200\231 guides/86.9 Build an Executable Archive from Ant without Using spring-boot-antlib.md" (57%) diff --git "a/IX. \342\200\230How-to\342\200\231 guides/84.9 Build an executable archive from Ant without using spring-boot-antlib.md" "b/IX. \342\200\230How-to\342\200\231 guides/86.9 Build an Executable Archive from Ant without Using spring-boot-antlib.md" similarity index 57% rename from "IX. \342\200\230How-to\342\200\231 guides/84.9 Build an executable archive from Ant without using spring-boot-antlib.md" rename to "IX. \342\200\230How-to\342\200\231 guides/86.9 Build an Executable Archive from Ant without Using spring-boot-antlib.md" index b7696713..53171e15 100644 --- "a/IX. \342\200\230How-to\342\200\231 guides/84.9 Build an executable archive from Ant without using spring-boot-antlib.md" +++ "b/IX. \342\200\230How-to\342\200\231 guides/86.9 Build an Executable Archive from Ant without Using spring-boot-antlib.md" @@ -1,4 +1,4 @@ -### 84.9 使用Ant构建可执行存档(不使用spring-boot-antlib) +### 86.9 使用Ant构建可执行存档(不使用spring-boot-antlib) 想要使用Ant进行构建,你需要抓取依赖,编译,然后像通常那样创建一个jar或war存档。为了让它可以执行,你可以使用`spring-boot-antlib`,也可以使用以下指令: @@ -6,30 +6,30 @@ 2. 对于jar,添加运行时依赖到内嵌的`BOOT-INF/lib`目录。对于war,则添加到`WEB-INF/lib`目录。注意不能压缩存档中的实体。 3. 对于jar,添加`provided`依赖到内嵌的`BOOT-INF/lib`目录。对于war,则添加到`WEB-INF/lib-provided`目录。注意不能压缩存档中的实体。 4. 在存档的根目录添加`spring-boot-loader`类(这样`Main-Class`就可用了)。 -5. 使用恰当的启动器,比如对于jar使用`JarLauncher`作为manifest的`Main-Class`属性,指定manifest的其他属性,特别是`Start-Class`。 +5. 使用恰当的启动器,比如对于jar使用`JarLauncher`作为manifest的`Main-Class`属性,指定manifest的其他属性,特别是设置`Start-Class`属性。 示例: ```xml - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + ``` 该[Ant示例](https://github.com/spring-projects/spring-boot/tree/v2.0.0.RELEASE/spring-boot-samples/spring-boot-sample-ant)中有一个`build.xml`文件及`manual`任务,可以使用以下命令来运行: From ce15c63814eedddc1c65088814a5eedf461f5818 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E7=83=AD=E5=BF=83=E5=B8=82=E6=B0=91=E9=92=9F=E5=B0=8F?= =?UTF-8?q?=E5=BC=BA?= Date: Mon, 24 Feb 2020 13:10:11 +0800 Subject: [PATCH 812/865] Update SUMMARY.md --- SUMMARY.md | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/SUMMARY.md b/SUMMARY.md index 2938ecf0..eafd8e2c 100644 --- a/SUMMARY.md +++ b/SUMMARY.md @@ -556,13 +556,13 @@ * [86.7 使用排除创建不可执行的JAR](IX. ‘How-to’ guides/86.7 Create a Non-executable JAR with Exclusions.md) * [86.8 远程调试使用Maven启动的Spring Boot项目](IX. ‘How-to’ guides/86.8 Remote Debug a Spring Boot Application Started with Maven.md) * [86.9 使用Ant构建可执行存档(不使用spring-boot-antlib)](IX. ‘How-to’ guides/86.9 Build an Executable Archive from Ant without Using spring-boot-antlib.md) - * [85. 传统部署](IX. ‘How-to’ guides/85. Traditional deployment.md) - * [85.1 创建可部署的war文件](IX. ‘How-to’ guides/85.1 Create a deployable war file.md) - * [85.2 为老的servlet容器创建可部署的war文件](IX. ‘How-to’ guides/85.2 Create a deployable war file for older servlet containers.md) - * [85.3 将现有的应用转换为Spring Boot](IX. ‘How-to’ guides/85.3 Convert an existing application to Spring Boot.md) - * [85.4 部署WAR到Weblogic](IX. ‘How-to’ guides/85.4 Deploying a WAR to Weblogic.md) - * [85.5 部署WAR到老的(Servlet2.5)容器](IX. ‘How-to’ guides/85.5 Deploying a WAR in an Old(Servlet 2.5)Container.md) - * [85.6 使用Lettuce来代替Jedis](IX. ‘How-to’ guides/85.6 Use Lettuce instead of Jedis.md) + * [87. 传统部署](IX. ‘How-to’ guides/87. Traditional Deployment.md) + * [87.1 创建可部署的war文件](IX. ‘How-to’ guides/87.1 Create a Deployable War File.md) + * [87.2 为老的servlet容器创建可部署的war文件](IX. ‘How-to’ guides/87.2 Create a Deployable War File for Older Servlet Containers.md) + * [87.3 将现有的应用转换为Spring Boot](IX. ‘How-to’ guides/87.3 Convert an Existing Application to Spring Boot.md) + * [87.4 部署WAR到Weblogic](IX. ‘How-to’ guides/87.4 Deploying a WAR to Weblogic.md) + * [87.5 部署WAR到老的(Servlet2.5)容器](IX. ‘How-to’ guides/87.5 Deploying a WAR in an Old(Servlet 2.5)Container.md) + * [87.6 使用Lettuce来代替Jedis](IX. ‘How-to’ guides/87.6 Use Jedis Instead of Lettuce.md) * [X.附录](X. Appendices/README.md) * [附录A. 常见应用属性](X. Appendices/A. Common application properties.md) * [附录B. 配置元数据](X. Appendices/B. Configuration meta-data.md) From 7c8d1783fd6163a301e5341a33e9b11513f5f230 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E7=83=AD=E5=BF=83=E5=B8=82=E6=B0=91=E9=92=9F=E5=B0=8F?= =?UTF-8?q?=E5=BC=BA?= Date: Mon, 24 Feb 2020 13:13:37 +0800 Subject: [PATCH 813/865] Update and rename 85. Traditional deployment.md to 87. Traditional Deployment.md --- .../85. Traditional deployment.md" | 1 - .../87. Traditional Deployment.md" | 3 +++ 2 files changed, 3 insertions(+), 1 deletion(-) delete mode 100644 "IX. \342\200\230How-to\342\200\231 guides/85. Traditional deployment.md" create mode 100644 "IX. \342\200\230How-to\342\200\231 guides/87. Traditional Deployment.md" diff --git "a/IX. \342\200\230How-to\342\200\231 guides/85. Traditional deployment.md" "b/IX. \342\200\230How-to\342\200\231 guides/85. Traditional deployment.md" deleted file mode 100644 index b8ebc19f..00000000 --- "a/IX. \342\200\230How-to\342\200\231 guides/85. Traditional deployment.md" +++ /dev/null @@ -1 +0,0 @@ -### 85. 传统部署 diff --git "a/IX. \342\200\230How-to\342\200\231 guides/87. Traditional Deployment.md" "b/IX. \342\200\230How-to\342\200\231 guides/87. Traditional Deployment.md" new file mode 100644 index 00000000..1af7e516 --- /dev/null +++ "b/IX. \342\200\230How-to\342\200\231 guides/87. Traditional Deployment.md" @@ -0,0 +1,3 @@ +### 87. 传统部署 + +Spring Boot支持传统部署和更现代的部署形式。本节回答关于传统部署的常见问题。 From f004d36f5c845073e69262c03024c505d24a96c5 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E7=83=AD=E5=BF=83=E5=B8=82=E6=B0=91=E9=92=9F=E5=B0=8F?= =?UTF-8?q?=E5=BC=BA?= Date: Mon, 24 Feb 2020 13:36:04 +0800 Subject: [PATCH 814/865] Update and rename 85.1 Create a deployable war file.md to 87.1 Create a Deployable War File.md --- .../87.1 Create a Deployable War File.md" | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) rename "IX. \342\200\230How-to\342\200\231 guides/85.1 Create a deployable war file.md" => "IX. \342\200\230How-to\342\200\231 guides/87.1 Create a Deployable War File.md" (70%) diff --git "a/IX. \342\200\230How-to\342\200\231 guides/85.1 Create a deployable war file.md" "b/IX. \342\200\230How-to\342\200\231 guides/87.1 Create a Deployable War File.md" similarity index 70% rename from "IX. \342\200\230How-to\342\200\231 guides/85.1 Create a deployable war file.md" rename to "IX. \342\200\230How-to\342\200\231 guides/87.1 Create a Deployable War File.md" index f6b74989..526608da 100644 --- "a/IX. \342\200\230How-to\342\200\231 guides/85.1 Create a deployable war file.md" +++ "b/IX. \342\200\230How-to\342\200\231 guides/87.1 Create a Deployable War File.md" @@ -1,4 +1,4 @@ -### 85.1 创建可部署的war文件 +### 87.1 创建可部署的war文件 产生一个可部署war包的第一步是提供一个`SpringBootServletInitializer`子类,并覆盖它的`configure`方法,这充分利用了Spring框架对Servlet 3.0的支持,并允许你在应用通过servlet容器启动时配置它。通常,你只需把应用的主类改为继承`SpringBootServletInitializer`即可: ```java @@ -26,7 +26,7 @@ apply plugin: 'war' ``` 该过程最后的一步是确保内嵌的servlet容器不能干扰war包将部署的servlet容器。为了达到这个目的,你需要将内嵌容器的依赖标记为`provided`。 -如果使用Maven: +如果你使用Maven,下面的示例将servlet容器(本例中为Tomcat)标记为提供: ```xml @@ -38,7 +38,7 @@ apply plugin: 'war' ``` -如果使用Gradle: +如果你使用Gradle,下面的示例将servlet容器(本例中为Tomcat)标记为提供: ```gradle dependencies { // … @@ -48,6 +48,6 @@ dependencies { ``` **注** `providedRuntime`更适合Gradle的`compileOnly`配置,因为`compileOnly`依赖不在测试类路径上,所以任何基于web的综合测试都会失败。 -如果你使用[Spring Boot构建工具](../VIII. Build tool plugins/README.md),将内嵌容器依赖标记为`provided`将产生一个可执行war包,在`lib-provided`目录有该war包的`provided`依赖。这意味着,除了部署到servlet容器,你还可以通过使用命令行`java -jar`命令来运行应用。 +如果你使用[Spring Boot构建工具](https://docs.spring.io/spring-boot/docs/2.0.0.RELEASE/reference/htmlsingle/#build-tool-plugins),将内嵌容器依赖标记为`provided`将产生一个可执行war包,在`lib-provided`目录有该war包的`provided`依赖。这意味着,除了部署到servlet容器,你还可以通过使用命令行`java -jar`命令来运行应用。 -**提示** 查看Spring Boot基于以上配置的一个[Maven示例应用](http://github.com/spring-projects/spring-boot/tree/master/spring-boot-samples/spring-boot-sample-traditional/pom.xml)。 +**提示** 查看Spring Boot基于以上配置的一个[Maven示例应用](https://github.com/spring-projects/spring-boot/tree/v2.0.0.RELEASE/spring-boot-samples/spring-boot-sample-traditional/pom.xml)。 From b794b6d339253733d53141126991b677c1a0a2ce Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E7=83=AD=E5=BF=83=E5=B8=82=E6=B0=91=E9=92=9F=E5=B0=8F?= =?UTF-8?q?=E5=BC=BA?= Date: Tue, 25 Feb 2020 14:17:25 +0800 Subject: [PATCH 815/865] Update and rename 85.2 Create a deployable war file for older servlet containers.md to 87.2 Create a Deployable War File for Older Servlet Containers.md --- ...reate a Deployable War File for Older Servlet Containers.md" | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) rename "IX. \342\200\230How-to\342\200\231 guides/85.2 Create a deployable war file for older servlet containers.md" => "IX. \342\200\230How-to\342\200\231 guides/87.2 Create a Deployable War File for Older Servlet Containers.md" (82%) diff --git "a/IX. \342\200\230How-to\342\200\231 guides/85.2 Create a deployable war file for older servlet containers.md" "b/IX. \342\200\230How-to\342\200\231 guides/87.2 Create a Deployable War File for Older Servlet Containers.md" similarity index 82% rename from "IX. \342\200\230How-to\342\200\231 guides/85.2 Create a deployable war file for older servlet containers.md" rename to "IX. \342\200\230How-to\342\200\231 guides/87.2 Create a Deployable War File for Older Servlet Containers.md" index 67c1b4e6..611e3f1c 100644 --- "a/IX. \342\200\230How-to\342\200\231 guides/85.2 Create a deployable war file for older servlet containers.md" +++ "b/IX. \342\200\230How-to\342\200\231 guides/87.2 Create a Deployable War File for Older Servlet Containers.md" @@ -1,3 +1,3 @@ -### 85.2 为老的servlet容器创建可部署的war文件 +### 87.2 为老的servlet容器创建可部署的war文件 老的Servlet容器不支持在Servlet 3.0中使用的`ServletContextInitializer`启动处理。你仍旧可以在这些容器使用Spring和Spring Boot,但你需要为应用添加一个`web.xml`,并将它配置为通过一个`DispatcherServlet`加载一个`ApplicationContext`。 From eb97145fbddd9ff21e81e26b9e974da7149886ba Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E7=83=AD=E5=BF=83=E5=B8=82=E6=B0=91=E9=92=9F=E5=B0=8F?= =?UTF-8?q?=E5=BC=BA?= Date: Tue, 25 Feb 2020 14:31:33 +0800 Subject: [PATCH 816/865] Update and rename 85.3 Convert an existing application to Spring Boot.md to 87.3 Convert an Existing Application to Spring Boot.md --- ... Convert an Existing Application to Spring Boot.md" | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) rename "IX. \342\200\230How-to\342\200\231 guides/85.3 Convert an existing application to Spring Boot.md" => "IX. \342\200\230How-to\342\200\231 guides/87.3 Convert an Existing Application to Spring Boot.md" (83%) diff --git "a/IX. \342\200\230How-to\342\200\231 guides/85.3 Convert an existing application to Spring Boot.md" "b/IX. \342\200\230How-to\342\200\231 guides/87.3 Convert an Existing Application to Spring Boot.md" similarity index 83% rename from "IX. \342\200\230How-to\342\200\231 guides/85.3 Convert an existing application to Spring Boot.md" rename to "IX. \342\200\230How-to\342\200\231 guides/87.3 Convert an Existing Application to Spring Boot.md" index a29c9c74..423fa4a9 100644 --- "a/IX. \342\200\230How-to\342\200\231 guides/85.3 Convert an existing application to Spring Boot.md" +++ "b/IX. \342\200\230How-to\342\200\231 guides/87.3 Convert an Existing Application to Spring Boot.md" @@ -1,6 +1,6 @@ -### 85.3 将现有的应用转换为Spring Boot +### 87.3 将现有的应用转换为Spring Boot -对于一个非web项目,转换为Spring Boot应用很容易(抛弃创建`ApplicationContext`的代码,取而代之的是调用`SpringApplication`或`SpringApplicationBuilder`)。Spring MVC web应用通常先创建一个可部署的war应用,然后将它迁移为一个可执行的war或jar,建议阅读[Getting Started Guide on Converting a jar to a war.](http://spring.io/guides/gs/convert-jar-to-war/)。 +对于一个非web项目,转换为Spring Boot应用很容易(抛弃创建`ApplicationContext`的代码,取而代之的是调用`SpringApplication`或`SpringApplicationBuilder`)。Spring MVC web应用通常先创建一个可部署的war应用,然后将它迁移为一个可执行的war或jar。建议阅读[Getting Started Guide on Converting a jar to a war.](https://spring.io/guides/gs/convert-jar-to-war/)。 通过继承`SpringBootServletInitializer`创建一个可执行war(比如,在一个名为`Application`的类中),然后添加Spring Boot的`@SpringBootApplication`注解,示例: ```java @@ -61,8 +61,8 @@ public class Application extends SpringBootServletInitializer { - 有上下文层次的应用 - 没有上下文层次的应用 -所有这些都可以进行适当的转化,但每个可能需要稍微不同的技巧。 +所有这些都可以进行适当的转化,但每个可能需要稍微不同的技术。 -Servlet 3.0+的应用转化的相当简单,如果它们已经使用Spring Servlet 3.0+初始化器辅助类。通常所有来自一个存在的`WebApplicationInitializer`的代码可以移到一个`SpringBootServletInitializer`中。如果一个存在的应用有多个`ApplicationContext`(比如,如果它使用`AbstractDispatcherServletInitializer`),那你可以将所有上下文源放进一个单一的`SpringApplication`。你遇到的主要难题可能是如果那样不能工作,那你就要维护上下文层次。参考示例[entry on building a hierarchy](http://docs.spring.io/spring-boot/docs/current-SNAPSHOT/reference/htmlsingle/#howto-build-an-application-context-hierarchy)。一个存在的包含web相关特性的父上下文通常需要分解,这样所有的`ServletContextAware`组件都处于子上下文中。 +Servlet 3.0+的应用转化的相当简单,如果它们已经使用Spring Servlet 3.0+初始化器辅助类。通常所有来自一个存在的`WebApplicationInitializer`的代码可以移到一个`SpringBootServletInitializer`中。如果一个存在的应用有多个`ApplicationContext`(比如,如果它使用`AbstractDispatcherServletInitializer`),那你可以将所有上下文源放进一个单一的`SpringApplication`。你遇到的主要难题可能是如果那样不能工作,那你就要维护上下文层次。参考示例[entry on building a hierarchy](https://docs.spring.io/spring-boot/docs/2.0.0.RELEASE/reference/htmlsingle/#howto-build-an-application-context-hierarchy)。一个存在的包含web相关特性的父上下文通常需要分解,这样所有的`ServletContextAware`组件都处于子上下文中。 -对于还不是Spring应用的应用来说,上面的指南有助于你把应用转换为一个Spring Boot应用,但你也可以选择其他方式。 +对于还不是Spring应用的应用来说,上面的指南有助于你把应用转换为一个Spring Boot应用。然而,你可能会遇到一些问题。在这种情况下,我们建议[使用spring-boot标签在Stack Overflow上提问](https://stackoverflow.com/questions/tagged/spring-boot)。 From 6350f5bd30a4387aea7e848c125e286c1559d161 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E7=83=AD=E5=BF=83=E5=B8=82=E6=B0=91=E9=92=9F=E5=B0=8F?= =?UTF-8?q?=E5=BC=BA?= Date: Fri, 28 Feb 2020 14:48:25 +0800 Subject: [PATCH 817/865] Update and rename 85.4 Deploying a WAR to Weblogic.md to 87.4 Deploying a WAR to Weblogic.md --- .../87.4 Deploying a WAR to Weblogic.md" | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) rename "IX. \342\200\230How-to\342\200\231 guides/85.4 Deploying a WAR to Weblogic.md" => "IX. \342\200\230How-to\342\200\231 guides/87.4 Deploying a WAR to Weblogic.md" (85%) diff --git "a/IX. \342\200\230How-to\342\200\231 guides/85.4 Deploying a WAR to Weblogic.md" "b/IX. \342\200\230How-to\342\200\231 guides/87.4 Deploying a WAR to Weblogic.md" similarity index 85% rename from "IX. \342\200\230How-to\342\200\231 guides/85.4 Deploying a WAR to Weblogic.md" rename to "IX. \342\200\230How-to\342\200\231 guides/87.4 Deploying a WAR to Weblogic.md" index f848e4fb..0fb4f5b7 100644 --- "a/IX. \342\200\230How-to\342\200\231 guides/85.4 Deploying a WAR to Weblogic.md" +++ "b/IX. \342\200\230How-to\342\200\231 guides/87.4 Deploying a WAR to Weblogic.md" @@ -1,11 +1,11 @@ -### 85.4 部署WAR到Weblogic +### 87.4 部署WAR到Weblogic 想要将Spring Boot应用部署到Weblogic,你需要确保你的servlet初始化器直接实现`WebApplicationInitializer`(即使你继承的基类已经实现了它)。 一个传统的Weblogic初始化器可能如下所示: ```java import org.springframework.boot.autoconfigure.SpringBootApplication; -import org.springframework.boot.context.web.SpringBootServletInitializer; +import org.springframework.boot.web.servlet.support.SpringBootServletInitializer; import org.springframework.web.WebApplicationInitializer; @SpringBootApplication @@ -13,7 +13,7 @@ public class MyApplication extends SpringBootServletInitializer implements WebAp } ``` -如果使用logback,你需要告诉Weblogic你倾向使用的打包版本而不是服务器预装的版本。你可以通过添加一个具有如下内容的`WEB-INF/weblogic.xml`实现该操作: +如果使用Logback,你需要告诉Weblogic你倾向使用的打包版本而不是服务器预装的版本。你可以通过添加一个具有如下内容的`WEB-INF/weblogic.xml`实现该操作: ```xml Date: Fri, 28 Feb 2020 14:57:24 +0800 Subject: [PATCH 818/865] =?UTF-8?q?Update=20and=20rename=2085.5=20Deployin?= =?UTF-8?q?g=20a=20WAR=20in=20an=20Old=EF=BC=88Servlet=202.5=EF=BC=89Conta?= =?UTF-8?q?iner.md=20to=2087.5=20Deploying=20a=20WAR=20in=20an=20Old?= =?UTF-8?q?=EF=BC=88Servlet=202.5=EF=BC=89Container.md?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- ...AR in an Old\357\274\210Servlet 2.5\357\274\211Container.md" | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) rename "IX. \342\200\230How-to\342\200\231 guides/85.5 Deploying a WAR in an Old\357\274\210Servlet 2.5\357\274\211Container.md" => "IX. \342\200\230How-to\342\200\231 guides/87.5 Deploying a WAR in an Old\357\274\210Servlet 2.5\357\274\211Container.md" (96%) diff --git "a/IX. \342\200\230How-to\342\200\231 guides/85.5 Deploying a WAR in an Old\357\274\210Servlet 2.5\357\274\211Container.md" "b/IX. \342\200\230How-to\342\200\231 guides/87.5 Deploying a WAR in an Old\357\274\210Servlet 2.5\357\274\211Container.md" similarity index 96% rename from "IX. \342\200\230How-to\342\200\231 guides/85.5 Deploying a WAR in an Old\357\274\210Servlet 2.5\357\274\211Container.md" rename to "IX. \342\200\230How-to\342\200\231 guides/87.5 Deploying a WAR in an Old\357\274\210Servlet 2.5\357\274\211Container.md" index e7086bed..e982dd76 100644 --- "a/IX. \342\200\230How-to\342\200\231 guides/85.5 Deploying a WAR in an Old\357\274\210Servlet 2.5\357\274\211Container.md" +++ "b/IX. \342\200\230How-to\342\200\231 guides/87.5 Deploying a WAR in an Old\357\274\210Servlet 2.5\357\274\211Container.md" @@ -1,4 +1,4 @@ -### 85.5 部署WAR到老的(Servlet2.5)容器 +### 87.5 部署WAR到老的(Servlet2.5)容器 Spring Boot使用 Servlet 3.0 APIs初始化`ServletContext`(注册`Servlets`等),所以你不能在一个Servlet 2.5的容器中原封不动的使用同样的应用。使用一些特定的工具也是可以在老的容器中运行Spring Boot应用的。如果添加了`org.springframework.boot:spring-boot-legacy`依赖,你只需要创建一个`web.xml`,声明一个用于创建应用上下文的上下文监听器,过滤器和servlets。上下文监听器是专用于Spring Boot的,其他的都是一个Servlet 2.5的Spring应用所具有的。示例: ```xml From 8e807ec87910fc9d4bab6a1260443beee0b1c5c3 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E7=83=AD=E5=BF=83=E5=B8=82=E6=B0=91=E9=92=9F=E5=B0=8F?= =?UTF-8?q?=E5=BC=BA?= Date: Fri, 28 Feb 2020 15:06:31 +0800 Subject: [PATCH 819/865] Update and rename 85.6 Use Lettuce instead of Jedis.md to 87.6 Use Jedis Instead of Lettuce.md --- .../85.6 Use Lettuce instead of Jedis.md" | 37 ------------------- .../87.6 Use Jedis Instead of Lettuce.md" | 32 ++++++++++++++++ 2 files changed, 32 insertions(+), 37 deletions(-) delete mode 100644 "IX. \342\200\230How-to\342\200\231 guides/85.6 Use Lettuce instead of Jedis.md" create mode 100644 "IX. \342\200\230How-to\342\200\231 guides/87.6 Use Jedis Instead of Lettuce.md" diff --git "a/IX. \342\200\230How-to\342\200\231 guides/85.6 Use Lettuce instead of Jedis.md" "b/IX. \342\200\230How-to\342\200\231 guides/85.6 Use Lettuce instead of Jedis.md" deleted file mode 100644 index a1d0ce1b..00000000 --- "a/IX. \342\200\230How-to\342\200\231 guides/85.6 Use Lettuce instead of Jedis.md" +++ /dev/null @@ -1,37 +0,0 @@ -### 85.6 使用Lettuce来代替Jedis - -Spring Boot starter(`spring-boot-starter-data-redis`)默认使用[Jedis](https://github.com/xetorthio/jedis/)。你需要排除那个依赖,并把[Lettuce](https://github.com/lettuce-io/lettuce-core/)的依赖加入进来。你还需要`commons-pool2`。Spring Boot管理这些依赖,使这些步骤尽可能容易。 - -Maven的例子: -```xml - - org.springframework.boot - spring-boot-starter-data-redis - - - redis.clients - jedis - - - - - io.lettuce - lettuce-core - - - org.apache.commons - commons-pool2 - -``` -Gradle的例子: -```gradle -configurations { - compile.exclude module: "jedis" -} - -dependencies { - compile("io.lettuce:lettuce-core") - compile("org.apache.commons:commons-pool2") - // ... -} -``` diff --git "a/IX. \342\200\230How-to\342\200\231 guides/87.6 Use Jedis Instead of Lettuce.md" "b/IX. \342\200\230How-to\342\200\231 guides/87.6 Use Jedis Instead of Lettuce.md" new file mode 100644 index 00000000..54ba1b38 --- /dev/null +++ "b/IX. \342\200\230How-to\342\200\231 guides/87.6 Use Jedis Instead of Lettuce.md" @@ -0,0 +1,32 @@ +### 87.6 使用Jedis来代替Lettuce + +Spring Boot starter(`spring-boot-starter-data-redis`)默认使用[Lettuce](https://github.com/lettuce-io/lettuce-core/)。你需要排除那个依赖,并把[Jedis](https://github.com/xetorthio/jedis/)的依赖加入进来。Spring Boot管理这些依赖,使这些步骤尽可能容易。 + +Maven的例子: +```xml + + org.springframework.boot + spring-boot-starter-data-redis + + + io.lettuce + lettuce-core + + + + + redis.clients + jedis + +``` +Gradle的例子: +```gradle +configurations { + compile.exclude module: "lettuce" +} + +dependencies { + compile("redis.clients:jedis") + // ... +} +``` From b2e3d9a6485a98381aa606628f828f469c2822c6 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E7=83=AD=E5=BF=83=E5=B8=82=E6=B0=91=E9=92=9F=E5=B0=8F?= =?UTF-8?q?=E5=BC=BA?= Date: Tue, 3 Mar 2020 17:06:14 +0800 Subject: [PATCH 820/865] Update A. Common application properties.md --- .../A. Common application properties.md | 1535 +++++++++-------- 1 file changed, 851 insertions(+), 684 deletions(-) diff --git a/X. Appendices/A. Common application properties.md b/X. Appendices/A. Common application properties.md index f7bde356..8bd45139 100644 --- a/X. Appendices/A. Common application properties.md +++ b/X. Appendices/A. Common application properties.md @@ -11,64 +11,73 @@ # COMMON SPRING BOOT PROPERTIES # # This sample file is provided as a guideline. Do NOT copy it in its -# entirety to your own application. ^^^ +# entirety to your own application. ^^^ # =================================================================== # ---------------------------------------- # CORE PROPERTIES # ---------------------------------------- - -# BANNER -banner.charset=UTF-8 # Banner file encoding. -banner.location=classpath:banner.txt # Banner file location. -banner.image.location=classpath:banner.gif # Banner image file location (jpg/png can also be used). -banner.image.width= # Width of the banner image in chars (default 76) -banner.image.height= # Height of the banner image in chars (default based on image height) -banner.image.margin= # Left hand image margin in chars (default 2) -banner.image.invert= # If images should be inverted for dark terminal themes (default false) +debug=false # Enable debug logs. +trace=false # Enable trace logs. # LOGGING -logging.config= # Location of the logging configuration file. For instance `classpath:logback.xml` for Logback +logging.config= # Location of the logging configuration file. For instance, `classpath:logback.xml` for Logback. logging.exception-conversion-word=%wEx # Conversion word used when logging exceptions. -logging.file= # Log file name. For instance `myapp.log` -logging.level.*= # Log levels severity mapping. For instance `logging.level.org.springframework=DEBUG` -logging.path= # Location of the log file. For instance `/var/log` -logging.pattern.console= # Appender pattern for output to the console. Only supported with the default logback setup. -logging.pattern.file= # Appender pattern for output to the file. Only supported with the default logback setup. -logging.pattern.level= # Appender pattern for log level (default %5p). Only supported with the default logback setup. +logging.file= # Log file name (for instance, `myapp.log`). Names can be an exact location or relative to the current directory. +logging.file.max-history=0 # Maximum of archive log files to keep. Only supported with the default logback setup. +logging.file.max-size=10MB # Maximum log file size. Only supported with the default logback setup. +logging.level.*= # Log levels severity mapping. For instance, `logging.level.org.springframework=DEBUG`. +logging.path= # Location of the log file. For instance, `/var/log`. +logging.pattern.console= # Appender pattern for output to the console. Supported only with the default Logback setup. +logging.pattern.dateformat=yyyy-MM-dd HH:mm:ss.SSS # Appender pattern for log date format. Supported only with the default Logback setup. +logging.pattern.file= # Appender pattern for output to a file. Supported only with the default Logback setup. +logging.pattern.level=%5p # Appender pattern for log level. Supported only with the default Logback setup. logging.register-shutdown-hook=false # Register a shutdown hook for the logging system when it is initialized. # AOP spring.aop.auto=true # Add @EnableAspectJAutoProxy. -spring.aop.proxy-target-class=true # Whether subclass-based (CGLIB) proxies are to be created (true) as opposed to standard Java interface-based proxies (false). +spring.aop.proxy-target-class=true # Whether subclass-based (CGLIB) proxies are to be created (true), as opposed to standard Java interface-based proxies (false). # IDENTITY (ContextIdApplicationContextInitializer) -spring.application.index= # Application index. spring.application.name= # Application name. # ADMIN (SpringApplicationAdminJmxAutoConfiguration) -spring.application.admin.enabled=false # Enable admin features for the application. +spring.application.admin.enabled=false # Whether to enable admin features for the application. spring.application.admin.jmx-name=org.springframework.boot:type=Admin,name=SpringApplication # JMX name of the application admin MBean. # AUTO-CONFIGURATION spring.autoconfigure.exclude= # Auto-configuration classes to exclude. +# BANNER +spring.banner.charset=UTF-8 # Banner file encoding. +spring.banner.location=classpath:banner.txt # Banner text resource location. +spring.banner.image.location=classpath:banner.gif # Banner image file location (jpg or png can also be used). +spring.banner.image.width=76 # Width of the banner image in chars. +spring.banner.image.height= # Height of the banner image in chars (default based on image height). +spring.banner.image.margin=2 # Left hand image margin in chars. +spring.banner.image.invert=false # Whether images should be inverted for dark terminal themes. + # SPRING CORE -spring.beaninfo.ignore=true # Skip search of BeanInfo classes. +spring.beaninfo.ignore=true # Whether to skip search of BeanInfo classes. # SPRING CACHE (CacheProperties) spring.cache.cache-names= # Comma-separated list of cache names to create if supported by the underlying cache manager. -spring.cache.caffeine.spec= # The spec to use to create caches. Check CaffeineSpec for more details on the spec format. -spring.cache.couchbase.expiration=0 # Entry expiration in milliseconds. By default the entries never expire. +spring.cache.caffeine.spec= # The spec to use to create caches. See CaffeineSpec for more details on the spec format. +spring.cache.couchbase.expiration=0ms # Entry expiration. By default the entries never expire. Note that this value is ultimately converted to seconds. spring.cache.ehcache.config= # The location of the configuration file to use to initialize EhCache. spring.cache.infinispan.config= # The location of the configuration file to use to initialize Infinispan. spring.cache.jcache.config= # The location of the configuration file to use to initialize the cache manager. -spring.cache.jcache.provider= # Fully qualified name of the CachingProvider implementation to use to retrieve the JSR-107 compliant cache manager. Only needed if more than one JSR-107 implementation is available on the classpath. -spring.cache.type= # Cache type, auto-detected according to the environment by default. +spring.cache.jcache.provider= # Fully qualified name of the CachingProvider implementation to use to retrieve the JSR-107 compliant cache manager. Needed only if more than one JSR-107 implementation is available on the classpath. +spring.cache.redis.cache-null-values=true # Allow caching null values. +spring.cache.redis.key-prefix= # Key prefix. +spring.cache.redis.time-to-live=0ms # Entry expiration. By default the entries never expire. +spring.cache.redis.use-key-prefix=true # Whether to use the key prefix when writing to Redis. +spring.cache.type= # Cache type. By default, auto-detected according to the environment. # SPRING CONFIG - using environment property only (ConfigFileApplicationListener) -spring.config.location= # Config file locations. +spring.config.additional-location= # Config file locations used in addition to the defaults. +spring.config.location= # Config file locations that replace the defaults. spring.config.name=application # Config file name. # HAZELCAST (HazelcastProperties) @@ -85,54 +94,55 @@ spring.jmx.server=mbeanServer # MBeanServer bean name. # Email (MailProperties) spring.mail.default-encoding=UTF-8 # Default MimeMessage encoding. -spring.mail.host= # SMTP server host. For instance `smtp.example.com` -spring.mail.jndi-name= # Session JNDI name. When set, takes precedence to others mail settings. +spring.mail.host= # SMTP server host. For instance, `smtp.example.com`. +spring.mail.jndi-name= # Session JNDI name. When set, takes precedence over other mail settings. spring.mail.password= # Login password of the SMTP server. spring.mail.port= # SMTP server port. spring.mail.properties.*= # Additional JavaMail session properties. spring.mail.protocol=smtp # Protocol used by the SMTP server. -spring.mail.test-connection=false # Test that the mail server is available on startup. +spring.mail.test-connection=false # Whether to test that the mail server is available on startup. spring.mail.username= # Login user of the SMTP server. # APPLICATION SETTINGS (SpringApplication) spring.main.banner-mode=console # Mode used to display the banner when the application runs. -spring.main.sources= # Sources (class name, package name or XML resource location) to include in the ApplicationContext. -spring.main.web-application-type= # Flag to explicitly request a specific type of web application. Auto-detected based on the classpath if not set. +spring.main.sources= # Sources (class names, package names, or XML resource locations) to include in the ApplicationContext. +spring.main.web-application-type= # Flag to explicitly request a specific type of web application. If not set, auto-detected based on the classpath. # FILE ENCODING (FileEncodingApplicationListener) spring.mandatory-file-encoding= # Expected character encoding the application must use. -# INTERNATIONALIZATION (MessageSourceAutoConfiguration) -spring.messages.always-use-message-format=false # Set whether to always apply the MessageFormat rules, parsing even messages without arguments. -spring.messages.basename=messages # Comma-separated list of basenames, each following the ResourceBundle convention. -spring.messages.cache-seconds=-1 # Loaded resource bundle files cache expiration, in seconds. When set to -1, bundles are cached forever. +# INTERNATIONALIZATION (MessageSourceProperties) +spring.messages.always-use-message-format=false # Whether to always apply the MessageFormat rules, parsing even messages without arguments. +spring.messages.basename=messages # Comma-separated list of basenames (essentially a fully-qualified classpath location), each following the ResourceBundle convention with relaxed support for slash based locations. +spring.messages.cache-duration= # Loaded resource bundle files cache duration. When not set, bundles are cached forever. If a duration suffix is not specified, seconds will be used. spring.messages.encoding=UTF-8 # Message bundles encoding. -spring.messages.fallback-to-system-locale=true # Set whether to fall back to the system Locale if no files for a specific Locale have been found. +spring.messages.fallback-to-system-locale=true # Whether to fall back to the system Locale if no files for a specific Locale have been found. +spring.messages.use-code-as-default-message=false # Whether to use the message code as the default message instead of throwing a "NoSuchMessageException". Recommended during development only. # OUTPUT -spring.output.ansi.enabled=detect # Configure the ANSI output. +spring.output.ansi.enabled=detect # Configures the ANSI output. # PID FILE (ApplicationPidFileWriter) -spring.pid.fail-on-write-error= # Fail if ApplicationPidFileWriter is used but it cannot write the PID file. +spring.pid.fail-on-write-error= # Fails if ApplicationPidFileWriter is used but it cannot write the PID file. spring.pid.file= # Location of the PID file to write (if ApplicationPidFileWriter is used). # PROFILES -spring.profiles.active= # Comma-separated list (or list if using YAML) of active profiles. -spring.profiles.include= # Unconditionally activate the specified comma separated profiles (or list of profiles if using YAML). +spring.profiles.active= # Comma-separated list of active profiles. Can be overridden by a command line switch. +spring.profiles.include= # Unconditionally activate the specified comma-separated list of profiles (or list of profiles if using YAML). # QUARTZ SCHEDULER (QuartzProperties) +spring.quartz.jdbc.initialize-schema=embedded # Database schema initialization mode. +spring.quartz.jdbc.schema=classpath:org/quartz/impl/jdbcjobstore/tables_@@platform@@.sql # Path to the SQL file to use to initialize the database schema. spring.quartz.job-store-type=memory # Quartz job store type. spring.quartz.properties.*= # Additional Quartz Scheduler properties. -spring.quartz.jdbc.initialize-schema=false # Create the required Quartz Scheduler tables on startup. -spring.quartz.jdbc.schema=classpath:org/quartz/impl/jdbcjobstore/tables_@@platform@@.sql # Path to the SQL file to use to initialize the database schema. -# Reactor -spring.reactor.stacktrace-mode.enabled=false # Set whether Reactor should collect stacktrace information at runtime. +# REACTOR (ReactorCoreProperties) +spring.reactor.stacktrace-mode.enabled=false # Whether Reactor should collect stacktrace information at runtime. # SENDGRID (SendGridAutoConfiguration) -spring.sendgrid.api-key= # SendGrid api key (alternative to username/password) -spring.sendgrid.proxy.host= # SendGrid proxy host -spring.sendgrid.proxy.port= # SendGrid proxy port +spring.sendgrid.api-key= # SendGrid API key. +spring.sendgrid.proxy.host= # SendGrid proxy host. +spring.sendgrid.proxy.port= # SendGrid proxy port. # ---------------------------------------- @@ -140,53 +150,54 @@ spring.sendgrid.proxy.port= # SendGrid proxy port # ---------------------------------------- # EMBEDDED SERVER CONFIGURATION (ServerProperties) -server.address= # Network address to which the server should bind to. -server.compression.enabled=false # If response compression is enabled. +server.address= # Network address to which the server should bind. +server.compression.enabled=false # Whether response compression is enabled. server.compression.excluded-user-agents= # List of user-agents to exclude from compression. -server.compression.mime-types= # Comma-separated list of MIME types that should be compressed. For instance `text/html,text/css,application/json` -server.compression.min-response-size= # Minimum response size that is required for compression to be performed. For instance 2048 -server.connection-timeout= # Time in milliseconds that connectors will wait for another HTTP request before closing the connection. When not set, the connector's container-specific default will be used. Use a value of -1 to indicate no (i.e. infinite) timeout. -server.display-name=application # Display name of the application. -server.max-http-header-size=0 # Maximum size in bytes of the HTTP message header. +server.compression.mime-types=text/html,text/xml,text/plain,text/css,text/javascript,application/javascript # Comma-separated list of MIME types that should be compressed. +server.compression.min-response-size=2048 # Minimum "Content-Length" value that is required for compression to be performed. +server.connection-timeout= # Time that connectors wait for another HTTP request before closing the connection. When not set, the connector's container-specific default is used. Use a value of -1 to indicate no (that is, an infinite) timeout. server.error.include-exception=false # Include the "exception" attribute. server.error.include-stacktrace=never # When to include a "stacktrace" attribute. server.error.path=/error # Path of the error controller. -server.error.whitelabel.enabled=true # Enable the default error page displayed in browsers in case of a server error. +server.error.whitelabel.enabled=true # Whether to enable the default error page displayed in browsers in case of a server error. +server.http2.enabled=false # Whether to enable HTTP/2 support, if the current environment supports it. server.jetty.acceptors= # Number of acceptor threads to use. server.jetty.accesslog.append=false # Append to log. server.jetty.accesslog.date-format=dd/MMM/yyyy:HH:mm:ss Z # Timestamp format of the request log. server.jetty.accesslog.enabled=false # Enable access log. server.jetty.accesslog.extended-format=false # Enable extended NCSA format. server.jetty.accesslog.file-date-format= # Date format to place in log file name. -server.jetty.accesslog.filename= # Log filename. If not specified, logs will be redirected to "System.err". +server.jetty.accesslog.filename= # Log filename. If not specified, logs redirect to "System.err". server.jetty.accesslog.locale= # Locale of the request log. server.jetty.accesslog.log-cookies=false # Enable logging of the request cookies. server.jetty.accesslog.log-latency=false # Enable logging of request processing time. server.jetty.accesslog.log-server=false # Enable logging of the request hostname. server.jetty.accesslog.retention-period=31 # Number of days before rotated log files are deleted. server.jetty.accesslog.time-zone=GMT # Timezone of the request log. -server.jetty.max-http-post-size=0 # Maximum size in bytes of the HTTP post or put content. +server.jetty.max-http-post-size=0 # Maximum size, in bytes, of the HTTP post or put content. server.jetty.selectors= # Number of selector threads to use. +server.max-http-header-size=0 # Maximum size, in bytes, of the HTTP message header. server.port=8080 # Server HTTP port. -server.server-header= # Value to use for the Server response header (no header is sent if empty) -server.use-forward-headers= # If X-Forwarded-* headers should be applied to the HttpRequest. -server.servlet.context-parameters.*= # Servlet context init parameters +server.server-header= # Value to use for the Server response header (if empty, no header is sent). +server.use-forward-headers= # Whether X-Forwarded-* headers should be applied to the HttpRequest. +server.servlet.context-parameters.*= # Servlet context init parameters. server.servlet.context-path= # Context path of the application. +server.servlet.application-display-name=application # Display name of the application. server.servlet.jsp.class-name=org.apache.jasper.servlet.JspServlet # The class name of the JSP servlet. -server.servlet.jsp.init-parameters.*= # Init parameters used to configure the JSP servlet -server.servlet.jsp.registered=true # Whether or not the JSP servlet is registered +server.servlet.jsp.init-parameters.*= # Init parameters used to configure the JSP servlet. +server.servlet.jsp.registered=true # Whether the JSP servlet is registered. server.servlet.path=/ # Path of the main dispatcher servlet. -server.session.cookie.comment= # Comment for the session cookie. -server.session.cookie.domain= # Domain for the session cookie. -server.session.cookie.http-only= # "HttpOnly" flag for the session cookie. -server.session.cookie.max-age= # Maximum age of the session cookie in seconds. -server.session.cookie.name= # Session cookie name. -server.session.cookie.path= # Path of the session cookie. -server.session.cookie.secure= # "Secure" flag for the session cookie. -server.session.persistent=false # Persist session data between restarts. -server.session.store-dir= # Directory used to store session data. -server.session.timeout= # Session timeout in seconds. -server.session.tracking-modes= # Session tracking modes (one or more of the following: "cookie", "url", "ssl"). +server.servlet.session.cookie.comment= # Comment for the session cookie. +server.servlet.session.cookie.domain= # Domain for the session cookie. +server.servlet.session.cookie.http-only= # "HttpOnly" flag for the session cookie. +server.servlet.session.cookie.max-age= # Maximum age of the session cookie. If a duration suffix is not specified, seconds will be used. +server.servlet.session.cookie.name= # Session cookie name. +server.servlet.session.cookie.path= # Path of the session cookie. +server.servlet.session.cookie.secure= # "Secure" flag for the session cookie. +server.servlet.session.persistent=false # Whether to persist session data between restarts. +server.servlet.session.store-dir= # Directory used to store session data. +server.servlet.session.timeout= # Session timeout. If a duration suffix is not specified, seconds will be used. +server.servlet.session.tracking-modes= # Session tracking modes (one or more of the following: "cookie", "url", "ssl"). server.ssl.ciphers= # Supported SSL ciphers. server.ssl.client-auth= # Whether client authentication is wanted ("want") or needed ("need"). Requires a trust store. server.ssl.enabled= # Enable SSL support. @@ -202,82 +213,84 @@ server.ssl.trust-store= # Trust store that holds SSL certificates. server.ssl.trust-store-password= # Password used to access the trust store. server.ssl.trust-store-provider= # Provider for the trust store. server.ssl.trust-store-type= # Type of the trust store. -server.tomcat.accept-count= # Maximum queue length for incoming connection requests when all possible request processing threads are in use. -server.tomcat.accesslog.buffered=true # Buffer output such that it is only flushed periodically. -server.tomcat.accesslog.directory=logs # Directory in which log files are created. Can be relative to the tomcat base dir or absolute. +server.tomcat.accept-count=0 # Maximum queue length for incoming connection requests when all possible request processing threads are in use. +server.tomcat.accesslog.buffered=true # Whether to buffer output such that it is flushed only periodically. +server.tomcat.accesslog.directory=logs # Directory in which log files are created. Can be absolute or relative to the Tomcat base dir. server.tomcat.accesslog.enabled=false # Enable access log. -server.tomcat.accesslog.file-date-format=.yyyy-MM-dd # Date format to place in log file name. +server.tomcat.accesslog.file-date-format=.yyyy-MM-dd # Date format to place in the log file name. server.tomcat.accesslog.pattern=common # Format pattern for access logs. server.tomcat.accesslog.prefix=access_log # Log file name prefix. -server.tomcat.accesslog.rename-on-rotate=false # Defer inclusion of the date stamp in the file name until rotate time. -server.tomcat.accesslog.request-attributes-enabled=false # Set request attributes for IP address, Hostname, protocol and port used for the request. -server.tomcat.accesslog.rotate=true # Enable access log rotation. +server.tomcat.accesslog.rename-on-rotate=false # Whether to defer inclusion of the date stamp in the file name until rotate time. +server.tomcat.accesslog.request-attributes-enabled=false # Set request attributes for the IP address, Hostname, protocol, and port used for the request. +server.tomcat.accesslog.rotate=true # Whether to enable access log rotation. server.tomcat.accesslog.suffix=.log # Log file name suffix. server.tomcat.additional-tld-skip-patterns= # Comma-separated list of additional patterns that match jars to ignore for TLD scanning. -server.tomcat.background-processor-delay=30 # Delay in seconds between the invocation of backgroundProcess methods. -server.tomcat.basedir= # Tomcat base directory. If not specified a temporary directory will be used. +server.tomcat.background-processor-delay=30s # Delay between the invocation of backgroundProcess methods. If a duration suffix is not specified, seconds will be used. +server.tomcat.basedir= # Tomcat base directory. If not specified, a temporary directory is used. server.tomcat.internal-proxies=10\\.\\d{1,3}\\.\\d{1,3}\\.\\d{1,3}|\\ - 192\\.168\\.\\d{1,3}\\.\\d{1,3}|\\ - 169\\.254\\.\\d{1,3}\\.\\d{1,3}|\\ - 127\\.\\d{1,3}\\.\\d{1,3}\\.\\d{1,3}|\\ - 172\\.1[6-9]{1}\\.\\d{1,3}\\.\\d{1,3}|\\ - 172\\.2[0-9]{1}\\.\\d{1,3}\\.\\d{1,3}|\\ - 172\\.3[0-1]{1}\\.\\d{1,3}\\.\\d{1,3} # regular expression matching trusted IP addresses. -server.tomcat.max-connections= # Maximum number of connections that the server will accept and process at any given time. -server.tomcat.max-http-header-size=0 # Maximum size in bytes of the HTTP message header. -server.tomcat.max-http-post-size=0 # Maximum size in bytes of the HTTP post content. -server.tomcat.max-threads=0 # Maximum amount of worker threads. -server.tomcat.min-spare-threads=0 # Minimum amount of worker threads. + 192\\.168\\.\\d{1,3}\\.\\d{1,3}|\\ + 169\\.254\\.\\d{1,3}\\.\\d{1,3}|\\ + 127\\.\\d{1,3}\\.\\d{1,3}\\.\\d{1,3}|\\ + 172\\.1[6-9]{1}\\.\\d{1,3}\\.\\d{1,3}|\\ + 172\\.2[0-9]{1}\\.\\d{1,3}\\.\\d{1,3}|\\ + 172\\.3[0-1]{1}\\.\\d{1,3}\\.\\d{1,3} # Regular expression matching trusted IP addresses. +server.tomcat.max-connections=0 # Maximum number of connections that the server accepts and processes at any given time. +server.tomcat.max-http-header-size=0 # Maximum size, in bytes, of the HTTP message header. +server.tomcat.max-http-post-size=0 # Maximum size, in bytes, of the HTTP post content. +server.tomcat.max-threads=0 # Maximum number of worker threads. +server.tomcat.min-spare-threads=0 # Minimum number of worker threads. server.tomcat.port-header=X-Forwarded-Port # Name of the HTTP header used to override the original port value. server.tomcat.protocol-header= # Header that holds the incoming protocol, usually named "X-Forwarded-Proto". -server.tomcat.protocol-header-https-value=https # Value of the protocol header that indicates that the incoming request uses SSL. +server.tomcat.protocol-header-https-value=https # Value of the protocol header indicating whether the incoming request uses SSL. server.tomcat.redirect-context-root= # Whether requests to the context root should be redirected by appending a / to the path. -server.tomcat.remote-ip-header= # Name of the http header from which the remote ip is extracted. For instance `X-FORWARDED-FOR` +server.tomcat.remote-ip-header= # Name of the HTTP header from which the remote IP is extracted. For instance, `X-FORWARDED-FOR`. +server.tomcat.resource.cache-ttl= # Time-to-live of the static resource cache. server.tomcat.uri-encoding=UTF-8 # Character encoding to use to decode the URI. +server.tomcat.use-relative-redirects= # Whether HTTP 1.1 and later location headers generated by a call to sendRedirect will use relative or absolute redirects. server.undertow.accesslog.dir= # Undertow access log directory. -server.undertow.accesslog.enabled=false # Enable access log. +server.undertow.accesslog.enabled=false # Whether to enable the access log. server.undertow.accesslog.pattern=common # Format pattern for access logs. server.undertow.accesslog.prefix=access_log. # Log file name prefix. -server.undertow.accesslog.rotate=true # Enable access log rotation. +server.undertow.accesslog.rotate=true # Whether to enable access log rotation. server.undertow.accesslog.suffix=log # Log file name suffix. -server.undertow.buffer-size= # Size of each buffer in bytes. -server.undertow.direct-buffers= # Allocate buffers outside the Java heap. +server.undertow.buffer-size= # Size of each buffer, in bytes. +server.undertow.direct-buffers= # Whether to allocate buffers outside the Java heap. server.undertow.io-threads= # Number of I/O threads to create for the worker. server.undertow.eager-filter-init=true # Whether servlet filters should be initialized on startup. -server.undertow.max-http-post-size=0 # Maximum size in bytes of the HTTP post content. +server.undertow.max-http-post-size=0 # Maximum size, in bytes, of the HTTP post content. server.undertow.worker-threads= # Number of worker threads. -# FREEMARKER (FreeMarkerAutoConfiguration) -spring.freemarker.allow-request-override=false # Set whether HttpServletRequest attributes are allowed to override (hide) controller generated model attributes of the same name. -spring.freemarker.allow-session-override=false # Set whether HttpSession attributes are allowed to override (hide) controller generated model attributes of the same name. -spring.freemarker.cache=false # Enable template caching. +# FREEMARKER (FreeMarkerProperties) +spring.freemarker.allow-request-override=false # Whether HttpServletRequest attributes are allowed to override (hide) controller generated model attributes of the same name. +spring.freemarker.allow-session-override=false # Whether HttpSession attributes are allowed to override (hide) controller generated model attributes of the same name. +spring.freemarker.cache=false # Whether to enable template caching. spring.freemarker.charset=UTF-8 # Template encoding. -spring.freemarker.check-template-location=true # Check that the templates location exists. +spring.freemarker.check-template-location=true # Whether to check that the templates location exists. spring.freemarker.content-type=text/html # Content-Type value. -spring.freemarker.enabled=true # Enable MVC view resolution for this technology. -spring.freemarker.expose-request-attributes=false # Set whether all request attributes should be added to the model prior to merging with the template. -spring.freemarker.expose-session-attributes=false # Set whether all HttpSession attributes should be added to the model prior to merging with the template. -spring.freemarker.expose-spring-macro-helpers=true # Set whether to expose a RequestContext for use by Spring's macro library, under the name "springMacroRequestContext". -spring.freemarker.prefer-file-system-access=true # Prefer file system access for template loading. File system access enables hot detection of template changes. +spring.freemarker.enabled=true # Whether to enable MVC view resolution for this technology. +spring.freemarker.expose-request-attributes=false # Whether all request attributes should be added to the model prior to merging with the template. +spring.freemarker.expose-session-attributes=false # Whether all HttpSession attributes should be added to the model prior to merging with the template. +spring.freemarker.expose-spring-macro-helpers=true # Whether to expose a RequestContext for use by Spring's macro library, under the name "springMacroRequestContext". +spring.freemarker.prefer-file-system-access=true # Whether to prefer file system access for template loading. File system access enables hot detection of template changes. spring.freemarker.prefix= # Prefix that gets prepended to view names when building a URL. spring.freemarker.request-context-attribute= # Name of the RequestContext attribute for all views. -spring.freemarker.settings.*= # Well-known FreeMarker keys which will be passed to FreeMarker's Configuration. -spring.freemarker.suffix= # Suffix that gets appended to view names when building a URL. +spring.freemarker.settings.*= # Well-known FreeMarker keys which are passed to FreeMarker's Configuration. +spring.freemarker.suffix=.ftl # Suffix that gets appended to view names when building a URL. spring.freemarker.template-loader-path=classpath:/templates/ # Comma-separated list of template paths. spring.freemarker.view-names= # White list of view names that can be resolved. -# GROOVY TEMPLATES (GroovyTemplateAutoConfiguration) -spring.groovy.template.allow-request-override=false # Set whether HttpServletRequest attributes are allowed to override (hide) controller generated model attributes of the same name. -spring.groovy.template.allow-session-override=false # Set whether HttpSession attributes are allowed to override (hide) controller generated model attributes of the same name. -spring.groovy.template.cache= # Enable template caching. +# GROOVY TEMPLATES (GroovyTemplateProperties) +spring.groovy.template.allow-request-override=false # Whether HttpServletRequest attributes are allowed to override (hide) controller generated model attributes of the same name. +spring.groovy.template.allow-session-override=false # Whether HttpSession attributes are allowed to override (hide) controller generated model attributes of the same name. +spring.groovy.template.cache=false # Whether to enable template caching. spring.groovy.template.charset=UTF-8 # Template encoding. -spring.groovy.template.check-template-location=true # Check that the templates location exists. +spring.groovy.template.check-template-location=true # Whether to check that the templates location exists. spring.groovy.template.configuration.*= # See GroovyMarkupConfigurer -spring.groovy.template.content-type=test/html # Content-Type value. -spring.groovy.template.enabled=true # Enable MVC view resolution for this technology. -spring.groovy.template.expose-request-attributes=false # Set whether all request attributes should be added to the model prior to merging with the template. -spring.groovy.template.expose-session-attributes=false # Set whether all HttpSession attributes should be added to the model prior to merging with the template. -spring.groovy.template.expose-spring-macro-helpers=true # Set whether to expose a RequestContext for use by Spring's macro library, under the name "springMacroRequestContext". +spring.groovy.template.content-type=text/html # Content-Type value. +spring.groovy.template.enabled=true # Whether to enable MVC view resolution for this technology. +spring.groovy.template.expose-request-attributes=false # Whether all request attributes should be added to the model prior to merging with the template. +spring.groovy.template.expose-session-attributes=false # Whether all HttpSession attributes should be added to the model prior to merging with the template. +spring.groovy.template.expose-spring-macro-helpers=true # Whether to expose a RequestContext for use by Spring's macro library, under the name "springMacroRequestContext". spring.groovy.template.prefix= # Prefix that gets prepended to view names when building a URL. spring.groovy.template.request-context-attribute= # Name of the RequestContext attribute for all views. spring.groovy.template.resource-loader-path=classpath:/templates/ # Template path. @@ -285,173 +298,193 @@ spring.groovy.template.suffix=.tpl # Suffix that gets appended to view names whe spring.groovy.template.view-names= # White list of view names that can be resolved. # SPRING HATEOAS (HateoasProperties) -spring.hateoas.use-hal-as-default-json-media-type=true # Specify if application/hal+json responses should be sent to requests that accept application/json. +spring.hateoas.use-hal-as-default-json-media-type=true # Whether application/hal+json responses should be sent to requests that accept application/json. # HTTP message conversion -spring.http.converters.preferred-json-mapper=jackson # Preferred JSON mapper to use for HTTP message conversion. Set to "gson" to force the use of Gson when both it and Jackson are on the classpath. +spring.http.converters.preferred-json-mapper= # Preferred JSON mapper to use for HTTP message conversion. By default, auto-detected according to the environment. # HTTP encoding (HttpEncodingProperties) spring.http.encoding.charset=UTF-8 # Charset of HTTP requests and responses. Added to the "Content-Type" header if not set explicitly. -spring.http.encoding.enabled=true # Enable http encoding support. -spring.http.encoding.force= # Force the encoding to the configured charset on HTTP requests and responses. -spring.http.encoding.force-request= # Force the encoding to the configured charset on HTTP requests. Defaults to true when "force" has not been specified. -spring.http.encoding.force-response= # Force the encoding to the configured charset on HTTP responses. -spring.http.encoding.mapping= # Locale to Encoding mapping. +spring.http.encoding.enabled=true # Whether to enable http encoding support. +spring.http.encoding.force= # Whether to force the encoding to the configured charset on HTTP requests and responses. +spring.http.encoding.force-request= # Whether to force the encoding to the configured charset on HTTP requests. Defaults to true when "force" has not been specified. +spring.http.encoding.force-response= # Whether to force the encoding to the configured charset on HTTP responses. +spring.http.encoding.mapping= # Locale in which to encode mapping. # MULTIPART (MultipartProperties) -spring.servlet.multipart.enabled=true # Enable support of multipart uploads. -spring.servlet.multipart.file-size-threshold=0 # Threshold after which files will be written to disk. Values can use the suffixes "MB" or "KB" to indicate megabytes or kilobytes respectively. +spring.servlet.multipart.enabled=true # Whether to enable support of multipart uploads. +spring.servlet.multipart.file-size-threshold=0 # Threshold after which files are written to disk. Values can use the suffixes "MB" or "KB" to indicate megabytes or kilobytes, respectively. spring.servlet.multipart.location= # Intermediate location of uploaded files. -spring.servlet.multipart.max-file-size=1MB # Max file size. Values can use the suffixes "MB" or "KB" to indicate megabytes or kilobytes respectively. -spring.servlet.multipart.max-request-size=10MB # Max request size. Values can use the suffixes "MB" or "KB" to indicate megabytes or kilobytes respectively. +spring.servlet.multipart.max-file-size=1MB # Max file size. Values can use the suffixes "MB" or "KB" to indicate megabytes or kilobytes, respectively. +spring.servlet.multipart.max-request-size=10MB # Max request size. Values can use the suffixes "MB" or "KB" to indicate megabytes or kilobytes, respectively. spring.servlet.multipart.resolve-lazily=false # Whether to resolve the multipart request lazily at the time of file or parameter access. # JACKSON (JacksonProperties) -spring.jackson.date-format= # Date format string or a fully-qualified date format class name. For instance `yyyy-MM-dd HH:mm:ss`. -spring.jackson.default-property-inclusion= # Controls the inclusion of properties during serialization. +spring.jackson.date-format= # Date format string or a fully-qualified date format class name. For instance, `yyyy-MM-dd HH:mm:ss`. +spring.jackson.default-property-inclusion= # Controls the inclusion of properties during serialization. Configured with one of the values in Jackson's JsonInclude.Include enumeration. spring.jackson.deserialization.*= # Jackson on/off features that affect the way Java objects are deserialized. spring.jackson.generator.*= # Jackson on/off features for generators. -spring.jackson.joda-date-time-format= # Joda date time format string. If not configured, "date-format" will be used as a fallback if it is configured with a format string. +spring.jackson.joda-date-time-format= # Joda date time format string. If not configured, "date-format" is used as a fallback if it is configured with a format string. spring.jackson.locale= # Locale used for formatting. spring.jackson.mapper.*= # Jackson general purpose on/off features. spring.jackson.parser.*= # Jackson on/off features for parsers. spring.jackson.property-naming-strategy= # One of the constants on Jackson's PropertyNamingStrategy. Can also be a fully-qualified class name of a PropertyNamingStrategy subclass. spring.jackson.serialization.*= # Jackson on/off features that affect the way Java objects are serialized. -spring.jackson.time-zone= # Time zone used when formatting dates. For instance `America/Los_Angeles` +spring.jackson.time-zone= # Time zone used when formatting dates. For instance, "America/Los_Angeles" or "GMT+10". + +# GSON (GsonProperties) +spring.gson.date-format= # Format to use when serializing Date objects. +spring.gson.disable-html-escaping= # Whether to disable the escaping of HTML characters such as '<', '>', etc. +spring.gson.disable-inner-class-serialization= # Whether to exclude inner classes during serialization. +spring.gson.enable-complex-map-key-serialization= # Whether to enable serialization of complex map keys (i.e. non-primitives). +spring.gson.exclude-fields-without-expose-annotation= # Whether to exclude all fields from consideration for serialization or deserialization that do not have the "Expose" annotation. +spring.gson.field-naming-policy= # Naming policy that should be applied to an object's field during serialization and deserialization. +spring.gson.generate-non-executable-json= # Whether to generate non executable JSON by prefixing the output with some special text. +spring.gson.lenient= # Whether to be lenient about parsing JSON that doesn't conform to RFC 4627. +spring.gson.long-serialization-policy= # Serialization policy for Long and long types. +spring.gson.pretty-printing= # Whether to output serialized JSON that fits in a page for pretty printing. +spring.gson.serialize-nulls= # Whether to serialize null fields. # JERSEY (JerseyProperties) -spring.jersey.application-path= # Path that serves as the base URI for the application. Overrides the value of "@ApplicationPath" if specified. +spring.jersey.application-path= # Path that serves as the base URI for the application. If specified, overrides the value of "@ApplicationPath". spring.jersey.filter.order=0 # Jersey filter chain order. -spring.jersey.init.*= # Init parameters to pass to Jersey via the servlet or filter. +spring.jersey.init.*= # Init parameters to pass to Jersey through the servlet or filter. spring.jersey.servlet.load-on-startup=-1 # Load on startup priority of the Jersey servlet. spring.jersey.type=servlet # Jersey integration type. # SPRING LDAP (LdapProperties) -spring.ldap.urls= # LDAP URLs of the server. +spring.ldap.anonymous-read-only=false # Whether read-only operations should use an anonymous environment. spring.ldap.base= # Base suffix from which all operations should originate. -spring.ldap.username= # Login user of the server. -spring.ldap.password= # Login password of the server. spring.ldap.base-environment.*= # LDAP specification settings. +spring.ldap.password= # Login password of the server. +spring.ldap.urls= # LDAP URLs of the server. +spring.ldap.username= # Login username of the server. # EMBEDDED LDAP (EmbeddedLdapProperties) -spring.ldap.embedded.base-dn= # The base DN +spring.ldap.embedded.base-dn= # List of base DNs. spring.ldap.embedded.credential.username= # Embedded LDAP username. spring.ldap.embedded.credential.password= # Embedded LDAP password. spring.ldap.embedded.ldif=classpath:schema.ldif # Schema (LDIF) script resource reference. -spring.ldap.embedded.port= # Embedded LDAP port. -spring.ldap.embedded.validation.enabled=true # Enable LDAP schema validation. +spring.ldap.embedded.port=0 # Embedded LDAP port. +spring.ldap.embedded.validation.enabled=true # Whether to enable LDAP schema validation. spring.ldap.embedded.validation.schema= # Path to the custom schema. -# SPRING MOBILE DEVICE VIEWS (DeviceDelegatingViewResolverAutoConfiguration) -spring.mobile.devicedelegatingviewresolver.enable-fallback=false # Enable support for fallback resolution. -spring.mobile.devicedelegatingviewresolver.enabled=false # Enable device view resolver. -spring.mobile.devicedelegatingviewresolver.mobile-prefix=mobile/ # Prefix that gets prepended to view names for mobile devices. -spring.mobile.devicedelegatingviewresolver.mobile-suffix= # Suffix that gets appended to view names for mobile devices. -spring.mobile.devicedelegatingviewresolver.normal-prefix= # Prefix that gets prepended to view names for normal devices. -spring.mobile.devicedelegatingviewresolver.normal-suffix= # Suffix that gets appended to view names for normal devices. -spring.mobile.devicedelegatingviewresolver.tablet-prefix=tablet/ # Prefix that gets prepended to view names for tablet devices. -spring.mobile.devicedelegatingviewresolver.tablet-suffix= # Suffix that gets appended to view names for tablet devices. - -# SPRING MOBILE SITE PREFERENCE (SitePreferenceAutoConfiguration) -spring.mobile.sitepreference.enabled=true # Enable SitePreferenceHandler. - # MUSTACHE TEMPLATES (MustacheAutoConfiguration) -spring.mustache.allow-request-override= # Set whether HttpServletRequest attributes are allowed to override (hide) controller generated model attributes of the same name. -spring.mustache.allow-session-override= # Set whether HttpSession attributes are allowed to override (hide) controller generated model attributes of the same name. -spring.mustache.cache= # Enable template caching. -spring.mustache.charset= # Template encoding. -spring.mustache.check-template-location= # Check that the templates location exists. -spring.mustache.content-type= # Content-Type value. -spring.mustache.enabled= # Enable MVC view resolution for this technology. -spring.mustache.expose-request-attributes= # Set whether all request attributes should be added to the model prior to merging with the template. -spring.mustache.expose-session-attributes= # Set whether all HttpSession attributes should be added to the model prior to merging with the template. -spring.mustache.expose-spring-macro-helpers= # Set whether to expose a RequestContext for use by Spring's macro library, under the name "springMacroRequestContext". +spring.mustache.allow-request-override=false # Whether HttpServletRequest attributes are allowed to override (hide) controller generated model attributes of the same name. +spring.mustache.allow-session-override=false # Whether HttpSession attributes are allowed to override (hide) controller generated model attributes of the same name. +spring.mustache.cache=false # Whether to enable template caching. +spring.mustache.charset=UTF-8 # Template encoding. +spring.mustache.check-template-location=true # Whether to check that the templates location exists. +spring.mustache.content-type=text/html # Content-Type value. +spring.mustache.enabled=true # Whether to enable MVC view resolution for this technology. +spring.mustache.expose-request-attributes=false # Whether all request attributes should be added to the model prior to merging with the template. +spring.mustache.expose-session-attributes=false # Whether all HttpSession attributes should be added to the model prior to merging with the template. +spring.mustache.expose-spring-macro-helpers=true # Whether to expose a RequestContext for use by Spring's macro library, under the name "springMacroRequestContext". spring.mustache.prefix=classpath:/templates/ # Prefix to apply to template names. spring.mustache.request-context-attribute= # Name of the RequestContext attribute for all views. spring.mustache.suffix=.mustache # Suffix to apply to template names. spring.mustache.view-names= # White list of view names that can be resolved. # SPRING MVC (WebMvcProperties) -spring.mvc.async.request-timeout= # Amount of time (in milliseconds) before asynchronous request handling times out. -spring.mvc.date-format= # Date format to use. For instance `dd/MM/yyyy`. -spring.mvc.dispatch-trace-request=false # Dispatch TRACE requests to the FrameworkServlet doService method. -spring.mvc.dispatch-options-request=true # Dispatch OPTIONS requests to the FrameworkServlet doService method. -spring.mvc.favicon.enabled=true # Enable resolution of favicon.ico. -spring.mvc.formcontent.putfilter.enabled=true # Enable Spring's HttpPutFormContentFilter. -spring.mvc.ignore-default-model-on-redirect=true # If the content of the "default" model should be ignored during redirect scenarios. +spring.mvc.async.request-timeout= # Amount of time before asynchronous request handling times out. +spring.mvc.contentnegotiation.favor-parameter=false # Whether a request parameter ("format" by default) should be used to determine the requested media type. +spring.mvc.contentnegotiation.favor-path-extension=false # Whether the path extension in the URL path should be used to determine the requested media type. +spring.mvc.contentnegotiation.media-types.*= # Map file extensions to media types for content negotiation. For instance, yml to text/yaml. +spring.mvc.contentnegotiation.parameter-name= # Query parameter name to use when "favor-parameter" is enabled. +spring.mvc.date-format= # Date format to use. For instance, `dd/MM/yyyy`. +spring.mvc.dispatch-trace-request=false # Whether to dispatch TRACE requests to the FrameworkServlet doService method. +spring.mvc.dispatch-options-request=true # Whether to dispatch OPTIONS requests to the FrameworkServlet doService method. +spring.mvc.favicon.enabled=true # Whether to enable resolution of favicon.ico. +spring.mvc.formcontent.putfilter.enabled=true # Whether to enable Spring's HttpPutFormContentFilter. +spring.mvc.ignore-default-model-on-redirect=true # Whether the content of the "default" model should be ignored during redirect scenarios. spring.mvc.locale= # Locale to use. By default, this locale is overridden by the "Accept-Language" header. spring.mvc.locale-resolver=accept-header # Define how the locale should be resolved. -spring.mvc.log-resolved-exception=false # Enable warn logging of exceptions resolved by a "HandlerExceptionResolver". -spring.mvc.media-types.*= # Maps file extensions to media types for content negotiation. -spring.mvc.message-codes-resolver-format= # Formatting strategy for message codes. For instance `PREFIX_ERROR_CODE`. -spring.mvc.servlet.load-on-startup=-1 # Load on startup priority of the Spring Web Services servlet. +spring.mvc.log-resolved-exception=false # Whether to enable warn logging of exceptions resolved by a "HandlerExceptionResolver". +spring.mvc.message-codes-resolver-format= # Formatting strategy for message codes. For instance, `PREFIX_ERROR_CODE`. +spring.mvc.pathmatch.use-registered-suffix-pattern=false # Whether suffix pattern matching should work only against extensions registered with "spring.mvc.contentnegotiation.media-types.*". +spring.mvc.pathmatch.use-suffix-pattern=false # Whether to use suffix pattern match (".*") when matching patterns to requests. +spring.mvc.servlet.load-on-startup=-1 # Load on startup priority of the dispatcher servlet. spring.mvc.static-path-pattern=/** # Path pattern used for static resources. -spring.mvc.throw-exception-if-no-handler-found=false # If a "NoHandlerFoundException" should be thrown if no Handler was found to process a request. +spring.mvc.throw-exception-if-no-handler-found=false # Whether a "NoHandlerFoundException" should be thrown if no Handler was found to process a request. spring.mvc.view.prefix= # Spring MVC view prefix. spring.mvc.view.suffix= # Spring MVC view suffix. # SPRING RESOURCES HANDLING (ResourceProperties) -spring.resources.add-mappings=true # Enable default resource handling. -spring.resources.cache-period= # Cache period for the resources served by the resource handler, in seconds. -spring.resources.chain.cache=true # Enable caching in the Resource chain. -spring.resources.chain.enabled= # Enable the Spring Resource Handling chain. Disabled by default unless at least one strategy has been enabled. -spring.resources.chain.gzipped=false # Enable resolution of already gzipped resources. -spring.resources.chain.html-application-cache=false # Enable HTML5 application cache manifest rewriting. -spring.resources.chain.strategy.content.enabled=false # Enable the content Version Strategy. -spring.resources.chain.strategy.content.paths=/** # Comma-separated list of patterns to apply to the Version Strategy. -spring.resources.chain.strategy.fixed.enabled=false # Enable the fixed Version Strategy. -spring.resources.chain.strategy.fixed.paths=/** # Comma-separated list of patterns to apply to the Version Strategy. -spring.resources.chain.strategy.fixed.version= # Version string to use for the Version Strategy. +spring.resources.add-mappings=true # Whether to enable default resource handling. +spring.resources.cache.cachecontrol.cache-private= # Indicate that the response message is intended for a single user and must not be stored by a shared cache. +spring.resources.cache.cachecontrol.cache-public= # Indicate that any cache may store the response. +spring.resources.cache.cachecontrol.max-age= # Maximum time the response should be cached, in seconds if no duration suffix is not specified. +spring.resources.cache.cachecontrol.must-revalidate= # Indicate that once it has become stale, a cache must not use the response without re-validating it with the server. +spring.resources.cache.cachecontrol.no-cache= # Indicate that the cached response can be reused only if re-validated with the server. +spring.resources.cache.cachecontrol.no-store= # Indicate to not cache the response in any case. +spring.resources.cache.cachecontrol.no-transform= # Indicate intermediaries (caches and others) that they should not transform the response content. +spring.resources.cache.cachecontrol.proxy-revalidate= # Same meaning as the "must-revalidate" directive, except that it does not apply to private caches. +spring.resources.cache.cachecontrol.s-max-age= # Maximum time the response should be cached by shared caches, in seconds if no duration suffix is not specified. +spring.resources.cache.cachecontrol.stale-if-error= # Maximum time the response may be used when errors are encountered, in seconds if no duration suffix is not specified. +spring.resources.cache.cachecontrol.stale-while-revalidate= # Maximum time the response can be served after it becomes stale, in seconds if no duration suffix is not specified. +spring.resources.cache.period= # Cache period for the resources served by the resource handler. If a duration suffix is not specified, seconds will be used. +spring.resources.chain.cache=true # Whether to enable caching in the Resource chain. +spring.resources.chain.enabled= # Whether to enable the Spring Resource Handling chain. By default, disabled unless at least one strategy has been enabled. +spring.resources.chain.gzipped=false # Whether to enable resolution of already gzipped resources. +spring.resources.chain.html-application-cache=false # Whether to enable HTML5 application cache manifest rewriting. +spring.resources.chain.strategy.content.enabled=false # Whether to enable the content Version Strategy. +spring.resources.chain.strategy.content.paths=/** # Comma-separated list of patterns to apply to the content Version Strategy. +spring.resources.chain.strategy.fixed.enabled=false # Whether to enable the fixed Version Strategy. +spring.resources.chain.strategy.fixed.paths=/** # Comma-separated list of patterns to apply to the fixed Version Strategy. +spring.resources.chain.strategy.fixed.version= # Version string to use for the fixed Version Strategy. spring.resources.static-locations=classpath:/META-INF/resources/,classpath:/resources/,classpath:/static/,classpath:/public/ # Locations of static resources. # SPRING SESSION (SessionProperties) -spring.session.hazelcast.flush-mode=on-save # Sessions flush mode. -spring.session.hazelcast.map-name=spring:session:sessions # Name of the map used to store sessions. -spring.session.jdbc.initializer.enabled= # Create the required session tables on startup if necessary. Enabled automatically if the default table name is set or a custom schema is configured. -spring.session.jdbc.schema=classpath:org/springframework/session/jdbc/schema-@@platform@@.sql # Path to the SQL file to use to initialize the database schema. -spring.session.jdbc.table-name=SPRING_SESSION # Name of database table used to store sessions. -spring.session.redis.flush-mode=on-save # Sessions flush mode. -spring.session.redis.namespace= # Namespace for keys used to store sessions. spring.session.store-type= # Session store type. +spring.session.servlet.filter-order=-2147483598 # Session repository filter order. +spring.session.servlet.filter-dispatcher-types=async,error,request # Session repository filter dispatcher types. -# SPRING SOCIAL (SocialWebAutoConfiguration) -spring.social.auto-connection-views=false # Enable the connection status view for supported providers. +# SPRING SESSION HAZELCAST (HazelcastSessionProperties) +spring.session.hazelcast.flush-mode=on-save # Sessions flush mode. +spring.session.hazelcast.map-name=spring:session:sessions # Name of the map used to store sessions. -# SPRING SOCIAL FACEBOOK (FacebookAutoConfiguration) -spring.social.facebook.app-id= # your application's Facebook App ID -spring.social.facebook.app-secret= # your application's Facebook App Secret +# SPRING SESSION JDBC (JdbcSessionProperties) +spring.session.jdbc.cleanup-cron=0 * * * * * # Cron expression for expired session cleanup job. +spring.session.jdbc.initialize-schema=embedded # Database schema initialization mode. +spring.session.jdbc.schema=classpath:org/springframework/session/jdbc/schema-@@platform@@.sql # Path to the SQL file to use to initialize the database schema. +spring.session.jdbc.table-name=SPRING_SESSION # Name of the database table used to store sessions. -# SPRING SOCIAL LINKEDIN (LinkedInAutoConfiguration) -spring.social.linkedin.app-id= # your application's LinkedIn App ID -spring.social.linkedin.app-secret= # your application's LinkedIn App Secret +# SPRING SESSION MONGODB (MongoSessionProperties) +spring.session.mongodb.collection-name=sessions # Collection name used to store sessions. -# SPRING SOCIAL TWITTER (TwitterAutoConfiguration) -spring.social.twitter.app-id= # your application's Twitter App ID -spring.social.twitter.app-secret= # your application's Twitter App Secret +# SPRING SESSION REDIS (RedisSessionProperties) +spring.session.redis.cleanup-cron=0 * * * * * # Cron expression for expired session cleanup job. +spring.session.redis.flush-mode=on-save # Sessions flush mode. +spring.session.redis.namespace=spring:session # Namespace for keys used to store sessions. # THYMELEAF (ThymeleafAutoConfiguration) -spring.thymeleaf.cache=true # Enable template caching. -spring.thymeleaf.check-template=true # Check that the template exists before rendering it. -spring.thymeleaf.check-template-location=true # Check that the templates location exists. -spring.thymeleaf.enabled=true # Enable Thymeleaf view resolution for Web frameworks. +spring.thymeleaf.cache=true # Whether to enable template caching. +spring.thymeleaf.check-template=true # Whether to check that the template exists before rendering it. +spring.thymeleaf.check-template-location=true # Whether to check that the templates location exists. +spring.thymeleaf.enabled=true # Whether to enable Thymeleaf view resolution for Web frameworks. +spring.thymeleaf.enable-spring-el-compiler=false # Enable the SpringEL compiler in SpringEL expressions. spring.thymeleaf.encoding=UTF-8 # Template files encoding. -spring.thymeleaf.excluded-view-names= # Comma-separated list of view names that should be excluded from resolution. -spring.thymeleaf.mode=HTML5 # Template mode to be applied to templates. See also StandardTemplateModeHandlers. +spring.thymeleaf.excluded-view-names= # Comma-separated list of view names (patterns allowed) that should be excluded from resolution. +spring.thymeleaf.mode=HTML # Template mode to be applied to templates. See also Thymeleaf's TemplateMode enum. spring.thymeleaf.prefix=classpath:/templates/ # Prefix that gets prepended to view names when building a URL. -spring.thymeleaf.reactive.max-chunk-size= # Maximum size of data buffers used for writing to the response, in bytes. +spring.thymeleaf.reactive.chunked-mode-view-names= # Comma-separated list of view names (patterns allowed) that should be the only ones executed in CHUNKED mode when a max chunk size is set. +spring.thymeleaf.reactive.full-mode-view-names= # Comma-separated list of view names (patterns allowed) that should be executed in FULL mode even if a max chunk size is set. +spring.thymeleaf.reactive.max-chunk-size=0 # Maximum size of data buffers used for writing to the response, in bytes. spring.thymeleaf.reactive.media-types= # Media types supported by the view technology. spring.thymeleaf.servlet.content-type=text/html # Content-Type value written to HTTP responses. spring.thymeleaf.suffix=.html # Suffix that gets appended to view names when building a URL. spring.thymeleaf.template-resolver-order= # Order of the template resolver in the chain. -spring.thymeleaf.view-names= # Comma-separated list of view names that can be resolved. +spring.thymeleaf.view-names= # Comma-separated list of view names (patterns allowed) that can be resolved. -# SPRING WEB FLUX (WebFluxProperties) +# SPRING WEBFLUX (WebFluxProperties) +spring.webflux.date-format= # Date format to use. For instance, `dd/MM/yyyy`. spring.webflux.static-path-pattern=/** # Path pattern used for static resources. # SPRING WEB SERVICES (WebServicesProperties) spring.webservices.path=/services # Path that serves as the base URI for the services. spring.webservices.servlet.init= # Servlet init parameters to pass to Spring Web Services. spring.webservices.servlet.load-on-startup=-1 # Load on startup priority of the Spring Web Services servlet. +spring.webservices.wsdl-locations= # Comma-separated list of locations of WSDLs and accompanying XSDs to be exposed as beans. @@ -459,141 +492,110 @@ spring.webservices.servlet.load-on-startup=-1 # Load on startup priority of the # SECURITY PROPERTIES # ---------------------------------------- # SECURITY (SecurityProperties) -security.basic.authorize-mode=role # Security authorize mode to apply. -security.basic.enabled=true # Enable basic authentication. -security.basic.path=/** # Comma-separated list of paths to secure. -security.basic.realm=Spring # HTTP basic realm name. -security.enable-csrf=false # Enable Cross Site Request Forgery support. -security.filter-order=0 # Security filter chain order. -security.filter-dispatcher-types=ASYNC, FORWARD, INCLUDE, REQUEST # Security filter chain dispatcher types. -security.headers.cache=true # Enable cache control HTTP headers. -security.headers.content-security-policy= # Value for content security policy header. -security.headers.content-security-policy-mode=default # Content security policy mode. -security.headers.content-type=true # Enable "X-Content-Type-Options" header. -security.headers.frame=true # Enable "X-Frame-Options" header. -security.headers.hsts=all # HTTP Strict Transport Security (HSTS) mode (none, domain, all). -security.headers.xss=true # Enable cross site scripting (XSS) protection. -security.ignored= # Comma-separated list of paths to exclude from the default secured paths. -security.require-ssl=false # Enable secure channel for all requests. -security.sessions=stateless # Session creation policy (always, never, if_required, stateless). -security.user.name=user # Default user name. -security.user.password= # Password for the default user name. A random password is logged on startup by default. -security.user.role=USER # Granted roles for the default user name. +spring.security.filter.order=-100 # Security filter chain order. +spring.security.filter.dispatcher-types=async,error,request # Security filter chain dispatcher types. +spring.security.user.name=user # Default user name. +spring.security.user.password= # Password for the default user name. +spring.security.user.roles= # Granted roles for the default user name. # SECURITY OAUTH2 CLIENT (OAuth2ClientProperties) -security.oauth2.client.client-id= # OAuth2 client id. -security.oauth2.client.client-secret= # OAuth2 client secret. A random secret is generated by default - -# SECURITY OAUTH2 RESOURCES (ResourceServerProperties) -security.oauth2.resource.filter-order= # The order of the filter chain used to authenticate tokens. -security.oauth2.resource.id= # Identifier of the resource. -security.oauth2.resource.jwt.key-uri= # The URI of the JWT token. Can be set if the value is not available and the key is public. -security.oauth2.resource.jwt.key-value= # The verification key of the JWT token. Can either be a symmetric secret or PEM-encoded RSA public key. -security.oauth2.resource.prefer-token-info=true # Use the token info, can be set to false to use the user info. -security.oauth2.resource.service-id=resource # -security.oauth2.resource.token-info-uri= # URI of the token decoding endpoint. -security.oauth2.resource.token-type= # The token type to send when using the userInfoUri. -security.oauth2.resource.user-info-uri= # URI of the user endpoint. - -# SECURITY OAUTH2 SSO (OAuth2SsoProperties) -security.oauth2.sso.filter-order= # Filter order to apply if not providing an explicit WebSecurityConfigurerAdapter -security.oauth2.sso.login-path=/login # Path to the login page, i.e. the one that triggers the redirect to the OAuth2 Authorization Server - +spring.security.oauth2.client.provider.*= # OAuth provider details. +spring.security.oauth2.client.registration.*= # OAuth client registrations. # ---------------------------------------- # DATA PROPERTIES # ---------------------------------------- # FLYWAY (FlywayProperties) -flyway.allow-mixed-migrations= # -flyway.baseline-description= # -flyway.baseline-on-migrate= # -flyway.baseline-version=1 # version to start migration -flyway.check-location=false # Check that migration scripts location exists. -flyway.clean-disabled= # -flyway.clean-on-validation-error= # -flyway.enabled=true # Enable flyway. -flyway.encoding= # -flyway.ignore-failed-future-migration= # -flyway.ignore-future-migrations= # -flyway.ignore-missing-migrations= # -flyway.init-sqls= # SQL statements to execute to initialize a connection immediately after obtaining it. -flyway.installed-by= # -flyway.locations=classpath:db/migration # locations of migrations scripts -flyway.out-of-order= # -flyway.password= # JDBC password if you want Flyway to create its own DataSource -flyway.placeholder-prefix= # -flyway.placeholder-replacement= # -flyway.placeholder-suffix= # -flyway.placeholders.*= # -flyway.repeatable-sql-migration-prefix= # -flyway.schemas= # schemas to update -flyway.skip-default-callbacks= # -flyway.skip-default-resolvers= # -flyway.sql-migration-prefix=V # -flyway.sql-migration-separator= # -flyway.sql-migration-suffix=.sql # -flyway.table= # -flyway.target= # -flyway.url= # JDBC url of the database to migrate. If not set, the primary configured data source is used. -flyway.user= # Login user of the database to migrate. -flyway.validate-on-migrate= # +spring.flyway.baseline-description= # +spring.flyway.baseline-on-migrate= # +spring.flyway.baseline-version=1 # Version to start migration +spring.flyway.check-location=true # Whether to check that migration scripts location exists. +spring.flyway.clean-disabled= # +spring.flyway.clean-on-validation-error= # +spring.flyway.dry-run-output= # +spring.flyway.enabled=true # Whether to enable flyway. +spring.flyway.encoding= # +spring.flyway.error-handlers= # +spring.flyway.group= # +spring.flyway.ignore-future-migrations= # +spring.flyway.ignore-missing-migrations= # +spring.flyway.init-sqls= # SQL statements to execute to initialize a connection immediately after obtaining it. +spring.flyway.installed-by= # +spring.flyway.locations=classpath:db/migration # The locations of migrations scripts. +spring.flyway.mixed= # +spring.flyway.out-of-order= # +spring.flyway.password= # JDBC password to use if you want Flyway to create its own DataSource. +spring.flyway.placeholder-prefix= # +spring.flyway.placeholder-replacement= # +spring.flyway.placeholder-suffix= # +spring.flyway.placeholders.*= # +spring.flyway.repeatable-sql-migration-prefix= # +spring.flyway.schemas= # schemas to update +spring.flyway.skip-default-callbacks= # +spring.flyway.skip-default-resolvers= # +spring.flyway.sql-migration-prefix=V # +spring.flyway.sql-migration-separator= # +spring.flyway.sql-migration-suffix=.sql # +spring.flyway.sql-migration-suffixes= # +spring.flyway.table= # +spring.flyway.target= # +spring.flyway.undo-sql-migration-prefix= # +spring.flyway.url= # JDBC url of the database to migrate. If not set, the primary configured data source is used. +spring.flyway.user= # Login user of the database to migrate. +spring.flyway.validate-on-migrate= # # LIQUIBASE (LiquibaseProperties) -liquibase.change-log=classpath:/db/changelog/db.changelog-master.yaml # Change log configuration path. -liquibase.check-change-log-location=true # Check the change log location exists. -liquibase.contexts= # Comma-separated list of runtime contexts to use. -liquibase.default-schema= # Default database schema. -liquibase.drop-first=false # Drop the database schema first. -liquibase.enabled=true # Enable liquibase support. -liquibase.labels= # Comma-separated list of runtime labels to use. -liquibase.parameters.*= # Change log parameters. -liquibase.password= # Login password of the database to migrate. -liquibase.rollback-file= # File to which rollback SQL will be written when an update is performed. -liquibase.url= # JDBC url of the database to migrate. If not set, the primary configured data source is used. -liquibase.user= # Login user of the database to migrate. +spring.liquibase.change-log=classpath:/db/changelog/db.changelog-master.yaml # Change log configuration path. +spring.liquibase.check-change-log-location=true # Whether to check that the change log location exists. +spring.liquibase.contexts= # Comma-separated list of runtime contexts to use. +spring.liquibase.default-schema= # Default database schema. +spring.liquibase.drop-first=false # Whether to first drop the database schema. +spring.liquibase.enabled=true # Whether to enable Liquibase support. +spring.liquibase.labels= # Comma-separated list of runtime labels to use. +spring.liquibase.parameters.*= # Change log parameters. +spring.liquibase.password= # Login password of the database to migrate. +spring.liquibase.rollback-file= # File to which rollback SQL is written when an update is performed. +spring.liquibase.url= # JDBC URL of the database to migrate. If not set, the primary configured data source is used. +spring.liquibase.user= # Login user of the database to migrate. # COUCHBASE (CouchbaseProperties) spring.couchbase.bootstrap-hosts= # Couchbase nodes (host or IP address) to bootstrap from. spring.couchbase.bucket.name=default # Name of the bucket to connect to. spring.couchbase.bucket.password= # Password of the bucket. -spring.couchbase.env.endpoints.key-value=1 # Number of sockets per node against the Key/value service. -spring.couchbase.env.endpoints.query=1 # Number of sockets per node against the Query (N1QL) service. +spring.couchbase.env.endpoints.key-value=1 # Number of sockets per node against the key/value service. +spring.couchbase.env.endpoints.query=1 # Number of sockets per node against the query (N1QL) service. spring.couchbase.env.endpoints.view=1 # Number of sockets per node against the view service. -spring.couchbase.env.ssl.enabled= # Enable SSL support. Enabled automatically if a "keyStore" is provided unless specified otherwise. +spring.couchbase.env.ssl.enabled= # Whether to enable SSL support. Enabled automatically if a "keyStore" is provided unless specified otherwise. spring.couchbase.env.ssl.key-store= # Path to the JVM key store that holds the certificates. spring.couchbase.env.ssl.key-store-password= # Password used to access the key store. -spring.couchbase.env.timeouts.connect=5000 # Bucket connections timeout in milliseconds. -spring.couchbase.env.timeouts.key-value=2500 # Blocking operations performed on a specific key timeout in milliseconds. -spring.couchbase.env.timeouts.query=7500 # N1QL query operations timeout in milliseconds. -spring.couchbase.env.timeouts.socket-connect=1000 # Socket connect connections timeout in milliseconds. -spring.couchbase.env.timeouts.view=7500 # Regular and geospatial view operations timeout in milliseconds. +spring.couchbase.env.timeouts.connect=5000ms # Bucket connections timeouts. +spring.couchbase.env.timeouts.key-value=2500ms # Blocking operations performed on a specific key timeout. +spring.couchbase.env.timeouts.query=7500ms # N1QL query operations timeout. +spring.couchbase.env.timeouts.socket-connect=1000ms # Socket connect connections timeout. +spring.couchbase.env.timeouts.view=7500ms # Regular and geospatial view operations timeout. # DAO (PersistenceExceptionTranslationAutoConfiguration) -spring.dao.exceptiontranslation.enabled=true # Enable the PersistenceExceptionTranslationPostProcessor. +spring.dao.exceptiontranslation.enabled=true # Whether to enable the PersistenceExceptionTranslationPostProcessor. # CASSANDRA (CassandraProperties) spring.data.cassandra.cluster-name= # Name of the Cassandra cluster. spring.data.cassandra.compression=none # Compression supported by the Cassandra binary protocol. -spring.data.cassandra.connect-timeout-millis= # Socket option: connection time out. +spring.data.cassandra.connect-timeout= # Socket option: connection time out. spring.data.cassandra.consistency-level= # Queries consistency level. -spring.data.cassandra.contact-points=localhost # Comma-separated list of cluster node addresses. +spring.data.cassandra.contact-points=localhost # Cluster node addresses. spring.data.cassandra.fetch-size= # Queries default fetch size. -spring.data.cassandra.heartbeat-interval-seconds= # Pooling option: heartbeat interval. spring.data.cassandra.keyspace-name= # Keyspace name to use. spring.data.cassandra.load-balancing-policy= # Class name of the load balancing policy. -spring.data.cassandra.max-requests-per-connection.*= # Pooling option: max requests per connection. -spring.data.cassandra.max-queue-size= # Pooling option: max queue size. spring.data.cassandra.port= # Port of the Cassandra server. spring.data.cassandra.password= # Login password of the server. -spring.data.cassandra.pool.heartbeat-interval=30 # Heartbeat interval (in seconds) after which a message is sent on an idle connection to make sure it's still alive. -spring.data.cassandra.pool.idle-timeout=120 # Idle timeout (in seconds) before an idle connection is removed. -spring.data.cassandra.pool.max-queue-size=256 # Maximum number of requests that get enqueued if no connection is available. -spring.data.cassandra.pool.pool-timeout=5000 # Pool timeout (in milliseconds) when trying to acquire a connection from a host's pool. -spring.data.cassandra.reactive-repositories.enabled=true # Enable Cassandra reactive repositories. -spring.data.cassandra.read-timeout-millis= # Socket option: read time out. +spring.data.cassandra.pool.heartbeat-interval=30s # Heartbeat interval after which a message is sent on an idle connection to make sure it's still alive. If a duration suffix is not specified, seconds will be used. +spring.data.cassandra.pool.idle-timeout=120s # Idle timeout before an idle connection is removed. If a duration suffix is not specified, seconds will be used. +spring.data.cassandra.pool.max-queue-size=256 # Maximum number of requests that get queued if no connection is available. +spring.data.cassandra.pool.pool-timeout=5000ms # Pool timeout when trying to acquire a connection from a host's pool. +spring.data.cassandra.read-timeout= # Socket option: read time out. spring.data.cassandra.reconnection-policy= # Reconnection policy class. -spring.data.cassandra.repositories.enabled= # Enable Cassandra repositories. +spring.data.cassandra.repositories.type=auto # Type of Cassandra repositories to enable. spring.data.cassandra.retry-policy= # Class name of the retry policy. spring.data.cassandra.serial-consistency-level= # Queries serial consistency level. spring.data.cassandra.schema-action=none # Schema action to take at startup. @@ -603,143 +605,148 @@ spring.data.cassandra.username= # Login user of the server. # DATA COUCHBASE (CouchbaseDataProperties) spring.data.couchbase.auto-index=false # Automatically create views and indexes. spring.data.couchbase.consistency=read-your-own-writes # Consistency to apply by default on generated queries. -spring.data.couchbase.repositories.enabled=true # Enable Couchbase repositories. +spring.data.couchbase.repositories.type=auto # Type of Couchbase repositories to enable. # ELASTICSEARCH (ElasticsearchProperties) spring.data.elasticsearch.cluster-name=elasticsearch # Elasticsearch cluster name. spring.data.elasticsearch.cluster-nodes= # Comma-separated list of cluster node addresses. spring.data.elasticsearch.properties.*= # Additional properties used to configure the client. -spring.data.elasticsearch.repositories.enabled=true # Enable Elasticsearch repositories. +spring.data.elasticsearch.repositories.enabled=true # Whether to enable Elasticsearch repositories. # DATA LDAP -spring.data.ldap.repositories.enabled=true # Enable LDAP repositories. +spring.data.ldap.repositories.enabled=true # Whether to enable LDAP repositories. # MONGODB (MongoProperties) spring.data.mongodb.authentication-database= # Authentication database name. -spring.data.mongodb.database=test # Database name. +spring.data.mongodb.database= # Database name. spring.data.mongodb.field-naming-strategy= # Fully qualified name of the FieldNamingStrategy to use. spring.data.mongodb.grid-fs-database= # GridFS database name. -spring.data.mongodb.host=localhost # Mongo server host. Cannot be set with uri. -spring.data.mongodb.password= # Login password of the mongo server. Cannot be set with uri. -spring.data.mongodb.port=27017 # Mongo server port. Cannot be set with uri. -spring.data.mongodb.reactive-repositories.enabled=true # Enable Mongo reactive repositories. -spring.data.mongodb.repositories.enabled=true # Enable Mongo repositories. +spring.data.mongodb.host= # Mongo server host. Cannot be set with URI. +spring.data.mongodb.password= # Login password of the mongo server. Cannot be set with URI. +spring.data.mongodb.port= # Mongo server port. Cannot be set with URI. +spring.data.mongodb.repositories.type=auto # Type of Mongo repositories to enable. spring.data.mongodb.uri=mongodb://localhost/test # Mongo database URI. Cannot be set with host, port and credentials. -spring.data.mongodb.username= # Login user of the mongo server. Cannot be set with uri. +spring.data.mongodb.username= # Login user of the mongo server. Cannot be set with URI. # DATA REDIS -spring.data.redis.repositories.enabled=true # Enable Redis repositories. +spring.data.redis.repositories.enabled=true # Whether to enable Redis repositories. # NEO4J (Neo4jProperties) spring.data.neo4j.auto-index=none # Auto index mode. -spring.data.neo4j.embedded.enabled=true # Enable embedded mode if the embedded driver is available. -spring.data.neo4j.open-in-view=false # Register OpenSessionInViewInterceptor. Binds a Neo4j Session to the thread for the entire processing of the request. +spring.data.neo4j.embedded.enabled=true # Whether to enable embedded mode if the embedded driver is available. +spring.data.neo4j.open-in-view=true # Register OpenSessionInViewInterceptor. Binds a Neo4j Session to the thread for the entire processing of the request. spring.data.neo4j.password= # Login password of the server. -spring.data.neo4j.repositories.enabled=true # Enable Neo4j repositories. +spring.data.neo4j.repositories.enabled=true # Whether to enable Neo4j repositories. spring.data.neo4j.uri= # URI used by the driver. Auto-detected by default. spring.data.neo4j.username= # Login user of the server. # DATA REST (RepositoryRestProperties) spring.data.rest.base-path= # Base path to be used by Spring Data REST to expose repository resources. +spring.data.rest.default-media-type= # Content type to use as a default when none is specified. spring.data.rest.default-page-size= # Default size of pages. spring.data.rest.detection-strategy=default # Strategy to use to determine which repositories get exposed. -spring.data.rest.enable-enum-translation= # Enable enum value translation via the Spring Data REST default resource bundle. +spring.data.rest.enable-enum-translation= # Whether to enable enum value translation through the Spring Data REST default resource bundle. spring.data.rest.limit-param-name= # Name of the URL query string parameter that indicates how many results to return at once. spring.data.rest.max-page-size= # Maximum size of pages. spring.data.rest.page-param-name= # Name of the URL query string parameter that indicates what page to return. -spring.data.rest.return-body-on-create= # Return a response body after creating an entity. -spring.data.rest.return-body-on-update= # Return a response body after updating an entity. +spring.data.rest.return-body-on-create= # Whether to return a response body after creating an entity. +spring.data.rest.return-body-on-update= # Whether to return a response body after updating an entity. spring.data.rest.sort-param-name= # Name of the URL query string parameter that indicates what direction to sort results. # SOLR (SolrProperties) spring.data.solr.host=http://127.0.0.1:8983/solr # Solr host. Ignored if "zk-host" is set. -spring.data.solr.repositories.enabled=true # Enable Solr repositories. +spring.data.solr.repositories.enabled=true # Whether to enable Solr repositories. spring.data.solr.zk-host= # ZooKeeper host address in the form HOST:PORT. # DATA WEB (SpringDataWebProperties) spring.data.web.pageable.default-page-size=20 # Default page size. +spring.data.web.pageable.max-page-size=2000 # Maximum page size to be accepted. +spring.data.web.pageable.one-indexed-parameters=false # Whether to expose and assume 1-based page number indexes. spring.data.web.pageable.page-parameter=page # Page index parameter name. +spring.data.web.pageable.prefix= # General prefix to be prepended to the page number and page size parameters. +spring.data.web.pageable.qualifier-delimiter=_ # Delimiter to be used between the qualifier and the actual page number and size properties. spring.data.web.pageable.size-parameter=size # Page size parameter name. spring.data.web.sort.sort-parameter=sort # Sort parameter name. # DATASOURCE (DataSourceAutoConfiguration & DataSourceProperties) -spring.datasource.continue-on-error=false # Do not stop if an error occurs while initializing the database. +spring.datasource.continue-on-error=false # Whether to stop if an error occurs while initializing the database. spring.datasource.data= # Data (DML) script resource references. -spring.datasource.data-username= # User of the database to execute DML scripts (if different). +spring.datasource.data-username= # Username of the database to execute DML scripts (if different). spring.datasource.data-password= # Password of the database to execute DML scripts (if different). spring.datasource.dbcp2.*= # Commons DBCP2 specific settings spring.datasource.driver-class-name= # Fully qualified name of the JDBC driver. Auto-detected based on the URL by default. -spring.datasource.generate-unique-name=false # Generate a random datasource name. +spring.datasource.generate-unique-name=false # Whether to generate a random datasource name. spring.datasource.hikari.*= # Hikari specific settings -spring.datasource.initialize=true # Populate the database using 'data.sql'. -spring.datasource.jmx-enabled=false # Enable JMX support (if provided by the underlying pool). +spring.datasource.initialization-mode=embedded # Initialize the datasource with available DDL and DML scripts. +spring.datasource.jmx-enabled=false # Whether to enable JMX support (if provided by the underlying pool). spring.datasource.jndi-name= # JNDI location of the datasource. Class, url, username & password are ignored when set. -spring.datasource.name=testdb # Name of the datasource. +spring.datasource.name= # Name of the datasource. Default to "testdb" when using an embedded database. spring.datasource.password= # Login password of the database. -spring.datasource.platform=all # Platform to use in the schema resource (schema-${platform}.sql). +spring.datasource.platform=all # Platform to use in the DDL or DML scripts (such as schema-${platform}.sql or data-${platform}.sql). spring.datasource.schema= # Schema (DDL) script resource references. -spring.datasource.schema-username= # User of the database to execute DDL scripts (if different). +spring.datasource.schema-username= # Username of the database to execute DDL scripts (if different). spring.datasource.schema-password= # Password of the database to execute DDL scripts (if different). spring.datasource.separator=; # Statement separator in SQL initialization scripts. spring.datasource.sql-script-encoding= # SQL scripts encoding. spring.datasource.tomcat.*= # Tomcat datasource specific settings spring.datasource.type= # Fully qualified name of the connection pool implementation to use. By default, it is auto-detected from the classpath. -spring.datasource.url= # JDBC url of the database. -spring.datasource.username= # Login user of the database. +spring.datasource.url= # JDBC URL of the database. +spring.datasource.username= # Login username of the database. spring.datasource.xa.data-source-class-name= # XA datasource fully qualified name. spring.datasource.xa.properties= # Properties to pass to the XA data source. # JEST (Elasticsearch HTTP client) (JestProperties) -spring.elasticsearch.jest.connection-timeout=3000 # Connection timeout in milliseconds. -spring.elasticsearch.jest.multi-threaded=true # Enable connection requests from multiple execution threads. +spring.elasticsearch.jest.connection-timeout=3s # Connection timeout. +spring.elasticsearch.jest.multi-threaded=true # Whether to enable connection requests from multiple execution threads. spring.elasticsearch.jest.password= # Login password. spring.elasticsearch.jest.proxy.host= # Proxy host the HTTP client should use. spring.elasticsearch.jest.proxy.port= # Proxy port the HTTP client should use. -spring.elasticsearch.jest.read-timeout=3000 # Read timeout in milliseconds. +spring.elasticsearch.jest.read-timeout=3s # Read timeout. spring.elasticsearch.jest.uris=http://localhost:9200 # Comma-separated list of the Elasticsearch instances to use. -spring.elasticsearch.jest.username= # Login user. +spring.elasticsearch.jest.username= # Login username. # H2 Web Console (H2ConsoleProperties) -spring.h2.console.enabled=false # Enable the console. -spring.h2.console.path=/h2-console # Path at which the console will be available. -spring.h2.console.settings.trace=false # Enable trace output. -spring.h2.console.settings.web-allow-others=false # Enable remote access. +spring.h2.console.enabled=false # Whether to enable the console. +spring.h2.console.path=/h2-console # Path at which the console is available. +spring.h2.console.settings.trace=false # Whether to enable trace output. +spring.h2.console.settings.web-allow-others=false # Whether to enable remote access. # InfluxDB (InfluxDbProperties) spring.influx.password= # Login password. -spring.influx.url= # Url of the InfluxDB instance to connect to. +spring.influx.url= # URL of the InfluxDB instance to which to connect. spring.influx.user= # Login user. -# JOOQ (JooqAutoConfiguration) -spring.jooq.sql-dialect= # Sql dialect to use, auto-detected by default. +# JOOQ (JooqProperties) +spring.jooq.sql-dialect= # SQL dialect to use. Auto-detected by default. # JDBC (JdbcProperties) spring.jdbc.template.fetch-size=-1 # Number of rows that should be fetched from the database when more rows are needed. spring.jdbc.template.max-rows=-1 # Maximum number of rows. -spring.jdbc.template.query-timeout=-1 # Query timeout in seconds. +spring.jdbc.template.query-timeout= # Query timeout. Default is to use the JDBC driver's default configuration. If a duration suffix is not specified, seconds will be used. # JPA (JpaBaseConfiguration, HibernateJpaAutoConfiguration) -spring.data.jpa.repositories.enabled=true # Enable JPA repositories. +spring.data.jpa.repositories.enabled=true # Whether to enable JPA repositories. spring.jpa.database= # Target database to operate on, auto-detected by default. Can be alternatively set using the "databasePlatform" property. spring.jpa.database-platform= # Name of the target database to operate on, auto-detected by default. Can be alternatively set using the "Database" enum. -spring.jpa.generate-ddl=false # Initialize the schema on startup. -spring.jpa.hibernate.ddl-auto= # DDL mode. This is actually a shortcut for the "hibernate.hbm2ddl.auto" property. Default to "create-drop" when using an embedded database, "none" otherwise. -spring.jpa.hibernate.naming.implicit-strategy= # Hibernate 5 implicit naming strategy fully qualified name. -spring.jpa.hibernate.naming.physical-strategy= # Hibernate 5 physical naming strategy fully qualified name. -spring.jpa.hibernate.use-new-id-generator-mappings= # Use Hibernate's newer IdentifierGenerator for AUTO, TABLE and SEQUENCE. +spring.jpa.generate-ddl=false # Whether to initialize the schema on startup. +spring.jpa.hibernate.ddl-auto= # DDL mode. This is actually a shortcut for the "hibernate.hbm2ddl.auto" property. Defaults to "create-drop" when using an embedded database and no schema manager was detected. Otherwise, defaults to "none". +spring.jpa.hibernate.naming.implicit-strategy= # Fully qualified name of the implicit naming strategy. +spring.jpa.hibernate.naming.physical-strategy= # Fully qualified name of the physical naming strategy. +spring.jpa.hibernate.use-new-id-generator-mappings= # Whether to use Hibernate's newer IdentifierGenerator for AUTO, TABLE and SEQUENCE. +spring.jpa.mapping-resources= # Mapping resources (equivalent to "mapping-file" entries in persistence.xml). spring.jpa.open-in-view=true # Register OpenEntityManagerInViewInterceptor. Binds a JPA EntityManager to the thread for the entire processing of the request. spring.jpa.properties.*= # Additional native properties to set on the JPA provider. -spring.jpa.show-sql=false # Enable logging of SQL statements. +spring.jpa.show-sql=false # Whether to enable logging of SQL statements. # JTA (JtaAutoConfiguration) -spring.jta.enabled=true # Enable JTA support. +spring.jta.enabled=true # Whether to enable JTA support. spring.jta.log-dir= # Transaction logs directory. spring.jta.transaction-manager-id= # Transaction manager unique identifier. # ATOMIKOS (AtomikosProperties) spring.jta.atomikos.connectionfactory.borrow-connection-timeout=30 # Timeout, in seconds, for borrowing connections from the pool. -spring.jta.atomikos.connectionfactory.ignore-session-transacted-flag=true # Whether or not to ignore the transacted flag when creating session. -spring.jta.atomikos.connectionfactory.local-transaction-mode=false # Whether or not local transactions are desired. +spring.jta.atomikos.connectionfactory.ignore-session-transacted-flag=true # Whether to ignore the transacted flag when creating session. +spring.jta.atomikos.connectionfactory.local-transaction-mode=false # Whether local transactions are desired. spring.jta.atomikos.connectionfactory.maintenance-interval=60 # The time, in seconds, between runs of the pool's maintenance thread. spring.jta.atomikos.connectionfactory.max-idle-time=60 # The time, in seconds, after which connections are cleaned up from the pool. spring.jta.atomikos.connectionfactory.max-lifetime=0 # The time, in seconds, that a connection can be pooled for before being destroyed. 0 denotes no limit. @@ -747,7 +754,10 @@ spring.jta.atomikos.connectionfactory.max-pool-size=1 # The maximum size of the spring.jta.atomikos.connectionfactory.min-pool-size=1 # The minimum size of the pool. spring.jta.atomikos.connectionfactory.reap-timeout=0 # The reap timeout, in seconds, for borrowed connections. 0 denotes no limit. spring.jta.atomikos.connectionfactory.unique-resource-name=jmsConnectionFactory # The unique name used to identify the resource during recovery. +spring.jta.atomikos.connectionfactory.xa-connection-factory-class-name= # Vendor-specific implementation of XAConnectionFactory. +spring.jta.atomikos.connectionfactory.xa-properties= # Vendor-specific XA properties. spring.jta.atomikos.datasource.borrow-connection-timeout=30 # Timeout, in seconds, for borrowing connections from the pool. +spring.jta.atomikos.datasource.concurrent-connection-validation= # Whether to use concurrent connection validation. spring.jta.atomikos.datasource.default-isolation-level= # Default isolation level of connections provided by the pool. spring.jta.atomikos.datasource.login-timeout= # Timeout, in seconds, for establishing a database connection. spring.jta.atomikos.datasource.maintenance-interval=60 # The time, in seconds, between runs of the pool's maintenance thread. @@ -758,54 +768,65 @@ spring.jta.atomikos.datasource.min-pool-size=1 # The minimum size of the pool. spring.jta.atomikos.datasource.reap-timeout=0 # The reap timeout, in seconds, for borrowed connections. 0 denotes no limit. spring.jta.atomikos.datasource.test-query= # SQL query or statement used to validate a connection before returning it. spring.jta.atomikos.datasource.unique-resource-name=dataSource # The unique name used to identify the resource during recovery. -spring.jta.atomikos.properties.allow-sub-transactions=true # Specify if sub-transactions are allowed. -spring.jta.atomikos.properties.checkpoint-interval=500 # Interval between checkpoints. -spring.jta.atomikos.properties.default-jta-timeout=10000 # Default timeout for JTA transactions. -spring.jta.atomikos.properties.enable-logging=true # Enable disk logging. -spring.jta.atomikos.properties.force-shutdown-on-vm-exit=false # Specify if a VM shutdown should trigger forced shutdown of the transaction core. +spring.jta.atomikos.datasource.xa-data-source-class-name= # Vendor-specific implementation of XAConnectionFactory. +spring.jta.atomikos.datasource.xa-properties= # Vendor-specific XA properties. +spring.jta.atomikos.properties.allow-sub-transactions=true # Specify whether sub-transactions are allowed. +spring.jta.atomikos.properties.checkpoint-interval=500 # Interval between checkpoints, expressed as the number of log writes between two checkpoint. +spring.jta.atomikos.properties.default-jta-timeout=10000ms # Default timeout for JTA transactions. +spring.jta.atomikos.properties.default-max-wait-time-on-shutdown=9223372036854775807 # How long should normal shutdown (no-force) wait for transactions to complete. +spring.jta.atomikos.properties.enable-logging=true # Whether to enable disk logging. +spring.jta.atomikos.properties.force-shutdown-on-vm-exit=false # Whether a VM shutdown should trigger forced shutdown of the transaction core. spring.jta.atomikos.properties.log-base-dir= # Directory in which the log files should be stored. spring.jta.atomikos.properties.log-base-name=tmlog # Transactions log file base name. spring.jta.atomikos.properties.max-actives=50 # Maximum number of active transactions. -spring.jta.atomikos.properties.max-timeout=300000 # Maximum timeout (in milliseconds) that can be allowed for transactions. -spring.jta.atomikos.properties.recovery.delay=10000 # Delay between two recovery scans. -spring.jta.atomikos.properties.recovery.forget-orphaned-log-entries-delay=86400000 # Delay after which recovery can cleanup pending ('orphaned') log entries. -spring.jta.atomikos.properties.recovery.max-retries=5 # Number of retries attempts to commit the transaction before throwing an exception. -spring.jta.atomikos.properties.recovery.retry-interval=10000 # Delay between retry attempts. -spring.jta.atomikos.properties.serial-jta-transactions=true # Specify if sub-transactions should be joined when possible. +spring.jta.atomikos.properties.max-timeout=300000ms # Maximum timeout that can be allowed for transactions. +spring.jta.atomikos.properties.recovery.delay=10000ms # Delay between two recovery scans. +spring.jta.atomikos.properties.recovery.forget-orphaned-log-entries-delay=86400000ms # Delay after which recovery can cleanup pending ('orphaned') log entries. +spring.jta.atomikos.properties.recovery.max-retries=5 # Number of retry attempts to commit the transaction before throwing an exception. +spring.jta.atomikos.properties.recovery.retry-interval=10000ms # Delay between retry attempts. +spring.jta.atomikos.properties.serial-jta-transactions=true # Whether sub-transactions should be joined when possible. spring.jta.atomikos.properties.service= # Transaction manager implementation that should be started. -spring.jta.atomikos.properties.threaded-two-phase-commit=false # Use different (and concurrent) threads for two-phase commit on the participating resources. -spring.jta.atomikos.properties.transaction-manager-unique-name= # Transaction manager's unique name. +spring.jta.atomikos.properties.threaded-two-phase-commit=false # Whether to use different (and concurrent) threads for two-phase commit on the participating resources. +spring.jta.atomikos.properties.transaction-manager-unique-name= # The transaction manager's unique name. # BITRONIX spring.jta.bitronix.connectionfactory.acquire-increment=1 # Number of connections to create when growing the pool. spring.jta.bitronix.connectionfactory.acquisition-interval=1 # Time, in seconds, to wait before trying to acquire a connection again after an invalid connection was acquired. spring.jta.bitronix.connectionfactory.acquisition-timeout=30 # Timeout, in seconds, for acquiring connections from the pool. -spring.jta.bitronix.connectionfactory.allow-local-transactions=true # Whether or not the transaction manager should allow mixing XA and non-XA transactions. -spring.jta.bitronix.connectionfactory.apply-transaction-timeout=false # Whether or not the transaction timeout should be set on the XAResource when it is enlisted. -spring.jta.bitronix.connectionfactory.automatic-enlisting-enabled=true # Whether or not resources should be enlisted and delisted automatically. -spring.jta.bitronix.connectionfactory.cache-producers-consumers=true # Whether or not produces and consumers should be cached. -spring.jta.bitronix.connectionfactory.defer-connection-release=true # Whether or not the provider can run many transactions on the same connection and supports transaction interleaving. -spring.jta.bitronix.connectionfactory.ignore-recovery-failures=false # Whether or not recovery failures should be ignored. +spring.jta.bitronix.connectionfactory.allow-local-transactions=true # Whether the transaction manager should allow mixing XA and non-XA transactions. +spring.jta.bitronix.connectionfactory.apply-transaction-timeout=false # Whether the transaction timeout should be set on the XAResource when it is enlisted. +spring.jta.bitronix.connectionfactory.automatic-enlisting-enabled=true # Whether resources should be enlisted and delisted automatically. +spring.jta.bitronix.connectionfactory.cache-producers-consumers=true # Whether producers and consumers should be cached. +spring.jta.bitronix.connectionfactory.class-name= # Underlying implementation class name of the XA resource. +spring.jta.bitronix.connectionfactory.defer-connection-release=true # Whether the provider can run many transactions on the same connection and supports transaction interleaving. +spring.jta.bitronix.connectionfactory.disabled= # Whether this resource is disabled, meaning it's temporarily forbidden to acquire a connection from its pool. +spring.jta.bitronix.connectionfactory.driver-properties= # Properties that should be set on the underlying implementation. +spring.jta.bitronix.connectionfactory.failed= # Mark this resource producer as failed. +spring.jta.bitronix.connectionfactory.ignore-recovery-failures=false # Whether recovery failures should be ignored. spring.jta.bitronix.connectionfactory.max-idle-time=60 # The time, in seconds, after which connections are cleaned up from the pool. spring.jta.bitronix.connectionfactory.max-pool-size=10 # The maximum size of the pool. 0 denotes no limit. spring.jta.bitronix.connectionfactory.min-pool-size=0 # The minimum size of the pool. spring.jta.bitronix.connectionfactory.password= # The password to use to connect to the JMS provider. -spring.jta.bitronix.connectionfactory.share-transaction-connections=false # Whether or not connections in the ACCESSIBLE state can be shared within the context of a transaction. -spring.jta.bitronix.connectionfactory.test-connections=true # Whether or not connections should be tested when acquired from the pool. +spring.jta.bitronix.connectionfactory.share-transaction-connections=false # Whether connections in the ACCESSIBLE state can be shared within the context of a transaction. +spring.jta.bitronix.connectionfactory.test-connections=true # Whether connections should be tested when acquired from the pool. spring.jta.bitronix.connectionfactory.two-pc-ordering-position=1 # The position that this resource should take during two-phase commit (always first is Integer.MIN_VALUE, always last is Integer.MAX_VALUE). spring.jta.bitronix.connectionfactory.unique-name=jmsConnectionFactory # The unique name used to identify the resource during recovery. -spring.jta.bitronix.connectionfactory.use-tm-join=true Whether or not TMJOIN should be used when starting XAResources. +spring.jta.bitronix.connectionfactory.use-tm-join=true # Whether TMJOIN should be used when starting XAResources. spring.jta.bitronix.connectionfactory.user= # The user to use to connect to the JMS provider. spring.jta.bitronix.datasource.acquire-increment=1 # Number of connections to create when growing the pool. spring.jta.bitronix.datasource.acquisition-interval=1 # Time, in seconds, to wait before trying to acquire a connection again after an invalid connection was acquired. spring.jta.bitronix.datasource.acquisition-timeout=30 # Timeout, in seconds, for acquiring connections from the pool. -spring.jta.bitronix.datasource.allow-local-transactions=true # Whether or not the transaction manager should allow mixing XA and non-XA transactions. -spring.jta.bitronix.datasource.apply-transaction-timeout=false # Whether or not the transaction timeout should be set on the XAResource when it is enlisted. -spring.jta.bitronix.datasource.automatic-enlisting-enabled=true # Whether or not resources should be enlisted and delisted automatically. +spring.jta.bitronix.datasource.allow-local-transactions=true # Whether the transaction manager should allow mixing XA and non-XA transactions. +spring.jta.bitronix.datasource.apply-transaction-timeout=false # Whether the transaction timeout should be set on the XAResource when it is enlisted. +spring.jta.bitronix.datasource.automatic-enlisting-enabled=true # Whether resources should be enlisted and delisted automatically. +spring.jta.bitronix.datasource.class-name= # Underlying implementation class name of the XA resource. spring.jta.bitronix.datasource.cursor-holdability= # The default cursor holdability for connections. -spring.jta.bitronix.datasource.defer-connection-release=true # Whether or not the database can run many transactions on the same connection and supports transaction interleaving. -spring.jta.bitronix.datasource.enable-jdbc4-connection-test= # Whether or not Connection.isValid() is called when acquiring a connection from the pool. -spring.jta.bitronix.datasource.ignore-recovery-failures=false # Whether or not recovery failures should be ignored. +spring.jta.bitronix.datasource.defer-connection-release=true # Whether the database can run many transactions on the same connection and supports transaction interleaving. +spring.jta.bitronix.datasource.disabled= # Whether this resource is disabled, meaning it's temporarily forbidden to acquire a connection from its pool. +spring.jta.bitronix.datasource.driver-properties= # Properties that should be set on the underlying implementation. +spring.jta.bitronix.datasource.enable-jdbc4-connection-test= # Whether Connection.isValid() is called when acquiring a connection from the pool. +spring.jta.bitronix.datasource.failed= # Mark this resource producer as failed. +spring.jta.bitronix.datasource.ignore-recovery-failures=false # Whether recovery failures should be ignored. spring.jta.bitronix.datasource.isolation-level= # The default isolation level for connections. spring.jta.bitronix.datasource.local-auto-commit= # The default auto-commit mode for local transactions. spring.jta.bitronix.datasource.login-timeout= # Timeout, in seconds, for establishing a database connection. @@ -813,81 +834,81 @@ spring.jta.bitronix.datasource.max-idle-time=60 # The time, in seconds, after wh spring.jta.bitronix.datasource.max-pool-size=10 # The maximum size of the pool. 0 denotes no limit. spring.jta.bitronix.datasource.min-pool-size=0 # The minimum size of the pool. spring.jta.bitronix.datasource.prepared-statement-cache-size=0 # The target size of the prepared statement cache. 0 disables the cache. -spring.jta.bitronix.datasource.share-transaction-connections=false # Whether or not connections in the ACCESSIBLE state can be shared within the context of a transaction. +spring.jta.bitronix.datasource.share-transaction-connections=false # Whether connections in the ACCESSIBLE state can be shared within the context of a transaction. spring.jta.bitronix.datasource.test-query= # SQL query or statement used to validate a connection before returning it. -spring.jta.bitronix.datasource.two-pc-ordering-position=1 # The position that this resource should take during two-phase commit (always first is Integer.MIN_VALUE, always last is Integer.MAX_VALUE). +spring.jta.bitronix.datasource.two-pc-ordering-position=1 # The position that this resource should take during two-phase commit (always first is Integer.MIN_VALUE, and always last is Integer.MAX_VALUE). spring.jta.bitronix.datasource.unique-name=dataSource # The unique name used to identify the resource during recovery. -spring.jta.bitronix.datasource.use-tm-join=true Whether or not TMJOIN should be used when starting XAResources. -spring.jta.bitronix.properties.allow-multiple-lrc=false # Allow multiple LRC resources to be enlisted into the same transaction. -spring.jta.bitronix.properties.asynchronous2-pc=false # Enable asynchronously execution of two phase commit. +spring.jta.bitronix.datasource.use-tm-join=true # Whether TMJOIN should be used when starting XAResources. +spring.jta.bitronix.properties.allow-multiple-lrc=false # Whether to allow multiple LRC resources to be enlisted into the same transaction. +spring.jta.bitronix.properties.asynchronous2-pc=false # Whether to enable asynchronously execution of two phase commit. spring.jta.bitronix.properties.background-recovery-interval-seconds=60 # Interval in seconds at which to run the recovery process in the background. -spring.jta.bitronix.properties.current-node-only-recovery=true # Recover only the current node. -spring.jta.bitronix.properties.debug-zero-resource-transaction=false # Log the creation and commit call stacks of transactions executed without a single enlisted resource. -spring.jta.bitronix.properties.default-transaction-timeout=60 # Default transaction timeout in seconds. -spring.jta.bitronix.properties.disable-jmx=false # Enable JMX support. +spring.jta.bitronix.properties.current-node-only-recovery=true # Whether to recover only the current node. +spring.jta.bitronix.properties.debug-zero-resource-transaction=false # Whether to log the creation and commit call stacks of transactions executed without a single enlisted resource. +spring.jta.bitronix.properties.default-transaction-timeout=60 # Default transaction timeout, in seconds. +spring.jta.bitronix.properties.disable-jmx=false # Whether to enable JMX support. spring.jta.bitronix.properties.exception-analyzer= # Set the fully qualified name of the exception analyzer implementation to use. -spring.jta.bitronix.properties.filter-log-status=false # Enable filtering of logs so that only mandatory logs are written. -spring.jta.bitronix.properties.force-batching-enabled=true # Set if disk forces are batched. -spring.jta.bitronix.properties.forced-write-enabled=true # Set if logs are forced to disk. -spring.jta.bitronix.properties.graceful-shutdown-interval=60 # Maximum amount of seconds the TM will wait for transactions to get done before aborting them at shutdown time. +spring.jta.bitronix.properties.filter-log-status=false # Whether to enable filtering of logs so that only mandatory logs are written. +spring.jta.bitronix.properties.force-batching-enabled=true # Whether disk forces are batched. +spring.jta.bitronix.properties.forced-write-enabled=true # Whether logs are forced to disk. +spring.jta.bitronix.properties.graceful-shutdown-interval=60 # Maximum amount of seconds the TM waits for transactions to get done before aborting them at shutdown time. spring.jta.bitronix.properties.jndi-transaction-synchronization-registry-name= # JNDI name of the TransactionSynchronizationRegistry. spring.jta.bitronix.properties.jndi-user-transaction-name= # JNDI name of the UserTransaction. -spring.jta.bitronix.properties.journal=disk # Name of the journal. Can be 'disk', 'null' or a class name. +spring.jta.bitronix.properties.journal=disk # Name of the journal. Can be 'disk', 'null', or a class name. spring.jta.bitronix.properties.log-part1-filename=btm1.tlog # Name of the first fragment of the journal. spring.jta.bitronix.properties.log-part2-filename=btm2.tlog # Name of the second fragment of the journal. spring.jta.bitronix.properties.max-log-size-in-mb=2 # Maximum size in megabytes of the journal fragments. spring.jta.bitronix.properties.resource-configuration-filename= # ResourceLoader configuration file name. -spring.jta.bitronix.properties.server-id= # ASCII ID that must uniquely identify this TM instance. Default to the machine's IP address. +spring.jta.bitronix.properties.server-id= # ASCII ID that must uniquely identify this TM instance. Defaults to the machine's IP address. spring.jta.bitronix.properties.skip-corrupted-logs=false # Skip corrupted transactions log entries. -spring.jta.bitronix.properties.warn-about-zero-resource-transaction=true # Log a warning for transactions executed without a single enlisted resource. +spring.jta.bitronix.properties.warn-about-zero-resource-transaction=true # Whether to log a warning for transactions executed without a single enlisted resource. # NARAYANA (NarayanaProperties) -spring.jta.narayana.default-timeout=60 # Transaction timeout in seconds. +spring.jta.narayana.default-timeout=60s # Transaction timeout. If a duration suffix is not specified, seconds will be used. spring.jta.narayana.expiry-scanners=com.arjuna.ats.internal.arjuna.recovery.ExpiredTransactionStatusManagerScanner # Comma-separated list of expiry scanners. spring.jta.narayana.log-dir= # Transaction object store directory. -spring.jta.narayana.one-phase-commit=true # Enable one phase commit optimisation. -spring.jta.narayana.periodic-recovery-period=120 # Interval in which periodic recovery scans are performed in seconds. -spring.jta.narayana.recovery-backoff-period=10 # Back off period between first and second phases of the recovery scan in seconds. -spring.jta.narayana.recovery-db-pass= # Database password to be used by recovery manager. -spring.jta.narayana.recovery-db-user= # Database username to be used by recovery manager. -spring.jta.narayana.recovery-jms-pass= # JMS password to be used by recovery manager. -spring.jta.narayana.recovery-jms-user= # JMS username to be used by recovery manager. +spring.jta.narayana.one-phase-commit=true # Whether to enable one phase commit optimization. +spring.jta.narayana.periodic-recovery-period=120s # Interval in which periodic recovery scans are performed. If a duration suffix is not specified, seconds will be used. +spring.jta.narayana.recovery-backoff-period=10s # Back off period between first and second phases of the recovery scan. If a duration suffix is not specified, seconds will be used. +spring.jta.narayana.recovery-db-pass= # Database password to be used by the recovery manager. +spring.jta.narayana.recovery-db-user= # Database username to be used by the recovery manager. +spring.jta.narayana.recovery-jms-pass= # JMS password to be used by the recovery manager. +spring.jta.narayana.recovery-jms-user= # JMS username to be used by the recovery manager. spring.jta.narayana.recovery-modules= # Comma-separated list of recovery modules. spring.jta.narayana.transaction-manager-id=1 # Unique transaction manager id. spring.jta.narayana.xa-resource-orphan-filters= # Comma-separated list of orphan filters. # EMBEDDED MONGODB (EmbeddedMongoProperties) -spring.mongodb.embedded.features=SYNC_DELAY # Comma-separated list of features to enable. +spring.mongodb.embedded.features=sync_delay # Comma-separated list of features to enable. spring.mongodb.embedded.storage.database-dir= # Directory used for data storage. -spring.mongodb.embedded.storage.oplog-size= # Maximum size of the oplog in megabytes. +spring.mongodb.embedded.storage.oplog-size= # Maximum size of the oplog, in megabytes. spring.mongodb.embedded.storage.repl-set-name= # Name of the replica set. -spring.mongodb.embedded.version=2.6.10 # Version of Mongo to use. +spring.mongodb.embedded.version=3.2.2 # Version of Mongo to use. # REDIS (RedisProperties) spring.redis.cluster.max-redirects= # Maximum number of redirects to follow when executing commands across the cluster. spring.redis.cluster.nodes= # Comma-separated list of "host:port" pairs to bootstrap from. spring.redis.database=0 # Database index used by the connection factory. -spring.redis.url= # Connection URL, will override host, port and password (user will be ignored), e.g. redis://user:password@example.com:6379 +spring.redis.url= # Connection URL. Overrides host, port, and password. User is ignored. Example: redis://user:password@example.com:6379 spring.redis.host=localhost # Redis server host. -spring.redis.jedis.pool.max-active=8 # Max number of connections that can be allocated by the pool at a given time. Use a negative value for no limit. -spring.redis.jedis.pool.max-idle=8 # Max number of "idle" connections in the pool. Use a negative value to indicate an unlimited number of idle connections. -spring.redis.jedis.pool.max-wait=-1 # Maximum amount of time (in milliseconds) a connection allocation should block before throwing an exception when the pool is exhausted. Use a negative value to block indefinitely. +spring.redis.jedis.pool.max-active=8 # Maximum number of connections that can be allocated by the pool at a given time. Use a negative value for no limit. +spring.redis.jedis.pool.max-idle=8 # Maximum number of "idle" connections in the pool. Use a negative value to indicate an unlimited number of idle connections. +spring.redis.jedis.pool.max-wait=-1ms # Maximum amount of time a connection allocation should block before throwing an exception when the pool is exhausted. Use a negative value to block indefinitely. spring.redis.jedis.pool.min-idle=0 # Target for the minimum number of idle connections to maintain in the pool. This setting only has an effect if it is positive. -spring.redis.lettuce.pool.max-active=8 # Max number of connections that can be allocated by the pool at a given time. Use a negative value for no limit. -spring.redis.lettuce.pool.max-idle=8 # Max number of "idle" connections in the pool. Use a negative value to indicate an unlimited number of idle connections. -spring.redis.lettuce.pool.max-wait=-1 # Maximum amount of time (in milliseconds) a connection allocation should block before throwing an exception when the pool is exhausted. Use a negative value to block indefinitely. +spring.redis.lettuce.pool.max-active=8 # Maximum number of connections that can be allocated by the pool at a given time. Use a negative value for no limit. +spring.redis.lettuce.pool.max-idle=8 # Maximum number of "idle" connections in the pool. Use a negative value to indicate an unlimited number of idle connections. +spring.redis.lettuce.pool.max-wait=-1ms # Maximum amount of time a connection allocation should block before throwing an exception when the pool is exhausted. Use a negative value to block indefinitely. spring.redis.lettuce.pool.min-idle=0 # Target for the minimum number of idle connections to maintain in the pool. This setting only has an effect if it is positive. -spring.redis.lettuce.shutdown-timeout=100 # Shutdown timeout in milliseconds. +spring.redis.lettuce.shutdown-timeout=100ms # Shutdown timeout. spring.redis.password= # Login password of the redis server. spring.redis.port=6379 # Redis server port. -spring.redis.sentinel.master= # Name of Redis server. -spring.redis.sentinel.nodes= # Comma-separated list of host:port pairs. -spring.redis.ssl=false # Enable SSL support. -spring.redis.timeout=0 # Connection timeout in milliseconds. +spring.redis.sentinel.master= # Name of the Redis server. +spring.redis.sentinel.nodes= # Comma-separated list of "host:port" pairs. +spring.redis.ssl=false # Whether to enable SSL support. +spring.redis.timeout= # Connection timeout. # TRANSACTION (TransactionProperties) -spring.transaction.default-timeout= # Default transaction timeout in seconds. -spring.transaction.rollback-on-commit-failure= # Perform the rollback on commit failures. +spring.transaction.default-timeout= # Default transaction timeout. If a duration suffix is not specified, seconds will be used. +spring.transaction.rollback-on-commit-failure= # Whether to roll back on commit failures. @@ -896,25 +917,34 @@ spring.transaction.rollback-on-commit-failure= # Perform the rollback on commit # ---------------------------------------- # ACTIVEMQ (ActiveMQProperties) -spring.activemq.broker-url= # URL of the ActiveMQ broker. Auto-generated by default. For instance `tcp://localhost:61616` -spring.activemq.in-memory=true # Specify if the default broker URL should be in memory. Ignored if an explicit broker has been specified. +spring.activemq.broker-url= # URL of the ActiveMQ broker. Auto-generated by default. +spring.activemq.close-timeout=15s # Time to wait before considering a close complete. +spring.activemq.in-memory=true # Whether the default broker URL should be in memory. Ignored if an explicit broker has been specified. +spring.activemq.non-blocking-redelivery=false # Whether to stop message delivery before re-delivering messages from a rolled back transaction. This implies that message order is not preserved when this is enabled. spring.activemq.password= # Login password of the broker. +spring.activemq.send-timeout=0ms # Time to wait on message sends for a response. Set it to 0 to wait forever. spring.activemq.user= # Login user of the broker. -spring.activemq.packages.trust-all=false # Trust all packages. +spring.activemq.packages.trust-all= # Whether to trust all packages. spring.activemq.packages.trusted= # Comma-separated list of specific packages to trust (when not trusting all packages). -spring.activemq.pool.configuration.*= # See PooledConnectionFactory. -spring.activemq.pool.enabled=false # Whether a PooledConnectionFactory should be created instead of a regular ConnectionFactory. -spring.activemq.pool.expiry-timeout=0 # Connection expiration timeout in milliseconds. -spring.activemq.pool.idle-timeout=30000 # Connection idle timeout in milliseconds. +spring.activemq.pool.block-if-full=true # Whether to block when a connection is requested and the pool is full. Set it to false to throw a "JMSException" instead. +spring.activemq.pool.block-if-full-timeout=-1ms # Blocking period before throwing an exception if the pool is still full. +spring.activemq.pool.create-connection-on-startup=true # Whether to create a connection on startup. Can be used to warm up the pool on startup. +spring.activemq.pool.enabled=false # Whether a PooledConnectionFactory should be created, instead of a regular ConnectionFactory. +spring.activemq.pool.expiry-timeout=0ms # Connection expiration timeout. +spring.activemq.pool.idle-timeout=30s # Connection idle timeout. spring.activemq.pool.max-connections=1 # Maximum number of pooled connections. +spring.activemq.pool.maximum-active-session-per-connection=500 # Maximum number of active sessions per connection. +spring.activemq.pool.reconnect-on-exception=true # Reset the connection when a "JMSException" occurs. +spring.activemq.pool.time-between-expiration-check=-1ms # Time to sleep between runs of the idle connection eviction thread. When negative, no idle connection eviction thread runs. +spring.activemq.pool.use-anonymous-producers=true # Whether to use only one anonymous "MessageProducer" instance. Set it to false to create one "MessageProducer" every time one is required. # ARTEMIS (ArtemisProperties) spring.artemis.embedded.cluster-password= # Cluster password. Randomly generated on startup by default. spring.artemis.embedded.data-directory= # Journal file directory. Not necessary if persistence is turned off. -spring.artemis.embedded.enabled=true # Enable embedded mode if the Artemis server APIs are available. -spring.artemis.embedded.persistent=false # Enable persistent store. +spring.artemis.embedded.enabled=true # Whether to enable embedded mode if the Artemis server APIs are available. +spring.artemis.embedded.persistent=false # Whether to enable persistent store. spring.artemis.embedded.queues= # Comma-separated list of queues to create on startup. -spring.artemis.embedded.server-id= # Server id. By default, an auto-incremented counter is used. +spring.artemis.embedded.server-id= # Server ID. By default, an auto-incremented counter is used. spring.artemis.embedded.topics= # Comma-separated list of topics to create on startup. spring.artemis.host=localhost # Artemis broker host. spring.artemis.mode= # Artemis deployment mode, auto-detected by default. @@ -923,14 +953,14 @@ spring.artemis.port=61616 # Artemis broker port. spring.artemis.user= # Login user of the broker. # SPRING BATCH (BatchProperties) -spring.batch.initializer.enabled= # Create the required batch tables on startup if necessary. Enabled automatically if no custom table prefix is set or if a custom schema is configured. +spring.batch.initialize-schema=embedded # Database schema initialization mode. spring.batch.job.enabled=true # Execute all Spring Batch jobs in the context on startup. -spring.batch.job.names= # Comma-separated list of job names to execute on startup (For instance `job1,job2`). By default, all Jobs found in the context are executed. +spring.batch.job.names= # Comma-separated list of job names to execute on startup (for instance, `job1,job2`). By default, all Jobs found in the context are executed. spring.batch.schema=classpath:org/springframework/batch/core/schema-@@platform@@.sql # Path to the SQL file to use to initialize the database schema. spring.batch.table-prefix= # Table prefix for all the batch meta-data tables. # SPRING INTEGRATION (IntegrationProperties) -spring.integration.jdbc.initializer.enabled=false # Create the required integration tables on startup. +spring.integration.jdbc.initialize-schema=embedded # Database schema initialization mode. spring.integration.jdbc.schema=classpath:org/springframework/integration/jdbc/schema-@@platform@@.sql # Path to the SQL file to use to initialize the database schema. # JMS (JmsProperties) @@ -939,29 +969,38 @@ spring.jms.listener.acknowledge-mode= # Acknowledge mode of the container. By de spring.jms.listener.auto-startup=true # Start the container automatically on startup. spring.jms.listener.concurrency= # Minimum number of concurrent consumers. spring.jms.listener.max-concurrency= # Maximum number of concurrent consumers. -spring.jms.pub-sub-domain=false # Specify if the default destination type is topic. -spring.jms.template.default-destination= # Default destination to use on send/receive operations that do not have a destination parameter. -spring.jms.template.delivery-delay= # Delivery delay to use for send calls in milliseconds. -spring.jms.template.delivery-mode= # Delivery mode. Enable QoS when set. -spring.jms.template.priority= # Priority of a message when sending. Enable QoS when set. -spring.jms.template.qos-enabled= # Enable explicit QoS when sending a message. -spring.jms.template.receive-timeout= # Timeout to use for receive calls in milliseconds. -spring.jms.template.time-to-live= # Time-to-live of a message when sending in milliseconds. Enable QoS when set. +spring.jms.pub-sub-domain=false # Whether the default destination type is topic. +spring.jms.template.default-destination= # Default destination to use on send and receive operations that do not have a destination parameter. +spring.jms.template.delivery-delay= # Delivery delay to use for send calls. +spring.jms.template.delivery-mode= # Delivery mode. Enables QoS (Quality of Service) when set. +spring.jms.template.priority= # Priority of a message when sending. Enables QoS (Quality of Service) when set. +spring.jms.template.qos-enabled= # Whether to enable explicit QoS (Quality of Service) when sending a message. +spring.jms.template.receive-timeout= # Timeout to use for receive calls. +spring.jms.template.time-to-live= # Time-to-live of a message when sending. Enables QoS (Quality of Service) when set. # APACHE KAFKA (KafkaProperties) +spring.kafka.admin.client-id= # ID to pass to the server when making requests. Used for server-side logging. +spring.kafka.admin.fail-fast=false # Whether to fail fast if the broker is not available on startup. +spring.kafka.admin.properties.*= # Additional admin-specific properties used to configure the client. +spring.kafka.admin.ssl.key-password= # Password of the private key in the key store file. +spring.kafka.admin.ssl.keystore-location= # Location of the key store file. +spring.kafka.admin.ssl.keystore-password= # Store password for the key store file. +spring.kafka.admin.ssl.truststore-location= # Location of the trust store file. +spring.kafka.admin.ssl.truststore-password= # Store password for the trust store file. spring.kafka.bootstrap-servers= # Comma-delimited list of host:port pairs to use for establishing the initial connection to the Kafka cluster. -spring.kafka.client-id= # Id to pass to the server when making requests; used for server-side logging. -spring.kafka.consumer.auto-commit-interval= # Frequency in milliseconds that the consumer offsets are auto-committed to Kafka if 'enable.auto.commit' true. -spring.kafka.consumer.auto-offset-reset= # What to do when there is no initial offset in Kafka or if the current offset does not exist any more on the server. +spring.kafka.client-id= # ID to pass to the server when making requests. Used for server-side logging. +spring.kafka.consumer.auto-commit-interval= # Frequency with which the consumer offsets are auto-committed to Kafka if 'enable.auto.commit' is set to true. +spring.kafka.consumer.auto-offset-reset= # What to do when there is no initial offset in Kafka or if the current offset no longer exists on the server. spring.kafka.consumer.bootstrap-servers= # Comma-delimited list of host:port pairs to use for establishing the initial connection to the Kafka cluster. -spring.kafka.consumer.client-id= # Id to pass to the server when making requests; used for server-side logging. -spring.kafka.consumer.enable-auto-commit= # If true the consumer's offset will be periodically committed in the background. -spring.kafka.consumer.fetch-max-wait= # Maximum amount of time in milliseconds the server will block before answering the fetch request if there isn't sufficient data to immediately satisfy the requirement given by "fetch.min.bytes". -spring.kafka.consumer.fetch-min-size= # Minimum amount of data the server should return for a fetch request in bytes. -spring.kafka.consumer.group-id= # Unique string that identifies the consumer group this consumer belongs to. -spring.kafka.consumer.heartbeat-interval= # Expected time in milliseconds between heartbeats to the consumer coordinator. +spring.kafka.consumer.client-id= # ID to pass to the server when making requests. Used for server-side logging. +spring.kafka.consumer.enable-auto-commit= # Whether the consumer's offset is periodically committed in the background. +spring.kafka.consumer.fetch-max-wait= # Maximum amount of time the server blocks before answering the fetch request if there isn't sufficient data to immediately satisfy the requirement given by "fetch.min.bytes". +spring.kafka.consumer.fetch-min-size= # Minimum amount of data, in bytes, the server should return for a fetch request. +spring.kafka.consumer.group-id= # Unique string that identifies the consumer group to which this consumer belongs. +spring.kafka.consumer.heartbeat-interval= # Expected time between heartbeats to the consumer coordinator. spring.kafka.consumer.key-deserializer= # Deserializer class for keys. spring.kafka.consumer.max-poll-records= # Maximum number of records returned in a single call to poll(). +spring.kafka.consumer.properties.*= # Additional consumer-specific properties used to configure the client. spring.kafka.consumer.ssl.key-password= # Password of the private key in the key store file. spring.kafka.consumer.ssl.keystore-location= # Location of the key store file. spring.kafka.consumer.ssl.keystore-password= # Store password for the key store file. @@ -969,87 +1008,104 @@ spring.kafka.consumer.ssl.truststore-location= # Location of the trust store fil spring.kafka.consumer.ssl.truststore-password= # Store password for the trust store file. spring.kafka.consumer.value-deserializer= # Deserializer class for values. spring.kafka.jaas.control-flag=required # Control flag for login configuration. -spring.kafka.jaas.enabled= # Enable JAAS configuration. +spring.kafka.jaas.enabled=false # Whether to enable JAAS configuration. spring.kafka.jaas.login-module=com.sun.security.auth.module.Krb5LoginModule # Login module. spring.kafka.jaas.options= # Additional JAAS options. spring.kafka.listener.ack-count= # Number of records between offset commits when ackMode is "COUNT" or "COUNT_TIME". -spring.kafka.listener.ack-mode= # Listener AckMode; see the spring-kafka documentation. -spring.kafka.listener.ack-time= # Time in milliseconds between offset commits when ackMode is "TIME" or "COUNT_TIME". +spring.kafka.listener.ack-mode= # Listener AckMode. See the spring-kafka documentation. +spring.kafka.listener.ack-time= # Time between offset commits when ackMode is "TIME" or "COUNT_TIME". +spring.kafka.listener.client-id= # Prefix for the listener's consumer client.id property. spring.kafka.listener.concurrency= # Number of threads to run in the listener containers. -spring.kafka.listener.poll-timeout= # Timeout in milliseconds to use when polling the consumer. +spring.kafka.listener.idle-event-interval= # Time between publishing idle consumer events (no data received). +spring.kafka.listener.log-container-config= # Whether to log the container configuration during initialization (INFO level). +spring.kafka.listener.monitor-interval= # Time between checks for non-responsive consumers. If a duration suffix is not specified, seconds will be used. +spring.kafka.listener.no-poll-threshold= # Multiplier applied to "pollTimeout" to determine if a consumer is non-responsive. +spring.kafka.listener.poll-timeout= # Timeout to use when polling the consumer. spring.kafka.listener.type=single # Listener type. spring.kafka.producer.acks= # Number of acknowledgments the producer requires the leader to have received before considering a request complete. spring.kafka.producer.batch-size= # Number of records to batch before sending. spring.kafka.producer.bootstrap-servers= # Comma-delimited list of host:port pairs to use for establishing the initial connection to the Kafka cluster. spring.kafka.producer.buffer-memory= # Total bytes of memory the producer can use to buffer records waiting to be sent to the server. -spring.kafka.producer.client-id= # Id to pass to the server when making requests; used for server-side logging. +spring.kafka.producer.client-id= # ID to pass to the server when making requests. Used for server-side logging. spring.kafka.producer.compression-type= # Compression type for all data generated by the producer. spring.kafka.producer.key-serializer= # Serializer class for keys. +spring.kafka.producer.properties.*= # Additional producer-specific properties used to configure the client. spring.kafka.producer.retries= # When greater than zero, enables retrying of failed sends. spring.kafka.producer.ssl.key-password= # Password of the private key in the key store file. spring.kafka.producer.ssl.keystore-location= # Location of the key store file. spring.kafka.producer.ssl.keystore-password= # Store password for the key store file. spring.kafka.producer.ssl.truststore-location= # Location of the trust store file. spring.kafka.producer.ssl.truststore-password= # Store password for the trust store file. +spring.kafka.producer.transaction-id-prefix= # When non empty, enables transaction support for producer. spring.kafka.producer.value-serializer= # Serializer class for values. -spring.kafka.properties.*= # Additional properties used to configure the client. +spring.kafka.properties.*= # Additional properties, common to producers and consumers, used to configure the client. spring.kafka.ssl.key-password= # Password of the private key in the key store file. spring.kafka.ssl.keystore-location= # Location of the key store file. spring.kafka.ssl.keystore-password= # Store password for the key store file. spring.kafka.ssl.truststore-location= # Location of the trust store file. spring.kafka.ssl.truststore-password= # Store password for the trust store file. -spring.kafka.template.default-topic= # Default topic to which messages will be sent. +spring.kafka.template.default-topic= # Default topic to which messages are sent. # RABBIT (RabbitProperties) spring.rabbitmq.addresses= # Comma-separated list of addresses to which the client should connect. -spring.rabbitmq.cache.channel.checkout-timeout= # Number of milliseconds to wait to obtain a channel if the cache size has been reached. +spring.rabbitmq.cache.channel.checkout-timeout= # Duration to wait to obtain a channel if the cache size has been reached. spring.rabbitmq.cache.channel.size= # Number of channels to retain in the cache. spring.rabbitmq.cache.connection.mode=channel # Connection factory cache mode. spring.rabbitmq.cache.connection.size= # Number of connections to cache. -spring.rabbitmq.connection-timeout= # Connection timeout, in milliseconds; zero for infinite. -spring.rabbitmq.dynamic=true # Create an AmqpAdmin bean. +spring.rabbitmq.connection-timeout= # Connection timeout. Set it to zero to wait forever. +spring.rabbitmq.dynamic=true # Whether to create an AmqpAdmin bean. spring.rabbitmq.host=localhost # RabbitMQ host. spring.rabbitmq.listener.direct.acknowledge-mode= # Acknowledge mode of container. -spring.rabbitmq.listener.direct.auto-startup=true # Start the container automatically on startup. +spring.rabbitmq.listener.direct.auto-startup=true # Whether to start the container automatically on startup. spring.rabbitmq.listener.direct.consumers-per-queue= # Number of consumers per queue. -spring.rabbitmq.listener.direct.default-requeue-rejected= # Whether rejected deliveries are requeued by default; default true. -spring.rabbitmq.listener.direct.idle-event-interval= # How often idle container events should be published in milliseconds. +spring.rabbitmq.listener.direct.default-requeue-rejected= # Whether rejected deliveries are re-queued by default. +spring.rabbitmq.listener.direct.idle-event-interval= # How often idle container events should be published. spring.rabbitmq.listener.direct.prefetch= # Number of messages to be handled in a single request. It should be greater than or equal to the transaction size (if used). +spring.rabbitmq.listener.direct.retry.enabled=false # Whether publishing retries are enabled. +spring.rabbitmq.listener.direct.retry.initial-interval=1000ms # Duration between the first and second attempt to deliver a message. +spring.rabbitmq.listener.direct.retry.max-attempts=3 # Maximum number of attempts to deliver a message. +spring.rabbitmq.listener.direct.retry.max-interval=10000ms # Maximum duration between attempts. +spring.rabbitmq.listener.direct.retry.multiplier=1 # Multiplier to apply to the previous retry interval. +spring.rabbitmq.listener.direct.retry.stateless=true # Whether retries are stateless or stateful. spring.rabbitmq.listener.simple.acknowledge-mode= # Acknowledge mode of container. -spring.rabbitmq.listener.simple.auto-startup=true # Start the container automatically on startup. +spring.rabbitmq.listener.simple.auto-startup=true # Whether to start the container automatically on startup. spring.rabbitmq.listener.simple.concurrency= # Minimum number of listener invoker threads. -spring.rabbitmq.listener.simple.default-requeue-rejected= # Whether or not to requeue delivery failures. -spring.rabbitmq.listener.simple.idle-event-interval= # How often idle container events should be published in milliseconds. -spring.rabbitmq.listener.simple.max-concurrency= # Maximum number of listener invoker. +spring.rabbitmq.listener.simple.default-requeue-rejected= # Whether rejected deliveries are re-queued by default. +spring.rabbitmq.listener.simple.idle-event-interval= # How often idle container events should be published. +spring.rabbitmq.listener.simple.max-concurrency= # Maximum number of listener invoker threads. spring.rabbitmq.listener.simple.prefetch= # Number of messages to be handled in a single request. It should be greater than or equal to the transaction size (if used). -spring.rabbitmq.listener.simple.retry.enabled=false # Whether or not publishing retries are enabled. -spring.rabbitmq.listener.simple.retry.initial-interval=1000 # Interval between the first and second attempt to deliver a message. +spring.rabbitmq.listener.simple.retry.enabled=false # Whether publishing retries are enabled. +spring.rabbitmq.listener.simple.retry.initial-interval=1000ms # Duration between the first and second attempt to deliver a message. spring.rabbitmq.listener.simple.retry.max-attempts=3 # Maximum number of attempts to deliver a message. -spring.rabbitmq.listener.simple.retry.max-interval=10000 # Maximum interval between attempts. -spring.rabbitmq.listener.simple.retry.multiplier=1.0 # A multiplier to apply to the previous delivery retry interval. -spring.rabbitmq.listener.simple.retry.stateless=true # Whether or not retry is stateless or stateful. -spring.rabbitmq.listener.simple.transaction-size= # Number of messages to be processed in a transaction; number of messages between acks. For best results it should be less than or equal to the prefetch count. +spring.rabbitmq.listener.simple.retry.max-interval=10000ms # Maximum duration between attempts. +spring.rabbitmq.listener.simple.retry.multiplier=1 # Multiplier to apply to the previous retry interval. +spring.rabbitmq.listener.simple.retry.stateless=true # Whether retries are stateless or stateful. +spring.rabbitmq.listener.simple.transaction-size= # Number of messages to be processed in a transaction. That is, the number of messages between acks. For best results, it should be less than or equal to the prefetch count. spring.rabbitmq.listener.type=simple # Listener container type. -spring.rabbitmq.password= # Login to authenticate against the broker. +spring.rabbitmq.password=guest # Login to authenticate against the broker. spring.rabbitmq.port=5672 # RabbitMQ port. -spring.rabbitmq.publisher-confirms=false # Enable publisher confirms. -spring.rabbitmq.publisher-returns=false # Enable publisher returns. -spring.rabbitmq.requested-heartbeat= # Requested heartbeat timeout, in seconds; zero for none. -spring.rabbitmq.ssl.enabled=false # Enable SSL support. +spring.rabbitmq.publisher-confirms=false # Whether to enable publisher confirms. +spring.rabbitmq.publisher-returns=false # Whether to enable publisher returns. +spring.rabbitmq.requested-heartbeat= # Requested heartbeat timeout; zero for none. If a duration suffix is not specified, seconds will be used. +spring.rabbitmq.ssl.enabled=false # Whether to enable SSL support. spring.rabbitmq.ssl.key-store= # Path to the key store that holds the SSL certificate. spring.rabbitmq.ssl.key-store-password= # Password used to access the key store. +spring.rabbitmq.ssl.key-store-type=PKCS12 # Key store type. spring.rabbitmq.ssl.trust-store= # Trust store that holds SSL certificates. spring.rabbitmq.ssl.trust-store-password= # Password used to access the trust store. -spring.rabbitmq.ssl.algorithm= # SSL algorithm to use. By default configure by the rabbit client library. -spring.rabbitmq.template.mandatory=false # Enable mandatory messages. -spring.rabbitmq.template.receive-timeout=0 # Timeout for `receive()` methods. -spring.rabbitmq.template.reply-timeout=5000 # Timeout for `sendAndReceive()` methods. -spring.rabbitmq.template.retry.enabled=false # Set to true to enable retries in the `RabbitTemplate`. -spring.rabbitmq.template.retry.initial-interval=1000 # Interval between the first and second attempt to publish a message. -spring.rabbitmq.template.retry.max-attempts=3 # Maximum number of attempts to publish a message. -spring.rabbitmq.template.retry.max-interval=10000 # Maximum number of attempts to publish a message. -spring.rabbitmq.template.retry.multiplier=1.0 # A multiplier to apply to the previous publishing retry interval. -spring.rabbitmq.username= # Login user to authenticate to the broker. +spring.rabbitmq.ssl.trust-store-type=JKS # Trust store type. +spring.rabbitmq.ssl.algorithm= # SSL algorithm to use. By default, configured by the Rabbit client library. +spring.rabbitmq.template.exchange= # Name of the default exchange to use for send operations. +spring.rabbitmq.template.mandatory= # Whether to enable mandatory messages. +spring.rabbitmq.template.receive-timeout= # Timeout for `receive()` operations. +spring.rabbitmq.template.reply-timeout= # Timeout for `sendAndReceive()` operations. +spring.rabbitmq.template.retry.enabled=false # Whether publishing retries are enabled. +spring.rabbitmq.template.retry.initial-interval=1000ms # Duration between the first and second attempt to deliver a message. +spring.rabbitmq.template.retry.max-attempts=3 # Maximum number of attempts to deliver a message. +spring.rabbitmq.template.retry.max-interval=10000ms # Maximum duration between attempts. +spring.rabbitmq.template.retry.multiplier=1 # Multiplier to apply to the previous retry interval. +spring.rabbitmq.template.routing-key= # Value of a default routing key to use for send operations. +spring.rabbitmq.username=guest # Login user to authenticate to the broker. spring.rabbitmq.virtual-host= # Virtual host to use when connecting to the broker. @@ -1057,180 +1113,292 @@ spring.rabbitmq.virtual-host= # Virtual host to use when connecting to the broke # ACTUATOR PROPERTIES # ---------------------------------------- -# ENDPOINTS (AbstractEndpoint subclasses) -endpoints.enabled=true # Enable endpoints. -endpoints.sensitive= # Default endpoint sensitive setting. -endpoints.actuator.enabled=true # Enable the endpoint. -endpoints.actuator.path= # Endpoint URL path. -endpoints.actuator.sensitive=false # Enable security on the endpoint. -endpoints.auditevents.enabled= # Enable the endpoint. -endpoints.auditevents.path= # Endpoint path. -endpoints.auditevents.sensitive=false # Enable security on the endpoint. -endpoints.autoconfig.enabled= # Enable the endpoint. -endpoints.autoconfig.id= # Endpoint identifier. -endpoints.autoconfig.path= # Endpoint path. -endpoints.autoconfig.sensitive= # Mark if the endpoint exposes sensitive information. -endpoints.beans.enabled= # Enable the endpoint. -endpoints.beans.id= # Endpoint identifier. -endpoints.beans.path= # Endpoint path. -endpoints.beans.sensitive= # Mark if the endpoint exposes sensitive information. -endpoints.configprops.enabled= # Enable the endpoint. -endpoints.configprops.id= # Endpoint identifier. -endpoints.configprops.keys-to-sanitize=password,secret,key,token,.*credentials.*,vcap_services # Keys that should be sanitized. Keys can be simple strings that the property ends with or regex expressions. -endpoints.configprops.path= # Endpoint path. -endpoints.configprops.sensitive= # Mark if the endpoint exposes sensitive information. -endpoints.docs.curies.enabled=false # Enable the curie generation. -endpoints.docs.enabled=true # Enable actuator docs endpoint. -endpoints.docs.path=/docs # -endpoints.docs.sensitive=false # -endpoints.dump.enabled= # Enable the endpoint. -endpoints.dump.id= # Endpoint identifier. -endpoints.dump.path= # Endpoint path. -endpoints.dump.sensitive= # Mark if the endpoint exposes sensitive information. -endpoints.env.enabled= # Enable the endpoint. -endpoints.env.id= # Endpoint identifier. -endpoints.env.keys-to-sanitize=password,secret,key,token,.*credentials.*,vcap_services # Keys that should be sanitized. Keys can be simple strings that the property ends with or regex expressions. -endpoints.env.path= # Endpoint path. -endpoints.env.sensitive= # Mark if the endpoint exposes sensitive information. -endpoints.flyway.enabled= # Enable the endpoint. -endpoints.flyway.id= # Endpoint identifier. -endpoints.flyway.sensitive= # Mark if the endpoint exposes sensitive information. -endpoints.health.enabled= # Enable the endpoint. -endpoints.health.id= # Endpoint identifier. -endpoints.health.mapping.*= # Mapping of health statuses to HttpStatus codes. By default, registered health statuses map to sensible defaults (i.e. UP maps to 200). -endpoints.health.path= # Endpoint path. -endpoints.health.sensitive= # Mark if the endpoint exposes sensitive information. -endpoints.health.time-to-live=1000 # Time to live for cached result, in milliseconds. -endpoints.heapdump.enabled= # Enable the endpoint. -endpoints.heapdump.path= # Endpoint path. -endpoints.heapdump.sensitive= # Mark if the endpoint exposes sensitive information. -endpoints.hypermedia.enabled=false # Enable hypermedia support for endpoints. -endpoints.info.enabled= # Enable the endpoint. -endpoints.info.id= # Endpoint identifier. -endpoints.info.path= # Endpoint path. -endpoints.info.sensitive= # Mark if the endpoint exposes sensitive information. -endpoints.jolokia.enabled=true # Enable Jolokia endpoint. -endpoints.jolokia.path=/jolokia # Endpoint URL path. -endpoints.jolokia.sensitive=true # Enable security on the endpoint. -endpoints.liquibase.enabled= # Enable the endpoint. -endpoints.liquibase.id= # Endpoint identifier. -endpoints.liquibase.sensitive= # Mark if the endpoint exposes sensitive information. -endpoints.logfile.enabled=true # Enable the endpoint. -endpoints.logfile.external-file= # External Logfile to be accessed. -endpoints.logfile.path=/logfile # Endpoint URL path. -endpoints.logfile.sensitive=true # Enable security on the endpoint. -endpoints.loggers.enabled=true # Enable the endpoint. -endpoints.loggers.id= # Endpoint identifier. -endpoints.loggers.path=/logfile # Endpoint path. -endpoints.loggers.sensitive=true # Mark if the endpoint exposes sensitive information. -endpoints.mappings.enabled= # Enable the endpoint. -endpoints.mappings.id= # Endpoint identifier. -endpoints.mappings.path= # Endpoint path. -endpoints.mappings.sensitive= # Mark if the endpoint exposes sensitive information. -endpoints.metrics.enabled= # Enable the endpoint. -endpoints.metrics.filter.enabled=true # Enable the metrics servlet filter. -endpoints.metrics.filter.gauge-submissions=merged # Http filter gauge submissions (merged, per-http-method) -endpoints.metrics.filter.counter-submissions=merged # Http filter counter submissions (merged, per-http-method) -endpoints.metrics.id= # Endpoint identifier. -endpoints.metrics.path= # Endpoint path. -endpoints.metrics.sensitive= # Mark if the endpoint exposes sensitive information. -endpoints.shutdown.enabled= # Enable the endpoint. -endpoints.shutdown.id= # Endpoint identifier. -endpoints.shutdown.path= # Endpoint path. -endpoints.shutdown.sensitive= # Mark if the endpoint exposes sensitive information. -endpoints.trace.enabled= # Enable the endpoint. -endpoints.trace.filter.enabled=true # Enable the trace servlet filter. -endpoints.trace.id= # Endpoint identifier. -endpoints.trace.path= # Endpoint path. -endpoints.trace.sensitive= # Mark if the endpoint exposes sensitive information. - -# ENDPOINTS CORS CONFIGURATION (EndpointCorsProperties) -endpoints.cors.allow-credentials= # Set whether credentials are supported. When not set, credentials are not supported. -endpoints.cors.allowed-headers= # Comma-separated list of headers to allow in a request. '*' allows all headers. -endpoints.cors.allowed-methods=GET # Comma-separated list of methods to allow. '*' allows all methods. -endpoints.cors.allowed-origins= # Comma-separated list of origins to allow. '*' allows all origins. When not set, CORS support is disabled. -endpoints.cors.exposed-headers= # Comma-separated list of headers to include in a response. -endpoints.cors.max-age=1800 # How long, in seconds, the response from a pre-flight request can be cached by clients. - -# JMX ENDPOINT (EndpointMBeanExportProperties) -endpoints.jmx.domain= # JMX domain name. Initialized with the value of 'spring.jmx.default-domain' if set. -endpoints.jmx.enabled=true # Enable JMX export of all endpoints. -endpoints.jmx.static-names= # Additional static properties to append to all ObjectNames of MBeans representing Endpoints. -endpoints.jmx.unique-names=false # Ensure that ObjectNames are modified in case of conflict. - -# JOLOKIA (JolokiaProperties) -jolokia.config.*= # See Jolokia manual - # MANAGEMENT HTTP SERVER (ManagementServerProperties) -management.add-application-context-header=false # Add the "X-Application-Context" HTTP header in each response. -management.address= # Network address that the management endpoints should bind to. -management.context-path= # Management endpoint context-path. For instance `/actuator` -management.cloudfoundry.enabled= # Enable extended Cloud Foundry actuator endpoints -management.cloudfoundry.skip-ssl-validation= # Skip SSL verification for Cloud Foundry actuator endpoint security calls -management.port= # Management endpoint HTTP port. Uses the same port as the application by default. Configure a different port to use management-specific SSL. -management.security.enabled=true # Enable security. -management.security.roles=ACTUATOR # Comma-separated list of roles that can access the management endpoint. -management.security.sessions=stateless # Session creating policy to use (always, never, if_required, stateless). -management.ssl.ciphers= # Supported SSL ciphers. Requires a custom management.port. -management.ssl.client-auth= # Whether client authentication is wanted ("want") or needed ("need"). Requires a trust store. Requires a custom management.port. -management.ssl.enabled= # Enable SSL support. Requires a custom management.port. -management.ssl.enabled-protocols= # Enabled SSL protocols. Requires a custom management.port. -management.ssl.key-alias= # Alias that identifies the key in the key store. Requires a custom management.port. -management.ssl.key-password= # Password used to access the key in the key store. Requires a custom management.port. -management.ssl.key-store= # Path to the key store that holds the SSL certificate (typically a jks file). Requires a custom management.port. -management.ssl.key-store-password= # Password used to access the key store. Requires a custom management.port. -management.ssl.key-store-provider= # Provider for the key store. Requires a custom management.port. -management.ssl.key-store-type= # Type of the key store. Requires a custom management.port. -management.ssl.protocol=TLS # SSL protocol to use. Requires a custom management.port. -management.ssl.trust-store= # Trust store that holds SSL certificates. Requires a custom management.port. -management.ssl.trust-store-password= # Password used to access the trust store. Requires a custom management.port. -management.ssl.trust-store-provider= # Provider for the trust store. Requires a custom management.port. -management.ssl.trust-store-type= # Type of the trust store. Requires a custom management.port. +management.server.add-application-context-header=false # Add the "X-Application-Context" HTTP header in each response. +management.server.address= # Network address to which the management endpoints should bind. Requires a custom management.server.port. +management.server.port= # Management endpoint HTTP port (uses the same port as the application by default). Configure a different port to use management-specific SSL. +management.server.servlet.context-path= # Management endpoint context-path (for instance, `/management`). Requires a custom management.server.port. +management.server.ssl.ciphers= # Supported SSL ciphers. Requires a custom management.port. +management.server.ssl.client-auth= # Whether client authentication is wanted ("want") or needed ("need"). Requires a trust store. Requires a custom management.server.port. +management.server.ssl.enabled= # Whether to enable SSL support. Requires a custom management.server.port. +management.server.ssl.enabled-protocols= # Enabled SSL protocols. Requires a custom management.server.port. +management.server.ssl.key-alias= # Alias that identifies the key in the key store. Requires a custom management.server.port. +management.server.ssl.key-password= # Password used to access the key in the key store. Requires a custom management.server.port. +management.server.ssl.key-store= # Path to the key store that holds the SSL certificate (typically a jks file). Requires a custom management.server.port. +management.server.ssl.key-store-password= # Password used to access the key store. Requires a custom management.server.port. +management.server.ssl.key-store-provider= # Provider for the key store. Requires a custom management.server.port. +management.server.ssl.key-store-type= # Type of the key store. Requires a custom management.server.port. +management.server.ssl.protocol=TLS # SSL protocol to use. Requires a custom management.server.port. +management.server.ssl.trust-store= # Trust store that holds SSL certificates. Requires a custom management.server.port. +management.server.ssl.trust-store-password= # Password used to access the trust store. Requires a custom management.server.port. +management.server.ssl.trust-store-provider= # Provider for the trust store. Requires a custom management.server.port. +management.server.ssl.trust-store-type= # Type of the trust store. Requires a custom management.server.port. + +# CLOUDFOUNDRY +management.cloudfoundry.enabled=true # Whether to enable extended Cloud Foundry actuator endpoints. +management.cloudfoundry.skip-ssl-validation=false # Whether to skip SSL verification for Cloud Foundry actuator endpoint security calls. + +# ENDPOINTS GENERAL CONFIGURATION +management.endpoints.enabled-by-default= # Whether to enable or disable all endpoints by default. + +# ENDPOINTS JMX CONFIGURATION (JmxEndpointProperties) +management.endpoints.jmx.domain=org.springframework.boot # Endpoints JMX domain name. Fallback to 'spring.jmx.default-domain' if set. +management.endpoints.jmx.exposure.include=* # Endpoint IDs that should be included or '*' for all. +management.endpoints.jmx.exposure.exclude= # Endpoint IDs that should be excluded. +management.endpoints.jmx.static-names= # Additional static properties to append to all ObjectNames of MBeans representing Endpoints. +management.endpoints.jmx.unique-names=false # Whether to ensure that ObjectNames are modified in case of conflict. + +# ENDPOINTS WEB CONFIGURATION (WebEndpointProperties) +management.endpoints.web.exposure.include=health,info # Endpoint IDs that should be included or '*' for all. +management.endpoints.web.exposure.exclude= # Endpoint IDs that should be excluded. +management.endpoints.web.base-path=/actuator # Base path for Web endpoints. Relative to server.servlet.context-path or management.server.servlet.context-path if management.server.port is configured. +management.endpoints.web.path-mapping= # Mapping between endpoint IDs and the path that should expose them. + +# ENDPOINTS CORS CONFIGURATION (CorsEndpointProperties) +management.endpoints.web.cors.allow-credentials= # Whether credentials are supported. When not set, credentials are not supported. +management.endpoints.web.cors.allowed-headers= # Comma-separated list of headers to allow in a request. '*' allows all headers. +management.endpoints.web.cors.allowed-methods= # Comma-separated list of methods to allow. '*' allows all methods. When not set, defaults to GET. +management.endpoints.web.cors.allowed-origins= # Comma-separated list of origins to allow. '*' allows all origins. When not set, CORS support is disabled. +management.endpoints.web.cors.exposed-headers= # Comma-separated list of headers to include in a response. +management.endpoints.web.cors.max-age=1800s # How long the response from a pre-flight request can be cached by clients. If a duration suffix is not specified, seconds will be used. + +# AUDIT EVENTS ENDPOINT (AuditEventsEndpoint) +management.endpoint.auditevents.cache.time-to-live=0ms # Maximum time that a response can be cached. +management.endpoint.auditevents.enabled=true # Whether to enable the auditevents endpoint. + +# BEANS ENDPOINT (BeansEndpoint) +management.endpoint.beans.cache.time-to-live=0ms # Maximum time that a response can be cached. +management.endpoint.beans.enabled=true # Whether to enable the beans endpoint. + +# CONDITIONS REPORT ENDPOINT (ConditionsReportEndpoint) +management.endpoint.conditions.cache.time-to-live=0ms # Maximum time that a response can be cached. +management.endpoint.conditions.enabled=true # Whether to enable the conditions endpoint. + +# CONFIGURATION PROPERTIES REPORT ENDPOINT (ConfigurationPropertiesReportEndpoint, ConfigurationPropertiesReportEndpointProperties) +management.endpoint.configprops.cache.time-to-live=0ms # Maximum time that a response can be cached. +management.endpoint.configprops.enabled=true # Whether to enable the configprops endpoint. +management.endpoint.configprops.keys-to-sanitize=password,secret,key,token,.*credentials.*,vcap_services # Keys that should be sanitized. Keys can be simple strings that the property ends with or regular expressions. + +# ENVIRONMENT ENDPOINT (EnvironmentEndpoint, EnvironmentEndpointProperties) +management.endpoint.env.cache.time-to-live=0ms # Maximum time that a response can be cached. +management.endpoint.env.enabled=true # Whether to enable the env endpoint. +management.endpoint.env.keys-to-sanitize=password,secret,key,token,.*credentials.*,vcap_services # Keys that should be sanitized. Keys can be simple strings that the property ends with or regular expressions. + +# FLYWAY ENDPOINT (FlywayEndpoint) +management.endpoint.flyway.cache.time-to-live=0ms # Maximum time that a response can be cached. +management.endpoint.flyway.enabled=true # Whether to enable the flyway endpoint. + +# HEALTH ENDPOINT (HealthEndpoint, HealthEndpointProperties) +management.endpoint.health.cache.time-to-live=0ms # Maximum time that a response can be cached. +management.endpoint.health.enabled=true # Whether to enable the health endpoint. +management.endpoint.health.roles= # Roles used to determine whether or not a user is authorized to be shown details. When empty, all authenticated users are authorized. +management.endpoint.health.show-details=never # When to show full health details. + +# HEAP DUMP ENDPOINT (HeapDumpWebEndpoint) +management.endpoint.heapdump.cache.time-to-live=0ms # Maximum time that a response can be cached. +management.endpoint.heapdump.enabled=true # Whether to enable the heapdump endpoint. + +# HTTP TRACE ENDPOINT (HttpTraceEndpoint) +management.endpoint.httptrace.cache.time-to-live=0ms # Maximum time that a response can be cached. +management.endpoint.httptrace.enabled=true # Whether to enable the httptrace endpoint. + +# INFO ENDPOINT (InfoEndpoint) +info= # Arbitrary properties to add to the info endpoint. +management.endpoint.info.cache.time-to-live=0ms # Maximum time that a response can be cached. +management.endpoint.info.enabled=true # Whether to enable the info endpoint. + +# JOLOKIA ENDPOINT (JolokiaProperties) +management.endpoint.jolokia.config.*= # Jolokia settings. Refer to the documentation of Jolokia for more details. +management.endpoint.jolokia.enabled=true # Whether to enable the jolokia endpoint. + +# LIQUIBASE ENDPOINT (LiquibaseEndpoint) +management.endpoint.liquibase.cache.time-to-live=0ms # Maximum time that a response can be cached. +management.endpoint.liquibase.enabled=true # Whether to enable the liquibase endpoint. + +# LOG FILE ENDPOINT (LogFileWebEndpoint, LogFileWebEndpointProperties) +management.endpoint.logfile.cache.time-to-live=0ms # Maximum time that a response can be cached. +management.endpoint.logfile.enabled=true # Whether to enable the logfile endpoint. +management.endpoint.logfile.external-file= # External Logfile to be accessed. Can be used if the logfile is written by output redirect and not by the logging system itself. + +# LOGGERS ENDPOINT (LoggersEndpoint) +management.endpoint.loggers.cache.time-to-live=0ms # Maximum time that a response can be cached. +management.endpoint.loggers.enabled=true # Whether to enable the loggers endpoint. + +# REQUEST MAPPING ENDPOINT (MappingsEndpoint) +management.endpoint.mappings.cache.time-to-live=0ms # Maximum time that a response can be cached. +management.endpoint.mappings.enabled=true # Whether to enable the mappings endpoint. + +# METRICS ENDPOINT (MetricsEndpoint) +management.endpoint.metrics.cache.time-to-live=0ms # Maximum time that a response can be cached. +management.endpoint.metrics.enabled=true # Whether to enable the metrics endpoint. + +# PROMETHEUS ENDPOINT (PrometheusScrapeEndpoint) +management.endpoint.prometheus.cache.time-to-live=0ms # Maximum time that a response can be cached. +management.endpoint.prometheus.enabled=true # Whether to enable the prometheus endpoint. + +# SCHEDULED TASKS ENDPOINT (ScheduledTasksEndpoint) +management.endpoint.scheduledtasks.cache.time-to-live=0ms # Maximum time that a response can be cached. +management.endpoint.scheduledtasks.enabled=true # Whether to enable the scheduledtasks endpoint. + +# SESSIONS ENDPOINT (SessionsEndpoint) +management.endpoint.sessions.enabled=true # Whether to enable the sessions endpoint. + +# SHUTDOWN ENDPOINT (ShutdownEndpoint) +management.endpoint.shutdown.enabled=false # Whether to enable the shutdown endpoint. + +# THREAD DUMP ENDPOINT (ThreadDumpEndpoint) +management.endpoint.threaddump.cache.time-to-live=0ms # Maximum time that a response can be cached. +management.endpoint.threaddump.enabled=true # Whether to enable the threaddump endpoint. # HEALTH INDICATORS -management.health.db.enabled=true # Enable database health check. -management.health.cassandra.enabled=true # Enable cassandra health check. -management.health.couchbase.enabled=true # Enable couchbase health check. -management.health.defaults.enabled=true # Enable default health indicators. -management.health.diskspace.enabled=true # Enable disk space health check. +management.health.db.enabled=true # Whether to enable database health check. +management.health.cassandra.enabled=true # Whether to enable Cassandra health check. +management.health.couchbase.enabled=true # Whether to enable Couchbase health check. +management.health.defaults.enabled=true # Whether to enable default health indicators. +management.health.diskspace.enabled=true # Whether to enable disk space health check. management.health.diskspace.path= # Path used to compute the available disk space. -management.health.diskspace.threshold=0 # Minimum disk space that should be available, in bytes. -management.health.elasticsearch.enabled=true # Enable elasticsearch health check. +management.health.diskspace.threshold=0 # Minimum disk space, in bytes, that should be available. +management.health.elasticsearch.enabled=true # Whether to enable Elasticsearch health check. management.health.elasticsearch.indices= # Comma-separated index names. -management.health.elasticsearch.response-timeout=100 # The time, in milliseconds, to wait for a response from the cluster. -management.health.jms.enabled=true # Enable JMS health check. -management.health.ldap.enabled=true # Enable LDAP health check. -management.health.mail.enabled=true # Enable Mail health check. -management.health.mongo.enabled=true # Enable MongoDB health check. -management.health.rabbit.enabled=true # Enable RabbitMQ health check. -management.health.redis.enabled=true # Enable Redis health check. -management.health.solr.enabled=true # Enable Solr health check. -management.health.status.order=DOWN, OUT_OF_SERVICE, UP, UNKNOWN # Comma-separated list of health statuses in order of severity. +management.health.elasticsearch.response-timeout=100ms # Time to wait for a response from the cluster. +management.health.influxdb.enabled=true # Whether to enable InfluxDB health check. +management.health.jms.enabled=true # Whether to enable JMS health check. +management.health.ldap.enabled=true # Whether to enable LDAP health check. +management.health.mail.enabled=true # Whether to enable Mail health check. +management.health.mongo.enabled=true # Whether to enable MongoDB health check. +management.health.neo4j.enabled=true # Whether to enable Neo4j health check. +management.health.rabbit.enabled=true # Whether to enable RabbitMQ health check. +management.health.redis.enabled=true # Whether to enable Redis health check. +management.health.solr.enabled=true # Whether to enable Solr health check. +management.health.status.http-mapping= # Mapping of health statuses to HTTP status codes. By default, registered health statuses map to sensible defaults (for example, UP maps to 200). +management.health.status.order=DOWN,OUT_OF_SERVICE,UP,UNKNOWN # Comma-separated list of health statuses in order of severity. + +# HTTP TRACING (HttpTraceProperties) +management.trace.http.enabled=true # Whether to enable HTTP request-response tracing. +management.trace.http.include=request-headers,response-headers,cookies,errors # Items to be included in the trace. # INFO CONTRIBUTORS (InfoContributorProperties) -management.info.build.enabled=true # Enable build info. -management.info.defaults.enabled=true # Enable default info contributors. -management.info.env.enabled=true # Enable environment info. -management.info.git.enabled=true # Enable git info. +management.info.build.enabled=true # Whether to enable build info. +management.info.defaults.enabled=true # Whether to enable default info contributors. +management.info.env.enabled=true # Whether to enable environment info. +management.info.git.enabled=true # Whether to enable git info. management.info.git.mode=simple # Mode to use to expose git information. -# TRACING (TraceProperties) -management.trace.include=request-headers,response-headers,cookies,errors # Items to be included in the trace. - -# METRICS EXPORT (MetricExportProperties) -spring.metrics.export.aggregate.key-pattern= # Pattern that tells the aggregator what to do with the keys from the source repository. -spring.metrics.export.aggregate.prefix= # Prefix for global repository if active. -spring.metrics.export.delay-millis=5000 # Delay in milliseconds between export ticks. Metrics are exported to external sources on a schedule with this delay. -spring.metrics.export.enabled=true # Flag to enable metric export (assuming a MetricWriter is available). -spring.metrics.export.excludes= # List of patterns for metric names to exclude. Applied after the includes. -spring.metrics.export.includes= # List of patterns for metric names to include. -spring.metrics.export.redis.key=keys.spring.metrics # Key for redis repository export (if active). -spring.metrics.export.redis.prefix=spring.metrics # Prefix for redis repository if active. -spring.metrics.export.send-latest= # Flag to switch off any available optimizations based on not exporting unchanged metric values. -spring.metrics.export.statsd.host= # Host of a statsd server to receive exported metrics. -spring.metrics.export.statsd.port=8125 # Port of a statsd server to receive exported metrics. -spring.metrics.export.statsd.prefix= # Prefix for statsd exported metrics. -spring.metrics.export.triggers.*= # Specific trigger properties per MetricWriter bean name. +# METRICS +management.metrics.binders.files.enabled=true # Whether to enable files metrics. +management.metrics.binders.integration.enabled=true # Whether to enable Spring Integration metrics. +management.metrics.binders.jvm.enabled=true # Whether to enable JVM metrics. +management.metrics.binders.logback.enabled=true # Whether to enable Logback metrics. +management.metrics.binders.processor.enabled=true # Whether to enable processor metrics. +management.metrics.binders.uptime.enabled=true # Whether to enable uptime metrics. +management.metrics.distribution.percentiles-histogram.*= # Whether meter IDs starting-with the specified name should be publish percentile histograms. +management.metrics.distribution.percentiles.*= # Specific computed non-aggregable percentiles to ship to the backend for meter IDs starting-with the specified name. +management.metrics.distribution.sla.*= # Specific SLA boundaries for meter IDs starting-with the specified name. The longest match wins, the key `all` can also be used to configure all meters. +management.metrics.enable.*= # Whether meter IDs starting-with the specified name should be enabled. The longest match wins, the key `all` can also be used to configure all meters. +management.metrics.export.atlas.batch-size=10000 # Number of measurements per request to use for this backend. If more measurements are found, then multiple requests will be made. +management.metrics.export.atlas.config-refresh-frequency=10s # Frequency for refreshing config settings from the LWC service. +management.metrics.export.atlas.config-time-to-live=150s # Time to live for subscriptions from the LWC service. +management.metrics.export.atlas.config-uri=http://localhost:7101/lwc/api/v1/expressions/local-dev # URI for the Atlas LWC endpoint to retrieve current subscriptions. +management.metrics.export.atlas.connect-timeout=1s # Connection timeout for requests to this backend. +management.metrics.export.atlas.enabled=true # Whether exporting of metrics to this backend is enabled. +management.metrics.export.atlas.eval-uri=http://localhost:7101/lwc/api/v1/evaluate # URI for the Atlas LWC endpoint to evaluate the data for a subscription. +management.metrics.export.atlas.lwc-enabled=false # Whether to enable streaming to Atlas LWC. +management.metrics.export.atlas.meter-time-to-live=15m # Time to live for meters that do not have any activity. After this period the meter will be considered expired and will not get reported. +management.metrics.export.atlas.num-threads=2 # Number of threads to use with the metrics publishing scheduler. +management.metrics.export.atlas.read-timeout=10s # Read timeout for requests to this backend. +management.metrics.export.atlas.step=1m # Step size (i.e. reporting frequency) to use. +management.metrics.export.atlas.uri=http://localhost:7101/api/v1/publish # URI of the Atlas server. +management.metrics.export.datadog.api-key= # Datadog API key. +management.metrics.export.datadog.application-key= # Datadog application key. Not strictly required, but improves the Datadog experience by sending meter descriptions, types, and base units to Datadog. +management.metrics.export.datadog.batch-size=10000 # Number of measurements per request to use for this backend. If more measurements are found, then multiple requests will be made. +management.metrics.export.datadog.connect-timeout=1s # Connection timeout for requests to this backend. +management.metrics.export.datadog.descriptions=true # Whether to publish descriptions metadata to Datadog. Turn this off to minimize the amount of metadata sent. +management.metrics.export.datadog.enabled=true # Whether exporting of metrics to this backend is enabled. +management.metrics.export.datadog.host-tag=instance # Tag that will be mapped to "host" when shipping metrics to Datadog. +management.metrics.export.datadog.num-threads=2 # Number of threads to use with the metrics publishing scheduler. +management.metrics.export.datadog.read-timeout=10s # Read timeout for requests to this backend. +management.metrics.export.datadog.step=1m # Step size (i.e. reporting frequency) to use. +management.metrics.export.datadog.uri=https://app.datadoghq.com # URI to ship metrics to. If you need to publish metrics to an internal proxy en-route to Datadog, you can define the location of the proxy with this. +management.metrics.export.ganglia.addressing-mode=multicast # UDP addressing mode, either unicast or multicast. +management.metrics.export.ganglia.duration-units=milliseconds # Base time unit used to report durations. +management.metrics.export.ganglia.enabled=true # Whether exporting of metrics to Ganglia is enabled. +management.metrics.export.ganglia.host=localhost # Host of the Ganglia server to receive exported metrics. +management.metrics.export.ganglia.port=8649 # Port of the Ganglia server to receive exported metrics. +management.metrics.export.ganglia.protocol-version=3.1 # Ganglia protocol version. Must be either 3.1 or 3.0. +management.metrics.export.ganglia.rate-units=seconds # Base time unit used to report rates. +management.metrics.export.ganglia.step=1m # Step size (i.e. reporting frequency) to use. +management.metrics.export.ganglia.time-to-live=1 # Time to live for metrics on Ganglia. Set the multi-cast Time-To-Live to be one greater than the number of hops (routers) between the hosts. +management.metrics.export.graphite.duration-units=milliseconds # Base time unit used to report durations. +management.metrics.export.graphite.enabled=true # Whether exporting of metrics to Graphite is enabled. +management.metrics.export.graphite.host=localhost # Host of the Graphite server to receive exported metrics. +management.metrics.export.graphite.port=2004 # Port of the Graphite server to receive exported metrics. +management.metrics.export.graphite.protocol=pickled # Protocol to use while shipping data to Graphite. +management.metrics.export.graphite.rate-units=seconds # Base time unit used to report rates. +management.metrics.export.graphite.step=1m # Step size (i.e. reporting frequency) to use. +management.metrics.export.graphite.tags-as-prefix= # For the default naming convention, turn the specified tag keys into part of the metric prefix. +management.metrics.export.influx.auto-create-db=true # Whether to create the Influx database if it does not exist before attempting to publish metrics to it. +management.metrics.export.influx.batch-size=10000 # Number of measurements per request to use for this backend. If more measurements are found, then multiple requests will be made. +management.metrics.export.influx.compressed=true # Whether to enable GZIP compression of metrics batches published to Influx. +management.metrics.export.influx.connect-timeout=1s # Connection timeout for requests to this backend. +management.metrics.export.influx.consistency=one # Write consistency for each point. +management.metrics.export.influx.db=mydb # Tag that will be mapped to "host" when shipping metrics to Influx. +management.metrics.export.influx.enabled=true # Whether exporting of metrics to this backend is enabled. +management.metrics.export.influx.num-threads=2 # Number of threads to use with the metrics publishing scheduler. +management.metrics.export.influx.password= # Login password of the Influx server. +management.metrics.export.influx.read-timeout=10s # Read timeout for requests to this backend. +management.metrics.export.influx.retention-policy= # Retention policy to use (Influx writes to the DEFAULT retention policy if one is not specified). +management.metrics.export.influx.step=1m # Step size (i.e. reporting frequency) to use. +management.metrics.export.influx.uri=http://localhost:8086 # URI of the Influx server. +management.metrics.export.influx.user-name= # Login user of the Influx server. +management.metrics.export.jmx.enabled=true # Whether exporting of metrics to JMX is enabled. +management.metrics.export.jmx.step=1m # Step size (i.e. reporting frequency) to use. +management.metrics.export.newrelic.account-id= # New Relic account ID. +management.metrics.export.newrelic.api-key= # New Relic API key. +management.metrics.export.newrelic.batch-size=10000 # Number of measurements per request to use for this backend. If more measurements are found, then multiple requests will be made. +management.metrics.export.newrelic.connect-timeout=1s # Connection timeout for requests to this backend. +management.metrics.export.newrelic.enabled=true # Whether exporting of metrics to this backend is enabled. +management.metrics.export.newrelic.num-threads=2 # Number of threads to use with the metrics publishing scheduler. +management.metrics.export.newrelic.read-timeout=10s # Read timeout for requests to this backend. +management.metrics.export.newrelic.step=1m # Step size (i.e. reporting frequency) to use. +management.metrics.export.newrelic.uri=https://insights-collector.newrelic.com # URI to ship metrics to. +management.metrics.export.prometheus.descriptions=true # Whether to enable publishing descriptions as part of the scrape payload to Prometheus. Turn this off to minimize the amount of data sent on each scrape. +management.metrics.export.prometheus.enabled=true # Whether exporting of metrics to Prometheus is enabled. +management.metrics.export.prometheus.step=1m # Step size (i.e. reporting frequency) to use. +management.metrics.export.signalfx.access-token= # SignalFX access token. +management.metrics.export.signalfx.batch-size=10000 # Number of measurements per request to use for this backend. If more measurements are found, then multiple requests will be made. +management.metrics.export.signalfx.connect-timeout=1s # Connection timeout for requests to this backend. +management.metrics.export.signalfx.enabled=true # Whether exporting of metrics to this backend is enabled. +management.metrics.export.signalfx.num-threads=2 # Number of threads to use with the metrics publishing scheduler. +management.metrics.export.signalfx.read-timeout=10s # Read timeout for requests to this backend. +management.metrics.export.signalfx.source= # Uniquely identifies the app instance that is publishing metrics to SignalFx. Defaults to the local host name. +management.metrics.export.signalfx.step=10s # Step size (i.e. reporting frequency) to use. +management.metrics.export.signalfx.uri=https://ingest.signalfx.com # URI to ship metrics to. +management.metrics.export.simple.enabled=true # Whether, in the absence of any other exporter, exporting of metrics to an in-memory backend is enabled. +management.metrics.export.simple.mode=cumulative # Counting mode. +management.metrics.export.simple.step=1m # Step size (i.e. reporting frequency) to use. +management.metrics.export.statsd.enabled=true # Whether exporting of metrics to StatsD is enabled. +management.metrics.export.statsd.flavor=datadog # StatsD line protocol to use. +management.metrics.export.statsd.host=localhost # Host of the StatsD server to receive exported metrics. +management.metrics.export.statsd.max-packet-length=1400 # Total length of a single payload should be kept within your network's MTU. +management.metrics.export.statsd.polling-frequency=10s # How often gauges will be polled. When a gauge is polled, its value is recalculated and if the value has changed (or publishUnchangedMeters is true), it is sent to the StatsD server. +management.metrics.export.statsd.port=8125 # Port of the StatsD server to receive exported metrics. +management.metrics.export.statsd.publish-unchanged-meters=true # Whether to send unchanged meters to the StatsD server. +management.metrics.export.statsd.queue-size=2147483647 # Maximum size of the queue of items waiting to be sent to the StatsD server. +management.metrics.export.wavefront.api-token= # API token used when publishing metrics directly to the Wavefront API host. +management.metrics.export.wavefront.batch-size=10000 # Number of measurements per request to use for this backend. If more measurements are found, then multiple requests will be made. +management.metrics.export.wavefront.connect-timeout=1s # Connection timeout for requests to this backend. +management.metrics.export.wavefront.enabled=true # Whether exporting of metrics to this backend is enabled. +management.metrics.export.wavefront.global-prefix= # Global prefix to separate metrics originating from this app's white box instrumentation from those originating from other Wavefront integrations when viewed in the Wavefront UI. +management.metrics.export.wavefront.num-threads=2 # Number of threads to use with the metrics publishing scheduler. +management.metrics.export.wavefront.read-timeout=10s # Read timeout for requests to this backend. +management.metrics.export.wavefront.source= # Unique identifier for the app instance that is the source of metrics being published to Wavefront. Defaults to the local host name. +management.metrics.export.wavefront.step=10s # Step size (i.e. reporting frequency) to use. +management.metrics.export.wavefront.uri=https://longboard.wavefront.com # URI to ship metrics to. +management.metrics.use-global-registry=true # Whether auto-configured MeterRegistry implementations should be bound to the global static registry on Metrics. +management.metrics.web.client.max-uri-tags=100 # Maximum number of unique URI tag values allowed. After the max number of tag values is reached, metrics with additional tag values are denied by filter. +management.metrics.web.client.requests-metric-name=http.client.requests # Name of the metric for sent requests. +management.metrics.web.server.auto-time-requests=true # Whether requests handled by Spring MVC or WebFlux should be automatically timed. +management.metrics.web.server.requests-metric-name=http.server.requests # Name of the metric for received requests. # ---------------------------------------- @@ -1238,23 +1406,22 @@ spring.metrics.export.triggers.*= # Specific trigger properties per MetricWriter # ---------------------------------------- # DEVTOOLS (DevToolsProperties) -spring.devtools.livereload.enabled=true # Enable a livereload.com compatible server. +spring.devtools.livereload.enabled=true # Whether to enable a livereload.com-compatible server. spring.devtools.livereload.port=35729 # Server port. spring.devtools.restart.additional-exclude= # Additional patterns that should be excluded from triggering a full restart. spring.devtools.restart.additional-paths= # Additional paths to watch for changes. -spring.devtools.restart.enabled=true # Enable automatic restart. -spring.devtools.restart.exclude=META-INF/maven/**,META-INF/resources/**,resources/**,static/**,public/**,templates/**,**/*Test.class,**/*Tests.class,git.properties # Patterns that should be excluded from triggering a full restart. -spring.devtools.restart.poll-interval=1000 # Amount of time (in milliseconds) to wait between polling for classpath changes. -spring.devtools.restart.quiet-period=400 # Amount of quiet time (in milliseconds) required without any classpath changes before a restart is triggered. -spring.devtools.restart.trigger-file= # Name of a specific file that when changed will trigger the restart check. If not specified any classpath file change will trigger the restart. +spring.devtools.restart.enabled=true # Whether to enable automatic restart. +spring.devtools.restart.exclude=META-INF/maven/**,META-INF/resources/**,resources/**,static/**,public/**,templates/**,**/*Test.class,**/*Tests.class,git.properties,META-INF/build-info.properties # Patterns that should be excluded from triggering a full restart. +spring.devtools.restart.log-condition-evaluation-delta=true # Whether to log the condition evaluation delta upon restart. +spring.devtools.restart.poll-interval=1s # Amount of time to wait between polling for classpath changes. +spring.devtools.restart.quiet-period=400ms # Amount of quiet time required without any classpath changes before a restart is triggered. +spring.devtools.restart.trigger-file= # Name of a specific file that, when changed, triggers the restart check. If not specified, any classpath file change triggers the restart. # REMOTE DEVTOOLS (RemoteDevToolsProperties) spring.devtools.remote.context-path=/.~~spring-boot!~ # Context path used to handle the remote connection. -spring.devtools.remote.debug.enabled=true # Enable remote debug support. -spring.devtools.remote.debug.local-port=8000 # Local remote debug server port. spring.devtools.remote.proxy.host= # The host of the proxy to use to connect to the remote application. spring.devtools.remote.proxy.port= # The port of the proxy to use to connect to the remote application. -spring.devtools.remote.restart.enabled=true # Enable remote restart. +spring.devtools.remote.restart.enabled=true # Whether to enable remote restart. spring.devtools.remote.secret= # A shared secret required to establish a connection (required to enable remote support). spring.devtools.remote.secret-header-name=X-AUTH-TOKEN # HTTP header used to transfer the shared secret. @@ -1265,4 +1432,4 @@ spring.devtools.remote.secret-header-name=X-AUTH-TOKEN # HTTP header used to tra spring.test.database.replace=any # Type of existing DataSource to replace. spring.test.mockmvc.print=default # MVC Print option. -``` \ No newline at end of file +``` From 53b231288fd7a6d097291906ec78b60cd950d6d6 Mon Sep 17 00:00:00 2001 From: Zhong Zengqiang Date: Wed, 4 Mar 2020 11:19:30 +0800 Subject: [PATCH 821/865] update B.1 Metadata Format --- SUMMARY.md | 6 +- ...a-data.md => B. Configuration Metadata.md} | 10 +- X. Appendices/B.1. Meta-data format.md | 79 --------------- X. Appendices/B.1. Metadata Format.md | 79 +++++++++++++++ X. Appendices/B.1.2. Property Attributes.md | 96 +++++++++---------- X. Appendices/B.1.3 Hint Attributes.md | 46 ++++----- .../B.1.4. Repeated Metadata Items.md | 3 + .../B.1.4. Repeated meta-data items.md | 3 - 8 files changed, 161 insertions(+), 161 deletions(-) rename X. Appendices/{B. Configuration meta-data.md => B. Configuration Metadata.md} (99%) delete mode 100644 X. Appendices/B.1. Meta-data format.md create mode 100644 X. Appendices/B.1. Metadata Format.md create mode 100644 X. Appendices/B.1.4. Repeated Metadata Items.md delete mode 100644 X. Appendices/B.1.4. Repeated meta-data items.md diff --git a/SUMMARY.md b/SUMMARY.md index eafd8e2c..e7a66b04 100644 --- a/SUMMARY.md +++ b/SUMMARY.md @@ -565,12 +565,12 @@ * [87.6 使用Lettuce来代替Jedis](IX. ‘How-to’ guides/87.6 Use Jedis Instead of Lettuce.md) * [X.附录](X. Appendices/README.md) * [附录A. 常见应用属性](X. Appendices/A. Common application properties.md) - * [附录B. 配置元数据](X. Appendices/B. Configuration meta-data.md) - * [附录B.1. 元数据格式](X. Appendices/B.1. Meta-data format.md) + * [附录B. 配置元数据](X. Appendices/B. Configuration Metadata.md) + * [附录B.1. 元数据格式](X. Appendices/B.1. Metadata Format.md) * [附录B.1.1. Group属性](X. Appendices/B.1.1. Group Attributes.md) * [附录B.1.2. Property属性](X. Appendices/B.1.2. Property Attributes.md) * [附录B.1.3. Hint属性](X. Appendices/B.1.3 Hint Attributes.md) - * [附录B.1.4. 可重复的元数据节点](X. Appendices/B.1.4. Repeated meta-data items.md) + * [附录B.1.4. 可重复的元数据节点](X. Appendices/B.1.4. Repeated Metadata Items.md) * [附录B.2. 提供人工提示](X. Appendices/B.2 Providing manual hints.md) * [附录 B.2.1 值提示](X. Appendices/B.2.1 Value hint.md) * [附录 B.2.2 值提供者](X. Appendices/B.2.2 Value provider.md) diff --git a/X. Appendices/B. Configuration meta-data.md b/X. Appendices/B. Configuration Metadata.md similarity index 99% rename from X. Appendices/B. Configuration meta-data.md rename to X. Appendices/B. Configuration Metadata.md index 1345a2ea..ce7eee09 100644 --- a/X. Appendices/B. Configuration meta-data.md +++ b/X. Appendices/B. Configuration Metadata.md @@ -1,5 +1,5 @@ -### 附录B. 配置元数据 - -Spring Boot jars包含元数据文件,它们提供了所有支持的配置属性详情。这些文件设计用于让IDE开发者能够为使用`application.properties`或`application.yml`文件的用户提供上下文帮助及代码完成功能。 - -主要的元数据文件是在编译器通过处理所有被`@ConfigurationProperties`注解的节点来自动生成的。尽管如此,在实现个别案例或者更加高级的使用案例时,还是可以[手写部分元数据](https://docs.spring.io/spring-boot/docs/2.0.0.RELEASE/reference/htmlsingle/#configuration-metadata-additional-metadata)。 +### 附录B. 配置元数据 + +Spring Boot jars包含元数据文件,它们提供了所有支持的配置属性详情。这些文件设计用于让IDE开发者能够为使用`application.properties`或`application.yml`文件的用户提供上下文帮助及代码完成功能。 + +主要的元数据文件是在编译器通过处理所有被`@ConfigurationProperties`注解的节点来自动生成的。尽管如此,在实现个别案例或者更加高级的使用案例时,还是可以[手写部分元数据](https://docs.spring.io/spring-boot/docs/2.0.0.RELEASE/reference/htmlsingle/#configuration-metadata-additional-metadata)。 diff --git a/X. Appendices/B.1. Meta-data format.md b/X. Appendices/B.1. Meta-data format.md deleted file mode 100644 index 76273e26..00000000 --- a/X. Appendices/B.1. Meta-data format.md +++ /dev/null @@ -1,79 +0,0 @@ -### 附录B.1. 元数据格式 - -配置元数据位于jars文件中的`META-INF/spring-configuration-metadata.json`,它们使用一个具有"groups"或"properties"分类节点的简单JSON格式: -```json -{"groups": [ - { - "name": "server", - "type": "org.springframework.boot.autoconfigure.web.ServerProperties", - "sourceType": "org.springframework.boot.autoconfigure.web.ServerProperties" - }, - { - "name": "spring.jpa.hibernate", - "type": "org.springframework.boot.autoconfigure.orm.jpa.JpaProperties$Hibernate", - "sourceType": "org.springframework.boot.autoconfigure.orm.jpa.JpaProperties", - "sourceMethod": "getHibernate()" - } - ... -],"properties": [ - { - "name": "server.port", - "type": "java.lang.Integer", - "sourceType": "org.springframework.boot.autoconfigure.web.ServerProperties" - }, - { - "name": "server.servlet.path", - "type": "java.lang.String", - "sourceType": "org.springframework.boot.autoconfigure.web.ServerProperties", - "defaultValue": "/" - }, - { - "name": "spring.jpa.hibernate.ddl-auto", - "type": "java.lang.String", - "description": "DDL mode. This is actually a shortcut for the \"hibernate.hbm2ddl.auto\" property.", - "sourceType": "org.springframework.boot.autoconfigure.orm.jpa.JpaProperties$Hibernate" - } - ... -],"hints": [ - { - "name": "spring.jpa.hibernate.ddl-auto", - "values": [ - { - "value": "none", - "description": "Disable DDL handling." - }, - { - "value": "validate", - "description": "Validate the schema, make no changes to the database." - }, - { - "value": "update", - "description": "Update the schema if necessary." - }, - { - "value": "create", - "description": "Create the schema and destroy previous data." - }, - { - "value": "create-drop", - "description": "Create and then destroy the schema at the end of the session." - } - ] - } -]} -``` -每个"property"是一个配置节点,用户可以使用特定的值指定它。例如,`server.port`和`server.servlet.path`可能在`application.properties`中如以下定义: -```properties -server.port=9090 -server.servlet.path=/home -``` -"groups"是高级别的节点,它们本身不指定一个值,但为properties提供一个有上下文关联的分组。例如,`server.port`和`server.servlet.path`属性是`server`组的一部分。 - -**注** 不需要每个"property"都有一个"group",一些属性可以以自己的形式存在。 - - - - - - - diff --git a/X. Appendices/B.1. Metadata Format.md b/X. Appendices/B.1. Metadata Format.md new file mode 100644 index 00000000..5b0ef804 --- /dev/null +++ b/X. Appendices/B.1. Metadata Format.md @@ -0,0 +1,79 @@ +### 附录B.1. 元数据格式 + +配置元数据位于jars文件中的`META-INF/spring-configuration-metadata.json`,它们使用一个具有"groups"或"properties"分类节点的简单JSON格式: +```json +{"groups": [ + { + "name": "server", + "type": "org.springframework.boot.autoconfigure.web.ServerProperties", + "sourceType": "org.springframework.boot.autoconfigure.web.ServerProperties" + }, + { + "name": "spring.jpa.hibernate", + "type": "org.springframework.boot.autoconfigure.orm.jpa.JpaProperties$Hibernate", + "sourceType": "org.springframework.boot.autoconfigure.orm.jpa.JpaProperties", + "sourceMethod": "getHibernate()" + } + ... +],"properties": [ + { + "name": "server.port", + "type": "java.lang.Integer", + "sourceType": "org.springframework.boot.autoconfigure.web.ServerProperties" + }, + { + "name": "server.servlet.path", + "type": "java.lang.String", + "sourceType": "org.springframework.boot.autoconfigure.web.ServerProperties", + "defaultValue": "/" + }, + { + "name": "spring.jpa.hibernate.ddl-auto", + "type": "java.lang.String", + "description": "DDL mode. This is actually a shortcut for the \"hibernate.hbm2ddl.auto\" property.", + "sourceType": "org.springframework.boot.autoconfigure.orm.jpa.JpaProperties$Hibernate" + } + ... +],"hints": [ + { + "name": "spring.jpa.hibernate.ddl-auto", + "values": [ + { + "value": "none", + "description": "Disable DDL handling." + }, + { + "value": "validate", + "description": "Validate the schema, make no changes to the database." + }, + { + "value": "update", + "description": "Update the schema if necessary." + }, + { + "value": "create", + "description": "Create the schema and destroy previous data." + }, + { + "value": "create-drop", + "description": "Create and then destroy the schema at the end of the session." + } + ] + } +]} +``` +每个"property"是一个配置节点,用户可以使用特定的值指定它。例如,`server.port`和`server.servlet.path`可能在`application.properties`中如以下定义: +```properties +server.port=9090 +server.servlet.path=/home +``` +"groups"是高级别的节点,它们本身不指定一个值,但为properties提供一个有上下文关联的分组。例如,`server.port`和`server.servlet.path`属性是`server`组的一部分。 + +**注** 不需要每个"property"都有一个"group",一些属性可以以自己的形式存在。 + + + + + + + diff --git a/X. Appendices/B.1.2. Property Attributes.md b/X. Appendices/B.1.2. Property Attributes.md index 6ee08b14..81cdb135 100644 --- a/X. Appendices/B.1.2. Property Attributes.md +++ b/X. Appendices/B.1.2. Property Attributes.md @@ -1,49 +1,49 @@ -### 附录B.1.2. Property属性 - -`properties`数组中包含的JSON对象可以包含以下属性: - -|名称|类型|目的| -|----|:----|:----| -|`name`|String|property的全名,格式为小写虚线分割的形式(比如`server.servlet.path`)。该属性是强制性的| -|`type`|String|property数据类型的完整的签名。例如`java.lang.String`,但也可以是一个完整的泛型类,比如`java.util.Map`。该属性可以用来指导用户他们可以输入值的类型。为了保持一致,原生类型使用它们的包装类代替,比如`boolean`变成了`java.lang.Boolean`。注意,这个类可能是个从一个字符串转换而来的复杂类型。如果类型未知则该属性会被忽略| -|`description`|String|一个简短的组的描述,用于展示给用户。如果没有描述可用则该属性会被省略。推荐使用一个简短的段落描述,开头提供一个简要的总结,最后一行以句号(`.`)结束| -|`sourceType`|String|贡献property的来源类名。例如,如果property来自一个被`@ConfigurationProperties`注解的类,该属性将包括该类的全限定名。如果来源类型未知则该属性会被忽略| -|`defaultValue`|Object|当property没有定义时使用的默认值。如果property类型是个数组则该属性也可以是个数组。如果默认值未知则该属性会被忽略| -|`deprecated`|Deprecation|指定该property是否弃用。如果该字段没有弃用或该信息未知则该属性会被忽略。更多细节请查看下面| - -每一个`properties`元素的`deprecation`属性包含的JSON对象可以包含如下的属性: - -|名称|类型|目的| -|----|:----|:----| -|`level`|String|弃用的级别,可以是`warning`(默认)或者`error`。当一个属性有`warning`弃用级别,它应当还是会被绑定在环境里。但是,当它有一个`error`启用级别,这个属性就不再被管理,也不再被绑定。 -|`reason`|String|对这个属性被弃用的原因的简短描述。没有原因则可能会被省略。推荐使用一个简短的段落描述,开头提供一个简要的总结,最后一行以句号(`.`)结束| -|`replacement`|String|属性的全名,代替弃用的属性。如果没有代替的属性则会被省略| - -**注** 在Spring Boot 1.3之前,单个的`deprecated`布尔属性可以用来代替`deprecation`元素。在弃用的方式里,这仍旧被支持,但是不应当再被使用。如果没有可用的reason和replacement,一个空的`deprecation`对象应当被设置。 - -Deprecation也可以通过在暴露deprecated属性的getter方法上,添加`@DeprecatedConfigurationProperty`标注的方式,在代码中声明式地指定。比如,让我们假设`app.foo.target`属性令人困惑,被重命名成了`app.foo.name`: -```java -@ConfigurationProperties("app.foo") -public class FooProperties { - - private String name; - - public String getName() { ... } - - public void setName(String name) { ... } - - @DeprecatedConfigurationProperty(replacement = "app.foo.name") - @Deprecated - public String getTarget() { - return getName(); - } - - @Deprecated - public void setTarget(String target) { - setName(target); - } -} -``` -**注** 没有办法设置`level`,因为代码还在处理这个属性,所以一直是`warning`。 - +### 附录B.1.2. Property属性 + +`properties`数组中包含的JSON对象可以包含以下属性: + +|名称|类型|目的| +|----|:----|:----| +|`name`|String|property的全名,格式为小写句点分割的形式(比如`server.servlet.path`)。该属性是强制性的| +|`type`|String|property数据类型的完整的签名。例如`java.lang.String`,但也可以是一个完整的泛型类,比如`java.util.Map`。该属性可以用来指导用户他们可以输入值的类型。为了保持一致,原生类型使用它们的包装类代替,比如`boolean`变成了`java.lang.Boolean`。注意,这个类可能是个从一个字符串转换而来的复杂类型。如果类型未知则该属性会被忽略| +|`description`|String|一个简短的组的描述,用于展示给用户。如果没有描述可用则该属性会被省略。推荐使用一个简短的段落描述,开头提供一个简要的总结,最后一行以句号(`.`)结束| +|`sourceType`|String|贡献property的来源类名。例如,如果property来自一个被`@ConfigurationProperties`注解的类,该属性将包括该类的全限定名。如果来源类型未知则该属性会被忽略| +|`defaultValue`|Object|当property没有定义时使用的默认值。如果property类型是个数组则该属性也可以是个数组。如果默认值未知则该属性会被忽略| +|`deprecated`|Deprecation|指定该property是否弃用。如果该字段没有弃用或该信息未知则该属性会被忽略。下表提供了关于`deprecation`属性的更多详细信息| + +每一个`properties`元素的`deprecation`属性包含的JSON对象可以包含如下的属性: + +|名称|类型|目的| +|----|:----|:----| +|`level`|String|弃用的级别,可以是`warning`(默认)或者`error`。当一个属性有`warning`弃用级别,它应当还是会被绑定在环境里。但是,当它有一个`error`启用级别,这个属性就不再被管理,也不再被绑定。 +|`reason`|String|对这个属性被弃用的原因的简短描述。没有原因则可能会被省略。推荐使用一个简短的段落描述,开头提供一个简要的总结,最后一行以句号(`.`)结束| +|`replacement`|String|属性的全名,代替弃用的属性。如果没有代替的属性则会被省略| + +**注** 在Spring Boot 1.3之前,单个的`deprecated`布尔属性可以用来代替`deprecation`元素。在弃用的方式里,这仍旧被支持,但是不应当再被使用。如果没有可用的reason和replacement,一个空的`deprecation`对象应当被设置。 + +Deprecation也可以通过在暴露deprecated属性的getter方法上,添加`@DeprecatedConfigurationProperty`标注的方式,在代码中声明式地指定。比如,让我们假设`app.acme.target`属性令人困惑,被重命名成了`app.acme.name`。下面的例子展示了如何处理这种情况: +```java +@ConfigurationProperties("app.acme") +public class AcmeProperties { + + private String name; + + public String getName() { ... } + + public void setName(String name) { ... } + + @DeprecatedConfigurationProperty(replacement = "app.acme.name") + @Deprecated + public String getTarget() { + return getName(); + } + + @Deprecated + public void setTarget(String target) { + setName(target); + } +} +``` +**注** 没有办法设置`level`,因为代码还在处理这个属性,所以一直是`warning`。 + 上面的代码确保了弃用的属性依旧工作(在幕后委托给`name`属性)。一旦`getTarget`和`setTarget`方法可以从你的公共API移除,元数据里的自动的弃用提示也会一同消失。如果你想要保持提示,用`error`弃用级别添加手工的元数据,保证用户仍旧会收到关于那个属性的通知。当提供了`replacement`的时候,这会特别有用。 \ No newline at end of file diff --git a/X. Appendices/B.1.3 Hint Attributes.md b/X. Appendices/B.1.3 Hint Attributes.md index 710b7e79..ab3e7446 100644 --- a/X. Appendices/B.1.3 Hint Attributes.md +++ b/X. Appendices/B.1.3 Hint Attributes.md @@ -1,23 +1,23 @@ -### 附录B.1.3. Hint属性 - -`hints`数组中包含的JSON对象能够包含以下属性: - -|名称|类型|目的| -|----|:----|:----| -|`name`|String|该hint参考的property的全名。格式为小写虚线分割的形式(比如`server.servlet.path`)。如果这个属性参考一个map(比如`system.contexts`),hint要么应用到map的key(`system.context.keys`)上,要么应用到value上(`system.context.values`)。该属性是强制性的| -|`values`|ValueHint[]|由`ValueHint`对象定义的有效值的列表(看下面)。每一个入口都定义了值,并可能有一段描述| -|`providers`|ValueProvider[]|由`ValueProvider`对象定义的提供者的列表(看下面)。每一个入口都定义了提供者的名字和它的参数,如果有的话| - -每一个`hint`元素的`values`属性包含的JSON对象可以包含如下的属性: - -|名称|类型|目的| -|----|:----|:----| -|`value`|Object|该hint参考的元素的有效值。如果属性的类型是数组,那么也可以是有效值的数组。该属性是强制性的| -|`description`|String|一个简短的对有效值的描述,用于展示给用户。如果没有描述可用则该属性会被省略。推荐使用一个简短的段落描述,开头提供一个简要的总结,最后一行以句号(`.`)结束| - -每一个`hint`元素的`providers`属性包含的JSON对象可以包含如下的属性: - -|名称|类型|目的| -|----|:----|:----| -|`name`|String|提供者的名字,为该hint参考的元素提供额外的内容。| -|`parameters`|JSON object|提供者支持的任何额外的内容(更多细节,请查看提供者的文档)| +### 附录B.1.3. Hint属性 + +`hints`数组中包含的JSON对象能够包含以下属性: + +|名称|类型|目的| +|----|:----|:----| +|`name`|String|该hint参考的property的全名。格式为小写句点分割的形式(比如`server.servlet.path`)。如果这个属性参考一个map(比如`system.contexts`),hint要么应用到map的key(`system.context.keys`)上,要么应用到value上(`system.context.values`)。该属性是强制性的| +|`values`|ValueHint[]|由`ValueHint`对象定义的有效值的列表(在下表中说明)。每一个入口都定义了值,并可能有一段描述| +|`providers`|ValueProvider[]|由`ValueProvider`对象定义的提供者的列表(本文档稍后将对此进行描述)。每一个入口都定义了提供者的名字和它的参数,如果有的话| + +每一个`hint`元素的`values`属性包含的JSON对象可以包含如下的属性: + +|名称|类型|目的| +|----|:----|:----| +|`value`|Object|该hint参考的元素的有效值。如果属性的类型是数组,那么也可以是有效值的数组。该属性是强制性的| +|`description`|String|一个简短的对有效值的描述,用于展示给用户。如果没有描述可用则该属性会被省略。推荐使用一个简短的段落描述,开头提供一个简要的总结,最后一行以句号(`.`)结束| + +每一个`hint`元素的`providers`属性包含的JSON对象可以包含如下的属性: + +|名称|类型|目的| +|----|:----|:----| +|`name`|String|提供者的名字,为该hint参考的元素提供额外的内容。| +|`parameters`|JSON object|提供者支持的任何额外的内容(更多细节,请查看提供者的文档)| diff --git a/X. Appendices/B.1.4. Repeated Metadata Items.md b/X. Appendices/B.1.4. Repeated Metadata Items.md new file mode 100644 index 00000000..01ec12fa --- /dev/null +++ b/X. Appendices/B.1.4. Repeated Metadata Items.md @@ -0,0 +1,3 @@ +### 附录B.1.4. 可重复的元数据节点 + +在同一个元数据文件中可以有多个"property"和"group"名称都相同的对象。例如,Spring Boot将`spring.datasource`属性绑定到Hikari,Tomcat和DBCP类,并且每个都潜在的提供了重复的属性名。虽然多次出现在元数据中的相同名称不应该是常见的,但是元数据的使用者应该注意确保他们支持它。 diff --git a/X. Appendices/B.1.4. Repeated meta-data items.md b/X. Appendices/B.1.4. Repeated meta-data items.md deleted file mode 100644 index 00dce5ad..00000000 --- a/X. Appendices/B.1.4. Repeated meta-data items.md +++ /dev/null @@ -1,3 +0,0 @@ -### 附录B.1.4. 可重复的元数据节点 - -在同一个元数据文件中出现多次相同名称的"property"和"group"对象是可以接受的。例如,Spring Boot将`spring.datasource`属性绑定到Hikari,Tomcat和DBCP类,并且每个都潜在的提供了重复的属性名。这些元数据的消费者需要确保他们支持这样的场景。 From 925266803c69d71a8154e16c3b835561d44bf82e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E7=83=AD=E5=BF=83=E5=B8=82=E6=B0=91=E9=92=9F=E5=B0=8F?= =?UTF-8?q?=E5=BC=BA?= Date: Wed, 4 Mar 2020 11:55:22 +0800 Subject: [PATCH 822/865] Update README.md --- README.md | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/README.md b/README.md index d672fd60..2f8e678d 100644 --- a/README.md +++ b/README.md @@ -13,3 +13,9 @@ GitBook : [Spring Boot参考指南](https://jack80342.gitbook.io/spring-boot/) GitHub : [Spring Boot参考指南](https://github.com/jack80342/Spring-Boot-Reference-Guide) 我从二零一七年夏天开始翻译这份文档。这份文档在[qibaoguang](https://github.com/qibaoguang)的1.4.1版本上新增了Spring Boot 2.0.0版本的内容,对修改的地方也做了更新。 + +如果这份文档帮到了你🙃,你可以给我家的小白买几条小鱼干🐟。 + +|WeChatPay|ALipay|Paypal| +|:----|:----|:----| +|![WeChatPay](https://github.com/jack80342/Materials/blob/master/wechatpay.jpg)|![ALiPay](https://github.com/jack80342/Materials/blob/master/alipay.jpg)|![PayPal](https://github.com/jack80342/Materials/blob/master/paypal.PNG)| From 7daeb1276d472d5e72a8e3f035338f4b1e1835b3 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E7=83=AD=E5=BF=83=E5=B8=82=E6=B0=91=E9=92=9F=E5=B0=8F?= =?UTF-8?q?=E5=BC=BA?= Date: Wed, 4 Mar 2020 22:39:05 +0800 Subject: [PATCH 823/865] Update README.md --- README.md | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/README.md b/README.md index 2f8e678d..14e3ff8d 100644 --- a/README.md +++ b/README.md @@ -16,6 +16,6 @@ GitHub : [Spring Boot参考指南](https://github.com/jack80342/Spring-Boot-Refe 如果这份文档帮到了你🙃,你可以给我家的小白买几条小鱼干🐟。 -|WeChatPay|ALipay|Paypal| -|:----|:----|:----| -|![WeChatPay](https://github.com/jack80342/Materials/blob/master/wechatpay.jpg)|![ALiPay](https://github.com/jack80342/Materials/blob/master/alipay.jpg)|![PayPal](https://github.com/jack80342/Materials/blob/master/paypal.PNG)| +|WeChatPay|ALipay| +|:----|:----| +|![WeChatPay](https://github.com/jack80342/Materials/blob/master/wechatpay.jpg)|![ALiPay](https://github.com/jack80342/Materials/blob/master/alipay.jpg)| From 3e50c03571410c7486189f1e9f1bf49e626b730a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E7=83=AD=E5=BF=83=E5=B8=82=E6=B0=91=E9=92=9F=E5=B0=8F?= =?UTF-8?q?=E5=BC=BA?= Date: Thu, 5 Mar 2020 13:22:00 +0800 Subject: [PATCH 824/865] Update README.md --- README.md | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/README.md b/README.md index 14e3ff8d..2fad938c 100644 --- a/README.md +++ b/README.md @@ -16,6 +16,6 @@ GitHub : [Spring Boot参考指南](https://github.com/jack80342/Spring-Boot-Refe 如果这份文档帮到了你🙃,你可以给我家的小白买几条小鱼干🐟。 -|WeChatPay|ALipay| -|:----|:----| -|![WeChatPay](https://github.com/jack80342/Materials/blob/master/wechatpay.jpg)|![ALiPay](https://github.com/jack80342/Materials/blob/master/alipay.jpg)| +|WeChatPay|ALipay|[Paypal](https://www.paypal.me/jack8034)| +|:----|:----|:----| +|![WeChatPay](https://github.com/jack80342/Materials/blob/master/wechatpay.jpg)|![ALiPay](https://github.com/jack80342/Materials/blob/master/alipay.jpg)|![PayPal](https://github.com/jack80342/Materials/blob/master/paypal.PNG)| From 75caa1681d84f9f7588598dd5ea135304c86087c Mon Sep 17 00:00:00 2001 From: Zhong Zengqiang Date: Sat, 7 Mar 2020 10:16:26 +0800 Subject: [PATCH 825/865] =?UTF-8?q?update=20B.2=20Providing=20Manual=20Hin?= =?UTF-8?q?ts=E3=80=81B.2.1=20Value=20Hint?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- SUMMARY.md | 6 +- X. Appendices/B.2 Providing Manual Hints.md | 7 + X. Appendices/B.2 Providing manual hints.md | 13 +- X. Appendices/B.2.1 Value Hint.md | 32 +++ X. Appendices/B.2.1 Value hint.md | 64 +++--- X. Appendices/B.2.2 Value Provider.md | 222 ++++++++++++++++++++ 6 files changed, 303 insertions(+), 41 deletions(-) create mode 100644 X. Appendices/B.2 Providing Manual Hints.md create mode 100644 X. Appendices/B.2.1 Value Hint.md create mode 100644 X. Appendices/B.2.2 Value Provider.md diff --git a/SUMMARY.md b/SUMMARY.md index e7a66b04..29265723 100644 --- a/SUMMARY.md +++ b/SUMMARY.md @@ -571,9 +571,9 @@ * [附录B.1.2. Property属性](X. Appendices/B.1.2. Property Attributes.md) * [附录B.1.3. Hint属性](X. Appendices/B.1.3 Hint Attributes.md) * [附录B.1.4. 可重复的元数据节点](X. Appendices/B.1.4. Repeated Metadata Items.md) - * [附录B.2. 提供人工提示](X. Appendices/B.2 Providing manual hints.md) - * [附录 B.2.1 值提示](X. Appendices/B.2.1 Value hint.md) - * [附录 B.2.2 值提供者](X. Appendices/B.2.2 Value provider.md) + * [附录B.2. 提供人工提示](X. Appendices/B.2 Providing Manual Hints.md) + * [附录 B.2.1 值提示](X. Appendices/B.2.1 Value Hint.md) + * [附录 B.2.2 值提供者](X. Appendices/B.2.2 Value Provider.md) * [附录B.3. 使用注解处理器产生自己的元数据](X. Appendices/B.3. Generating your own meta-data using the annotation processor.md) * [附录 B.3.1. 内嵌属性](X. Appendices/B.3.1. Nested properties.md) * [附录 B.3.2. 添加其他的元数据](X. Appendices/B.3.2. Adding additional meta-data.md) diff --git a/X. Appendices/B.2 Providing Manual Hints.md b/X. Appendices/B.2 Providing Manual Hints.md new file mode 100644 index 00000000..3d2db71c --- /dev/null +++ b/X. Appendices/B.2 Providing Manual Hints.md @@ -0,0 +1,7 @@ +### 附录B.2 提供人工提示 + +为了优化用户体验,协助用户配置一个给定的属性,你可以提供额外的元数据: + +- 描述一个属性的可能值的列表。 +- 联系提供者,将良好定义的语义添加到属性上。这样,工具就可以基于工程的上下文,发现可能值的列表。 + diff --git a/X. Appendices/B.2 Providing manual hints.md b/X. Appendices/B.2 Providing manual hints.md index a024b4f9..3d2db71c 100644 --- a/X. Appendices/B.2 Providing manual hints.md +++ b/X. Appendices/B.2 Providing manual hints.md @@ -1,6 +1,7 @@ -### 附录B.2 提供人工提示 - -为了优化用户体验,协助用户配置一个给定的属性,你可以提供额外的元数据: - -1. 描述一个属性的可能值的列表。 -2. 联系提供者,将良好定义的语义添加到属性上。这样,工具就可以基于工程的上下文,发现可能值的列表。 \ No newline at end of file +### 附录B.2 提供人工提示 + +为了优化用户体验,协助用户配置一个给定的属性,你可以提供额外的元数据: + +- 描述一个属性的可能值的列表。 +- 联系提供者,将良好定义的语义添加到属性上。这样,工具就可以基于工程的上下文,发现可能值的列表。 + diff --git a/X. Appendices/B.2.1 Value Hint.md b/X. Appendices/B.2.1 Value Hint.md new file mode 100644 index 00000000..6f408a95 --- /dev/null +++ b/X. Appendices/B.2.1 Value Hint.md @@ -0,0 +1,32 @@ +### 附录B.2.1 值提示 + +每一个hint的`name`属性参考了property的`name`。在[上面最初的例子](https://docs.spring.io/spring-boot/docs/2.0.0.RELEASE/reference/htmlsingle/#configuration-metadata-format)里,我们为`spring.jpa.hibernate.ddl-auto`属性提供了5个值:`none`、`validate`、`update`、`create`和`create-drop`。每个值也可以有一个描述。 + +如果你的属性不是`Map`类型,你可以为key和value一起提供hint(但不是为map它自己)。特殊的`.keys`和`.values`后缀必须被分别地用于参考keys和values。 + +让我们假设一个`sample.contexts`,它把神奇的String值映射到一个Integer: +```java +@ConfigurationProperties("sample") +public class SampleProperties { + + private Map contexts; + // getters and setters +} +``` +例如,神奇的值是`sample1`和`sample2`。为了给key提供额外的内容帮助,你可以将以下内容添加到[模块的手工元数据](https://docs.spring.io/spring-boot/docs/2.0.0.RELEASE/reference/htmlsingle/#configuration-metadata-additional-metadata): +```json +{"hints": [ + { + "name": "sample.contexts.keys", + "values": [ + { + "value": "sample1" + }, + { + "value": "sample2" + } + ] + } +]} +``` +**注** 我们建议你对这两个值使用`Enum`。如果你的IDE支持,这是目前为止实现自动补全的最有效的方式。 \ No newline at end of file diff --git a/X. Appendices/B.2.1 Value hint.md b/X. Appendices/B.2.1 Value hint.md index ab8b63e0..6f408a95 100644 --- a/X. Appendices/B.2.1 Value hint.md +++ b/X. Appendices/B.2.1 Value hint.md @@ -1,32 +1,32 @@ -### 附录B.2.1 值提示 - -每一个hint的`name`属性参考了property的`name`。在上面最初的例子里,我们为`spring.jpa.hibernate.ddl-auto`属性提供了5个值:`none`,`validate`,`update`,`create`和`create-drop`。每个值也可以有一个描述。 - -如果你的属性不是`Map`类型,你可以为key和value一起提供hint(但不是为map它自己)。特殊的`.keys`和`.values`后缀必须被分别地用于参考keys和values。 - -让我们假设一个`foo.contexts`,它把神奇的String值映射到一个Integer: -```java -@ConfigurationProperties("foo") -public class FooProperties { - - private Map contexts; - // getters and setters -} -``` -例如,神奇的值是foo和bar。为了给key提供额外的内容帮助,你可以将以下内容添加到[模块的手工元数据](https://docs.spring.io/spring-boot/docs/2.0.0.RELEASE/reference/htmlsingle/#configuration-metadata-additional-metadata): -```json -{"hints": [ - { - "name": "foo.contexts.keys", - "values": [ - { - "value": "foo" - }, - { - "value": "bar" - } - ] - } -]} -``` -**注** 当然,对那些有两个值的,你应当有一个替代的`Enum`。如果你的IDE支持,这是目前为止实现自动补全的最有效的方式。 \ No newline at end of file +### 附录B.2.1 值提示 + +每一个hint的`name`属性参考了property的`name`。在[上面最初的例子](https://docs.spring.io/spring-boot/docs/2.0.0.RELEASE/reference/htmlsingle/#configuration-metadata-format)里,我们为`spring.jpa.hibernate.ddl-auto`属性提供了5个值:`none`、`validate`、`update`、`create`和`create-drop`。每个值也可以有一个描述。 + +如果你的属性不是`Map`类型,你可以为key和value一起提供hint(但不是为map它自己)。特殊的`.keys`和`.values`后缀必须被分别地用于参考keys和values。 + +让我们假设一个`sample.contexts`,它把神奇的String值映射到一个Integer: +```java +@ConfigurationProperties("sample") +public class SampleProperties { + + private Map contexts; + // getters and setters +} +``` +例如,神奇的值是`sample1`和`sample2`。为了给key提供额外的内容帮助,你可以将以下内容添加到[模块的手工元数据](https://docs.spring.io/spring-boot/docs/2.0.0.RELEASE/reference/htmlsingle/#configuration-metadata-additional-metadata): +```json +{"hints": [ + { + "name": "sample.contexts.keys", + "values": [ + { + "value": "sample1" + }, + { + "value": "sample2" + } + ] + } +]} +``` +**注** 我们建议你对这两个值使用`Enum`。如果你的IDE支持,这是目前为止实现自动补全的最有效的方式。 \ No newline at end of file diff --git a/X. Appendices/B.2.2 Value Provider.md b/X. Appendices/B.2.2 Value Provider.md new file mode 100644 index 00000000..183a0a36 --- /dev/null +++ b/X. Appendices/B.2.2 Value Provider.md @@ -0,0 +1,222 @@ +### 附录B.2.2 值提供者 + +提供者是将语义附加到属性上的一种强大的方式。我们在下面的章节里定义了官方的提供者,你可以为你自己的提示使用它们。但是,必须记住:你最喜欢的IDE可能实现了其中的一部分,或者什么也没有实现。它也可以最后提供它自己。 + +**注** 由于这是一个新特性,IDE供应商将不得不追上这个新特性。 + +下面👇的表格总结了支持的提供者的列表: + +|名称|描述| +|----|:----| +|`any`|允许提供额外的值| +|`class-reference`|自动补全项目里可用的类。通常被一个由`目标`参数指定的基础的类约束| +|`handle-as`|操作属性,就好像它是由强制的`目标`参数定义的类型一样| +|`logger-name`|自动补全有效的记录器名。典型地,目前项目里可用的包名和类名会被自动补全| +|`spring-bean-reference`|自动补全当前项目里可用的bean的名字。通常被一个由`目标`参数指定的基础的类约束| +|`spring-profile-name`|自动补全当前项目里可用的Spring profile的名字| + +**提示** 对于一个给定的属性,只能有一个有效的提供者。但是,如果可以以某种方式共同管理属性,你也可以指定多个提供者。确保把最强大的提供者放在第一位,因为IDE必须使用它能够处理的JSON部分里的第一个。如果对于一个给定的属性,没有提供者提供支持,也不会有特殊的内容帮助被提供。 + +**Any** + +The any provider permits any additional values to be provided. Regular value validation based on the property type should be applied if this is supported. + +This provider will be typically used if you have a list of values and any extra values are still to be considered as valid. + +The example below offers on and off as auto-completion values for system.state; any other value is also allowed: + +{"hints": [ + { + "name": "system.state", + "values": [ + { + "value": "on" + }, + { + "value": "off" + } + ], + "providers": [ + { + "name": "any" + } + ] + } +]} +Class reference + +The class-reference provider auto-completes classes available in the project. This provider supports these parameters: + +Parameter Type Default value Description +target + +String (Class) + +none + +The fully qualified name of the class that should be assignable to the chosen value. Typically used to filter out non candidate classes. Note that this information can be provided by the type itself by exposing a class with the appropriate upper bound. + +concrete + +boolean + +true + +Specify if only concrete classes are to be considered as valid candidates. + +The meta-data snippet below corresponds to the standard server.servlet.jsp.class-name property that defines the JspServlet class name to use: + +{"hints": [ + { + "name": "server.servlet.jsp.class-name", + "providers": [ + { + "name": "class-reference", + "parameters": { + "target": "javax.servlet.http.HttpServlet" + } + } + ] + } +]} +Handle As + +The handle-as provider allows you to substitute the type of the property to a more high-level type. This typically happens when the property has a java.lang.String type because you don’t want your configuration classes to rely on classes that may not be on the classpath. This provider supports these parameters: + +Parameter Type Default value Description +target + +String (Class) + +none + +The fully qualified name of the type to consider for the property. This parameter is mandatory. + +The following types can be used: + +Any java.lang.Enum that lists the possible values for the property (By all means, try to define the property with the Enum type instead as no further hint should be required for the IDE to auto-complete the values). +java.nio.charset.Charset: auto-completion of charset/encoding values (e.g. UTF-8) +java.util.Locale: auto-completion of locales (e.g. en_US) +org.springframework.util.MimeType: auto-completion of content type values (e.g. text/plain) +org.springframework.core.io.Resource: auto-completion of Spring’s Resource abstraction to refer to a file on the filesystem or on the classpath. (e.g. classpath:/foo.properties) +[Note] +If multiple values can be provided, use a Collection or Array type to teach the IDE about it. +The meta-data snippet below corresponds to the standard liquibase.change-log property that defines the path to the changelog to use. It is actually used internally as a org.springframework.core.io.Resource but cannot be exposed as such as we need to keep the original String value to pass it to the Liquibase API. + +{"hints": [ + { + "name": "liquibase.change-log", + "providers": [ + { + "name": "handle-as", + "parameters": { + "target": "org.springframework.core.io.Resource" + } + } + ] + } +]} +Logger name + +The logger-name provider auto-completes valid logger names. Typically, package and class names available in the current project can be auto-completed. Specific frameworks may have extra magic logger names that could be supported as well. + +Since a logger name can be any arbitrary name, really, this provider should allow any value but could highlight valid packages and class names that are not available in the project’s classpath. + +The meta-data snippet below corresponds to the standard logging.level property, keys are logger names and values correspond to the standard log levels or any custom level: + +{"hints": [ + { + "name": "logging.level.keys", + "values": [ + { + "value": "root", + "description": "Root logger used to assign the default logging level." + } + ], + "providers": [ + { + "name": "logger-name" + } + ] + }, + { + "name": "logging.level.values", + "values": [ + { + "value": "trace" + }, + { + "value": "debug" + }, + { + "value": "info" + }, + { + "value": "warn" + }, + { + "value": "error" + }, + { + "value": "fatal" + }, + { + "value": "off" + } + + ], + "providers": [ + { + "name": "any" + } + ] + } +]} +Spring bean reference + +The spring-bean-reference provider auto-completes the beans that are defined in the configuration of the current project. This provider supports these parameters: + +Parameter Type Default value Description +target + +String (Class) + +none + +The fully qualified name of the bean class that should be assignable to the candidate. Typically used to filter out non candidate beans. + +The meta-data snippet below corresponds to the standard spring.jmx.server property that defines the name of the MBeanServer bean to use: + +{"hints": [ + { + "name": "spring.jmx.server", + "providers": [ + { + "name": "spring-bean-reference", + "parameters": { + "target": "javax.management.MBeanServer" + } + } + ] + } +]} +[Note] +The binder is not aware of the meta-data so if you provide that hint, you will still need to transform the bean name into an actual Bean reference using the ApplicationContext. +Spring profile name + +The spring-profile-name provider auto-completes the Spring profiles that are defined in the configuration of the current project. + +The meta-data snippet below corresponds to the standard spring.profiles.active property that defines the name of the Spring profile(s) to enable: + +{"hints": [ + { + "name": "spring.profiles.active", + "providers": [ + { + "name": "spring-profile-name" + } + ] + } +]} + + From 2fb192c44c9e63bb9d1340ac71b362ecd3bcc772 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E7=83=AD=E5=BF=83=E5=B8=82=E6=B0=91=E9=92=9F=E5=B0=8F?= =?UTF-8?q?=E5=BC=BA?= Date: Sat, 7 Mar 2020 10:19:45 +0800 Subject: [PATCH 826/865] Delete B.2 Providing manual hints.md --- X. Appendices/B.2 Providing manual hints.md | 7 ------- 1 file changed, 7 deletions(-) delete mode 100644 X. Appendices/B.2 Providing manual hints.md diff --git a/X. Appendices/B.2 Providing manual hints.md b/X. Appendices/B.2 Providing manual hints.md deleted file mode 100644 index 3d2db71c..00000000 --- a/X. Appendices/B.2 Providing manual hints.md +++ /dev/null @@ -1,7 +0,0 @@ -### 附录B.2 提供人工提示 - -为了优化用户体验,协助用户配置一个给定的属性,你可以提供额外的元数据: - -- 描述一个属性的可能值的列表。 -- 联系提供者,将良好定义的语义添加到属性上。这样,工具就可以基于工程的上下文,发现可能值的列表。 - From 242f5b61ebea1f91a00413e94b103dceeef873dd Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E7=83=AD=E5=BF=83=E5=B8=82=E6=B0=91=E9=92=9F=E5=B0=8F?= =?UTF-8?q?=E5=BC=BA?= Date: Sat, 7 Mar 2020 10:20:27 +0800 Subject: [PATCH 827/865] Delete B.2.1 Value hint.md --- X. Appendices/B.2.1 Value hint.md | 32 ------------------------------- 1 file changed, 32 deletions(-) delete mode 100644 X. Appendices/B.2.1 Value hint.md diff --git a/X. Appendices/B.2.1 Value hint.md b/X. Appendices/B.2.1 Value hint.md deleted file mode 100644 index 6f408a95..00000000 --- a/X. Appendices/B.2.1 Value hint.md +++ /dev/null @@ -1,32 +0,0 @@ -### 附录B.2.1 值提示 - -每一个hint的`name`属性参考了property的`name`。在[上面最初的例子](https://docs.spring.io/spring-boot/docs/2.0.0.RELEASE/reference/htmlsingle/#configuration-metadata-format)里,我们为`spring.jpa.hibernate.ddl-auto`属性提供了5个值:`none`、`validate`、`update`、`create`和`create-drop`。每个值也可以有一个描述。 - -如果你的属性不是`Map`类型,你可以为key和value一起提供hint(但不是为map它自己)。特殊的`.keys`和`.values`后缀必须被分别地用于参考keys和values。 - -让我们假设一个`sample.contexts`,它把神奇的String值映射到一个Integer: -```java -@ConfigurationProperties("sample") -public class SampleProperties { - - private Map contexts; - // getters and setters -} -``` -例如,神奇的值是`sample1`和`sample2`。为了给key提供额外的内容帮助,你可以将以下内容添加到[模块的手工元数据](https://docs.spring.io/spring-boot/docs/2.0.0.RELEASE/reference/htmlsingle/#configuration-metadata-additional-metadata): -```json -{"hints": [ - { - "name": "sample.contexts.keys", - "values": [ - { - "value": "sample1" - }, - { - "value": "sample2" - } - ] - } -]} -``` -**注** 我们建议你对这两个值使用`Enum`。如果你的IDE支持,这是目前为止实现自动补全的最有效的方式。 \ No newline at end of file From 41281e32a24dfbd71cb4b7d6a909206c376b5238 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E7=83=AD=E5=BF=83=E5=B8=82=E6=B0=91=E9=92=9F=E5=B0=8F?= =?UTF-8?q?=E5=BC=BA?= Date: Sat, 7 Mar 2020 10:21:03 +0800 Subject: [PATCH 828/865] Delete B.2.2 Value provider.md --- X. Appendices/B.2.2 Value provider.md | 222 -------------------------- 1 file changed, 222 deletions(-) delete mode 100644 X. Appendices/B.2.2 Value provider.md diff --git a/X. Appendices/B.2.2 Value provider.md b/X. Appendices/B.2.2 Value provider.md deleted file mode 100644 index 183a0a36..00000000 --- a/X. Appendices/B.2.2 Value provider.md +++ /dev/null @@ -1,222 +0,0 @@ -### 附录B.2.2 值提供者 - -提供者是将语义附加到属性上的一种强大的方式。我们在下面的章节里定义了官方的提供者,你可以为你自己的提示使用它们。但是,必须记住:你最喜欢的IDE可能实现了其中的一部分,或者什么也没有实现。它也可以最后提供它自己。 - -**注** 由于这是一个新特性,IDE供应商将不得不追上这个新特性。 - -下面👇的表格总结了支持的提供者的列表: - -|名称|描述| -|----|:----| -|`any`|允许提供额外的值| -|`class-reference`|自动补全项目里可用的类。通常被一个由`目标`参数指定的基础的类约束| -|`handle-as`|操作属性,就好像它是由强制的`目标`参数定义的类型一样| -|`logger-name`|自动补全有效的记录器名。典型地,目前项目里可用的包名和类名会被自动补全| -|`spring-bean-reference`|自动补全当前项目里可用的bean的名字。通常被一个由`目标`参数指定的基础的类约束| -|`spring-profile-name`|自动补全当前项目里可用的Spring profile的名字| - -**提示** 对于一个给定的属性,只能有一个有效的提供者。但是,如果可以以某种方式共同管理属性,你也可以指定多个提供者。确保把最强大的提供者放在第一位,因为IDE必须使用它能够处理的JSON部分里的第一个。如果对于一个给定的属性,没有提供者提供支持,也不会有特殊的内容帮助被提供。 - -**Any** - -The any provider permits any additional values to be provided. Regular value validation based on the property type should be applied if this is supported. - -This provider will be typically used if you have a list of values and any extra values are still to be considered as valid. - -The example below offers on and off as auto-completion values for system.state; any other value is also allowed: - -{"hints": [ - { - "name": "system.state", - "values": [ - { - "value": "on" - }, - { - "value": "off" - } - ], - "providers": [ - { - "name": "any" - } - ] - } -]} -Class reference - -The class-reference provider auto-completes classes available in the project. This provider supports these parameters: - -Parameter Type Default value Description -target - -String (Class) - -none - -The fully qualified name of the class that should be assignable to the chosen value. Typically used to filter out non candidate classes. Note that this information can be provided by the type itself by exposing a class with the appropriate upper bound. - -concrete - -boolean - -true - -Specify if only concrete classes are to be considered as valid candidates. - -The meta-data snippet below corresponds to the standard server.servlet.jsp.class-name property that defines the JspServlet class name to use: - -{"hints": [ - { - "name": "server.servlet.jsp.class-name", - "providers": [ - { - "name": "class-reference", - "parameters": { - "target": "javax.servlet.http.HttpServlet" - } - } - ] - } -]} -Handle As - -The handle-as provider allows you to substitute the type of the property to a more high-level type. This typically happens when the property has a java.lang.String type because you don’t want your configuration classes to rely on classes that may not be on the classpath. This provider supports these parameters: - -Parameter Type Default value Description -target - -String (Class) - -none - -The fully qualified name of the type to consider for the property. This parameter is mandatory. - -The following types can be used: - -Any java.lang.Enum that lists the possible values for the property (By all means, try to define the property with the Enum type instead as no further hint should be required for the IDE to auto-complete the values). -java.nio.charset.Charset: auto-completion of charset/encoding values (e.g. UTF-8) -java.util.Locale: auto-completion of locales (e.g. en_US) -org.springframework.util.MimeType: auto-completion of content type values (e.g. text/plain) -org.springframework.core.io.Resource: auto-completion of Spring’s Resource abstraction to refer to a file on the filesystem or on the classpath. (e.g. classpath:/foo.properties) -[Note] -If multiple values can be provided, use a Collection or Array type to teach the IDE about it. -The meta-data snippet below corresponds to the standard liquibase.change-log property that defines the path to the changelog to use. It is actually used internally as a org.springframework.core.io.Resource but cannot be exposed as such as we need to keep the original String value to pass it to the Liquibase API. - -{"hints": [ - { - "name": "liquibase.change-log", - "providers": [ - { - "name": "handle-as", - "parameters": { - "target": "org.springframework.core.io.Resource" - } - } - ] - } -]} -Logger name - -The logger-name provider auto-completes valid logger names. Typically, package and class names available in the current project can be auto-completed. Specific frameworks may have extra magic logger names that could be supported as well. - -Since a logger name can be any arbitrary name, really, this provider should allow any value but could highlight valid packages and class names that are not available in the project’s classpath. - -The meta-data snippet below corresponds to the standard logging.level property, keys are logger names and values correspond to the standard log levels or any custom level: - -{"hints": [ - { - "name": "logging.level.keys", - "values": [ - { - "value": "root", - "description": "Root logger used to assign the default logging level." - } - ], - "providers": [ - { - "name": "logger-name" - } - ] - }, - { - "name": "logging.level.values", - "values": [ - { - "value": "trace" - }, - { - "value": "debug" - }, - { - "value": "info" - }, - { - "value": "warn" - }, - { - "value": "error" - }, - { - "value": "fatal" - }, - { - "value": "off" - } - - ], - "providers": [ - { - "name": "any" - } - ] - } -]} -Spring bean reference - -The spring-bean-reference provider auto-completes the beans that are defined in the configuration of the current project. This provider supports these parameters: - -Parameter Type Default value Description -target - -String (Class) - -none - -The fully qualified name of the bean class that should be assignable to the candidate. Typically used to filter out non candidate beans. - -The meta-data snippet below corresponds to the standard spring.jmx.server property that defines the name of the MBeanServer bean to use: - -{"hints": [ - { - "name": "spring.jmx.server", - "providers": [ - { - "name": "spring-bean-reference", - "parameters": { - "target": "javax.management.MBeanServer" - } - } - ] - } -]} -[Note] -The binder is not aware of the meta-data so if you provide that hint, you will still need to transform the bean name into an actual Bean reference using the ApplicationContext. -Spring profile name - -The spring-profile-name provider auto-completes the Spring profiles that are defined in the configuration of the current project. - -The meta-data snippet below corresponds to the standard spring.profiles.active property that defines the name of the Spring profile(s) to enable: - -{"hints": [ - { - "name": "spring.profiles.active", - "providers": [ - { - "name": "spring-profile-name" - } - ] - } -]} - - From 752742637c3640bcc42e4cd7b906b0f700125ff7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E7=83=AD=E5=BF=83=E5=B8=82=E6=B0=91=E9=92=9F=E5=B0=8F?= =?UTF-8?q?=E5=BC=BA?= Date: Sat, 14 Mar 2020 21:45:13 +0800 Subject: [PATCH 829/865] Update B.2.2 Value Provider.md --- X. Appendices/B.2.2 Value Provider.md | 324 +++++++++++++------------- 1 file changed, 156 insertions(+), 168 deletions(-) diff --git a/X. Appendices/B.2.2 Value Provider.md b/X. Appendices/B.2.2 Value Provider.md index 183a0a36..312346b0 100644 --- a/X. Appendices/B.2.2 Value Provider.md +++ b/X. Appendices/B.2.2 Value Provider.md @@ -2,7 +2,7 @@ 提供者是将语义附加到属性上的一种强大的方式。我们在下面的章节里定义了官方的提供者,你可以为你自己的提示使用它们。但是,必须记住:你最喜欢的IDE可能实现了其中的一部分,或者什么也没有实现。它也可以最后提供它自己。 -**注** 由于这是一个新特性,IDE供应商将不得不追上这个新特性。 +**注** 由于这是一个新特性,IDE供应商必须跟上它的工作方式。采用时间自然会有所不同。 下面👇的表格总结了支持的提供者的列表: @@ -15,208 +15,196 @@ |`spring-bean-reference`|自动补全当前项目里可用的bean的名字。通常被一个由`目标`参数指定的基础的类约束| |`spring-profile-name`|自动补全当前项目里可用的Spring profile的名字| -**提示** 对于一个给定的属性,只能有一个有效的提供者。但是,如果可以以某种方式共同管理属性,你也可以指定多个提供者。确保把最强大的提供者放在第一位,因为IDE必须使用它能够处理的JSON部分里的第一个。如果对于一个给定的属性,没有提供者提供支持,也不会有特殊的内容帮助被提供。 +**注** 对于一个给定的属性,只能有一个有效的提供者。但是,如果可以以某种方式共同管理属性,你也可以指定多个提供者。确保把最强大的提供者放在第一位,因为IDE必须使用它能够处理的JSON部分里的第一个。如果对于一个给定的属性,没有提供者提供支持,也不会有特殊的内容帮助被提供。 **Any** -The any provider permits any additional values to be provided. Regular value validation based on the property type should be applied if this is supported. +特殊的**any**提供程序值允许提供任何附加值。如果支持,应该应用基于属性类型的常规值验证。 -This provider will be typically used if you have a list of values and any extra values are still to be considered as valid. - -The example below offers on and off as auto-completion values for system.state; any other value is also allowed: +如果你有一个值列表,并且任何额外的值仍然被认为是有效的,则通常使用此提供程序。 +下面的例子提供了`on`和`off`作为`system.state`的自动完成值: +```json {"hints": [ - { - "name": "system.state", - "values": [ - { - "value": "on" - }, - { - "value": "off" - } - ], - "providers": [ - { - "name": "any" - } - ] - } + { + "name": "system.state", + "values": [ + { + "value": "on" + }, + { + "value": "off" + } + ], + "providers": [ + { + "name": "any" + } + ] + } ]} -Class reference - -The class-reference provider auto-completes classes available in the project. This provider supports these parameters: - -Parameter Type Default value Description -target - -String (Class) - -none - -The fully qualified name of the class that should be assignable to the chosen value. Typically used to filter out non candidate classes. Note that this information can be provided by the type itself by exposing a class with the appropriate upper bound. - -concrete - -boolean +``` +注意,在前面的示例中,还允许任何其他值。 -true +**Class Reference** -Specify if only concrete classes are to be considered as valid candidates. - -The meta-data snippet below corresponds to the standard server.servlet.jsp.class-name property that defines the JspServlet class name to use: +**class-reference**提供程序自动完成项目中可用的类。该提供程序支持以下参数: +|参数|类型|默认值|描述| +|----|:----|:----|:----| +|`target`|`String`(`Class`)|none|应该分配给所选值的类的完全限定名。通常用于过滤非候选类。请注意,此信息可以由类型本身提供,方法是公开具有适当上限的类。| +|`concrete`|`boolean`|true|指定是否只将具体类视为有效的候选类。| +下面的元数据片段对应于标准的`server.servlet.jsp.class-name`属性定义了要使用的`JspServlet`类名: +```json {"hints": [ - { - "name": "server.servlet.jsp.class-name", - "providers": [ - { - "name": "class-reference", - "parameters": { - "target": "javax.servlet.http.HttpServlet" - } - } - ] - } + { + "name": "server.servlet.jsp.class-name", + "providers": [ + { + "name": "class-reference", + "parameters": { + "target": "javax.servlet.http.HttpServlet" + } + } + ] + } ]} -Handle As - -The handle-as provider allows you to substitute the type of the property to a more high-level type. This typically happens when the property has a java.lang.String type because you don’t want your configuration classes to rely on classes that may not be on the classpath. This provider supports these parameters: +``` -Parameter Type Default value Description -target +**Handle As** -String (Class) +**handle-as**提供程序允许您将属性的类型替换为更高级的类型。当属性具有`java.lang.String`类型时,通常会发生这种情况。因为你不希望配置类依赖于可能不在类路径上的类。该提供程序支持以下参数: -none +|参数|类型|默认值|描述| +|----|:----|:----|:----| +|`target`|`String`(`Class`)|none|要考虑用于属性的类型的完全限定名。这个参数是强制性的。| -The fully qualified name of the type to consider for the property. This parameter is mandatory. +可以使用以下类型: -The following types can be used: +- 任何`java.lang.Enum`:列出属性的可能值。(我们建议使用`Enum`类型定义属性,因为IDE不需要进一步的提示就可以自动完成这些值。) +- `java.nio.charset.Charset`:支持自动完成字符集/编码值(如`UTF-8`) +- `java.util.Locale`:自动完成区域设置(如`en_US`) +- `org.springframework.util.MimeType`:支持自动完成内容类型值(例如`text/plain`) +- `org.springframework.core.io.Resource`:支持自动完成Spring的资源抽象,以引用文件系统或类路径上的文件。(如`classpath:/sample.properties`) -Any java.lang.Enum that lists the possible values for the property (By all means, try to define the property with the Enum type instead as no further hint should be required for the IDE to auto-complete the values). -java.nio.charset.Charset: auto-completion of charset/encoding values (e.g. UTF-8) -java.util.Locale: auto-completion of locales (e.g. en_US) -org.springframework.util.MimeType: auto-completion of content type values (e.g. text/plain) -org.springframework.core.io.Resource: auto-completion of Spring’s Resource abstraction to refer to a file on the filesystem or on the classpath. (e.g. classpath:/foo.properties) -[Note] -If multiple values can be provided, use a Collection or Array type to teach the IDE about it. -The meta-data snippet below corresponds to the standard liquibase.change-log property that defines the path to the changelog to use. It is actually used internally as a org.springframework.core.io.Resource but cannot be exposed as such as we need to keep the original String value to pass it to the Liquibase API. +**注** 如果可以提供多个值,则使用`集合`或数组类型来教导IDE。 +下面的元数据片段对应于标准的`spring.liquibase.change-log`属性,定义要使用的更改日志的路径。它实际上是作为一个`org.springframework.core.io.Resource`在内部使用的。但是不能这样公开,因为我们需要保留原始的字符串值,以便将它传递给Liquibase API。 +```json {"hints": [ - { - "name": "liquibase.change-log", - "providers": [ - { - "name": "handle-as", - "parameters": { - "target": "org.springframework.core.io.Resource" - } - } - ] - } + { + "name": "spring.liquibase.change-log", + "providers": [ + { + "name": "handle-as", + "parameters": { + "target": "org.springframework.core.io.Resource" + } + } + ] + } ]} -Logger name +``` -The logger-name provider auto-completes valid logger names. Typically, package and class names available in the current project can be auto-completed. Specific frameworks may have extra magic logger names that could be supported as well. +**Logger Name** -Since a logger name can be any arbitrary name, really, this provider should allow any value but could highlight valid packages and class names that are not available in the project’s classpath. +**logger-name**提供程序自动完成有效的日志程序名称。通常,当前项目中可用的包名和类名可以自动完成。特定的框架可能有额外的、也可以支持的神奇日志程序名称。 -The meta-data snippet below corresponds to the standard logging.level property, keys are logger names and values correspond to the standard log levels or any custom level: +由于记录器名称可以是任意的名称,因此该提供程序应该允许任何值,但是可以突出显示项目的类路径中不可用的有效包和类名称。 +下面的元数据片段对应于标准`logging.level`属性。键是记录器名称,值对应于标准日志级别或任何自定义级别。 +```json {"hints": [ - { - "name": "logging.level.keys", - "values": [ - { - "value": "root", - "description": "Root logger used to assign the default logging level." - } - ], - "providers": [ - { - "name": "logger-name" - } - ] - }, - { - "name": "logging.level.values", - "values": [ - { - "value": "trace" - }, - { - "value": "debug" - }, - { - "value": "info" - }, - { - "value": "warn" - }, - { - "value": "error" - }, - { - "value": "fatal" - }, - { - "value": "off" - } - - ], - "providers": [ - { - "name": "any" - } - ] - } + { + "name": "logging.level.keys", + "values": [ + { + "value": "root", + "description": "Root logger used to assign the default logging level." + } + ], + "providers": [ + { + "name": "logger-name" + } + ] + }, + { + "name": "logging.level.values", + "values": [ + { + "value": "trace" + }, + { + "value": "debug" + }, + { + "value": "info" + }, + { + "value": "warn" + }, + { + "value": "error" + }, + { + "value": "fatal" + }, + { + "value": "off" + } + + ], + "providers": [ + { + "name": "any" + } + ] + } ]} -Spring bean reference - -The spring-bean-reference provider auto-completes the beans that are defined in the configuration of the current project. This provider supports these parameters: - -Parameter Type Default value Description -target +``` -String (Class) +Spring Bean Reference -none +`spring-bean-reference`提供程序自动完成当前项目配置中定义的bean。该提供程序支持以下参数: -The fully qualified name of the bean class that should be assignable to the candidate. Typically used to filter out non candidate beans. - -The meta-data snippet below corresponds to the standard spring.jmx.server property that defines the name of the MBeanServer bean to use: +|参数|类型|默认值|描述| +|----|:----|:----|:----| +|`target`|`String`(`Class`)|none|bean类的应可赋值给候选者的完全限定名。通常用于过滤非候选bean。| +下面的元数据片段对应于标准的`spring.jmx.server`属性,定义要使用的`MBeanServer` bean的名称: +```json {"hints": [ - { - "name": "spring.jmx.server", - "providers": [ - { - "name": "spring-bean-reference", - "parameters": { - "target": "javax.management.MBeanServer" - } - } - ] - } + { + "name": "spring.jmx.server", + "providers": [ + { + "name": "spring-bean-reference", + "parameters": { + "target": "javax.management.MBeanServer" + } + } + ] + } ]} -[Note] -The binder is not aware of the meta-data so if you provide that hint, you will still need to transform the bean name into an actual Bean reference using the ApplicationContext. -Spring profile name +``` + +**注** 绑定器不知道元数据。如果你提供了那个提示,你仍然需要将bean名称转换为`ApplicationContext`使用的实际bean引用。 -The spring-profile-name provider auto-completes the Spring profiles that are defined in the configuration of the current project. +Spring Profile Name -The meta-data snippet below corresponds to the standard spring.profiles.active property that defines the name of the Spring profile(s) to enable: +`spring-profile-name`提供程序自动完成在当前项目的配置中定义的Spring配置文件。 +下面的元数据片段对应于标准的`spring.profiles.active`属性,定义要启用的Spring配置文件的名称: +```json {"hints": [ - { - "name": "spring.profiles.active", - "providers": [ - { - "name": "spring-profile-name" - } - ] - } + { + "name": "spring.profiles.active", + "providers": [ + { + "name": "spring-profile-name" + } + ] + } ]} - - +``` From 7aa4ca4e85563f3c9202627883a6aa53ef429b28 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E7=83=AD=E5=BF=83=E5=B8=82=E6=B0=91=E9=92=9F=E5=B0=8F?= =?UTF-8?q?=E5=BC=BA?= Date: Sun, 15 Mar 2020 12:45:17 +0800 Subject: [PATCH 830/865] Update and rename B.3. Generating your own meta-data using the annotation processor.md to B.3. Generating Your Own Metadata by Using the Annotation Processor.md --- ...ur Own Metadata by Using the Annotation Processor.md} | 9 +++------ 1 file changed, 3 insertions(+), 6 deletions(-) rename X. Appendices/{B.3. Generating your own meta-data using the annotation processor.md => B.3. Generating Your Own Metadata by Using the Annotation Processor.md} (70%) diff --git a/X. Appendices/B.3. Generating your own meta-data using the annotation processor.md b/X. Appendices/B.3. Generating Your Own Metadata by Using the Annotation Processor.md similarity index 70% rename from X. Appendices/B.3. Generating your own meta-data using the annotation processor.md rename to X. Appendices/B.3. Generating Your Own Metadata by Using the Annotation Processor.md index ddc6830a..c85959a2 100644 --- a/X. Appendices/B.3. Generating your own meta-data using the annotation processor.md +++ b/X. Appendices/B.3. Generating Your Own Metadata by Using the Annotation Processor.md @@ -8,7 +8,7 @@ true ``` -使用Gradle时,你可以使用[propdeps-plugin](https://github.com/spring-projects/gradle-plugins/tree/master/propdeps-plugin)并指定: +使用Gradle时,你可以使用[propdeps-plugin](https://github.com/spring-gradle-plugins/propdeps-plugin)并指定: ```gradle dependencies { optional "org.springframework.boot:spring-boot-configuration-processor" @@ -17,13 +17,10 @@ dependencies { compileJava.dependsOn(processResources) } ``` -**注**:你需要将`compileJava.dependsOn(processResources)`添加到构建中,以确保资源在代码编译之前处理。如果没有该指令,任何`additional-spring-configuration-metadata.json`文件都不会被处理。 +**注** 你需要将`compileJava.dependsOn(processResources)`添加到构建中,以确保资源在代码编译之前处理。如果没有该指令,任何`additional-spring-configuration-metadata.json`文件都不会被处理。 该处理器会处理被`@ConfigurationProperties`注解的类和方法,description属性用于产生配置类字段值的Javadoc说明。 -**注**:你应该使用简单的文本来设置`@ConfigurationProperties`字段的Javadoc,因为在没有被添加到JSON之前它们是不被处理的。 - +**注** 你应该使用简单的文本来设置`@ConfigurationProperties`字段的Javadoc,因为在没有被添加到JSON之前它们是不被处理的。 属性是通过判断是否存在标准的getters和setters来发现的,对于集合类型有特殊处理(即使只出现一个getter)。该注解处理器也支持使用lombok的`@Data`, `@Getter`和`@Setter`注解。 - - From 7629809504884c6d20a8dbc40c8cb500204c0f89 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E7=83=AD=E5=BF=83=E5=B8=82=E6=B0=91=E9=92=9F=E5=B0=8F?= =?UTF-8?q?=E5=BC=BA?= Date: Sun, 15 Mar 2020 12:49:19 +0800 Subject: [PATCH 831/865] Update SUMMARY.md --- SUMMARY.md | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/SUMMARY.md b/SUMMARY.md index 29265723..fd24dc33 100644 --- a/SUMMARY.md +++ b/SUMMARY.md @@ -574,9 +574,9 @@ * [附录B.2. 提供人工提示](X. Appendices/B.2 Providing Manual Hints.md) * [附录 B.2.1 值提示](X. Appendices/B.2.1 Value Hint.md) * [附录 B.2.2 值提供者](X. Appendices/B.2.2 Value Provider.md) - * [附录B.3. 使用注解处理器产生自己的元数据](X. Appendices/B.3. Generating your own meta-data using the annotation processor.md) - * [附录 B.3.1. 内嵌属性](X. Appendices/B.3.1. Nested properties.md) - * [附录 B.3.2. 添加其他的元数据](X. Appendices/B.3.2. Adding additional meta-data.md) + * [附录B.3. 使用注解处理器产生自己的元数据](X. Appendices/B.3. Generating Your Own Metadata by Using the Annotation Processor.md) + * [附录 B.3.1. 内嵌属性](X. Appendices/B.3.1. Nested Properties.md) + * [附录 B.3.2. 添加其他的元数据](X. Appendices/B.3.2. Adding Additional Metadata.md) * [附录C. 自动配置类](X. Appendices/C. Auto-configuration classes.md) * [附录 C.1. 来自spring-boot-autoconfigure模块](X. Appendices/C.1. From the “spring-boot-autoconfigure” module.md) * [附录C.2. 来自spring-boot-actuator模块](X. Appendices/C.2. From the “spring-boot-actuator” module.md) From 9365fc326fa4654e52f2f6379adde134c1db1ef6 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E7=83=AD=E5=BF=83=E5=B8=82=E6=B0=91=E9=92=9F=E5=B0=8F?= =?UTF-8?q?=E5=BC=BA?= Date: Sun, 15 Mar 2020 12:59:43 +0800 Subject: [PATCH 832/865] Update and rename B.3.1. Nested properties.md to B.3.1. Nested Properties.md --- X. Appendices/B.3.1. Nested Properties.md | 29 +++++++++++++++++++++++ X. Appendices/B.3.1. Nested properties.md | 25 ------------------- 2 files changed, 29 insertions(+), 25 deletions(-) create mode 100644 X. Appendices/B.3.1. Nested Properties.md delete mode 100644 X. Appendices/B.3.1. Nested properties.md diff --git a/X. Appendices/B.3.1. Nested Properties.md b/X. Appendices/B.3.1. Nested Properties.md new file mode 100644 index 00000000..02bb4490 --- /dev/null +++ b/X. Appendices/B.3.1. Nested Properties.md @@ -0,0 +1,29 @@ +### 附录 B.3.1. 内嵌属性 + +该注解处理器自动将内部类当做内嵌属性处理。例如,下面的类: +```java +@ConfigurationProperties(prefix="server") +public class ServerProperties { + + private String name; + + private Host host; + + // ... getter and setters + + private static class Host { + + private String ip; + + private int port; + + // ... getter and setters + + } + +} +``` + +前面的示例生成`server.name`、`server.host.ip`与`server.host.port`属性的元数据信息。你可以使用字段上的`@NestedConfigurationProperty`注释来指示应该将常规(非内部)类视为嵌套类。 + +**注** 这对集合和映射没有影响,因为这些类型是自动标识的,并且为每个类型生成一个元数据属性。 diff --git a/X. Appendices/B.3.1. Nested properties.md b/X. Appendices/B.3.1. Nested properties.md deleted file mode 100644 index cd86f5ab..00000000 --- a/X. Appendices/B.3.1. Nested properties.md +++ /dev/null @@ -1,25 +0,0 @@ -### 附录 B.3.1. 内嵌属性 - -该注解处理器自动将内部类当做内嵌属性处理。例如,下面的类: -```java -@ConfigurationProperties(prefix="server") -public class ServerProperties { - - private String name; - - private Host host; - - // ... getter and setters - - private static class Host { - - private String ip; - - private int port; - - // ... getter and setters - - } - -} -``` From 9d3e4378f19afa9a0442c6f88e022c68b305f9f6 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E7=83=AD=E5=BF=83=E5=B8=82=E6=B0=91=E9=92=9F=E5=B0=8F?= =?UTF-8?q?=E5=BC=BA?= Date: Sun, 15 Mar 2020 13:07:02 +0800 Subject: [PATCH 833/865] Update and rename B.3.2. Adding additional meta-data.md to B.3.2. Adding Additional Metadata.md --- X. Appendices/B.3.2. Adding Additional Metadata.md | 7 +++++++ X. Appendices/B.3.2. Adding additional meta-data.md | 1 - 2 files changed, 7 insertions(+), 1 deletion(-) create mode 100644 X. Appendices/B.3.2. Adding Additional Metadata.md delete mode 100644 X. Appendices/B.3.2. Adding additional meta-data.md diff --git a/X. Appendices/B.3.2. Adding Additional Metadata.md b/X. Appendices/B.3.2. Adding Additional Metadata.md new file mode 100644 index 00000000..37c8a61f --- /dev/null +++ b/X. Appendices/B.3.2. Adding Additional Metadata.md @@ -0,0 +1,7 @@ +### 附录 B.3.2. 添加其他的元数据 + +Spring Boot的配置文件处理非常灵活,通常存在不绑定到`@ConfigurationProperties` bean的属性。你可能还需要调优现有键的一些属性。为了支持这种情况并允许你提供自定义“提示”,注释处理器将自动合并来自`META-INF/additional-spring-configuration-metadata.json`的项,放入主元数据文件。 + +如果你引用的属性是自动检测到的,则会覆盖描述、默认值和弃用信息(如果指定的话)。如果当前模块中没有标识手动属性声明,则将其作为新属性添加。 + +`additional-spring-configuration-metadata.json`文件的格式与常规的`spring-configuration-metadata.json`完全相同。附加属性文件是可选的。如果没有任何其他属性,则不要添加该文件。 diff --git a/X. Appendices/B.3.2. Adding additional meta-data.md b/X. Appendices/B.3.2. Adding additional meta-data.md deleted file mode 100644 index 938822a2..00000000 --- a/X. Appendices/B.3.2. Adding additional meta-data.md +++ /dev/null @@ -1 +0,0 @@ -### 附录 B.3.2. 添加其他的元数据 From b859f59f1a0443086e935b46369eb37291dae161 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E7=83=AD=E5=BF=83=E5=B8=82=E6=B0=91=E9=92=9F=E5=B0=8F?= =?UTF-8?q?=E5=BC=BA?= Date: Sun, 15 Mar 2020 13:18:01 +0800 Subject: [PATCH 834/865] Update SUMMARY.md --- SUMMARY.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/SUMMARY.md b/SUMMARY.md index fd24dc33..c244f9a4 100644 --- a/SUMMARY.md +++ b/SUMMARY.md @@ -578,8 +578,8 @@ * [附录 B.3.1. 内嵌属性](X. Appendices/B.3.1. Nested Properties.md) * [附录 B.3.2. 添加其他的元数据](X. Appendices/B.3.2. Adding Additional Metadata.md) * [附录C. 自动配置类](X. Appendices/C. Auto-configuration classes.md) - * [附录 C.1. 来自spring-boot-autoconfigure模块](X. Appendices/C.1. From the “spring-boot-autoconfigure” module.md) - * [附录C.2. 来自spring-boot-actuator模块](X. Appendices/C.2. From the “spring-boot-actuator” module.md) + * [附录C.1. 来自spring-boot-autoconfigure模块](X. Appendices/C.1. From the “spring-boot-autoconfigure” module.md) + * [附录C.2. 来自spring-boot-actuator模块](X. Appendices/C.2. From the “spring-boot-actuator-autoconfigure” module.md) * [附录D. 测试自动配置的标注](X. Appendices/D. Test auto-configuration annotations.md) * [附录E. 可执行jar格式](X. Appendices/E. The executable jar format.md) * [附录E.1. 内嵌JARs](X. Appendices/E.1. Nested JARs.md) From afdbfd6ad4bc0ea30ecc048f7ae43a0c1b108835 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E7=83=AD=E5=BF=83=E5=B8=82=E6=B0=91=E9=92=9F=E5=B0=8F?= =?UTF-8?q?=E5=BC=BA?= Date: Sun, 15 Mar 2020 13:24:47 +0800 Subject: [PATCH 835/865] Update C. Auto-configuration classes.md --- X. Appendices/C. Auto-configuration classes.md | 11 +---------- 1 file changed, 1 insertion(+), 10 deletions(-) diff --git a/X. Appendices/C. Auto-configuration classes.md b/X. Appendices/C. Auto-configuration classes.md index b6da2ef2..07dafb54 100644 --- a/X. Appendices/C. Auto-configuration classes.md +++ b/X. Appendices/C. Auto-configuration classes.md @@ -1,12 +1,3 @@ ### 附录 C. 自动配置类 -这里有一个Spring Boot提供的所有自动配置类的文档链接和源码列表。也要记着看一下你的应用都开启了哪些自动配置(使用`--debug`或`-Debug`启动应用,或在一个Actuator应用中使用`autoconfig`端点)。 - - - - - - - - - +下面是Spring Boot提供的所有自动配置类的列表,其中有文档和源代码的链接。还请记住查看应用程序中的状况报告,以了解关于打开哪些功能的更多细节。(为此,使用`--debug`或`-Ddebug`启动应用程序,或者在执行器应用程序中使用`conditions`端点)。 From 52299a151613195e5b3a0befeb3b2b5a364b2ecf Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E7=83=AD=E5=BF=83=E5=B8=82=E6=B0=91=E9=92=9F=E5=B0=8F?= =?UTF-8?q?=E5=BC=BA?= Date: Sun, 15 Mar 2020 14:00:38 +0800 Subject: [PATCH 836/865] =?UTF-8?q?Update=20C.1.=20From=20the=20=E2=80=9Cs?= =?UTF-8?q?pring-boot-autoconfigure=E2=80=9D=20module.md?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- ...-boot-autoconfigure\342\200\235 module.md" | 47 ++++++++++--------- 1 file changed, 24 insertions(+), 23 deletions(-) diff --git "a/X. Appendices/C.1. From the \342\200\234spring-boot-autoconfigure\342\200\235 module.md" "b/X. Appendices/C.1. From the \342\200\234spring-boot-autoconfigure\342\200\235 module.md" index a39e7929..b2016a91 100644 --- "a/X. Appendices/C.1. From the \342\200\234spring-boot-autoconfigure\342\200\235 module.md" +++ "b/X. Appendices/C.1. From the \342\200\234spring-boot-autoconfigure\342\200\235 module.md" @@ -4,29 +4,30 @@ |配置类|链接| |------|:------| -|[`ActiveMQAutoConfiguration`](https://github.com/spring-projects/spring-boot/tree/v2.0.0.RELEASE/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/jms/activemq/ActiveMQAutoConfiguration.java)|[javadoc](https://docs.spring.io/spring-boot/docs/2.0.0.RELEASE/api/org/springframework/boot/autoconfigure/jms/activemq/ActiveMQAutoConfiguration.html)| -|[`AopAutoConfiguration`](https://github.com/spring-projects/spring-boot/tree/v2.0.0.RELEASE/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/aop/AopAutoConfiguration.java)|[javadoc](https://docs.spring.io/spring-boot/docs/2.0.0.RELEASE/api/org/springframework/boot/autoconfigure/aop/AopAutoConfiguration.html)| -|[`ArtemisAutoConfiguration`](https://github.com/spring-projects/spring-boot/tree/v2.0.0.RELEASE/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/jms/artemis/ArtemisAutoConfiguration.java)|[javadoc](https://docs.spring.io/spring-boot/docs/2.0.0.RELEASE/api/org/springframework/boot/autoconfigure/jms/artemis/ArtemisAutoConfiguration.html)| -|[`BatchAutoConfiguration`](https://github.com/spring-projects/spring-boot/tree/v2.0.0.RELEASE/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/batch/BatchAutoConfiguration.java)|[javadoc](https://docs.spring.io/spring-boot/docs/2.0.0.RELEASE/api/org/springframework/boot/autoconfigure/batch/BatchAutoConfiguration.html)| -|[`CacheAutoConfiguration`](https://github.com/spring-projects/spring-boot/tree/v2.0.0.RELEASE/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/cache/CacheAutoConfiguration.java)|[javadoc](https://docs.spring.io/spring-boot/docs/2.0.0.RELEASE/api/org/springframework/boot/autoconfigure/cache/CacheAutoConfiguration.html)| -|[`CassandraAutoConfiguration`](https://github.com/spring-projects/spring-boot/tree/v2.0.0.RELEASE/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/cassandra/CassandraAutoConfiguration.java)|[javadoc](https://docs.spring.io/spring-boot/docs/2.0.0.RELEASE/api/org/springframework/boot/autoconfigure/cassandra/CassandraAutoConfiguration.html)| -|[`CassandraDataAutoConfiguration`](https://github.com/spring-projects/spring-boot/tree/v2.0.0.RELEASE/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/data/cassandra/CassandraDataAutoConfiguration.java)|[javadoc](https://docs.spring.io/spring-boot/docs/2.0.0.RELEASE/api/org/springframework/boot/autoconfigure/data/cassandra/CassandraDataAutoConfiguration.html)| -|[`CassandraReactiveDataAutoConfiguration`](https://github.com/spring-projects/spring-boot/tree/v2.0.0.RELEASE/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/data/cassandra/CassandraReactiveDataAutoConfiguration.java)|[javadoc](https://docs.spring.io/spring-boot/docs/2.0.0.RELEASE/api/org/springframework/boot/autoconfigure/data/cassandra/CassandraReactiveDataAutoConfiguration.html)| -|[`CassandraReactiveRepositoriesAutoConfiguration`](https://github.com/spring-projects/spring-boot/tree/v2.0.0.RELEASE/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/data/cassandra/CassandraReactiveRepositoriesAutoConfiguration.java)|[javadoc](https://docs.spring.io/spring-boot/docs/2.0.0.RELEASE/api/org/springframework/boot/autoconfigure/data/cassandra/CassandraReactiveRepositoriesAutoConfiguration.html)| -|[`CassandraRepositoriesAutoConfiguration`](https://github.com/spring-projects/spring-boot/tree/v2.0.0.RELEASE/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/data/cassandra/CassandraRepositoriesAutoConfiguration.java)|[javadoc](https://docs.spring.io/spring-boot/docs/2.0.0.RELEASE/api/org/springframework/boot/autoconfigure/data/cassandra/CassandraRepositoriesAutoConfiguration.htmlCassandraReactiveRepositoriesAutoConfiguration.html)| -|[`CloudAutoConfiguration`](https://github.com/spring-projects/spring-boot/tree/v2.0.0.RELEASE/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/cloud/CloudAutoConfiguration.java)|[javadoc](https://docs.spring.io/spring-boot/docs/2.0.0.RELEASE/api/org/springframework/boot/autoconfigure/cloud/CloudAutoConfiguration.html)| -|[`ConfigurationPropertiesAutoConfiguration`](https://github.com/spring-projects/spring-boot/tree/v2.0.0.RELEASE/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/context/ConfigurationPropertiesAutoConfiguration.java)|[javadoc](https://docs.spring.io/spring-boot/docs/2.0.0.RELEASE/api/org/springframework/boot/autoconfigure/context/ConfigurationPropertiesAutoConfiguration.html)| -|[`CouchbaseAutoConfiguration`](https://github.com/spring-projects/spring-boot/tree/v2.0.0.RELEASE/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/couchbase/CouchbaseAutoConfiguration.java)|[javadoc](https://docs.spring.io/spring-boot/docs/2.0.0.RELEASE/api/org/springframework/boot/autoconfigure/couchbase/CouchbaseAutoConfiguration.html)| -|[`CouchbaseDataAutoConfiguration`](https://github.com/spring-projects/spring-boot/tree/v2.0.0.RELEASE/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/data/couchbase/CouchbaseDataAutoConfiguration.java)|[javadoc](https://docs.spring.io/spring-boot/docs/2.0.0.RELEASE/api/org/springframework/boot/autoconfigure/data/couchbase/CouchbaseDataAutoConfiguration.html)| -|[`CouchbaseRepositoriesAutoConfiguration`](https://github.com/spring-projects/spring-boot/tree/v2.0.0.RELEASE/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/data/couchbase/CouchbaseRepositoriesAutoConfiguration.java)|[javadoc](https://docs.spring.io/spring-boot/docs/2.0.0.RELEASE/api/org/springframework/boot/autoconfigure/data/couchbase/CouchbaseRepositoriesAutoConfiguration.html)| -|[`DataSourceAutoConfiguration`](https://github.com/spring-projects/spring-boot/tree/v2.0.0.RELEASE/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/jdbc/DataSourceAutoConfiguration.java)|[javadoc](https://docs.spring.io/spring-boot/docs/2.0.0.RELEASE/api/org/springframework/boot/autoconfigure/jdbc/DataSourceAutoConfiguration.html)| -|[`DataSourceTransactionManagerAutoConfiguration`](https://github.com/spring-projects/spring-boot/tree/v2.0.0.RELEASE/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/jdbc/DataSourceTransactionManagerAutoConfiguration.java)|[javadoc](https://docs.spring.io/spring-boot/docs/2.0.0.RELEASE/api/org/springframework/boot/autoconfigure/jdbc/DataSourceTransactionManagerAutoConfiguration.html)| -|[`DeviceDelegatingViewResolverAutoConfiguration`](https://github.com/spring-projects/spring-boot/tree/v2.0.0.RELEASE/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/mobile/DeviceDelegatingViewResolverAutoConfiguration.java)|[javadoc](https://docs.spring.io/spring-boot/docs/2.0.0.RELEASE/api/org/springframework/boot/autoconfigure/mobile/DeviceDelegatingViewResolverAutoConfiguration.html)| -|[`DeviceResolverAutoConfiguration`](https://github.com/spring-projects/spring-boot/tree/v2.0.0.RELEASE/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/mobile/DeviceResolverAutoConfiguration.java)|[javadoc](https://docs.spring.io/spring-boot/docs/2.0.0.RELEASE/api/org/springframework/boot/autoconfigure/mobile/DeviceResolverAutoConfiguration.html)| -|[`DispatcherServletAutoConfiguration`](https://github.com/spring-projects/spring-boot/tree/v2.0.0.RELEASE/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/web/servlet/DispatcherServletAutoConfiguration.java)|[javadoc](https://docs.spring.io/spring-boot/docs/2.0.0.RELEASE/api/org/springframework/boot/autoconfigure/web/servlet/DispatcherServletAutoConfiguration.html)| -|[`ElasticsearchAutoConfiguration`](https://github.com/spring-projects/spring-boot/tree/v2.0.0.RELEASE/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/data/elasticsearch/ElasticsearchAutoConfiguration.java)|[javadoc](https://docs.spring.io/spring-boot/docs/2.0.0.RELEASE/api/org/springframework/boot/autoconfigure/data/elasticsearch/ElasticsearchAutoConfiguration.html)| -|[`ElasticsearchDataAutoConfiguration`](https://github.com/spring-projects/spring-boot/tree/v2.0.0.RELEASE/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/data/elasticsearch/ElasticsearchDataAutoConfiguration.java)|[javadoc](https://docs.spring.io/spring-boot/docs/2.0.0.RELEASE/api/org/springframework/boot/autoconfigure/data/elasticsearch/ElasticsearchDataAutoConfiguration.html)| -|[`ElasticsearchRepositoriesAutoConfiguration`](https://github.com/spring-projects/spring-boot/tree/v2.0.0.RELEASE/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/data/elasticsearch/ElasticsearchRepositoriesAutoConfiguration.java)|[javadoc](https://docs.spring.io/spring-boot/docs/2.0.0.RELEASE/api/org/springframework/boot/autoconfigure/data/elasticsearch/ElasticsearchRepositoriesAutoConfiguration.html)| +|[`ActiveMQAutoConfiguration`](https://github.com/spring-projects/spring-boot/tree/v2.0.0.RELEASE/spring-boot-project/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/jms/activemq/ActiveMQAutoConfiguration.java)|[javadoc](https://docs.spring.io/spring-boot/docs/2.0.0.RELEASE/api/org/springframework/boot/autoconfigure/jms/activemq/ActiveMQAutoConfiguration.html)| +|[`AopAutoConfiguration`](https://github.com/spring-projects/spring-boot/tree/v2.0.0.RELEASE/spring-boot-project/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/aop/AopAutoConfiguration.java)|[javadoc](https://docs.spring.io/spring-boot/docs/2.0.0.RELEASE/api/org/springframework/boot/autoconfigure/aop/AopAutoConfiguration.html)| +|[`ArtemisAutoConfiguration`](https://github.com/spring-projects/spring-boot/tree/v2.0.0.RELEASE/spring-boot-project/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/jms/artemis/ArtemisAutoConfiguration.java)|[javadoc](https://docs.spring.io/spring-boot/docs/2.0.0.RELEASE/api/org/springframework/boot/autoconfigure/jms/artemis/ArtemisAutoConfiguration.html)| +|[`BatchAutoConfiguration`](https://github.com/spring-projects/spring-boot/tree/v2.0.0.RELEASE/spring-boot-project/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/batch/BatchAutoConfiguration.java)|[javadoc](https://docs.spring.io/spring-boot/docs/2.0.0.RELEASE/api/org/springframework/boot/autoconfigure/batch/BatchAutoConfiguration.html)| +|[`CacheAutoConfiguration`](https://github.com/spring-projects/spring-boot/tree/v2.0.0.RELEASE/spring-boot-project/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/cache/CacheAutoConfiguration.java)|[javadoc](https://docs.spring.io/spring-boot/docs/2.0.0.RELEASE/api/org/springframework/boot/autoconfigure/cache/CacheAutoConfiguration.html)| +|[`CassandraAutoConfiguration`](https://github.com/spring-projects/spring-boot/tree/v2.0.0.RELEASE/spring-boot-project/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/cassandra/CassandraAutoConfiguration.java)|[javadoc](https://docs.spring.io/spring-boot/docs/2.0.0.RELEASE/api/org/springframework/boot/autoconfigure/cassandra/CassandraAutoConfiguration.html)| +|[`CassandraDataAutoConfiguration`](https://github.com/spring-projects/spring-boot/tree/v2.0.0.RELEASE/spring-boot-project/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/data/cassandra/CassandraDataAutoConfiguration.java)|[javadoc](https://docs.spring.io/spring-boot/docs/2.0.0.RELEASE/api/org/springframework/boot/autoconfigure/data/cassandra/CassandraDataAutoConfiguration.html)| +|[`CassandraReactiveDataAutoConfiguration`](https://github.com/spring-projects/spring-boot/tree/v2.0.0.RELEASE/spring-boot-project/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/data/cassandra/CassandraReactiveDataAutoConfiguration.java)|[javadoc](https://docs.spring.io/spring-boot/docs/2.0.0.RELEASE/api/org/springframework/boot/autoconfigure/data/cassandra/CassandraReactiveDataAutoConfiguration.html)| +|[`CassandraReactiveRepositoriesAutoConfiguration`](https://github.com/spring-projects/spring-boot/tree/v2.0.0.RELEASE/spring-boot-project/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/data/cassandra/CassandraReactiveRepositoriesAutoConfiguration.java)|[javadoc](https://docs.spring.io/spring-boot/docs/2.0.0.RELEASE/api/org/springframework/boot/autoconfigure/data/cassandra/CassandraReactiveRepositoriesAutoConfiguration.html)| +|[`CassandraRepositoriesAutoConfiguration`](https://github.com/spring-projects/spring-boot/tree/v2.0.0.RELEASE/spring-boot-project/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/data/cassandra/CassandraRepositoriesAutoConfiguration.java)|[javadoc](https://docs.spring.io/spring-boot/docs/2.0.0.RELEASE/api/org/springframework/boot/autoconfigure/data/cassandra/CassandraRepositoriesAutoConfiguration.html)| +|[`CloudAutoConfiguration`](https://github.com/spring-projects/spring-boot/tree/v2.0.0.RELEASE/spring-boot-project/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/cloud/CloudAutoConfiguration.java)|[javadoc](https://docs.spring.io/spring-boot/docs/2.0.0.RELEASE/api/org/springframework/boot/autoconfigure/cloud/CloudAutoConfiguration.html)| +|[`CodecsAutoConfiguration`](https://github.com/spring-projects/spring-boot/tree/v2.0.0.RELEASE/spring-boot-project/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/http/codec/CodecsAutoConfiguration.java)|[javadoc](https://docs.spring.io/spring-boot/docs/2.0.0.RELEASE/api/org/springframework/boot/autoconfigure/http/codec/CodecsAutoConfiguration.html)| +|[`ConfigurationPropertiesAutoConfiguration`](https://github.com/spring-projects/spring-boot/tree/v2.0.0.RELEASE/spring-boot-project/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/context/ConfigurationPropertiesAutoConfiguration.java)|[javadoc](https://docs.spring.io/spring-boot/docs/2.0.0.RELEASE/api/org/springframework/boot/autoconfigure/context/ConfigurationPropertiesAutoConfiguration.html)| +|[`CouchbaseAutoConfiguration`](https://github.com/spring-projects/spring-boot/tree/v2.0.0.RELEASE/spring-boot-project/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/couchbase/CouchbaseAutoConfiguration.java)|[javadoc](https://docs.spring.io/spring-boot/docs/2.0.0.RELEASE/api/org/springframework/boot/autoconfigure/couchbase/CouchbaseAutoConfiguration.html)| +|[`CouchbaseDataAutoConfiguration`](https://github.com/spring-projects/spring-boot/tree/v2.0.0.RELEASE/spring-boot-project/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/data/couchbase/CouchbaseDataAutoConfiguration.java)|[javadoc](https://docs.spring.io/spring-boot/docs/2.0.0.RELEASE/api/org/springframework/boot/autoconfigure/data/couchbase/CouchbaseDataAutoConfiguration.html)| +|[`CouchbaseReactiveDataAutoConfiguration`](https://github.com/spring-projects/spring-boot/tree/v2.0.0.RELEASE/spring-boot-project/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/data/couchbase/CouchbaseReactiveDataAutoConfiguration.java)|[javadoc](https://docs.spring.io/spring-boot/docs/2.0.0.RELEASE/api/org/springframework/boot/autoconfigure/data/couchbase/CouchbaseReactiveDataAutoConfiguration.html)| +|[`CouchbaseReactiveRepositoriesAutoConfiguration`](https://github.com/spring-projects/spring-boot/tree/v2.0.0.RELEASE/spring-boot-project/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/data/couchbase/CouchbaseReactiveRepositoriesAutoConfiguration.java)|[javadoc](https://docs.spring.io/spring-boot/docs/2.0.0.RELEASE/api/org/springframework/boot/autoconfigure/data/couchbase/CouchbaseReactiveRepositoriesAutoConfiguration.html)| +|[`CouchbaseRepositoriesAutoConfiguration`](https://github.com/spring-projects/spring-boot/tree/v2.0.0.RELEASE/spring-boot-project/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/data/couchbase/CouchbaseRepositoriesAutoConfiguration.java)|[javadoc](https://docs.spring.io/spring-boot/docs/2.0.0.RELEASE/api/org/springframework/boot/autoconfigure/data/couchbase/CouchbaseRepositoriesAutoConfiguration.html)| +|[`DataSourceAutoConfiguration`](https://github.com/spring-projects/spring-boot/tree/v2.0.0.RELEASE/spring-boot-project/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/jdbc/DataSourceAutoConfiguration.java)|[javadoc](https://docs.spring.io/spring-boot/docs/2.0.0.RELEASE/api/org/springframework/boot/autoconfigure/jdbc/DataSourceAutoConfiguration.html)| +|[`DataSourceTransactionManagerAutoConfiguration`](https://github.com/spring-projects/spring-boot/tree/v2.0.0.RELEASE/spring-boot-project/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/jdbc/DataSourceTransactionManagerAutoConfiguration.java)|[javadoc](https://docs.spring.io/spring-boot/docs/2.0.0.RELEASE/api/org/springframework/boot/autoconfigure/jdbc/DataSourceTransactionManagerAutoConfiguration.html)| +|[`DispatcherServletAutoConfiguration`](https://github.com/spring-projects/spring-boot/tree/v2.0.0.RELEASE/spring-boot-project/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/web/servlet/DispatcherServletAutoConfiguration.java)|[javadoc](https://docs.spring.io/spring-boot/docs/2.0.0.RELEASE/api/org/springframework/boot/autoconfigure/web/servlet/DispatcherServletAutoConfiguration.html)| +|[`ElasticsearchAutoConfiguration`](https://github.com/spring-projects/spring-boot/tree/v2.0.0.RELEASE/spring-boot-project/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/data/elasticsearch/ElasticsearchAutoConfiguration.java)|[javadoc](https://docs.spring.io/spring-boot/docs/2.0.0.RELEASE/api/org/springframework/boot/autoconfigure/data/elasticsearch/ElasticsearchAutoConfiguration.html)| +|[`ElasticsearchDataAutoConfiguration`](https://github.com/spring-projects/spring-boot/tree/v2.0.0.RELEASE/spring-boot-project/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/data/elasticsearch/ElasticsearchDataAutoConfiguration.java)|[javadoc](https://docs.spring.io/spring-boot/docs/2.0.0.RELEASE/api/org/springframework/boot/autoconfigure/data/elasticsearch/ElasticsearchDataAutoConfiguration.html)| +|[`ElasticsearchRepositoriesAutoConfiguration`](https://github.com/spring-projects/spring-boot/tree/v2.0.0.RELEASE/spring-boot-project/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/data/elasticsearch/ElasticsearchRepositoriesAutoConfiguration.java)|[javadoc](https://docs.spring.io/spring-boot/docs/2.0.0.RELEASE/api/org/springframework/boot/autoconfigure/data/elasticsearch/ElasticsearchRepositoriesAutoConfiguration.html)| |[`EmbeddedLdapAutoConfiguration`](https://github.com/spring-projects/spring-boot/tree/v2.0.0.RELEASE/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/ldap/embedded/EmbeddedLdapAutoConfiguration.java)|[javadoc](https://docs.spring.io/spring-boot/docs/2.0.0.RELEASE/api/org/springframework/boot/autoconfigure/ldap/embedded/EmbeddedLdapAutoConfiguration.html)| |[`EmbeddedMongoAutoConfiguration`](https://github.com/spring-projects/spring-boot/tree/v2.0.0.RELEASE/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/mongo/embedded/EmbeddedMongoAutoConfiguration.java)|[javadoc](https://docs.spring.io/spring-boot/docs/2.0.0.RELEASE/api/org/springframework/boot/autoconfigure/mongo/embedded/EmbeddedMongoAutoConfiguration.html)| |[`ErrorMvcAutoConfiguration`](https://github.com/spring-projects/spring-boot/tree/v2.0.0.RELEASE/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/web/servlet/error/ErrorMvcAutoConfiguration.java)|[javadoc](https://docs.spring.io/spring-boot/docs/2.0.0.RELEASE/api/org/springframework/boot/autoconfigure/web/servlet/error/ErrorMvcAutoConfiguration.html)| From 914d85d154650867d34cf0e5e5628d74fff53513 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E7=83=AD=E5=BF=83=E5=B8=82=E6=B0=91=E9=92=9F=E5=B0=8F?= =?UTF-8?q?=E5=BC=BA?= Date: Mon, 16 Mar 2020 21:12:06 +0800 Subject: [PATCH 837/865] =?UTF-8?q?Update=20C.1.=20From=20the=20=E2=80=9Cs?= =?UTF-8?q?pring-boot-autoconfigure=E2=80=9D=20module.md?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- ...234spring-boot-autoconfigure\342\200\235 module.md" | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git "a/X. Appendices/C.1. From the \342\200\234spring-boot-autoconfigure\342\200\235 module.md" "b/X. Appendices/C.1. From the \342\200\234spring-boot-autoconfigure\342\200\235 module.md" index b2016a91..5ab56f01 100644 --- "a/X. Appendices/C.1. From the \342\200\234spring-boot-autoconfigure\342\200\235 module.md" +++ "b/X. Appendices/C.1. From the \342\200\234spring-boot-autoconfigure\342\200\235 module.md" @@ -28,11 +28,11 @@ |[`ElasticsearchAutoConfiguration`](https://github.com/spring-projects/spring-boot/tree/v2.0.0.RELEASE/spring-boot-project/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/data/elasticsearch/ElasticsearchAutoConfiguration.java)|[javadoc](https://docs.spring.io/spring-boot/docs/2.0.0.RELEASE/api/org/springframework/boot/autoconfigure/data/elasticsearch/ElasticsearchAutoConfiguration.html)| |[`ElasticsearchDataAutoConfiguration`](https://github.com/spring-projects/spring-boot/tree/v2.0.0.RELEASE/spring-boot-project/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/data/elasticsearch/ElasticsearchDataAutoConfiguration.java)|[javadoc](https://docs.spring.io/spring-boot/docs/2.0.0.RELEASE/api/org/springframework/boot/autoconfigure/data/elasticsearch/ElasticsearchDataAutoConfiguration.html)| |[`ElasticsearchRepositoriesAutoConfiguration`](https://github.com/spring-projects/spring-boot/tree/v2.0.0.RELEASE/spring-boot-project/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/data/elasticsearch/ElasticsearchRepositoriesAutoConfiguration.java)|[javadoc](https://docs.spring.io/spring-boot/docs/2.0.0.RELEASE/api/org/springframework/boot/autoconfigure/data/elasticsearch/ElasticsearchRepositoriesAutoConfiguration.html)| -|[`EmbeddedLdapAutoConfiguration`](https://github.com/spring-projects/spring-boot/tree/v2.0.0.RELEASE/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/ldap/embedded/EmbeddedLdapAutoConfiguration.java)|[javadoc](https://docs.spring.io/spring-boot/docs/2.0.0.RELEASE/api/org/springframework/boot/autoconfigure/ldap/embedded/EmbeddedLdapAutoConfiguration.html)| -|[`EmbeddedMongoAutoConfiguration`](https://github.com/spring-projects/spring-boot/tree/v2.0.0.RELEASE/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/mongo/embedded/EmbeddedMongoAutoConfiguration.java)|[javadoc](https://docs.spring.io/spring-boot/docs/2.0.0.RELEASE/api/org/springframework/boot/autoconfigure/mongo/embedded/EmbeddedMongoAutoConfiguration.html)| -|[`ErrorMvcAutoConfiguration`](https://github.com/spring-projects/spring-boot/tree/v2.0.0.RELEASE/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/web/servlet/error/ErrorMvcAutoConfiguration.java)|[javadoc](https://docs.spring.io/spring-boot/docs/2.0.0.RELEASE/api/org/springframework/boot/autoconfigure/web/servlet/error/ErrorMvcAutoConfiguration.html)| -|[`FacebookAutoConfiguration`](https://github.com/spring-projects/spring-boot/tree/v2.0.0.RELEASE/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/social/FacebookAutoConfiguration.java)|[javadoc](https://docs.spring.io/spring-boot/docs/2.0.0.RELEASE/api/org/springframework/boot/autoconfigure/social/FacebookAutoConfiguration.html)| -|[`FallbackWebSecurityAutoConfiguration`](https://github.com/spring-projects/spring-boot/tree/v2.0.0.RELEASE/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/security/FallbackWebSecurityAutoConfiguration.java)|[javadoc](https://docs.spring.io/spring-boot/docs/2.0.0.RELEASE/api/org/springframework/boot/autoconfigure/security/FallbackWebSecurityAutoConfiguration.html)| +|[`EmbeddedLdapAutoConfiguration`](https://github.com/spring-projects/spring-boot/tree/v2.0.0.RELEASE/spring-boot-project/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/ldap/embedded/EmbeddedLdapAutoConfiguration.java)|[javadoc](https://docs.spring.io/spring-boot/docs/2.0.0.RELEASE/api/org/springframework/boot/autoconfigure/ldap/embedded/EmbeddedLdapAutoConfiguration.html)| +|[`EmbeddedMongoAutoConfiguration`](https://github.com/spring-projects/spring-boot/tree/v2.0.0.RELEASE/spring-boot-project/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/mongo/embedded/EmbeddedMongoAutoConfiguration.java)|[javadoc](https://docs.spring.io/spring-boot/docs/2.0.0.RELEASE/api/org/springframework/boot/autoconfigure/mongo/embedded/EmbeddedMongoAutoConfiguration.html)| +|[`EmbeddedWebServerFactoryCustomizerAutoConfiguration`](https://github.com/spring-projects/spring-boot/tree/v2.0.0.RELEASE/spring-boot-project/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/web/embedded/EmbeddedWebServerFactoryCustomizerAutoConfiguration.java)|[javadoc](https://docs.spring.io/spring-boot/docs/2.0.0.RELEASE/api/org/springframework/boot/autoconfigure/web/embedded/EmbeddedWebServerFactoryCustomizerAutoConfiguration.html)| +|[`ErrorMvcAutoConfiguration`](https://github.com/spring-projects/spring-boot/tree/v2.0.0.RELEASE/spring-boot-project/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/web/servlet/error/ErrorMvcAutoConfiguration.java)|[javadoc](https://docs.spring.io/spring-boot/docs/2.0.0.RELEASE/api/org/springframework/boot/autoconfigure/web/servlet/error/ErrorMvcAutoConfiguration.html)| +|[`ErrorWebFluxAutoConfiguration`](https://github.com/spring-projects/spring-boot/tree/v2.0.0.RELEASE/spring-boot-project/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/web/reactive/error/ErrorWebFluxAutoConfiguration.java)|[javadoc](https://docs.spring.io/spring-boot/docs/2.0.0.RELEASE/api/org/springframework/boot/autoconfigure/web/reactive/error/ErrorWebFluxAutoConfiguration.html)| |[`FlywayAutoConfiguration`](https://github.com/spring-projects/spring-boot/tree/v2.0.0.RELEASE/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/flyway/FlywayAutoConfiguration.java)|[javadoc](https://docs.spring.io/spring-boot/docs/2.0.0.RELEASE/api/org/springframework/boot/autoconfigure/flyway/FlywayAutoConfiguration.html)| |[`FreeMarkerAutoConfiguration`](https://github.com/spring-projects/spring-boot/tree/v2.0.0.RELEASE/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/freemarker/FreeMarkerAutoConfiguration.java)|[javadoc](https://docs.spring.io/spring-boot/docs/2.0.0.RELEASE/api/org/springframework/boot/autoconfigure/freemarker/FreeMarkerAutoConfiguration.html)| |[`GroovyTemplateAutoConfiguration`](https://github.com/spring-projects/spring-boot/tree/v2.0.0.RELEASE/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/groovy/template/GroovyTemplateAutoConfiguration.java)|[javadoc](https://docs.spring.io/spring-boot/docs/2.0.0.RELEASE/api/org/springframework/boot/autoconfigure/groovy/template/GroovyTemplateAutoConfiguration.html)| From 9598b9cffee5a8c09af45412c79659136cea9d59 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E7=83=AD=E5=BF=83=E5=B8=82=E6=B0=91=E9=92=9F=E5=B0=8F?= =?UTF-8?q?=E5=BC=BA?= Date: Fri, 20 Mar 2020 16:59:04 +0800 Subject: [PATCH 838/865] =?UTF-8?q?Update=20C.1.=20From=20the=20=E2=80=9Cs?= =?UTF-8?q?pring-boot-autoconfigure=E2=80=9D=20module.md?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- ...-boot-autoconfigure\342\200\235 module.md" | 51 +++++++++++++++++-- 1 file changed, 47 insertions(+), 4 deletions(-) diff --git "a/X. Appendices/C.1. From the \342\200\234spring-boot-autoconfigure\342\200\235 module.md" "b/X. Appendices/C.1. From the \342\200\234spring-boot-autoconfigure\342\200\235 module.md" index 5ab56f01..7036f576 100644 --- "a/X. Appendices/C.1. From the \342\200\234spring-boot-autoconfigure\342\200\235 module.md" +++ "b/X. Appendices/C.1. From the \342\200\234spring-boot-autoconfigure\342\200\235 module.md" @@ -33,7 +33,50 @@ |[`EmbeddedWebServerFactoryCustomizerAutoConfiguration`](https://github.com/spring-projects/spring-boot/tree/v2.0.0.RELEASE/spring-boot-project/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/web/embedded/EmbeddedWebServerFactoryCustomizerAutoConfiguration.java)|[javadoc](https://docs.spring.io/spring-boot/docs/2.0.0.RELEASE/api/org/springframework/boot/autoconfigure/web/embedded/EmbeddedWebServerFactoryCustomizerAutoConfiguration.html)| |[`ErrorMvcAutoConfiguration`](https://github.com/spring-projects/spring-boot/tree/v2.0.0.RELEASE/spring-boot-project/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/web/servlet/error/ErrorMvcAutoConfiguration.java)|[javadoc](https://docs.spring.io/spring-boot/docs/2.0.0.RELEASE/api/org/springframework/boot/autoconfigure/web/servlet/error/ErrorMvcAutoConfiguration.html)| |[`ErrorWebFluxAutoConfiguration`](https://github.com/spring-projects/spring-boot/tree/v2.0.0.RELEASE/spring-boot-project/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/web/reactive/error/ErrorWebFluxAutoConfiguration.java)|[javadoc](https://docs.spring.io/spring-boot/docs/2.0.0.RELEASE/api/org/springframework/boot/autoconfigure/web/reactive/error/ErrorWebFluxAutoConfiguration.html)| -|[`FlywayAutoConfiguration`](https://github.com/spring-projects/spring-boot/tree/v2.0.0.RELEASE/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/flyway/FlywayAutoConfiguration.java)|[javadoc](https://docs.spring.io/spring-boot/docs/2.0.0.RELEASE/api/org/springframework/boot/autoconfigure/flyway/FlywayAutoConfiguration.html)| -|[`FreeMarkerAutoConfiguration`](https://github.com/spring-projects/spring-boot/tree/v2.0.0.RELEASE/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/freemarker/FreeMarkerAutoConfiguration.java)|[javadoc](https://docs.spring.io/spring-boot/docs/2.0.0.RELEASE/api/org/springframework/boot/autoconfigure/freemarker/FreeMarkerAutoConfiguration.html)| -|[`GroovyTemplateAutoConfiguration`](https://github.com/spring-projects/spring-boot/tree/v2.0.0.RELEASE/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/groovy/template/GroovyTemplateAutoConfiguration.java)|[javadoc](https://docs.spring.io/spring-boot/docs/2.0.0.RELEASE/api/org/springframework/boot/autoconfigure/groovy/template/GroovyTemplateAutoConfiguration.html)| -|[`GsonAutoConfiguration`](https://github.com/spring-projects/spring-boot/tree/v2.0.0.RELEASE/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/gson/GsonAutoConfiguration.java)|[javadoc](https://docs.spring.io/spring-boot/docs/2.0.0.RELEASE/api/org/springframework/boot/autoconfigure/gson/GsonAutoConfiguration.html)| +|[`FlywayAutoConfiguration`](https://github.com/spring-projects/spring-boot/tree/v2.0.0.RELEASE/spring-boot-project/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/flyway/FlywayAutoConfiguration.java)|[javadoc](https://docs.spring.io/spring-boot/docs/2.0.0.RELEASE/api/org/springframework/boot/autoconfigure/flyway/FlywayAutoConfiguration.html)| +|[`FreeMarkerAutoConfiguration`](https://github.com/spring-projects/spring-boot/tree/v2.0.0.RELEASE/spring-boot-project/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/freemarker/FreeMarkerAutoConfiguration.java)|[javadoc](https://docs.spring.io/spring-boot/docs/2.0.0.RELEASE/api/org/springframework/boot/autoconfigure/freemarker/FreeMarkerAutoConfiguration.html)| +|[`GroovyTemplateAutoConfiguration`](https://github.com/spring-projects/spring-boot/tree/v2.0.0.RELEASE/spring-boot-project/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/groovy/template/GroovyTemplateAutoConfiguration.java)|[javadoc](https://docs.spring.io/spring-boot/docs/2.0.0.RELEASE/api/org/springframework/boot/autoconfigure/groovy/template/GroovyTemplateAutoConfiguration.html)| +|[`GsonAutoConfiguration`](https://github.com/spring-projects/spring-boot/tree/v2.0.0.RELEASE/spring-boot-project/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/gson/GsonAutoConfiguration.java)|[javadoc](https://docs.spring.io/spring-boot/docs/2.0.0.RELEASE/api/org/springframework/boot/autoconfigure/gson/GsonAutoConfiguration.html)| +|[`H2ConsoleAutoConfiguration`](https://github.com/spring-projects/spring-boot/tree/v2.0.0.RELEASE/spring-boot-project/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/h2/H2ConsoleAutoConfiguration.java)|[javadoc](https://docs.spring.io/spring-boot/docs/2.0.0.RELEASE/api/org/springframework/boot/autoconfigure/h2/H2ConsoleAutoConfiguration.html)| +|[`HazelcastAutoConfiguration`](https://github.com/spring-projects/spring-boot/tree/v2.0.0.RELEASE/spring-boot-project/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/hazelcast/HazelcastAutoConfiguration.java)|[javadoc](https://docs.spring.io/spring-boot/docs/2.0.0.RELEASE/api/org/springframework/boot/autoconfigure/hazelcast/HazelcastAutoConfiguration.html)| +|[`HazelcastJpaDependencyAutoConfiguration`](https://github.com/spring-projects/spring-boot/tree/v2.0.0.RELEASE/spring-boot-project/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/hazelcast/HazelcastJpaDependencyAutoConfiguration.java)|[javadoc](https://docs.spring.io/spring-boot/docs/2.0.0.RELEASE/api/org/springframework/boot/autoconfigure/hazelcast/HazelcastJpaDependencyAutoConfiguration.html)| +|[`HibernateJpaAutoConfiguration`](https://github.com/spring-projects/spring-boot/tree/v2.0.0.RELEASE/spring-boot-project/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/orm/jpa/HibernateJpaAutoConfiguration.java)|[javadoc](https://docs.spring.io/spring-boot/docs/2.0.0.RELEASE/api/org/springframework/boot/autoconfigure/orm/jpa/HibernateJpaAutoConfiguration.html)| +|[`HttpEncodingAutoConfiguration`](https://github.com/spring-projects/spring-boot/tree/v2.0.0.RELEASE/spring-boot-project/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/web/servlet/HttpEncodingAutoConfiguration.java)|[javadoc](https://docs.spring.io/spring-boot/docs/2.0.0.RELEASE/api/org/springframework/boot/autoconfigure/web/servlet/HttpEncodingAutoConfiguration.html)| +|[`HttpHandlerAutoConfiguration`](https://github.com/spring-projects/spring-boot/tree/v2.0.0.RELEASE/spring-boot-project/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/web/reactive/HttpHandlerAutoConfiguration.java)|[javadoc](https://docs.spring.io/spring-boot/docs/2.0.0.RELEASE/api/org/springframework/boot/autoconfigure/web/reactive/HttpHandlerAutoConfiguration.html)| +|[`HttpMessageConvertersAutoConfiguration`](https://github.com/spring-projects/spring-boot/tree/v2.0.0.RELEASE/spring-boot-project/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/http/HttpMessageConvertersAutoConfiguration.java)|[javadoc](https://docs.spring.io/spring-boot/docs/2.0.0.RELEASE/api/org/springframework/boot/autoconfigure/http/HttpMessageConvertersAutoConfiguration.html)| +|[`HypermediaAutoConfiguration`](https://github.com/spring-projects/spring-boot/tree/v2.0.0.RELEASE/spring-boot-project/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/hateoas/HypermediaAutoConfiguration.java)|[javadoc](https://docs.spring.io/spring-boot/docs/2.0.0.RELEASE/api/org/springframework/boot/autoconfigure/hateoas/HypermediaAutoConfiguration.html)| +|[`InfluxDbAutoConfiguration`](https://github.com/spring-projects/spring-boot/tree/v2.0.0.RELEASE/spring-boot-project/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/influx/InfluxDbAutoConfiguration.java)|[javadoc](https://docs.spring.io/spring-boot/docs/2.0.0.RELEASE/api/org/springframework/boot/autoconfigure/influx/InfluxDbAutoConfiguration.html)| +|[`IntegrationAutoConfiguration`](https://github.com/spring-projects/spring-boot/tree/v2.0.0.RELEASE/spring-boot-project/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/integration/IntegrationAutoConfiguration.java)|[javadoc](https://docs.spring.io/spring-boot/docs/2.0.0.RELEASE/api/org/springframework/boot/autoconfigure/integration/IntegrationAutoConfiguration.html)| +|[`JacksonAutoConfiguration`](https://github.com/spring-projects/spring-boot/tree/v2.0.0.RELEASE/spring-boot-project/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/jackson/JacksonAutoConfiguration.java)|[javadoc](https://docs.spring.io/spring-boot/docs/2.0.0.RELEASE/api/org/springframework/boot/autoconfigure/jackson/JacksonAutoConfiguration.html)| +|[`JdbcTemplateAutoConfiguration`](https://github.com/spring-projects/spring-boot/tree/v2.0.0.RELEASE/spring-boot-project/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/jdbc/JdbcTemplateAutoConfiguration.java)|[javadoc](https://docs.spring.io/spring-boot/docs/2.0.0.RELEASE/api/org/springframework/boot/autoconfigure/jdbc/JdbcTemplateAutoConfiguration.html)| +|[`JerseyAutoConfiguration`](https://github.com/spring-projects/spring-boot/tree/v2.0.0.RELEASE/spring-boot-project/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/jersey/JerseyAutoConfiguration.java)|[javadoc](https://docs.spring.io/spring-boot/docs/2.0.0.RELEASE/api/org/springframework/boot/autoconfigure/jersey/JerseyAutoConfiguration.html)| +|[`JestAutoConfiguration`](https://github.com/spring-projects/spring-boot/tree/v2.0.0.RELEASE/spring-boot-project/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/elasticsearch/jest/JestAutoConfiguration.java)|[javadoc](https://docs.spring.io/spring-boot/docs/2.0.0.RELEASE/api/org/springframework/boot/autoconfigure/elasticsearch/jest/JestAutoConfiguration.html)| +|[`JmsAutoConfiguration`](https://github.com/spring-projects/spring-boot/tree/v2.0.0.RELEASE/spring-boot-project/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/jms/JmsAutoConfiguration.java)|[javadoc](https://docs.spring.io/spring-boot/docs/2.0.0.RELEASE/api/org/springframework/boot/autoconfigure/jms/JmsAutoConfiguration.html)| +|[`JmxAutoConfiguration`](https://github.com/spring-projects/spring-boot/tree/v2.0.0.RELEASE/spring-boot-project/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/jmx/JmxAutoConfiguration.java)|[javadoc](https://docs.spring.io/spring-boot/docs/2.0.0.RELEASE/api/org/springframework/boot/autoconfigure/jmx/JmxAutoConfiguration.html)| +|[`JndiConnectionFactoryAutoConfiguration`](https://github.com/spring-projects/spring-boot/tree/v2.0.0.RELEASE/spring-boot-project/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/jms/JndiConnectionFactoryAutoConfiguration.java)|[javadoc](https://docs.spring.io/spring-boot/docs/2.0.0.RELEASE/api/org/springframework/boot/autoconfigure/jms/JndiConnectionFactoryAutoConfiguration.html)| +|[`JndiDataSourceAutoConfiguration`](https://github.com/spring-projects/spring-boot/tree/v2.0.0.RELEASE/spring-boot-project/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/jdbc/JndiDataSourceAutoConfiguration.java)|[javadoc](https://docs.spring.io/spring-boot/docs/2.0.0.RELEASE/api/org/springframework/boot/autoconfigure/jdbc/JndiDataSourceAutoConfiguration.html)| +|[`JooqAutoConfiguration`](https://github.com/spring-projects/spring-boot/tree/v2.0.0.RELEASE/spring-boot-project/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/jooq/JooqAutoConfiguration.java)|[javadoc](https://docs.spring.io/spring-boot/docs/2.0.0.RELEASE/api/org/springframework/boot/autoconfigure/jooq/JooqAutoConfiguration.html)|[`JpaRepositoriesAutoConfiguration`](https://github.com/spring-projects/spring-boot/tree/v2.0.0.RELEASE/spring-boot-project/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/data/jpa/JpaRepositoriesAutoConfiguration.java)|[javadoc](https://docs.spring.io/spring-boot/docs/2.0.0.RELEASE/api/org/springframework/boot/autoconfigure/data/jpa/JpaRepositoriesAutoConfiguration.html)| +|[`JsonbAutoConfiguration`](https://github.com/spring-projects/spring-boot/tree/v2.0.0.RELEASE/spring-boot-project/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/jsonb/JsonbAutoConfiguration.java)|[javadoc](https://docs.spring.io/spring-boot/docs/2.0.0.RELEASE/api/org/springframework/boot/autoconfigure/jsonb/JsonbAutoConfiguration.html)| +|[`JtaAutoConfiguration`](https://github.com/spring-projects/spring-boot/tree/v2.0.0.RELEASE/spring-boot-project/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/transaction/jta/JtaAutoConfiguration.java)|[javadoc](https://docs.spring.io/spring-boot/docs/2.0.0.RELEASE/api/org/springframework/boot/autoconfigure/transaction/jta/JtaAutoConfiguration.html)| +|[`KafkaAutoConfiguration`](https://github.com/spring-projects/spring-boot/tree/v2.0.0.RELEASE/spring-boot-project/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/kafka/KafkaAutoConfiguration.java)|[javadoc](https://docs.spring.io/spring-boot/docs/2.0.0.RELEASE/api/org/springframework/boot/autoconfigure/kafka/KafkaAutoConfiguration.html)| +|[`LdapAutoConfiguration`](https://github.com/spring-projects/spring-boot/tree/v2.0.0.RELEASE/spring-boot-project/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/ldap/LdapAutoConfiguration.java)|[javadoc](https://docs.spring.io/spring-boot/docs/2.0.0.RELEASE/api/org/springframework/boot/autoconfigure/ldap/LdapAutoConfiguration.html)| +|[`LdapDataAutoConfiguration`](https://github.com/spring-projects/spring-boot/tree/v2.0.0.RELEASE/spring-boot-project/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/data/ldap/LdapDataAutoConfiguration.java)|[javadoc](https://docs.spring.io/spring-boot/docs/2.0.0.RELEASE/api/org/springframework/boot/autoconfigure/data/ldap/LdapDataAutoConfiguration.html)| +|[`LdapRepositoriesAutoConfiguration`](https://github.com/spring-projects/spring-boot/tree/v2.0.0.RELEASE/spring-boot-project/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/data/ldap/LdapRepositoriesAutoConfiguration.java)|[javadoc](https://docs.spring.io/spring-boot/docs/2.0.0.RELEASE/api/org/springframework/boot/autoconfigure/data/ldap/LdapRepositoriesAutoConfiguration.html)| +|[`LiquibaseAutoConfiguration`](https://github.com/spring-projects/spring-boot/tree/v2.0.0.RELEASE/spring-boot-project/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/liquibase/LiquibaseAutoConfiguration.java)|[javadoc](https://docs.spring.io/spring-boot/docs/2.0.0.RELEASE/api/org/springframework/boot/autoconfigure/liquibase/LiquibaseAutoConfiguration.html)| +|[`MailSenderAutoConfiguration`](https://github.com/spring-projects/spring-boot/tree/v2.0.0.RELEASE/spring-boot-project/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/mail/MailSenderAutoConfiguration.java)|[javadoc](https://docs.spring.io/spring-boot/docs/2.0.0.RELEASE/api/org/springframework/boot/autoconfigure/mail/MailSenderAutoConfiguration.html)| +|[`MailSenderValidatorAutoConfiguration`](https://github.com/spring-projects/spring-boot/tree/v2.0.0.RELEASE/spring-boot-project/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/mail/MailSenderValidatorAutoConfiguration.java)|[javadoc](https://docs.spring.io/spring-boot/docs/2.0.0.RELEASE/api/org/springframework/boot/autoconfigure/mail/MailSenderValidatorAutoConfiguration.html)| +|[`MessageSourceAutoConfiguration`](https://github.com/spring-projects/spring-boot/tree/v2.0.0.RELEASE/spring-boot-project/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/context/MessageSourceAutoConfiguration.java)|[javadoc](https://docs.spring.io/spring-boot/docs/2.0.0.RELEASE/api/org/springframework/boot/autoconfigure/context/MessageSourceAutoConfiguration.html)| +|[`MongoAutoConfiguration`](https://github.com/spring-projects/spring-boot/tree/v2.0.0.RELEASE/spring-boot-project/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/mongo/MongoAutoConfiguration.java)|[javadoc](https://docs.spring.io/spring-boot/docs/2.0.0.RELEASE/api/org/springframework/boot/autoconfigure/mongo/MongoAutoConfiguration.html)| +|[`MongoDataAutoConfiguration`](https://github.com/spring-projects/spring-boot/tree/v2.0.0.RELEASE/spring-boot-project/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/data/mongo/MongoDataAutoConfiguration.java)|[javadoc](https://docs.spring.io/spring-boot/docs/2.0.0.RELEASE/api/org/springframework/boot/autoconfigure/data/mongo/MongoDataAutoConfiguration.html)| +|[`MongoReactiveAutoConfiguration`](https://github.com/spring-projects/spring-boot/tree/v2.0.0.RELEASE/spring-boot-project/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/mongo/MongoReactiveAutoConfiguration.java)|[javadoc](https://docs.spring.io/spring-boot/docs/2.0.0.RELEASE/api/org/springframework/boot/autoconfigure/mongo/MongoReactiveAutoConfiguration.html)| +|[`MongoReactiveDataAutoConfiguration`](https://github.com/spring-projects/spring-boot/tree/v2.0.0.RELEASE/spring-boot-project/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/data/mongo/MongoReactiveDataAutoConfiguration.java)|[javadoc](https://docs.spring.io/spring-boot/docs/2.0.0.RELEASE/api/org/springframework/boot/autoconfigure/data/mongo/MongoReactiveDataAutoConfiguration.html)| +|[`MongoReactiveRepositoriesAutoConfiguration`](https://github.com/spring-projects/spring-boot/tree/v2.0.0.RELEASE/spring-boot-project/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/data/mongo/MongoReactiveRepositoriesAutoConfiguration.java)|[javadoc](https://docs.spring.io/spring-boot/docs/2.0.0.RELEASE/api/org/springframework/boot/autoconfigure/data/mongo/MongoReactiveRepositoriesAutoConfiguration.html)| +|[`MongoRepositoriesAutoConfiguration`](https://github.com/spring-projects/spring-boot/tree/v2.0.0.RELEASE/spring-boot-project/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/data/mongo/MongoRepositoriesAutoConfiguration.java)|[javadoc](https://docs.spring.io/spring-boot/docs/2.0.0.RELEASE/api/org/springframework/boot/autoconfigure/data/mongo/MongoRepositoriesAutoConfiguration.html)| +|[`MultipartAutoConfiguration`](https://github.com/spring-projects/spring-boot/tree/v2.0.0.RELEASE/spring-boot-project/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/web/servlet/MultipartAutoConfiguration.java)|[javadoc](https://docs.spring.io/spring-boot/docs/2.0.0.RELEASE/api/org/springframework/boot/autoconfigure/web/servlet/MultipartAutoConfiguration.html)| +|[`MustacheAutoConfiguration`](https://github.com/spring-projects/spring-boot/tree/v2.0.0.RELEASE/spring-boot-project/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/mustache/MustacheAutoConfiguration.java)|[javadoc](https://docs.spring.io/spring-boot/docs/2.0.0.RELEASE/api/org/springframework/boot/autoconfigure/mustache/MustacheAutoConfiguration.html)| +|[`Neo4jDataAutoConfiguration`](https://github.com/spring-projects/spring-boot/tree/v2.0.0.RELEASE/spring-boot-project/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/data/neo4j/Neo4jDataAutoConfiguration.java)|[javadoc](https://docs.spring.io/spring-boot/docs/2.0.0.RELEASE/api/org/springframework/boot/autoconfigure/data/neo4j/Neo4jDataAutoConfiguration.html)| +|[`Neo4jRepositoriesAutoConfiguration`](https://github.com/spring-projects/spring-boot/tree/v2.0.0.RELEASE/spring-boot-project/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/data/neo4j/Neo4jRepositoriesAutoConfiguration.java)|[javadoc](https://docs.spring.io/spring-boot/docs/2.0.0.RELEASE/api/org/springframework/boot/autoconfigure/data/neo4j/Neo4jRepositoriesAutoConfiguration.html)| +|[`OAuth2ClientAutoConfiguration`](https://github.com/spring-projects/spring-boot/tree/v2.0.0.RELEASE/spring-boot-project/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/security/oauth2/client/OAuth2ClientAutoConfiguration.java)|[javadoc](https://docs.spring.io/spring-boot/docs/2.0.0.RELEASE/api/org/springframework/boot/autoconfigure/security/oauth2/client/OAuth2ClientAutoConfiguration.html)| +|[`PersistenceExceptionTranslationAutoConfiguration`](https://github.com/spring-projects/spring-boot/tree/v2.0.0.RELEASE/spring-boot-project/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/dao/PersistenceExceptionTranslationAutoConfiguration.java)|[javadoc](https://docs.spring.io/spring-boot/docs/2.0.0.RELEASE/api/org/springframework/boot/autoconfigure/dao/PersistenceExceptionTranslationAutoConfiguration.html)| +|[`ProjectInfoAutoConfiguration`](https://github.com/spring-projects/spring-boot/tree/v2.0.0.RELEASE/spring-boot-project/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/info/ProjectInfoAutoConfiguration.java)|[javadoc](https://docs.spring.io/spring-boot/docs/2.0.0.RELEASE/api/org/springframework/boot/autoconfigure/info/ProjectInfoAutoConfiguration.html)| +|[`PropertyPlaceholderAutoConfiguration`](https://github.com/spring-projects/spring-boot/tree/v2.0.0.RELEASE/spring-boot-project/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/context/PropertyPlaceholderAutoConfiguration.java)|[javadoc](https://docs.spring.io/spring-boot/docs/2.0.0.RELEASE/api/org/springframework/boot/autoconfigure/context/PropertyPlaceholderAutoConfiguration.html)| From c1936b9a6137c3e519c92a081f22a30eb04484f8 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E7=83=AD=E5=BF=83=E5=B8=82=E6=B0=91=E9=92=9F=E5=B0=8F?= =?UTF-8?q?=E5=BC=BA?= Date: Fri, 20 Mar 2020 19:50:08 +0800 Subject: [PATCH 839/865] =?UTF-8?q?Update=20C.1.=20From=20the=20=E2=80=9Cs?= =?UTF-8?q?pring-boot-autoconfigure=E2=80=9D=20module.md?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- ...-boot-autoconfigure\342\200\235 module.md" | 23 +++++++++++++++++++ 1 file changed, 23 insertions(+) diff --git "a/X. Appendices/C.1. From the \342\200\234spring-boot-autoconfigure\342\200\235 module.md" "b/X. Appendices/C.1. From the \342\200\234spring-boot-autoconfigure\342\200\235 module.md" index 7036f576..b27015a6 100644 --- "a/X. Appendices/C.1. From the \342\200\234spring-boot-autoconfigure\342\200\235 module.md" +++ "b/X. Appendices/C.1. From the \342\200\234spring-boot-autoconfigure\342\200\235 module.md" @@ -80,3 +80,26 @@ |[`PersistenceExceptionTranslationAutoConfiguration`](https://github.com/spring-projects/spring-boot/tree/v2.0.0.RELEASE/spring-boot-project/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/dao/PersistenceExceptionTranslationAutoConfiguration.java)|[javadoc](https://docs.spring.io/spring-boot/docs/2.0.0.RELEASE/api/org/springframework/boot/autoconfigure/dao/PersistenceExceptionTranslationAutoConfiguration.html)| |[`ProjectInfoAutoConfiguration`](https://github.com/spring-projects/spring-boot/tree/v2.0.0.RELEASE/spring-boot-project/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/info/ProjectInfoAutoConfiguration.java)|[javadoc](https://docs.spring.io/spring-boot/docs/2.0.0.RELEASE/api/org/springframework/boot/autoconfigure/info/ProjectInfoAutoConfiguration.html)| |[`PropertyPlaceholderAutoConfiguration`](https://github.com/spring-projects/spring-boot/tree/v2.0.0.RELEASE/spring-boot-project/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/context/PropertyPlaceholderAutoConfiguration.java)|[javadoc](https://docs.spring.io/spring-boot/docs/2.0.0.RELEASE/api/org/springframework/boot/autoconfigure/context/PropertyPlaceholderAutoConfiguration.html)| +|[`QuartzAutoConfiguration`](https://github.com/spring-projects/spring-boot/tree/v2.0.0.RELEASE/spring-boot-project/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/quartz/QuartzAutoConfiguration.java)|[javadoc](https://docs.spring.io/spring-boot/docs/2.0.0.RELEASE/api/org/springframework/boot/autoconfigure/quartz/QuartzAutoConfiguration.html)| +|[`RabbitAutoConfiguration`](https://github.com/spring-projects/spring-boot/tree/v2.0.0.RELEASE/spring-boot-project/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/amqp/RabbitAutoConfiguration.java)|[javadoc](https://docs.spring.io/spring-boot/docs/2.0.0.RELEASE/api/org/springframework/boot/autoconfigure/amqp/RabbitAutoConfiguration.html)| +|[`ReactiveSecurityAutoConfiguration`](https://github.com/spring-projects/spring-boot/tree/v2.0.0.RELEASE/spring-boot-project/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/security/reactive/ReactiveSecurityAutoConfiguration.java)|[javadoc](https://docs.spring.io/spring-boot/docs/2.0.0.RELEASE/api/org/springframework/boot/autoconfigure/security/reactive/ReactiveSecurityAutoConfiguration.html)| +|[`ReactiveUserDetailsServiceAutoConfiguration`](https://github.com/spring-projects/spring-boot/tree/v2.0.0.RELEASE/spring-boot-project/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/security/reactive/ReactiveUserDetailsServiceAutoConfiguration.java)|[javadoc](https://docs.spring.io/spring-boot/docs/2.0.0.RELEASE/api/org/springframework/boot/autoconfigure/security/reactive/ReactiveUserDetailsServiceAutoConfiguration.html)| +|[`ReactiveWebServerFactoryAutoConfiguration`](https://github.com/spring-projects/spring-boot/tree/v2.0.0.RELEASE/spring-boot-project/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/web/reactive/ReactiveWebServerFactoryAutoConfiguration.java)|[javadoc](https://docs.spring.io/spring-boot/docs/2.0.0.RELEASE/api/org/springframework/boot/autoconfigure/web/reactive/ReactiveWebServerFactoryAutoConfiguration.html)| +|[`ReactorCoreAutoConfiguration`](https://github.com/spring-projects/spring-boot/tree/v2.0.0.RELEASE/spring-boot-project/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/reactor/core/ReactorCoreAutoConfiguration.java)|[javadoc](https://docs.spring.io/spring-boot/docs/2.0.0.RELEASE/api/org/springframework/boot/autoconfigure/reactor/core/ReactorCoreAutoConfiguration.html)| +|[`RedisAutoConfiguration`](https://github.com/spring-projects/spring-boot/tree/v2.0.0.RELEASE/spring-boot-project/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/data/redis/RedisAutoConfiguration.java)|[javadoc](https://docs.spring.io/spring-boot/docs/2.0.0.RELEASE/api/org/springframework/boot/autoconfigure/data/redis/RedisAutoConfiguration.html)| +|[`RedisReactiveAutoConfiguration`](https://github.com/spring-projects/spring-boot/tree/v2.0.0.RELEASE/spring-boot-project/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/data/redis/RedisReactiveAutoConfiguration.java)|[javadoc](https://docs.spring.io/spring-boot/docs/2.0.0.RELEASE/api/org/springframework/boot/autoconfigure/data/redis/RedisReactiveAutoConfiguration.html)| +|[`RedisRepositoriesAutoConfiguration`](https://github.com/spring-projects/spring-boot/tree/v2.0.0.RELEASE/spring-boot-project/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/data/redis/RedisRepositoriesAutoConfiguration.java)|[javadoc](https://docs.spring.io/spring-boot/docs/2.0.0.RELEASE/api/org/springframework/boot/autoconfigure/data/redis/RedisRepositoriesAutoConfiguration.html)| +|[`RepositoryRestMvcAutoConfiguration`](https://github.com/spring-projects/spring-boot/tree/v2.0.0.RELEASE/spring-boot-project/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/data/rest/RepositoryRestMvcAutoConfiguration.java)|[javadoc](https://docs.spring.io/spring-boot/docs/2.0.0.RELEASE/api/org/springframework/boot/autoconfigure/data/rest/RepositoryRestMvcAutoConfiguration.html)| +|[`RestTemplateAutoConfiguration`](https://github.com/spring-projects/spring-boot/tree/v2.0.0.RELEASE/spring-boot-project/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/web/client/RestTemplateAutoConfiguration.java)|[javadoc](https://docs.spring.io/spring-boot/docs/2.0.0.RELEASE/api/org/springframework/boot/autoconfigure/web/client/RestTemplateAutoConfiguration.html)| +|[`SecurityAutoConfiguration`](https://github.com/spring-projects/spring-boot/tree/v2.0.0.RELEASE/spring-boot-project/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/security/servlet/SecurityAutoConfiguration.java)|[javadoc](https://docs.spring.io/spring-boot/docs/2.0.0.RELEASE/api/org/springframework/boot/autoconfigure/security/servlet/SecurityAutoConfiguration.html)| +|[`SecurityFilterAutoConfiguration`](https://github.com/spring-projects/spring-boot/tree/v2.0.0.RELEASE/spring-boot-project/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/security/servlet/SecurityFilterAutoConfiguration.java)|[javadoc](https://docs.spring.io/spring-boot/docs/2.0.0.RELEASE/api/org/springframework/boot/autoconfigure/security/servlet/SecurityFilterAutoConfiguration.html)| +|[`SendGridAutoConfiguration`](https://github.com/spring-projects/spring-boot/tree/v2.0.0.RELEASE/spring-boot-project/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/sendgrid/SendGridAutoConfiguration.java)|[javadoc](https://docs.spring.io/spring-boot/docs/2.0.0.RELEASE/api/org/springframework/boot/autoconfigure/sendgrid/SendGridAutoConfiguration.html)| +|[`ServletWebServerFactoryAutoConfiguration`](https://github.com/spring-projects/spring-boot/tree/v2.0.0.RELEASE/spring-boot-project/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/web/servlet/ServletWebServerFactoryAutoConfiguration.java)|[javadoc](https://docs.spring.io/spring-boot/docs/2.0.0.RELEASE/api/org/springframework/boot/autoconfigure/web/servlet/ServletWebServerFactoryAutoConfiguration.html)| +|[`SessionAutoConfiguration`](https://github.com/spring-projects/spring-boot/tree/v2.0.0.RELEASE/spring-boot-project/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/session/SessionAutoConfiguration.java)|[javadoc](https://docs.spring.io/spring-boot/docs/2.0.0.RELEASE/api/org/springframework/boot/autoconfigure/session/SessionAutoConfiguration.html)| +|[`SolrAutoConfiguration`](https://github.com/spring-projects/spring-boot/tree/v2.0.0.RELEASE/spring-boot-project/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/solr/SolrAutoConfiguration.java)|[javadoc](https://docs.spring.io/spring-boot/docs/2.0.0.RELEASE/api/org/springframework/boot/autoconfigure/solr/SolrAutoConfiguration.html)| +|[`SolrRepositoriesAutoConfiguration`](https://github.com/spring-projects/spring-boot/tree/v2.0.0.RELEASE/spring-boot-project/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/data/solr/SolrRepositoriesAutoConfiguration.java)|[javadoc](https://docs.spring.io/spring-boot/docs/2.0.0.RELEASE/api/org/springframework/boot/autoconfigure/data/solr/SolrRepositoriesAutoConfiguration.html)| +|[`SpringApplicationAdminJmxAutoConfiguration`](https://github.com/spring-projects/spring-boot/tree/v2.0.0.RELEASE/spring-boot-project/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/admin/SpringApplicationAdminJmxAutoConfiguration.java)|[javadoc](https://docs.spring.io/spring-boot/docs/2.0.0.RELEASE/api/org/springframework/boot/autoconfigure/admin/SpringApplicationAdminJmxAutoConfiguration.html)| +|[`SpringDataWebAutoConfiguration`](https://github.com/spring-projects/spring-boot/tree/v2.0.0.RELEASE/spring-boot-project/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/data/web/SpringDataWebAutoConfiguration.java)|[javadoc](https://docs.spring.io/spring-boot/docs/2.0.0.RELEASE/api/org/springframework/boot/autoconfigure/data/web/SpringDataWebAutoConfiguration.html)| +|[`ThymeleafAutoConfiguration`](https://github.com/spring-projects/spring-boot/tree/v2.0.0.RELEASE/spring-boot-project/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/thymeleaf/ThymeleafAutoConfiguration.java)|[javadoc](https://docs.spring.io/spring-boot/docs/2.0.0.RELEASE/api/org/springframework/boot/autoconfigure/thymeleaf/ThymeleafAutoConfiguration.html)| +|[`TransactionAutoConfiguration`](https://github.com/spring-projects/spring-boot/tree/v2.0.0.RELEASE/spring-boot-project/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/transaction/TransactionAutoConfiguration.java)|[javadoc](https://docs.spring.io/spring-boot/docs/2.0.0.RELEASE/api/org/springframework/boot/autoconfigure/transaction/TransactionAutoConfiguration.html)| +|[`UserDetailsServiceAutoConfiguration`](https://github.com/spring-projects/spring-boot/tree/v2.0.0.RELEASE/spring-boot-project/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/security/servlet/UserDetailsServiceAutoConfiguration.java)|[javadoc](https://docs.spring.io/spring-boot/docs/2.0.0.RELEASE/api/org/springframework/boot/autoconfigure/security/servlet/UserDetailsServiceAutoConfiguration.html)| From de27525f184bda2ed0e4244de85767e0cd206749 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E7=83=AD=E5=BF=83=E5=B8=82=E6=B0=91=E9=92=9F=E5=B0=8F?= =?UTF-8?q?=E5=BC=BA?= Date: Sat, 28 Mar 2020 15:00:18 +0800 Subject: [PATCH 840/865] =?UTF-8?q?Update=20C.1.=20From=20the=20=E2=80=9Cs?= =?UTF-8?q?pring-boot-autoconfigure=E2=80=9D=20module.md?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- ...0\234spring-boot-autoconfigure\342\200\235 module.md" | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git "a/X. Appendices/C.1. From the \342\200\234spring-boot-autoconfigure\342\200\235 module.md" "b/X. Appendices/C.1. From the \342\200\234spring-boot-autoconfigure\342\200\235 module.md" index b27015a6..11ffcb14 100644 --- "a/X. Appendices/C.1. From the \342\200\234spring-boot-autoconfigure\342\200\235 module.md" +++ "b/X. Appendices/C.1. From the \342\200\234spring-boot-autoconfigure\342\200\235 module.md" @@ -103,3 +103,12 @@ |[`ThymeleafAutoConfiguration`](https://github.com/spring-projects/spring-boot/tree/v2.0.0.RELEASE/spring-boot-project/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/thymeleaf/ThymeleafAutoConfiguration.java)|[javadoc](https://docs.spring.io/spring-boot/docs/2.0.0.RELEASE/api/org/springframework/boot/autoconfigure/thymeleaf/ThymeleafAutoConfiguration.html)| |[`TransactionAutoConfiguration`](https://github.com/spring-projects/spring-boot/tree/v2.0.0.RELEASE/spring-boot-project/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/transaction/TransactionAutoConfiguration.java)|[javadoc](https://docs.spring.io/spring-boot/docs/2.0.0.RELEASE/api/org/springframework/boot/autoconfigure/transaction/TransactionAutoConfiguration.html)| |[`UserDetailsServiceAutoConfiguration`](https://github.com/spring-projects/spring-boot/tree/v2.0.0.RELEASE/spring-boot-project/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/security/servlet/UserDetailsServiceAutoConfiguration.java)|[javadoc](https://docs.spring.io/spring-boot/docs/2.0.0.RELEASE/api/org/springframework/boot/autoconfigure/security/servlet/UserDetailsServiceAutoConfiguration.html)| +|[`ValidationAutoConfiguration`](https://github.com/spring-projects/spring-boot/tree/v2.0.0.RELEASE/spring-boot-project/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/validation/ValidationAutoConfiguration.java)|[javadoc](https://docs.spring.io/spring-boot/docs/2.0.0.RELEASE/api/org/springframework/boot/autoconfigure/validation/ValidationAutoConfiguration.html)| +|[`WebClientAutoConfiguration`](https://github.com/spring-projects/spring-boot/tree/v2.0.0.RELEASE/spring-boot-project/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/web/reactive/function/client/WebClientAutoConfiguration.java)|[javadoc](https://docs.spring.io/spring-boot/docs/2.0.0.RELEASE/api/org/springframework/boot/autoconfigure/web/reactive/function/client/WebClientAutoConfiguration.html)| +|[`WebFluxAutoConfiguration`](https://github.com/spring-projects/spring-boot/tree/v2.0.0.RELEASE/spring-boot-project/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/web/reactive/WebFluxAutoConfiguration.java)|[javadoc](https://docs.spring.io/spring-boot/docs/2.0.0.RELEASE/api/org/springframework/boot/autoconfigure/web/reactive/WebFluxAutoConfiguration.html)| +|[`WebMvcAutoConfiguration`](https://github.com/spring-projects/spring-boot/tree/v2.0.0.RELEASE/spring-boot-project/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/web/servlet/WebMvcAutoConfiguration.java)|[javadoc](https://docs.spring.io/spring-boot/docs/2.0.0.RELEASE/api/org/springframework/boot/autoconfigure/web/servlet/WebMvcAutoConfiguration.html)| +|[`WebServicesAutoConfiguration`](https://github.com/spring-projects/spring-boot/tree/v2.0.0.RELEASE/spring-boot-project/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/webservices/WebServicesAutoConfiguration.java)|[javadoc](https://docs.spring.io/spring-boot/docs/2.0.0.RELEASE/api/org/springframework/boot/autoconfigure/webservices/WebServicesAutoConfiguration.html)| +|[`WebSocketMessagingAutoConfiguration`](https://github.com/spring-projects/spring-boot/tree/v2.0.0.RELEASE/spring-boot-project/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/websocket/servlet/WebSocketMessagingAutoConfiguration.java)|[javadoc](https://docs.spring.io/spring-boot/docs/2.0.0.RELEASE/api/org/springframework/boot/autoconfigure/websocket/servlet/WebSocketMessagingAutoConfiguration.html)| +|[`WebSocketReactiveAutoConfiguration`](https://github.com/spring-projects/spring-boot/tree/v2.0.0.RELEASE/spring-boot-project/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/websocket/reactive/WebSocketReactiveAutoConfiguration.java)|[javadoc](https://docs.spring.io/spring-boot/docs/2.0.0.RELEASE/api/org/springframework/boot/autoconfigure/websocket/reactive/WebSocketReactiveAutoConfiguration.html)| +|[`WebSocketServletAutoConfiguration`](https://github.com/spring-projects/spring-boot/tree/v2.0.0.RELEASE/spring-boot-project/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/websocket/servlet/WebSocketServletAutoConfiguration.java)|[javadoc](https://docs.spring.io/spring-boot/docs/2.0.0.RELEASE/api/org/springframework/boot/autoconfigure/websocket/servlet/WebSocketServletAutoConfiguration.html)| +|[`XADataSourceAutoConfiguration`](https://github.com/spring-projects/spring-boot/tree/v2.0.0.RELEASE/spring-boot-project/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/jdbc/XADataSourceAutoConfiguration.java)|[javadoc](https://docs.spring.io/spring-boot/docs/2.0.0.RELEASE/api/org/springframework/boot/autoconfigure/jdbc/XADataSourceAutoConfiguration.html)| From 38e750a2a007ce644f13c7344fa87564c0140725 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E7=83=AD=E5=BF=83=E5=B8=82=E6=B0=91=E9=92=9F=E5=B0=8F?= =?UTF-8?q?=E5=BC=BA?= Date: Sat, 28 Mar 2020 15:04:11 +0800 Subject: [PATCH 841/865] Update SUMMARY.md --- SUMMARY.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/SUMMARY.md b/SUMMARY.md index c244f9a4..a6da6281 100644 --- a/SUMMARY.md +++ b/SUMMARY.md @@ -579,7 +579,7 @@ * [附录 B.3.2. 添加其他的元数据](X. Appendices/B.3.2. Adding Additional Metadata.md) * [附录C. 自动配置类](X. Appendices/C. Auto-configuration classes.md) * [附录C.1. 来自spring-boot-autoconfigure模块](X. Appendices/C.1. From the “spring-boot-autoconfigure” module.md) - * [附录C.2. 来自spring-boot-actuator模块](X. Appendices/C.2. From the “spring-boot-actuator-autoconfigure” module.md) + * [附录C.2. 来自spring-boot-actuator-autoconfigure模块](X. Appendices/C.2. From the “spring-boot-actuator-autoconfigure” module.md) * [附录D. 测试自动配置的标注](X. Appendices/D. Test auto-configuration annotations.md) * [附录E. 可执行jar格式](X. Appendices/E. The executable jar format.md) * [附录E.1. 内嵌JARs](X. Appendices/E.1. Nested JARs.md) From e638d2e16d03b042513fa0adb21b977ecdb0065c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E7=83=AD=E5=BF=83=E5=B8=82=E6=B0=91=E9=92=9F=E5=B0=8F?= =?UTF-8?q?=E5=BC=BA?= Date: Sat, 28 Mar 2020 15:29:52 +0800 Subject: [PATCH 842/865] =?UTF-8?q?Update=20and=20rename=20C.2.=20From=20t?= =?UTF-8?q?he=20=E2=80=9Cspring-boot-actuator=E2=80=9D=20module.md=20to=20?= =?UTF-8?q?C.2.=20From=20the=20=E2=80=9Cspring-boot-actuator-autoconfigure?= =?UTF-8?q?=E2=80=9D=20module.md?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- ...ctuator-autoconfigure\342\200\235 module.md" | 17 +++++++++++++++++ ...4spring-boot-actuator\342\200\235 module.md" | 9 --------- 2 files changed, 17 insertions(+), 9 deletions(-) create mode 100644 "X. Appendices/C.2. From the \342\200\234spring-boot-actuator-autoconfigure\342\200\235 module.md" delete mode 100644 "X. Appendices/C.2. From the \342\200\234spring-boot-actuator\342\200\235 module.md" diff --git "a/X. Appendices/C.2. From the \342\200\234spring-boot-actuator-autoconfigure\342\200\235 module.md" "b/X. Appendices/C.2. From the \342\200\234spring-boot-actuator-autoconfigure\342\200\235 module.md" new file mode 100644 index 00000000..c1291a31 --- /dev/null +++ "b/X. Appendices/C.2. From the \342\200\234spring-boot-actuator-autoconfigure\342\200\235 module.md" @@ -0,0 +1,17 @@ +### 附录 C.2 来自`spring-boot-actuator-autoconfigure`模块 + +下列的自动配置类来自于`spring-boot-actuator-autoconfigure`模块: + +|配置类|链接| +|------|:------| +|[`AtlasMetricsExportAutoConfiguration`](https://github.com/spring-projects/spring-boot/tree/v2.0.0.RELEASE/spring-boot-project/spring-boot-actuator-autoconfigure/src/main/java/org/springframework/boot/actuate/autoconfigure/metrics/export/atlas/AtlasMetricsExportAutoConfiguration.java)|[javadoc](https://docs.spring.io/spring-boot/docs/2.0.0.RELEASE/api/org/springframework/boot/actuate/autoconfigure/metrics/export/atlas/AtlasMetricsExportAutoConfiguration.html)| +|[`AuditAutoConfiguration`](https://github.com/spring-projects/spring-boot/tree/v2.0.0.RELEASE/spring-boot-project/spring-boot-actuator-autoconfigure/src/main/java/org/springframework/boot/actuate/autoconfigure/audit/AuditAutoConfiguration.java)|[javadoc](https://docs.spring.io/spring-boot/docs/2.0.0.RELEASE/api/org/springframework/boot/actuate/autoconfigure/audit/AuditAutoConfiguration.html)| +|[`AuditEventsEndpointAutoConfiguration`](https://github.com/spring-projects/spring-boot/tree/v2.0.0.RELEASE/spring-boot-project/spring-boot-actuator-autoconfigure/src/main/java/org/springframework/boot/actuate/autoconfigure/audit/AuditEventsEndpointAutoConfiguration.java)|[javadoc](https://docs.spring.io/spring-boot/docs/2.0.0.RELEASE/api/org/springframework/boot/actuate/autoconfigure/audit/AuditEventsEndpointAutoConfiguration.html)| +|[`BeansEndpointAutoConfiguration`](https://github.com/spring-projects/spring-boot/tree/v2.0.0.RELEASE/spring-boot-project/spring-boot-actuator-autoconfigure/src/main/java/org/springframework/boot/actuate/autoconfigure/beans/BeansEndpointAutoConfiguration.java)|[javadoc](https://docs.spring.io/spring-boot/docs/2.0.0.RELEASE/api/org/springframework/boot/actuate/autoconfigure/beans/BeansEndpointAutoConfiguration.html)| +|[`CacheMetricsAutoConfiguration`](https://github.com/spring-projects/spring-boot/tree/v2.0.0.RELEASE/spring-boot-project/spring-boot-actuator-autoconfigure/src/main/java/org/springframework/boot/actuate/autoconfigure/metrics/cache/CacheMetricsAutoConfiguration.java)|[javadoc](https://docs.spring.io/spring-boot/docs/2.0.0.RELEASE/api/org/springframework/boot/actuate/autoconfigure/metrics/cache/CacheMetricsAutoConfiguration.html)| +|[`CassandraHealthIndicatorAutoConfiguration`](https://github.com/spring-projects/spring-boot/tree/v2.0.0.RELEASE/spring-boot-project/spring-boot-actuator-autoconfigure/src/main/java/org/springframework/boot/actuate/autoconfigure/cassandra/CassandraHealthIndicatorAutoConfiguration.java)|[javadoc](https://docs.spring.io/spring-boot/docs/2.0.0.RELEASE/api/org/springframework/boot/actuate/autoconfigure/cassandra/CassandraHealthIndicatorAutoConfiguration.html)| +|[`CloudFoundryActuatorAutoConfiguration`](https://github.com/spring-projects/spring-boot/tree/v2.0.0.RELEASE/spring-boot-project/spring-boot-actuator-autoconfigure/src/main/java/org/springframework/boot/actuate/autoconfigure/cloudfoundry/servlet/CloudFoundryActuatorAutoConfiguration.java)|[javadoc](https://docs.spring.io/spring-boot/docs/2.0.0.RELEASE/api/org/springframework/boot/actuate/autoconfigure/cloudfoundry/servlet/CloudFoundryActuatorAutoConfiguration.html)| +|[`CompositeMeterRegistryAutoConfiguration`](https://github.com/spring-projects/spring-boot/tree/v2.0.0.RELEASE/spring-boot-project/spring-boot-actuator-autoconfigure/src/main/java/org/springframework/boot/actuate/autoconfigure/metrics/CompositeMeterRegistryAutoConfiguration.java)|[javadoc](https://docs.spring.io/spring-boot/docs/2.0.0.RELEASE/api/org/springframework/boot/actuate/autoconfigure/metrics/CompositeMeterRegistryAutoConfiguration.html)| +|[`ConditionsReportEndpointAutoConfiguration`](https://github.com/spring-projects/spring-boot/tree/v2.0.0.RELEASE/spring-boot-project/spring-boot-actuator-autoconfigure/src/main/java/org/springframework/boot/actuate/autoconfigure/condition/ConditionsReportEndpointAutoConfiguration.java)|[javadoc](https://docs.spring.io/spring-boot/docs/2.0.0.RELEASE/api/org/springframework/boot/actuate/autoconfigure/condition/ConditionsReportEndpointAutoConfiguration.html)| +|[`ConfigurationPropertiesReportEndpointAutoConfiguration`](https://github.com/spring-projects/spring-boot/tree/v2.0.0.RELEASE/spring-boot-project/spring-boot-actuator-autoconfigure/src/main/java/org/springframework/boot/actuate/autoconfigure/context/properties/ConfigurationPropertiesReportEndpointAutoConfiguration.java)|[javadoc](https://docs.spring.io/spring-boot/docs/2.0.0.RELEASE/api/org/springframework/boot/actuate/autoconfigure/context/properties/ConfigurationPropertiesReportEndpointAutoConfiguration.html)| +|[`CouchbaseHealthIndicatorAutoConfiguration`](https://github.com/spring-projects/spring-boot/tree/v2.0.0.RELEASE/spring-boot-project/spring-boot-actuator-autoconfigure/src/main/java/org/springframework/boot/actuate/autoconfigure/couchbase/CouchbaseHealthIndicatorAutoConfiguration.java)|[javadoc](https://docs.spring.io/spring-boot/docs/2.0.0.RELEASE/api/org/springframework/boot/actuate/autoconfigure/couchbase/CouchbaseHealthIndicatorAutoConfiguration.html)| diff --git "a/X. Appendices/C.2. From the \342\200\234spring-boot-actuator\342\200\235 module.md" "b/X. Appendices/C.2. From the \342\200\234spring-boot-actuator\342\200\235 module.md" deleted file mode 100644 index ef807180..00000000 --- "a/X. Appendices/C.2. From the \342\200\234spring-boot-actuator\342\200\235 module.md" +++ /dev/null @@ -1,9 +0,0 @@ -### 附录 C.2 来自`spring-boot-actuator`模块 - -下列的自动配置类来自于`spring-boot-actuator`模块: - -|配置类|链接| -|------|:------| -|[`AuditAutoConfiguration`](https://github.com/spring-projects/spring-boot/tree/v2.0.0.RELEASE/spring-boot-actuator/src/main/java/org/springframework/boot/actuate/autoconfigure/AuditAutoConfiguration.java)|[javadoc](https://docs.spring.io/spring-boot/docs/2.0.0.RELEASE/api/org/springframework/boot/actuate/autoconfigure/AuditAutoConfiguration.html)| -|[`CacheStatisticsAutoConfiguration`](https://github.com/spring-projects/spring-boot/tree/v2.0.0.RELEASE/spring-boot-actuator/src/main/java/org/springframework/boot/actuate/autoconfigure/CacheStatisticsAutoConfiguration.java)|[javadoc](https://docs.spring.io/spring-boot/docs/2.0.0.RELEASE/api/org/springframework/boot/actuate/autoconfigure/CacheStatisticsAutoConfiguration.html)| -|[`CloudFoundryActuatorAutoConfiguration`](https://github.com/spring-projects/spring-boot/tree/v2.0.0.RELEASE/spring-boot-actuator/src/main/java/org/springframework/boot/actuate/cloudfoundry/CloudFoundryActuatorAutoConfiguration.java)|[javadoc](https://docs.spring.io/spring-boot/docs/2.0.0.RELEASE/api/org/springframework/boot/actuate/cloudfoundry/CloudFoundryActuatorAutoConfiguration.html)| From 62b5011460721b0b9530cd2d27f3ddf73a08c869 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E7=83=AD=E5=BF=83=E5=B8=82=E6=B0=91=E9=92=9F=E5=B0=8F?= =?UTF-8?q?=E5=BC=BA?= Date: Wed, 1 Apr 2020 22:12:59 +0800 Subject: [PATCH 843/865] =?UTF-8?q?Update=20C.2.=20From=20the=20=E2=80=9Cs?= =?UTF-8?q?pring-boot-actuator-autoconfigure=E2=80=9D=20module.md?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- ...uator-autoconfigure\342\200\235 module.md" | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) diff --git "a/X. Appendices/C.2. From the \342\200\234spring-boot-actuator-autoconfigure\342\200\235 module.md" "b/X. Appendices/C.2. From the \342\200\234spring-boot-actuator-autoconfigure\342\200\235 module.md" index c1291a31..9cf1b3b6 100644 --- "a/X. Appendices/C.2. From the \342\200\234spring-boot-actuator-autoconfigure\342\200\235 module.md" +++ "b/X. Appendices/C.2. From the \342\200\234spring-boot-actuator-autoconfigure\342\200\235 module.md" @@ -15,3 +15,22 @@ |[`ConditionsReportEndpointAutoConfiguration`](https://github.com/spring-projects/spring-boot/tree/v2.0.0.RELEASE/spring-boot-project/spring-boot-actuator-autoconfigure/src/main/java/org/springframework/boot/actuate/autoconfigure/condition/ConditionsReportEndpointAutoConfiguration.java)|[javadoc](https://docs.spring.io/spring-boot/docs/2.0.0.RELEASE/api/org/springframework/boot/actuate/autoconfigure/condition/ConditionsReportEndpointAutoConfiguration.html)| |[`ConfigurationPropertiesReportEndpointAutoConfiguration`](https://github.com/spring-projects/spring-boot/tree/v2.0.0.RELEASE/spring-boot-project/spring-boot-actuator-autoconfigure/src/main/java/org/springframework/boot/actuate/autoconfigure/context/properties/ConfigurationPropertiesReportEndpointAutoConfiguration.java)|[javadoc](https://docs.spring.io/spring-boot/docs/2.0.0.RELEASE/api/org/springframework/boot/actuate/autoconfigure/context/properties/ConfigurationPropertiesReportEndpointAutoConfiguration.html)| |[`CouchbaseHealthIndicatorAutoConfiguration`](https://github.com/spring-projects/spring-boot/tree/v2.0.0.RELEASE/spring-boot-project/spring-boot-actuator-autoconfigure/src/main/java/org/springframework/boot/actuate/autoconfigure/couchbase/CouchbaseHealthIndicatorAutoConfiguration.java)|[javadoc](https://docs.spring.io/spring-boot/docs/2.0.0.RELEASE/api/org/springframework/boot/actuate/autoconfigure/couchbase/CouchbaseHealthIndicatorAutoConfiguration.html)| +|[`DataSourceHealthIndicatorAutoConfiguration`](https://github.com/spring-projects/spring-boot/tree/v2.0.0.RELEASE/spring-boot-project/spring-boot-actuator-autoconfigure/src/main/java/org/springframework/boot/actuate/autoconfigure/jdbc/DataSourceHealthIndicatorAutoConfiguration.java)|[javadoc](https://docs.spring.io/spring-boot/docs/2.0.0.RELEASE/api/org/springframework/boot/actuate/autoconfigure/jdbc/DataSourceHealthIndicatorAutoConfiguration.html)| +|[`DataSourcePoolMetricsAutoConfiguration`](https://github.com/spring-projects/spring-boot/tree/v2.0.0.RELEASE/spring-boot-project/spring-boot-actuator-autoconfigure/src/main/java/org/springframework/boot/actuate/autoconfigure/metrics/jdbc/DataSourcePoolMetricsAutoConfiguration.java)|[javadoc](https://docs.spring.io/spring-boot/docs/2.0.0.RELEASE/api/org/springframework/boot/actuate/autoconfigure/metrics/jdbc/DataSourcePoolMetricsAutoConfiguration.html)| +|[`DatadogMetricsExportAutoConfiguration`](https://github.com/spring-projects/spring-boot/tree/v2.0.0.RELEASE/spring-boot-project/spring-boot-actuator-autoconfigure/src/main/java/org/springframework/boot/actuate/autoconfigure/metrics/export/datadog/DatadogMetricsExportAutoConfiguration.java)|[javadoc](https://docs.spring.io/spring-boot/docs/2.0.0.RELEASE/api/org/springframework/boot/actuate/autoconfigure/metrics/export/datadog/DatadogMetricsExportAutoConfiguration.html)| +|[`DiskSpaceHealthIndicatorAutoConfiguration`](https://github.com/spring-projects/spring-boot/tree/v2.0.0.RELEASE/spring-boot-project/spring-boot-actuator-autoconfigure/src/main/java/org/springframework/boot/actuate/autoconfigure/system/DiskSpaceHealthIndicatorAutoConfiguration.java)|[javadoc](https://docs.spring.io/spring-boot/docs/2.0.0.RELEASE/api/org/springframework/boot/actuate/autoconfigure/system/DiskSpaceHealthIndicatorAutoConfiguration.html)| +|[`ElasticsearchHealthIndicatorAutoConfiguration`](https://github.com/spring-projects/spring-boot/tree/v2.0.0.RELEASE/spring-boot-project/spring-boot-actuator-autoconfigure/src/main/java/org/springframework/boot/actuate/autoconfigure/elasticsearch/ElasticsearchHealthIndicatorAutoConfiguration.java)|[javadoc](https://docs.spring.io/spring-boot/docs/2.0.0.RELEASE/api/org/springframework/boot/actuate/autoconfigure/elasticsearch/ElasticsearchHealthIndicatorAutoConfiguration.html)| +|[`EndpointAutoConfiguration`](https://github.com/spring-projects/spring-boot/tree/v2.0.0.RELEASE/spring-boot-project/spring-boot-actuator-autoconfigure/src/main/java/org/springframework/boot/actuate/autoconfigure/endpoint/EndpointAutoConfiguration.java)|[javadoc](https://docs.spring.io/spring-boot/docs/2.0.0.RELEASE/api/org/springframework/boot/actuate/autoconfigure/endpoint/EndpointAutoConfiguration.html)| +|[`EnvironmentEndpointAutoConfiguration`](https://github.com/spring-projects/spring-boot/tree/v2.0.0.RELEASE/spring-boot-project/spring-boot-actuator-autoconfigure/src/main/java/org/springframework/boot/actuate/autoconfigure/env/EnvironmentEndpointAutoConfiguration.java)|[javadoc](https://docs.spring.io/spring-boot/docs/2.0.0.RELEASE/api/org/springframework/boot/actuate/autoconfigure/env/EnvironmentEndpointAutoConfiguration.html)| +|[`FlywayEndpointAutoConfiguration`](https://github.com/spring-projects/spring-boot/tree/v2.0.0.RELEASE/spring-boot-project/spring-boot-actuator-autoconfigure/src/main/java/org/springframework/boot/actuate/autoconfigure/flyway/FlywayEndpointAutoConfiguration.java)|[javadoc](https://docs.spring.io/spring-boot/docs/2.0.0.RELEASE/api/org/springframework/boot/actuate/autoconfigure/flyway/FlywayEndpointAutoConfiguration.html)| +|[`GangliaMetricsExportAutoConfiguration`](https://github.com/spring-projects/spring-boot/tree/v2.0.0.RELEASE/spring-boot-project/spring-boot-actuator-autoconfigure/src/main/java/org/springframework/boot/actuate/autoconfigure/metrics/export/ganglia/GangliaMetricsExportAutoConfiguration.java)|[javadoc](https://docs.spring.io/spring-boot/docs/2.0.0.RELEASE/api/org/springframework/boot/actuate/autoconfigure/metrics/export/ganglia/GangliaMetricsExportAutoConfiguration.html)| +|[`GraphiteMetricsExportAutoConfiguration`](https://github.com/spring-projects/spring-boot/tree/v2.0.0.RELEASE/spring-boot-project/spring-boot-actuator-autoconfigure/src/main/java/org/springframework/boot/actuate/autoconfigure/metrics/export/graphite/GraphiteMetricsExportAutoConfiguration.java)|[javadoc](https://docs.spring.io/spring-boot/docs/2.0.0.RELEASE/api/org/springframework/boot/actuate/autoconfigure/metrics/export/graphite/GraphiteMetricsExportAutoConfiguration.html)| +|[`HealthEndpointAutoConfiguration`](https://github.com/spring-projects/spring-boot/tree/v2.0.0.RELEASE/spring-boot-project/spring-boot-actuator-autoconfigure/src/main/java/org/springframework/boot/actuate/autoconfigure/health/HealthEndpointAutoConfiguration.java)|[javadoc](https://docs.spring.io/spring-boot/docs/2.0.0.RELEASE/api/org/springframework/boot/actuate/autoconfigure/health/HealthEndpointAutoConfiguration.html)| +|[`HealthIndicatorAutoConfiguration`](https://github.com/spring-projects/spring-boot/tree/v2.0.0.RELEASE/spring-boot-project/spring-boot-actuator-autoconfigure/src/main/java/org/springframework/boot/actuate/autoconfigure/health/HealthIndicatorAutoConfiguration.java)|[javadoc](https://docs.spring.io/spring-boot/docs/2.0.0.RELEASE/api/org/springframework/boot/actuate/autoconfigure/health/HealthIndicatorAutoConfiguration.html)| +|[`HeapDumpWebEndpointAutoConfiguration`](https://github.com/spring-projects/spring-boot/tree/v2.0.0.RELEASE/spring-boot-project/spring-boot-actuator-autoconfigure/src/main/java/org/springframework/boot/actuate/autoconfigure/management/HeapDumpWebEndpointAutoConfiguration.java)|[javadoc](https://docs.spring.io/spring-boot/docs/2.0.0.RELEASE/api/org/springframework/boot/actuate/autoconfigure/management/HeapDumpWebEndpointAutoConfiguration.html)| +|[`HttpTraceAutoConfiguration`](https://github.com/spring-projects/spring-boot/tree/v2.0.0.RELEASE/spring-boot-project/spring-boot-actuator-autoconfigure/src/main/java/org/springframework/boot/actuate/autoconfigure/trace/http/HttpTraceAutoConfiguration.java)|[javadoc](https://docs.spring.io/spring-boot/docs/2.0.0.RELEASE/api/org/springframework/boot/actuate/autoconfigure/trace/http/HttpTraceAutoConfiguration.html)| +|[`HttpTraceEndpointAutoConfiguration`](https://github.com/spring-projects/spring-boot/tree/v2.0.0.RELEASE/spring-boot-project/spring-boot-actuator-autoconfigure/src/main/java/org/springframework/boot/actuate/autoconfigure/trace/http/HttpTraceEndpointAutoConfiguration.java)|[javadoc](https://docs.spring.io/spring-boot/docs/2.0.0.RELEASE/api/org/springframework/boot/actuate/autoconfigure/trace/http/HttpTraceEndpointAutoConfiguration.html)| +|[`InfluxDbHealthIndicatorAutoConfiguration`](https://github.com/spring-projects/spring-boot/tree/v2.0.0.RELEASE/spring-boot-project/spring-boot-actuator-autoconfigure/src/main/java/org/springframework/boot/actuate/autoconfigure/influx/InfluxDbHealthIndicatorAutoConfiguration.java)|[javadoc](https://docs.spring.io/spring-boot/docs/2.0.0.RELEASE/api/org/springframework/boot/actuate/autoconfigure/influx/InfluxDbHealthIndicatorAutoConfiguration.html)| +|[`InfluxMetricsExportAutoConfiguration`](https://github.com/spring-projects/spring-boot/tree/v2.0.0.RELEASE/spring-boot-project/spring-boot-actuator-autoconfigure/src/main/java/org/springframework/boot/actuate/autoconfigure/metrics/export/influx/InfluxMetricsExportAutoConfiguration.java)|[javadoc](https://docs.spring.io/spring-boot/docs/2.0.0.RELEASE/api/org/springframework/boot/actuate/autoconfigure/metrics/export/influx/InfluxMetricsExportAutoConfiguration.html)| +|[`InfoContributorAutoConfiguration`](https://github.com/spring-projects/spring-boot/tree/v2.0.0.RELEASE/spring-boot-project/spring-boot-actuator-autoconfigure/src/main/java/org/springframework/boot/actuate/autoconfigure/info/InfoContributorAutoConfiguration.java)|[javadoc](https://docs.spring.io/spring-boot/docs/2.0.0.RELEASE/api/org/springframework/boot/actuate/autoconfigure/info/InfoContributorAutoConfiguration.html)| +|[`InfoEndpointAutoConfiguration`](https://github.com/spring-projects/spring-boot/tree/v2.0.0.RELEASE/spring-boot-project/spring-boot-actuator-autoconfigure/src/main/java/org/springframework/boot/actuate/autoconfigure/info/InfoEndpointAutoConfiguration.java)|[javadoc](https://docs.spring.io/spring-boot/docs/2.0.0.RELEASE/api/org/springframework/boot/actuate/autoconfigure/info/InfoEndpointAutoConfiguration.html)| From 4c98eb967e0c502a4c56c5e565d2af7551ad22b2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E7=83=AD=E5=BF=83=E5=B8=82=E6=B0=91=E9=92=9F=E5=B0=8F?= =?UTF-8?q?=E5=BC=BA?= Date: Sat, 4 Apr 2020 21:27:29 +0800 Subject: [PATCH 844/865] =?UTF-8?q?Update=20C.2.=20From=20the=20=E2=80=9Cs?= =?UTF-8?q?pring-boot-actuator-autoconfigure=E2=80=9D=20module.md?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- ...uator-autoconfigure\342\200\235 module.md" | 23 +++++++++++++++++++ 1 file changed, 23 insertions(+) diff --git "a/X. Appendices/C.2. From the \342\200\234spring-boot-actuator-autoconfigure\342\200\235 module.md" "b/X. Appendices/C.2. From the \342\200\234spring-boot-actuator-autoconfigure\342\200\235 module.md" index 9cf1b3b6..7eeeff0b 100644 --- "a/X. Appendices/C.2. From the \342\200\234spring-boot-actuator-autoconfigure\342\200\235 module.md" +++ "b/X. Appendices/C.2. From the \342\200\234spring-boot-actuator-autoconfigure\342\200\235 module.md" @@ -34,3 +34,26 @@ |[`InfluxMetricsExportAutoConfiguration`](https://github.com/spring-projects/spring-boot/tree/v2.0.0.RELEASE/spring-boot-project/spring-boot-actuator-autoconfigure/src/main/java/org/springframework/boot/actuate/autoconfigure/metrics/export/influx/InfluxMetricsExportAutoConfiguration.java)|[javadoc](https://docs.spring.io/spring-boot/docs/2.0.0.RELEASE/api/org/springframework/boot/actuate/autoconfigure/metrics/export/influx/InfluxMetricsExportAutoConfiguration.html)| |[`InfoContributorAutoConfiguration`](https://github.com/spring-projects/spring-boot/tree/v2.0.0.RELEASE/spring-boot-project/spring-boot-actuator-autoconfigure/src/main/java/org/springframework/boot/actuate/autoconfigure/info/InfoContributorAutoConfiguration.java)|[javadoc](https://docs.spring.io/spring-boot/docs/2.0.0.RELEASE/api/org/springframework/boot/actuate/autoconfigure/info/InfoContributorAutoConfiguration.html)| |[`InfoEndpointAutoConfiguration`](https://github.com/spring-projects/spring-boot/tree/v2.0.0.RELEASE/spring-boot-project/spring-boot-actuator-autoconfigure/src/main/java/org/springframework/boot/actuate/autoconfigure/info/InfoEndpointAutoConfiguration.java)|[javadoc](https://docs.spring.io/spring-boot/docs/2.0.0.RELEASE/api/org/springframework/boot/actuate/autoconfigure/info/InfoEndpointAutoConfiguration.html)| +|[`JmsHealthIndicatorAutoConfiguration`](https://github.com/spring-projects/spring-boot/tree/v2.0.0.RELEASE/spring-boot-project/spring-boot-actuator-autoconfigure/src/main/java/org/springframework/boot/actuate/autoconfigure/jms/JmsHealthIndicatorAutoConfiguration.java)|[javadoc](https://docs.spring.io/spring-boot/docs/2.0.0.RELEASE/api/org/springframework/boot/actuate/autoconfigure/jms/JmsHealthIndicatorAutoConfiguration.html)| +|[`JmxEndpointAutoConfiguration`](https://github.com/spring-projects/spring-boot/tree/v2.0.0.RELEASE/spring-boot-project/spring-boot-actuator-autoconfigure/src/main/java/org/springframework/boot/actuate/autoconfigure/endpoint/jmx/JmxEndpointAutoConfiguration.java)|[javadoc](https://docs.spring.io/spring-boot/docs/2.0.0.RELEASE/api/org/springframework/boot/actuate/autoconfigure/endpoint/jmx/JmxEndpointAutoConfiguration.html)| +|[`JmxMetricsExportAutoConfiguration`](https://github.com/spring-projects/spring-boot/tree/v2.0.0.RELEASE/spring-boot-project/spring-boot-actuator-autoconfigure/src/main/java/org/springframework/boot/actuate/autoconfigure/metrics/export/jmx/JmxMetricsExportAutoConfiguration.java)|[javadoc](https://docs.spring.io/spring-boot/docs/2.0.0.RELEASE/api/org/springframework/boot/actuate/autoconfigure/metrics/export/jmx/JmxMetricsExportAutoConfiguration.html)| +|[`JolokiaEndpointAutoConfiguration`](https://github.com/spring-projects/spring-boot/tree/v2.0.0.RELEASE/spring-boot-project/spring-boot-actuator-autoconfigure/src/main/java/org/springframework/boot/actuate/autoconfigure/jolokia/JolokiaEndpointAutoConfiguration.java)|[javadoc](https://docs.spring.io/spring-boot/docs/2.0.0.RELEASE/api/org/springframework/boot/actuate/autoconfigure/jolokia/JolokiaEndpointAutoConfiguration.html)| +|[`LdapHealthIndicatorAutoConfiguration`](https://github.com/spring-projects/spring-boot/tree/v2.0.0.RELEASE/spring-boot-project/spring-boot-actuator-autoconfigure/src/main/java/org/springframework/boot/actuate/autoconfigure/ldap/LdapHealthIndicatorAutoConfiguration.java)|[javadoc](https://docs.spring.io/spring-boot/docs/2.0.0.RELEASE/api/org/springframework/boot/actuate/autoconfigure/ldap/LdapHealthIndicatorAutoConfiguration.html)| +|[`LiquibaseEndpointAutoConfiguration`](https://github.com/spring-projects/spring-boot/tree/v2.0.0.RELEASE/spring-boot-project/spring-boot-actuator-autoconfigure/src/main/java/org/springframework/boot/actuate/autoconfigure/liquibase/LiquibaseEndpointAutoConfiguration.java)|[javadoc](https://docs.spring.io/spring-boot/docs/2.0.0.RELEASE/api/org/springframework/boot/actuate/autoconfigure/liquibase/LiquibaseEndpointAutoConfiguration.html)| +|[`LogFileWebEndpointAutoConfiguration`](https://github.com/spring-projects/spring-boot/tree/v2.0.0.RELEASE/spring-boot-project/spring-boot-actuator-autoconfigure/src/main/java/org/springframework/boot/actuate/autoconfigure/logging/LogFileWebEndpointAutoConfiguration.java)|[javadoc](https://docs.spring.io/spring-boot/docs/2.0.0.RELEASE/api/org/springframework/boot/actuate/autoconfigure/logging/LogFileWebEndpointAutoConfiguration.html)| +|[`LoggersEndpointAutoConfiguration`](https://github.com/spring-projects/spring-boot/tree/v2.0.0.RELEASE/spring-boot-project/spring-boot-actuator-autoconfigure/src/main/java/org/springframework/boot/actuate/autoconfigure/logging/LoggersEndpointAutoConfiguration.java)|[javadoc](https://docs.spring.io/spring-boot/docs/2.0.0.RELEASE/api/org/springframework/boot/actuate/autoconfigure/logging/LoggersEndpointAutoConfiguration.html)| +|[`MailHealthIndicatorAutoConfiguration`](https://github.com/spring-projects/spring-boot/tree/v2.0.0.RELEASE/spring-boot-project/spring-boot-actuator-autoconfigure/src/main/java/org/springframework/boot/actuate/autoconfigure/mail/MailHealthIndicatorAutoConfiguration.java)|[javadoc](https://docs.spring.io/spring-boot/docs/2.0.0.RELEASE/api/org/springframework/boot/actuate/autoconfigure/mail/MailHealthIndicatorAutoConfiguration.html)| +|[`ManagementContextAutoConfiguration`](https://github.com/spring-projects/spring-boot/tree/v2.0.0.RELEASE/spring-boot-project/spring-boot-actuator-autoconfigure/src/main/java/org/springframework/boot/actuate/autoconfigure/web/server/ManagementContextAutoConfiguration.java)|[javadoc](https://docs.spring.io/spring-boot/docs/2.0.0.RELEASE/api/org/springframework/boot/actuate/autoconfigure/web/server/ManagementContextAutoConfiguration.html)| +|[`MappingsEndpointAutoConfiguration`](https://github.com/spring-projects/spring-boot/tree/v2.0.0.RELEASE/spring-boot-project/spring-boot-actuator-autoconfigure/src/main/java/org/springframework/boot/actuate/autoconfigure/web/mappings/MappingsEndpointAutoConfiguration.java)|[javadoc](https://docs.spring.io/spring-boot/docs/2.0.0.RELEASE/api/org/springframework/boot/actuate/autoconfigure/web/mappings/MappingsEndpointAutoConfiguration.html)| +|[`MetricsAutoConfiguration`](https://github.com/spring-projects/spring-boot/tree/v2.0.0.RELEASE/spring-boot-project/spring-boot-actuator-autoconfigure/src/main/java/org/springframework/boot/actuate/autoconfigure/metrics/MetricsAutoConfiguration.java)|[javadoc](https://docs.spring.io/spring-boot/docs/2.0.0.RELEASE/api/org/springframework/boot/actuate/autoconfigure/metrics/MetricsAutoConfiguration.html)| +|[`MetricsEndpointAutoConfiguration`](https://github.com/spring-projects/spring-boot/tree/v2.0.0.RELEASE/spring-boot-project/spring-boot-actuator-autoconfigure/src/main/java/org/springframework/boot/actuate/autoconfigure/metrics/MetricsEndpointAutoConfiguration.java)|[javadoc](https://docs.spring.io/spring-boot/docs/2.0.0.RELEASE/api/org/springframework/boot/actuate/autoconfigure/metrics/MetricsEndpointAutoConfiguration.html)| +|[`MongoHealthIndicatorAutoConfiguration`](https://github.com/spring-projects/spring-boot/tree/v2.0.0.RELEASE/spring-boot-project/spring-boot-actuator-autoconfigure/src/main/java/org/springframework/boot/actuate/autoconfigure/mongo/MongoHealthIndicatorAutoConfiguration.java)|[javadoc](https://docs.spring.io/spring-boot/docs/2.0.0.RELEASE/api/org/springframework/boot/actuate/autoconfigure/mongo/MongoHealthIndicatorAutoConfiguration.html)| +|[`Neo4jHealthIndicatorAutoConfiguration`](https://github.com/spring-projects/spring-boot/tree/v2.0.0.RELEASE/spring-boot-project/spring-boot-actuator-autoconfigure/src/main/java/org/springframework/boot/actuate/autoconfigure/neo4j/Neo4jHealthIndicatorAutoConfiguration.java)|[javadoc](https://docs.spring.io/spring-boot/docs/2.0.0.RELEASE/api/org/springframework/boot/actuate/autoconfigure/neo4j/Neo4jHealthIndicatorAutoConfiguration.html)| +|[`NewRelicMetricsExportAutoConfiguration`](https://github.com/spring-projects/spring-boot/tree/v2.0.0.RELEASE/spring-boot-project/spring-boot-actuator-autoconfigure/src/main/java/org/springframework/boot/actuate/autoconfigure/metrics/export/newrelic/NewRelicMetricsExportAutoConfiguration.java)|[javadoc](https://docs.spring.io/spring-boot/docs/2.0.0.RELEASE/api/org/springframework/boot/actuate/autoconfigure/metrics/export/newrelic/NewRelicMetricsExportAutoConfiguration.html)| +|[`PrometheusMetricsExportAutoConfiguration`](https://github.com/spring-projects/spring-boot/tree/v2.0.0.RELEASE/spring-boot-project/spring-boot-actuator-autoconfigure/src/main/java/org/springframework/boot/actuate/autoconfigure/metrics/export/prometheus/PrometheusMetricsExportAutoConfiguration.java)|[javadoc](https://docs.spring.io/spring-boot/docs/2.0.0.RELEASE/api/org/springframework/boot/actuate/autoconfigure/metrics/export/prometheus/PrometheusMetricsExportAutoConfiguration.html)| +|[`RabbitHealthIndicatorAutoConfiguration`](https://github.com/spring-projects/spring-boot/tree/v2.0.0.RELEASE/spring-boot-project/spring-boot-actuator-autoconfigure/src/main/java/org/springframework/boot/actuate/autoconfigure/amqp/RabbitHealthIndicatorAutoConfiguration.java)|[javadoc](https://docs.spring.io/spring-boot/docs/2.0.0.RELEASE/api/org/springframework/boot/actuate/autoconfigure/amqp/RabbitHealthIndicatorAutoConfiguration.html)| +|[`RabbitMetricsAutoConfiguration`](https://github.com/spring-projects/spring-boot/tree/v2.0.0.RELEASE/spring-boot-project/spring-boot-actuator-autoconfigure/src/main/java/org/springframework/boot/actuate/autoconfigure/metrics/amqp/RabbitMetricsAutoConfiguration.java)|[javadoc](https://docs.spring.io/spring-boot/docs/2.0.0.RELEASE/api/org/springframework/boot/actuate/autoconfigure/metrics/amqp/RabbitMetricsAutoConfiguration.html)| +|[`ReactiveCloudFoundryActuatorAutoConfiguration`](https://github.com/spring-projects/spring-boot/tree/v2.0.0.RELEASE/spring-boot-project/spring-boot-actuator-autoconfigure/src/main/java/org/springframework/boot/actuate/autoconfigure/cloudfoundry/reactive/ReactiveCloudFoundryActuatorAutoConfiguration.java)|[javadoc](https://docs.spring.io/spring-boot/docs/2.0.0.RELEASE/api/org/springframework/boot/actuate/autoconfigure/cloudfoundry/reactive/ReactiveCloudFoundryActuatorAutoConfiguration.html)| +|[`ReactiveManagementContextAutoConfiguration`](https://github.com/spring-projects/spring-boot/tree/v2.0.0.RELEASE/spring-boot-project/spring-boot-actuator-autoconfigure/src/main/java/org/springframework/boot/actuate/autoconfigure/web/reactive/ReactiveManagementContextAutoConfiguration.java)|[javadoc](https://docs.spring.io/spring-boot/docs/2.0.0.RELEASE/api/org/springframework/boot/actuate/autoconfigure/web/reactive/ReactiveManagementContextAutoConfiguration.html)| +|[`RedisHealthIndicatorAutoConfiguration`](https://github.com/spring-projects/spring-boot/tree/v2.0.0.RELEASE/spring-boot-project/spring-boot-actuator-autoconfigure/src/main/java/org/springframework/boot/actuate/autoconfigure/redis/RedisHealthIndicatorAutoConfiguration.java)|[javadoc](https://docs.spring.io/spring-boot/docs/2.0.0.RELEASE/api/org/springframework/boot/actuate/autoconfigure/redis/RedisHealthIndicatorAutoConfiguration.html)| +|[`RestTemplateMetricsAutoConfiguration`](https://github.com/spring-projects/spring-boot/tree/v2.0.0.RELEASE/spring-boot-project/spring-boot-actuator-autoconfigure/src/main/java/org/springframework/boot/actuate/autoconfigure/metrics/web/client/RestTemplateMetricsAutoConfiguration.java)|[javadoc](https://docs.spring.io/spring-boot/docs/2.0.0.RELEASE/api/org/springframework/boot/actuate/autoconfigure/metrics/web/client/RestTemplateMetricsAutoConfiguration.html)| From daa4a1b54a9d8ed647ea96a57880c9d7e43e7bd8 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E7=83=AD=E5=BF=83=E5=B8=82=E6=B0=91=E9=92=9F=E5=B0=8F?= =?UTF-8?q?=E5=BC=BA?= Date: Tue, 7 Apr 2020 15:37:46 +0800 Subject: [PATCH 845/865] =?UTF-8?q?Update=20C.2.=20From=20the=20=E2=80=9Cs?= =?UTF-8?q?pring-boot-actuator-autoconfigure=E2=80=9D=20module.md?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- ...t-actuator-autoconfigure\342\200\235 module.md" | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git "a/X. Appendices/C.2. From the \342\200\234spring-boot-actuator-autoconfigure\342\200\235 module.md" "b/X. Appendices/C.2. From the \342\200\234spring-boot-actuator-autoconfigure\342\200\235 module.md" index 7eeeff0b..051bbc81 100644 --- "a/X. Appendices/C.2. From the \342\200\234spring-boot-actuator-autoconfigure\342\200\235 module.md" +++ "b/X. Appendices/C.2. From the \342\200\234spring-boot-actuator-autoconfigure\342\200\235 module.md" @@ -57,3 +57,17 @@ |[`ReactiveManagementContextAutoConfiguration`](https://github.com/spring-projects/spring-boot/tree/v2.0.0.RELEASE/spring-boot-project/spring-boot-actuator-autoconfigure/src/main/java/org/springframework/boot/actuate/autoconfigure/web/reactive/ReactiveManagementContextAutoConfiguration.java)|[javadoc](https://docs.spring.io/spring-boot/docs/2.0.0.RELEASE/api/org/springframework/boot/actuate/autoconfigure/web/reactive/ReactiveManagementContextAutoConfiguration.html)| |[`RedisHealthIndicatorAutoConfiguration`](https://github.com/spring-projects/spring-boot/tree/v2.0.0.RELEASE/spring-boot-project/spring-boot-actuator-autoconfigure/src/main/java/org/springframework/boot/actuate/autoconfigure/redis/RedisHealthIndicatorAutoConfiguration.java)|[javadoc](https://docs.spring.io/spring-boot/docs/2.0.0.RELEASE/api/org/springframework/boot/actuate/autoconfigure/redis/RedisHealthIndicatorAutoConfiguration.html)| |[`RestTemplateMetricsAutoConfiguration`](https://github.com/spring-projects/spring-boot/tree/v2.0.0.RELEASE/spring-boot-project/spring-boot-actuator-autoconfigure/src/main/java/org/springframework/boot/actuate/autoconfigure/metrics/web/client/RestTemplateMetricsAutoConfiguration.java)|[javadoc](https://docs.spring.io/spring-boot/docs/2.0.0.RELEASE/api/org/springframework/boot/actuate/autoconfigure/metrics/web/client/RestTemplateMetricsAutoConfiguration.html)| +|[`ScheduledTasksEndpointAutoConfiguration`](https://github.com/spring-projects/spring-boot/tree/v2.0.0.RELEASE/spring-boot-project/spring-boot-actuator-autoconfigure/src/main/java/org/springframework/boot/actuate/autoconfigure/scheduling/ScheduledTasksEndpointAutoConfiguration.java)|[javadoc](https://docs.spring.io/spring-boot/docs/2.0.0.RELEASE/api/org/springframework/boot/actuate/autoconfigure/scheduling/ScheduledTasksEndpointAutoConfiguration.html)| +|[`ServletManagementContextAutoConfiguration`](https://github.com/spring-projects/spring-boot/tree/v2.0.0.RELEASE/spring-boot-project/spring-boot-actuator-autoconfigure/src/main/java/org/springframework/boot/actuate/autoconfigure/web/servlet/ServletManagementContextAutoConfiguration.java)|[javadoc](https://docs.spring.io/spring-boot/docs/2.0.0.RELEASE/api/org/springframework/boot/actuate/autoconfigure/web/servlet/ServletManagementContextAutoConfiguration.html)| +|[`SessionsEndpointAutoConfiguration`](https://github.com/spring-projects/spring-boot/tree/v2.0.0.RELEASE/spring-boot-project/spring-boot-actuator-autoconfigure/src/main/java/org/springframework/boot/actuate/autoconfigure/session/SessionsEndpointAutoConfiguration.java)|[javadoc](https://docs.spring.io/spring-boot/docs/2.0.0.RELEASE/api/org/springframework/boot/actuate/autoconfigure/session/SessionsEndpointAutoConfiguration.html)| +|[`ShutdownEndpointAutoConfiguration`](https://github.com/spring-projects/spring-boot/tree/v2.0.0.RELEASE/spring-boot-project/spring-boot-actuator-autoconfigure/src/main/java/org/springframework/boot/actuate/autoconfigure/context/ShutdownEndpointAutoConfiguration.java)|[javadoc](https://docs.spring.io/spring-boot/docs/2.0.0.RELEASE/api/org/springframework/boot/actuate/autoconfigure/context/ShutdownEndpointAutoConfiguration.html)| +|[`SignalFxMetricsExportAutoConfiguration`](https://github.com/spring-projects/spring-boot/tree/v2.0.0.RELEASE/spring-boot-project/spring-boot-actuator-autoconfigure/src/main/java/org/springframework/boot/actuate/autoconfigure/metrics/export/signalfx/SignalFxMetricsExportAutoConfiguration.java)|[javadoc](https://docs.spring.io/spring-boot/docs/2.0.0.RELEASE/api/org/springframework/boot/actuate/autoconfigure/metrics/export/signalfx/SignalFxMetricsExportAutoConfiguration.html)| +|[`SimpleMetricsExportAutoConfiguration`](https://github.com/spring-projects/spring-boot/tree/v2.0.0.RELEASE/spring-boot-project/spring-boot-actuator-autoconfigure/src/main/java/org/springframework/boot/actuate/autoconfigure/metrics/export/simple/SimpleMetricsExportAutoConfiguration.java)|[javadoc](https://docs.spring.io/spring-boot/docs/2.0.0.RELEASE/api/org/springframework/boot/actuate/autoconfigure/metrics/export/simple/SimpleMetricsExportAutoConfiguration.html)| +|[`SolrHealthIndicatorAutoConfiguration`](https://github.com/spring-projects/spring-boot/tree/v2.0.0.RELEASE/spring-boot-project/spring-boot-actuator-autoconfigure/src/main/java/org/springframework/boot/actuate/autoconfigure/solr/SolrHealthIndicatorAutoConfiguration.java)|[javadoc](https://docs.spring.io/spring-boot/docs/2.0.0.RELEASE/api/org/springframework/boot/actuate/autoconfigure/solr/SolrHealthIndicatorAutoConfiguration.html)| +|[`StatsdMetricsExportAutoConfiguration`](https://github.com/spring-projects/spring-boot/tree/v2.0.0.RELEASE/spring-boot-project/spring-boot-actuator-autoconfigure/src/main/java/org/springframework/boot/actuate/autoconfigure/metrics/export/statsd/StatsdMetricsExportAutoConfiguration.java)|[javadoc](https://docs.spring.io/spring-boot/docs/2.0.0.RELEASE/api/org/springframework/boot/actuate/autoconfigure/metrics/export/statsd/StatsdMetricsExportAutoConfiguration.html)| +|[`ThreadDumpEndpointAutoConfiguration`](https://github.com/spring-projects/spring-boot/tree/v2.0.0.RELEASE/spring-boot-project/spring-boot-actuator-autoconfigure/src/main/java/org/springframework/boot/actuate/autoconfigure/management/ThreadDumpEndpointAutoConfiguration.java)|[javadoc](https://docs.spring.io/spring-boot/docs/2.0.0.RELEASE/api/org/springframework/boot/actuate/autoconfigure/management/ThreadDumpEndpointAutoConfiguration.html)| +|[`TomcatMetricsAutoConfiguration`](https://github.com/spring-projects/spring-boot/tree/v2.0.0.RELEASE/spring-boot-project/spring-boot-actuator-autoconfigure/src/main/java/org/springframework/boot/actuate/autoconfigure/metrics/web/tomcat/TomcatMetricsAutoConfiguration.java)|[javadoc](https://docs.spring.io/spring-boot/docs/2.0.0.RELEASE/api/org/springframework/boot/actuate/autoconfigure/metrics/web/tomcat/TomcatMetricsAutoConfiguration.html)| +|[`WavefrontMetricsExportAutoConfiguration`](https://github.com/spring-projects/spring-boot/tree/v2.0.0.RELEASE/spring-boot-project/spring-boot-actuator-autoconfigure/src/main/java/org/springframework/boot/actuate/autoconfigure/metrics/export/wavefront/WavefrontMetricsExportAutoConfiguration.java)|[javadoc](https://docs.spring.io/spring-boot/docs/2.0.0.RELEASE/api/org/springframework/boot/actuate/autoconfigure/metrics/export/wavefront/WavefrontMetricsExportAutoConfiguration.html)| +|[`WebEndpointAutoConfiguration`](https://github.com/spring-projects/spring-boot/tree/v2.0.0.RELEASE/spring-boot-project/spring-boot-actuator-autoconfigure/src/main/java/org/springframework/boot/actuate/autoconfigure/endpoint/web/WebEndpointAutoConfiguration.java)|[javadoc](https://docs.spring.io/spring-boot/docs/2.0.0.RELEASE/api/org/springframework/boot/actuate/autoconfigure/endpoint/web/WebEndpointAutoConfiguration.html)| +|[`WebFluxMetricsAutoConfiguration`](https://github.com/spring-projects/spring-boot/tree/v2.0.0.RELEASE/spring-boot-project/spring-boot-actuator-autoconfigure/src/main/java/org/springframework/boot/actuate/autoconfigure/metrics/web/reactive/WebFluxMetricsAutoConfiguration.java)|[javadoc](https://docs.spring.io/spring-boot/docs/2.0.0.RELEASE/api/org/springframework/boot/actuate/autoconfigure/metrics/web/reactive/WebFluxMetricsAutoConfiguration.html)| +|[`WebMvcMetricsAutoConfiguration`](https://github.com/spring-projects/spring-boot/tree/v2.0.0.RELEASE/spring-boot-project/spring-boot-actuator-autoconfigure/src/main/java/org/springframework/boot/actuate/autoconfigure/metrics/web/servlet/WebMvcMetricsAutoConfiguration.java)|[javadoc](https://docs.spring.io/spring-boot/docs/2.0.0.RELEASE/api/org/springframework/boot/actuate/autoconfigure/metrics/web/servlet/WebMvcMetricsAutoConfiguration.html)| From 100c0bb901e66d32ceecae5e514f03dac2a3ea71 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E7=83=AD=E5=BF=83=E5=B8=82=E6=B0=91=E9=92=9F=E5=B0=8F?= =?UTF-8?q?=E5=BC=BA?= Date: Tue, 7 Apr 2020 15:45:40 +0800 Subject: [PATCH 846/865] Update SUMMARY.md --- SUMMARY.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/SUMMARY.md b/SUMMARY.md index a6da6281..19801b9f 100644 --- a/SUMMARY.md +++ b/SUMMARY.md @@ -580,7 +580,7 @@ * [附录C. 自动配置类](X. Appendices/C. Auto-configuration classes.md) * [附录C.1. 来自spring-boot-autoconfigure模块](X. Appendices/C.1. From the “spring-boot-autoconfigure” module.md) * [附录C.2. 来自spring-boot-actuator-autoconfigure模块](X. Appendices/C.2. From the “spring-boot-actuator-autoconfigure” module.md) - * [附录D. 测试自动配置的标注](X. Appendices/D. Test auto-configuration annotations.md) + * [附录D. 测试的自动配置的标注](X. Appendices/D. Test auto-configuration annotations.md) * [附录E. 可执行jar格式](X. Appendices/E. The executable jar format.md) * [附录E.1. 内嵌JARs](X. Appendices/E.1. Nested JARs.md) * [附录E.1.1. 可执行jar文件结构](X. Appendices/E.1.1. The executable jar file structure.md) From e5156cad3bc91b74bd84f30f320aa776c30b5d42 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E7=83=AD=E5=BF=83=E5=B8=82=E6=B0=91=E9=92=9F=E5=B0=8F?= =?UTF-8?q?=E5=BC=BA?= Date: Tue, 7 Apr 2020 16:05:18 +0800 Subject: [PATCH 847/865] Update D. Test auto-configuration annotations.md --- .../D. Test auto-configuration annotations.md | 18 ++++++++++++++++-- 1 file changed, 16 insertions(+), 2 deletions(-) diff --git a/X. Appendices/D. Test auto-configuration annotations.md b/X. Appendices/D. Test auto-configuration annotations.md index 5e219f8b..670f2ef1 100644 --- a/X. Appendices/D. Test auto-configuration annotations.md +++ b/X. Appendices/D. Test auto-configuration annotations.md @@ -1,3 +1,17 @@ -### 附录 D. 测试自动配置的标注 +### 附录 D. 测试的自动配置的标注 -Here is a table of the various @…Test annotations that can be used to test slices of your application and the auto-configuration that they import by default: +下表列出了各种`@…Test`注释,这些注释可以用来测试你的应用程序的片段,以及默认情况下导入的自动配置。 + +|测试片段|导入的自动配置| +|------|:------| +|`@DataJpaTest`|`org.springframework.boot.autoconfigure.cache.CacheAutoConfiguration` `org.springframework.boot.autoconfigure.data.jpa.JpaRepositoriesAutoConfiguration` `org.springframework.boot.autoconfigure.flyway.FlywayAutoConfiguration` `org.springframework.boot.autoconfigure.jdbc.DataSourceAutoConfiguration` `org.springframework.boot.autoconfigure.jdbc.DataSourceTransactionManagerAutoConfiguration` `org.springframework.boot.autoconfigure.jdbc.JdbcTemplateAutoConfiguration` `org.springframework.boot.autoconfigure.liquibase.LiquibaseAutoConfiguration` `org.springframework.boot.autoconfigure.orm.jpa.HibernateJpaAutoConfiguration` `org.springframework.boot.autoconfigure.transaction.TransactionAutoConfiguration` `org.springframework.boot.test.autoconfigure.jdbc.TestDatabaseAutoConfiguration` `org.springframework.boot.test.autoconfigure.orm.jpa.TestEntityManagerAutoConfiguration`| +|`@DataLdapTest`|`org.springframework.boot.autoconfigure.cache.CacheAutoConfiguration` `org.springframework.boot.autoconfigure.data.ldap.LdapDataAutoConfiguration` `org.springframework.boot.autoconfigure.data.ldap.LdapRepositoriesAutoConfiguration` `org.springframework.boot.autoconfigure.ldap.LdapAutoConfiguration` `org.springframework.boot.autoconfigure.ldap.embedded.EmbeddedLdapAutoConfiguration`| +|`@DataMongoTest`|`org.springframework.boot.autoconfigure.cache.CacheAutoConfiguration` `org.springframework.boot.autoconfigure.data.mongo.MongoDataAutoConfiguration` `org.springframework.boot.autoconfigure.data.mongo.MongoReactiveDataAutoConfiguration` `org.springframework.boot.autoconfigure.data.mongo.MongoReactiveRepositoriesAutoConfiguration` `org.springframework.boot.autoconfigure.data.mongo.MongoRepositoriesAutoConfiguration` `org.springframework.boot.autoconfigure.mongo.MongoAutoConfiguration` `org.springframework.boot.autoconfigure.mongo.MongoReactiveAutoConfiguration` `org.springframework.boot.autoconfigure.mongo.embedded.EmbeddedMongoAutoConfiguration`| +|`@DataNeo4jTest`|`org.springframework.boot.autoconfigure.cache.CacheAutoConfiguration` `org.springframework.boot.autoconfigure.data.neo4j.Neo4jDataAutoConfiguration` `org.springframework.boot.autoconfigure.data.neo4j.Neo4jRepositoriesAutoConfiguration` `org.springframework.boot.autoconfigure.transaction.TransactionAutoConfiguration`| +|`@DataRedisTest`|`org.springframework.boot.autoconfigure.cache.CacheAutoConfiguration` `org.springframework.boot.autoconfigure.data.redis.RedisAutoConfiguration` `org.springframework.boot.autoconfigure.data.redis.RedisRepositoriesAutoConfiguration`| +|`@JdbcTest`|`org.springframework.boot.autoconfigure.cache.CacheAutoConfiguration` `org.springframework.boot.autoconfigure.flyway.FlywayAutoConfiguration` `org.springframework.boot.autoconfigure.jdbc.DataSourceAutoConfiguration` `org.springframework.boot.autoconfigure.jdbc.DataSourceTransactionManagerAutoConfiguration` `org.springframework.boot.autoconfigure.jdbc.JdbcTemplateAutoConfiguration` `org.springframework.boot.autoconfigure.liquibase.LiquibaseAutoConfiguration` `org.springframework.boot.autoconfigure.transaction.TransactionAutoConfiguration` `org.springframework.boot.test.autoconfigure.jdbc.TestDatabaseAutoConfiguration`| +|`@JooqTest`|`org.springframework.boot.autoconfigure.flyway.FlywayAutoConfiguration` `org.springframework.boot.autoconfigure.jdbc.DataSourceAutoConfiguration` `org.springframework.boot.autoconfigure.jdbc.DataSourceTransactionManagerAutoConfiguration` `org.springframework.boot.autoconfigure.jooq.JooqAutoConfiguration` `org.springframework.boot.autoconfigure.liquibase.LiquibaseAutoConfiguration` `org.springframework.boot.autoconfigure.transaction.TransactionAutoConfiguration`| +|`@JsonTest`|`org.springframework.boot.autoconfigure.cache.CacheAutoConfiguration` `org.springframework.boot.autoconfigure.gson.GsonAutoConfiguration` `org.springframework.boot.autoconfigure.jackson.JacksonAutoConfiguration` `org.springframework.boot.autoconfigure.jsonb.JsonbAutoConfiguration` `org.springframework.boot.test.autoconfigure.json.JsonTestersAutoConfiguration`| +|`@RestClientTest`|`org.springframework.boot.autoconfigure.cache.CacheAutoConfiguration` `org.springframework.boot.autoconfigure.gson.GsonAutoConfiguration` `org.springframework.boot.autoconfigure.http.HttpMessageConvertersAutoConfiguration` `org.springframework.boot.autoconfigure.http.codec.CodecsAutoConfiguration` `org.springframework.boot.autoconfigure.jackson.JacksonAutoConfiguration` `org.springframework.boot.autoconfigure.jsonb.JsonbAutoConfiguration` `org.springframework.boot.autoconfigure.web.client.RestTemplateAutoConfiguration` `org.springframework.boot.autoconfigure.web.reactive.function.client.WebClientAutoConfiguration` `org.springframework.boot.test.autoconfigure.web.client.MockRestServiceServerAutoConfiguration` `org.springframework.boot.test.autoconfigure.web.client.WebClientRestTemplateAutoConfiguration`| +|`@WebFluxTest`|`org.springframework.boot.autoconfigure.cache.CacheAutoConfiguration` `org.springframework.boot.autoconfigure.context.MessageSourceAutoConfiguration` `org.springframework.boot.autoconfigure.validation.ValidationAutoConfiguration` `org.springframework.boot.autoconfigure.web.reactive.WebFluxAutoConfiguration` `org.springframework.boot.test.autoconfigure.web.reactive.WebTestClientAutoConfiguration`| +|`@WebMvcTest`|`org.springframework.boot.autoconfigure.cache.CacheAutoConfiguration` `org.springframework.boot.autoconfigure.context.MessageSourceAutoConfiguration` `org.springframework.boot.autoconfigure.freemarker.FreeMarkerAutoConfiguration` `org.springframework.boot.autoconfigure.groovy.template.GroovyTemplateAutoConfiguration` `org.springframework.boot.autoconfigure.gson.GsonAutoConfiguration` `org.springframework.boot.autoconfigure.hateoas.HypermediaAutoConfiguration` `org.springframework.boot.autoconfigure.http.HttpMessageConvertersAutoConfiguration` `org.springframework.boot.autoconfigure.jackson.JacksonAutoConfiguration` `org.springframework.boot.autoconfigure.jsonb.JsonbAutoConfiguration` `org.springframework.boot.autoconfigure.mustache.MustacheAutoConfiguration` `org.springframework.boot.autoconfigure.thymeleaf.ThymeleafAutoConfiguration` `org.springframework.boot.autoconfigure.validation.ValidationAutoConfiguration` `org.springframework.boot.autoconfigure.web.servlet.WebMvcAutoConfiguration` `org.springframework.boot.autoconfigure.web.servlet.error.ErrorMvcAutoConfiguration` `org.springframework.boot.test.autoconfigure.web.servlet.MockMvcAutoConfiguration` `org.springframework.boot.test.autoconfigure.web.servlet.MockMvcSecurityAutoConfiguration` `org.springframework.boot.test.autoconfigure.web.servlet.MockMvcWebClientAutoConfiguration` `org.springframework.boot.test.autoconfigure.web.servlet.MockMvcWebDriverAutoConfiguration`| From 59fcf4e2348b522581ff5bed01c081bf4bd57159 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E7=83=AD=E5=BF=83=E5=B8=82=E6=B0=91=E9=92=9F=E5=B0=8F?= =?UTF-8?q?=E5=BC=BA?= Date: Tue, 7 Apr 2020 16:17:37 +0800 Subject: [PATCH 848/865] =?UTF-8?q?Update=20C.1.=20From=20the=20=E2=80=9Cs?= =?UTF-8?q?pring-boot-autoconfigure=E2=80=9D=20module.md?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- ...342\200\234spring-boot-autoconfigure\342\200\235 module.md" | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git "a/X. Appendices/C.1. From the \342\200\234spring-boot-autoconfigure\342\200\235 module.md" "b/X. Appendices/C.1. From the \342\200\234spring-boot-autoconfigure\342\200\235 module.md" index 11ffcb14..ccb4d2ec 100644 --- "a/X. Appendices/C.1. From the \342\200\234spring-boot-autoconfigure\342\200\235 module.md" +++ "b/X. Appendices/C.1. From the \342\200\234spring-boot-autoconfigure\342\200\235 module.md" @@ -55,7 +55,8 @@ |[`JmxAutoConfiguration`](https://github.com/spring-projects/spring-boot/tree/v2.0.0.RELEASE/spring-boot-project/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/jmx/JmxAutoConfiguration.java)|[javadoc](https://docs.spring.io/spring-boot/docs/2.0.0.RELEASE/api/org/springframework/boot/autoconfigure/jmx/JmxAutoConfiguration.html)| |[`JndiConnectionFactoryAutoConfiguration`](https://github.com/spring-projects/spring-boot/tree/v2.0.0.RELEASE/spring-boot-project/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/jms/JndiConnectionFactoryAutoConfiguration.java)|[javadoc](https://docs.spring.io/spring-boot/docs/2.0.0.RELEASE/api/org/springframework/boot/autoconfigure/jms/JndiConnectionFactoryAutoConfiguration.html)| |[`JndiDataSourceAutoConfiguration`](https://github.com/spring-projects/spring-boot/tree/v2.0.0.RELEASE/spring-boot-project/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/jdbc/JndiDataSourceAutoConfiguration.java)|[javadoc](https://docs.spring.io/spring-boot/docs/2.0.0.RELEASE/api/org/springframework/boot/autoconfigure/jdbc/JndiDataSourceAutoConfiguration.html)| -|[`JooqAutoConfiguration`](https://github.com/spring-projects/spring-boot/tree/v2.0.0.RELEASE/spring-boot-project/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/jooq/JooqAutoConfiguration.java)|[javadoc](https://docs.spring.io/spring-boot/docs/2.0.0.RELEASE/api/org/springframework/boot/autoconfigure/jooq/JooqAutoConfiguration.html)|[`JpaRepositoriesAutoConfiguration`](https://github.com/spring-projects/spring-boot/tree/v2.0.0.RELEASE/spring-boot-project/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/data/jpa/JpaRepositoriesAutoConfiguration.java)|[javadoc](https://docs.spring.io/spring-boot/docs/2.0.0.RELEASE/api/org/springframework/boot/autoconfigure/data/jpa/JpaRepositoriesAutoConfiguration.html)| +|[`JooqAutoConfiguration`](https://github.com/spring-projects/spring-boot/tree/v2.0.0.RELEASE/spring-boot-project/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/jooq/JooqAutoConfiguration.java)|[javadoc](https://docs.spring.io/spring-boot/docs/2.0.0.RELEASE/api/org/springframework/boot/autoconfigure/jooq/JooqAutoConfiguration.html)| +|[`JpaRepositoriesAutoConfiguration`](https://github.com/spring-projects/spring-boot/tree/v2.0.0.RELEASE/spring-boot-project/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/data/jpa/JpaRepositoriesAutoConfiguration.java)|[javadoc](https://docs.spring.io/spring-boot/docs/2.0.0.RELEASE/api/org/springframework/boot/autoconfigure/data/jpa/JpaRepositoriesAutoConfiguration.html)| |[`JsonbAutoConfiguration`](https://github.com/spring-projects/spring-boot/tree/v2.0.0.RELEASE/spring-boot-project/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/jsonb/JsonbAutoConfiguration.java)|[javadoc](https://docs.spring.io/spring-boot/docs/2.0.0.RELEASE/api/org/springframework/boot/autoconfigure/jsonb/JsonbAutoConfiguration.html)| |[`JtaAutoConfiguration`](https://github.com/spring-projects/spring-boot/tree/v2.0.0.RELEASE/spring-boot-project/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/transaction/jta/JtaAutoConfiguration.java)|[javadoc](https://docs.spring.io/spring-boot/docs/2.0.0.RELEASE/api/org/springframework/boot/autoconfigure/transaction/jta/JtaAutoConfiguration.html)| |[`KafkaAutoConfiguration`](https://github.com/spring-projects/spring-boot/tree/v2.0.0.RELEASE/spring-boot-project/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/kafka/KafkaAutoConfiguration.java)|[javadoc](https://docs.spring.io/spring-boot/docs/2.0.0.RELEASE/api/org/springframework/boot/autoconfigure/kafka/KafkaAutoConfiguration.html)| From 8b0b764c2f9a590185380da105bdc4b451babc23 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E7=83=AD=E5=BF=83=E5=B8=82=E6=B0=91=E9=92=9F=E5=B0=8F?= =?UTF-8?q?=E5=BC=BA?= Date: Wed, 15 Apr 2020 14:26:52 +0800 Subject: [PATCH 849/865] Update SUMMARY.md --- SUMMARY.md | 22 ++++++++++------------ 1 file changed, 10 insertions(+), 12 deletions(-) diff --git a/SUMMARY.md b/SUMMARY.md index 19801b9f..db9038c7 100644 --- a/SUMMARY.md +++ b/SUMMARY.md @@ -581,18 +581,16 @@ * [附录C.1. 来自spring-boot-autoconfigure模块](X. Appendices/C.1. From the “spring-boot-autoconfigure” module.md) * [附录C.2. 来自spring-boot-actuator-autoconfigure模块](X. Appendices/C.2. From the “spring-boot-actuator-autoconfigure” module.md) * [附录D. 测试的自动配置的标注](X. Appendices/D. Test auto-configuration annotations.md) - * [附录E. 可执行jar格式](X. Appendices/E. The executable jar format.md) + * [附录E. 可执行Jar格式](X. Appendices/E. The Executable Jar Format.md) * [附录E.1. 内嵌JARs](X. Appendices/E.1. Nested JARs.md) - * [附录E.1.1. 可执行jar文件结构](X. Appendices/E.1.1. The executable jar file structure.md) - * [附录E.1.2. 可执行war文件结构](X. Appendices/E.1.2. The executable war file structure.md) - * [附录E.2. Spring Boot的"JarFile"类](X. Appendices/E.2. Spring Boot’s “JarFile” class.md) - * [附录E.2.1. 对标准Java "JarFile"的兼容性](X. Appendices/E.2.1. Compatibility with the standard Java “JarFile”.md) - * [附录E.3. 启动可执行jars](X. Appendices/E.3. Launching executable jars.md) - * [附录E.3.1 Launcher manifest](X. Appendices/E.3.1. Launcher manifest.md) - * [附录E.3.2. 暴露的存档](X. Appendices/E.3.2. Exploded archives.md) + * [附录E.1.1. 可执行Jar文件结构](X. Appendices/E.1.1. The Executable Jar File Structure.md) + * [附录E.1.2. 可执行War文件结构](X. Appendices/E.1.2. The Executable War File Structure.md) + * [附录E.2. Spring Boot的"JarFile"类](X. Appendices/E.2. Spring Boot’s “JarFile” Class.md) + * [附录E.2.1. 对标准Java "JarFile"的兼容性](X. Appendices/E.2.1. Compatibility with the Standard Java “JarFile”.md) + * [附录E.3. 启动可执行Jars](X. Appendices/E.3. Launching Executable Jars.md) + * [附录E.3.1 Launcher manifest](X. Appendices/E.3.1. Launcher Manifest.md) + * [附录E.3.2. 暴露的存档](X. Appendices/E.3.2. Exploded Archives.md) * [附录E.4. PropertiesLauncher特性](X. Appendices/E.4. PropertiesLauncher Features.md) - * [附录E.5. 可执行jar的限制](X. Appendices/E.5. Executable jar restrictions.md) - * [附录E.5.1. Zip实体压缩](X. Appendices/E.5.1. Zip entry compression.md) - * [附录E.5.2. 系统ClassLoader](X. Appendices/E.5.2. System ClassLoader.md) - * [附录E.6. 可替代的单一jar解决方案](X. Appendices/E.6. Alternative single jar solutions.md) + * [附录E.5. 可执行jar的限制](X. Appendices/E.5. Executable Jar Restrictions.md) + * [附录E.6. 可替代的单一jar解决方案](X. Appendices/E.6. Alternative Single Jar Solutions.md) * [附录F. 依赖版本](X. Appendices/F. Dependency versions.md) From 21e5ff5945d530a189400050440c61c43e9ece1e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E7=83=AD=E5=BF=83=E5=B8=82=E6=B0=91=E9=92=9F=E5=B0=8F?= =?UTF-8?q?=E5=BC=BA?= Date: Wed, 15 Apr 2020 14:29:23 +0800 Subject: [PATCH 850/865] Update and rename E. The executable jar format.md to E. The Executable Jar Format.md --- ...executable jar format.md => E. The Executable Jar Format.md} | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) rename X. Appendices/{E. The executable jar format.md => E. The Executable Jar Format.md} (90%) diff --git a/X. Appendices/E. The executable jar format.md b/X. Appendices/E. The Executable Jar Format.md similarity index 90% rename from X. Appendices/E. The executable jar format.md rename to X. Appendices/E. The Executable Jar Format.md index 0168ff11..3eeb94c1 100644 --- a/X. Appendices/E. The executable jar format.md +++ b/X. Appendices/E. The Executable Jar Format.md @@ -1,4 +1,4 @@ -### 附录 E. 可执行jar格式 +### 附录 E. 可执行Jar格式 `spring-boot-loader`模块允许Spring Boot对可执行jar和war文件的支持。如果你正在使用Maven或Gradle插件,可执行jar会被自动产生,通常你不需要了解它是如何工作的。 From 6a2dd074cc184d05d6100e2f1c6b6a489358dede Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E7=83=AD=E5=BF=83=E5=B8=82=E6=B0=91=E9=92=9F=E5=B0=8F?= =?UTF-8?q?=E5=BC=BA?= Date: Wed, 15 Apr 2020 14:32:18 +0800 Subject: [PATCH 851/865] Update E.1. Nested JARs.md --- X. Appendices/E.1. Nested JARs.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/X. Appendices/E.1. Nested JARs.md b/X. Appendices/E.1. Nested JARs.md index 174181c7..378ba4d2 100644 --- a/X. Appendices/E.1. Nested JARs.md +++ b/X. Appendices/E.1. Nested JARs.md @@ -1,5 +1,5 @@ ### 附录 E.1. 内嵌JARs -Java没有提供任何标准的方式来加载内嵌的jar文件(也就是jar文件自身包含到一个jar中)。如果你正分发一个在不解压缩的情况下可以从命令行运行的自包含应用,那这将是个问题。 +Java没有提供任何标准的方式来加载内嵌的jar文件(也就是jar文件自身包含到一个jar中)。如果你需要分发一个在不解压缩的情况下可以从命令行运行的自包含应用,那这将是个问题。 -为了解决这个问题,很多开发者使用"影子" jars。一个影子jar只是简单的将所有jars的类打包进一个单独的"超级jar"。使用影子jars的问题是它很难分辨在你的应用中实际可以使用的库。在多个jars中存在相同的文件名(内容不同)也是一个问题。Spring Boot另辟蹊径,让你能够直接嵌套jars。 +为了解决这个问题,很多开发者使用"影子" jars。一个影子jar将所有jars的类打包进一个单独的"超级jar"。使用影子jars的问题是它很难分辨在你的应用中实际可以使用的库。在多个jars中存在相同的文件名(内容不同)也是一个问题。Spring Boot另辟蹊径,让你能够直接嵌套jars。 From 2f88756c9c85dad25a4742af684e02f48c5c322d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E7=83=AD=E5=BF=83=E5=B8=82=E6=B0=91=E9=92=9F=E5=B0=8F?= =?UTF-8?q?=E5=BC=BA?= Date: Wed, 15 Apr 2020 14:34:45 +0800 Subject: [PATCH 852/865] Update and rename E.1.1. The executable jar file structure.md to E.1.1. The Executable Jar File Structure.md --- ...structure.md => E.1.1. The Executable Jar File Structure.md} | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) rename X. Appendices/{E.1.1. The executable jar file structure.md => E.1.1. The Executable Jar File Structure.md} (88%) diff --git a/X. Appendices/E.1.1. The executable jar file structure.md b/X. Appendices/E.1.1. The Executable Jar File Structure.md similarity index 88% rename from X. Appendices/E.1.1. The executable jar file structure.md rename to X. Appendices/E.1.1. The Executable Jar File Structure.md index adbd56ea..db19898c 100644 --- a/X. Appendices/E.1.1. The executable jar file structure.md +++ b/X. Appendices/E.1.1. The Executable Jar File Structure.md @@ -1,4 +1,4 @@ -### 附录 E.1.1 可执行jar文件结构 +### 附录 E.1.1 可执行Jar文件结构 Spring Boot Loader兼容的jar文件应该遵循以下结构: From a4f428ceaf807344ac330793a1b81f5ba3bb0f2d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E7=83=AD=E5=BF=83=E5=B8=82=E6=B0=91=E9=92=9F=E5=B0=8F?= =?UTF-8?q?=E5=BC=BA?= Date: Wed, 15 Apr 2020 14:36:31 +0800 Subject: [PATCH 853/865] Update and rename E.1.2. The executable war file structure.md to E.1.2. The Executable War File Structure.md --- ...structure.md => E.1.2. The Executable War File Structure.md} | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) rename X. Appendices/{E.1.2. The executable war file structure.md => E.1.2. The Executable War File Structure.md} (90%) diff --git a/X. Appendices/E.1.2. The executable war file structure.md b/X. Appendices/E.1.2. The Executable War File Structure.md similarity index 90% rename from X. Appendices/E.1.2. The executable war file structure.md rename to X. Appendices/E.1.2. The Executable War File Structure.md index 1f87fa0d..3fa4f422 100644 --- a/X. Appendices/E.1.2. The executable war file structure.md +++ b/X. Appendices/E.1.2. The Executable War File Structure.md @@ -1,4 +1,4 @@ -### 附录 E.1.2. 可执行war文件结构 +### 附录 E.1.2. 可执行War文件结构 Spring Boot Loader兼容的war文件应该遵循以下结构: ```java From 612587f799497c84b7711bc78435de00f6fe3a60 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E7=83=AD=E5=BF=83=E5=B8=82=E6=B0=91=E9=92=9F=E5=B0=8F?= =?UTF-8?q?=E5=BC=BA?= Date: Wed, 15 Apr 2020 14:38:06 +0800 Subject: [PATCH 854/865] =?UTF-8?q?Rename=20E.2.=20Spring=20Boot=E2=80=99s?= =?UTF-8?q?=20=E2=80=9CJarFile=E2=80=9D=20class.md=20to=20E.2.=20Spring=20?= =?UTF-8?q?Boot=E2=80=99s=20=E2=80=9CJarFile=E2=80=9D=20Class.md?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- ...ng Boot\342\200\231s \342\200\234JarFile\342\200\235 Class.md" | 0 1 file changed, 0 insertions(+), 0 deletions(-) rename "X. Appendices/E.2. Spring Boot\342\200\231s \342\200\234JarFile\342\200\235 class.md" => "X. Appendices/E.2. Spring Boot\342\200\231s \342\200\234JarFile\342\200\235 Class.md" (100%) diff --git "a/X. Appendices/E.2. Spring Boot\342\200\231s \342\200\234JarFile\342\200\235 class.md" "b/X. Appendices/E.2. Spring Boot\342\200\231s \342\200\234JarFile\342\200\235 Class.md" similarity index 100% rename from "X. Appendices/E.2. Spring Boot\342\200\231s \342\200\234JarFile\342\200\235 class.md" rename to "X. Appendices/E.2. Spring Boot\342\200\231s \342\200\234JarFile\342\200\235 Class.md" From ab514bf9420a47fce232aa2f9a5eddb6cf0e6e24 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E7=83=AD=E5=BF=83=E5=B8=82=E6=B0=91=E9=92=9F=E5=B0=8F?= =?UTF-8?q?=E5=BC=BA?= Date: Wed, 15 Apr 2020 14:46:11 +0800 Subject: [PATCH 855/865] =?UTF-8?q?Update=20and=20rename=20E.2.1.=20Compat?= =?UTF-8?q?ibility=20with=20the=20standard=20Java=20=E2=80=9CJarFile?= =?UTF-8?q?=E2=80=9D.md=20to=20E.2.1.=20Compatibility=20with=20the=20Stand?= =?UTF-8?q?ard=20Java=20=E2=80=9CJarFile=E2=80=9D.md?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- ...y with the Standard Java \342\200\234JarFile\342\200\235.md" | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) rename "X. Appendices/E.2.1. Compatibility with the standard Java \342\200\234JarFile\342\200\235.md" => "X. Appendices/E.2.1. Compatibility with the Standard Java \342\200\234JarFile\342\200\235.md" (52%) diff --git "a/X. Appendices/E.2.1. Compatibility with the standard Java \342\200\234JarFile\342\200\235.md" "b/X. Appendices/E.2.1. Compatibility with the Standard Java \342\200\234JarFile\342\200\235.md" similarity index 52% rename from "X. Appendices/E.2.1. Compatibility with the standard Java \342\200\234JarFile\342\200\235.md" rename to "X. Appendices/E.2.1. Compatibility with the Standard Java \342\200\234JarFile\342\200\235.md" index b2ae99d7..70bf9284 100644 --- "a/X. Appendices/E.2.1. Compatibility with the standard Java \342\200\234JarFile\342\200\235.md" +++ "b/X. Appendices/E.2.1. Compatibility with the Standard Java \342\200\234JarFile\342\200\235.md" @@ -1,3 +1,3 @@ ### 附录 E.2.1 对标准Java "JarFile"的兼容性 -Spring Boot Loader努力保持对已有代码和库的兼容。`org.springframework.boot.loader.jar.JarFile`继承自`java.util.jar.JarFile`,可以作为降级替换。 +Spring Boot Loader努力保持对已有代码和库的兼容。`org.springframework.boot.loader.jar.JarFile`继承自`java.util.jar.JarFile`,可以作为降级替换。`getURL()`方法返回一个与`java.net.JarURLConnection`兼容的`URL`,并可与Java的`URLClassLoader`一起使用。 From 7b6cab8c316b3399f78345af4e0eda05da53c12f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E7=83=AD=E5=BF=83=E5=B8=82=E6=B0=91=E9=92=9F=E5=B0=8F?= =?UTF-8?q?=E5=BC=BA?= Date: Tue, 21 Apr 2020 09:20:04 +0800 Subject: [PATCH 856/865] Update and rename E.3. Launching executable jars.md to E.3. Launching Executable Jars.md --- X. Appendices/E.3. Launching Executable Jars.md | 5 +++++ X. Appendices/E.3. Launching executable jars.md | 5 ----- 2 files changed, 5 insertions(+), 5 deletions(-) create mode 100644 X. Appendices/E.3. Launching Executable Jars.md delete mode 100644 X. Appendices/E.3. Launching executable jars.md diff --git a/X. Appendices/E.3. Launching Executable Jars.md b/X. Appendices/E.3. Launching Executable Jars.md new file mode 100644 index 00000000..f08363dc --- /dev/null +++ b/X. Appendices/E.3. Launching Executable Jars.md @@ -0,0 +1,5 @@ +### 附录 E.3. 启动可执行jars + +`org.springframework.boot.loader.Launcher`类是个特殊的启动类,用于一个可执行jar的主要入口。它实际上就是你jar文件的`Main-Class`,并用来设置一个合适的`URLClassLoader`,最后调用你的`main()`方法。 + +这里有3个启动器子类(JarLauncher、WarLauncher和PropertiesLauncher)。它们的作用是从嵌套的jar或war文件目录中(相对于显示的从classpath)加载资源(.class文件等)。在`[Jar|War]Launcher`情况下,嵌套路径是固定的(`lib/*.jar`和war的`lib-provided/*.jar`),所以如果你需要很多其他jars只需添加到那些位置即可。PropertiesLauncher默认查找你应用存档的`lib/`目录,但你可以通过设置环境变量`LOADER_PATH`或application.properties中的`loader.path`来添加其他的位置(一个以逗号分隔的目录、存档或存档内的目录列表)。 diff --git a/X. Appendices/E.3. Launching executable jars.md b/X. Appendices/E.3. Launching executable jars.md deleted file mode 100644 index 2aa3a1ad..00000000 --- a/X. Appendices/E.3. Launching executable jars.md +++ /dev/null @@ -1,5 +0,0 @@ -### 附录 E.3. 启动可执行jars - -`org.springframework.boot.loader.Launcher`类是个特殊的启动类,用于一个可执行jars的主要入口。它实际上就是你jar文件的`Main-Class`,并用来设置一个合适的`URLClassLoader`,最后调用你的`main()`方法。 - -这里有3个启动器子类,JarLauncher,WarLauncher和PropertiesLauncher。它们的作用是从嵌套的jar或war文件目录中(相对于显示的从classpath)加载资源(.class文件等)。在`[Jar|War]Launcher`情况下,嵌套路径是固定的(`lib/*.jar`和war的`lib-provided/*.jar`),所以如果你需要很多其他jars只需添加到那些位置即可。PropertiesLauncher默认查找你应用存档的`lib/`目录,但你可以通过设置环境变量`LOADER_PATH`或application.properties中的`loader.path`来添加其他的位置(逗号分割的目录或存档列表)。 From cd174cc6aa1b28359a3933ba633895181dbc539d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E7=83=AD=E5=BF=83=E5=B8=82=E6=B0=91=E9=92=9F=E5=B0=8F?= =?UTF-8?q?=E5=BC=BA?= Date: Tue, 21 Apr 2020 09:22:24 +0800 Subject: [PATCH 857/865] Update and rename E.3.1. Launcher manifest.md to E.3.1. Launcher Manifest.md --- ...{E.3.1. Launcher manifest.md => E.3.1. Launcher Manifest.md} | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) rename X. Appendices/{E.3.1. Launcher manifest.md => E.3.1. Launcher Manifest.md} (93%) diff --git a/X. Appendices/E.3.1. Launcher manifest.md b/X. Appendices/E.3.1. Launcher Manifest.md similarity index 93% rename from X. Appendices/E.3.1. Launcher manifest.md rename to X. Appendices/E.3.1. Launcher Manifest.md index 6de74241..d97d5b17 100644 --- a/X. Appendices/E.3.1. Launcher manifest.md +++ b/X. Appendices/E.3.1. Launcher Manifest.md @@ -1,4 +1,4 @@ -### 附录 E.3.1 Launcher manifest +### E.3.1 Launcher Manifest 你需要指定一个合适的Launcher作为`META-INF/MANIFEST.MF`的`Main-Class`属性。你实际想要启动的类(也就是你编写的包含main方法的类)需要在`Start-Class`属性中定义。 From 94997410721b70dd70313f96100aae34ab12213f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E7=83=AD=E5=BF=83=E5=B8=82=E6=B0=91=E9=92=9F=E5=B0=8F?= =?UTF-8?q?=E5=BC=BA?= Date: Tue, 21 Apr 2020 09:23:33 +0800 Subject: [PATCH 858/865] Update E.3.1. Launcher Manifest.md --- X. Appendices/E.3.1. Launcher Manifest.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/X. Appendices/E.3.1. Launcher Manifest.md b/X. Appendices/E.3.1. Launcher Manifest.md index d97d5b17..df10679b 100644 --- a/X. Appendices/E.3.1. Launcher Manifest.md +++ b/X. Appendices/E.3.1. Launcher Manifest.md @@ -1,4 +1,4 @@ -### E.3.1 Launcher Manifest +### 附录 E.3.1 Launcher Manifest 你需要指定一个合适的Launcher作为`META-INF/MANIFEST.MF`的`Main-Class`属性。你实际想要启动的类(也就是你编写的包含main方法的类)需要在`Start-Class`属性中定义。 From 4d792900ad23b5a15781837a713dd58bf8bc3397 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E7=83=AD=E5=BF=83=E5=B8=82=E6=B0=91=E9=92=9F=E5=B0=8F?= =?UTF-8?q?=E5=BC=BA?= Date: Tue, 21 Apr 2020 09:24:39 +0800 Subject: [PATCH 859/865] Update and rename E.3.2. Exploded archives.md to E.3.2. Exploded Archives.md --- .../{E.3.2. Exploded archives.md => E.3.2. Exploded Archives.md} | 1 - 1 file changed, 1 deletion(-) rename X. Appendices/{E.3.2. Exploded archives.md => E.3.2. Exploded Archives.md} (97%) diff --git a/X. Appendices/E.3.2. Exploded archives.md b/X. Appendices/E.3.2. Exploded Archives.md similarity index 97% rename from X. Appendices/E.3.2. Exploded archives.md rename to X. Appendices/E.3.2. Exploded Archives.md index bd7e3b21..43d554e7 100644 --- a/X. Appendices/E.3.2. Exploded archives.md +++ b/X. Appendices/E.3.2. Exploded Archives.md @@ -5,4 +5,3 @@ $ unzip -q myapp.jar $ java org.springframework.boot.loader.JarLaunche ``` - From 1168dc574fb228e0c5b4ca9ac661e1a74e521e38 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E7=83=AD=E5=BF=83=E5=B8=82=E6=B0=91=E9=92=9F=E5=B0=8F?= =?UTF-8?q?=E5=BC=BA?= Date: Tue, 21 Apr 2020 10:08:01 +0800 Subject: [PATCH 860/865] Update E.4. PropertiesLauncher Features.md --- .../E.4. PropertiesLauncher Features.md | 43 +++++++++++++------ 1 file changed, 29 insertions(+), 14 deletions(-) diff --git a/X. Appendices/E.4. PropertiesLauncher Features.md b/X. Appendices/E.4. PropertiesLauncher Features.md index 8652a90a..62aeb44f 100644 --- a/X. Appendices/E.4. PropertiesLauncher Features.md +++ b/X. Appendices/E.4. PropertiesLauncher Features.md @@ -1,21 +1,36 @@ ### 附录 E.4. PropertiesLauncher特性 -PropertiesLauncher有一些特殊的性质,它们可以通过外部属性来启用(系统属性,环境变量,manifest实体或application.properties)。 +PropertiesLauncher有一些特殊的性质,它们可以通过外部属性来启用(系统属性、环境变量、manifest实体或application.properties)。下面的表格描述了这些属性: -|Key|作用| +|键|作用| |----|:-----| -|loader.path|逗号分割的classpath,比如`lib:${HOME}/app/lib`| -|loader.home|其他属性文件的位置,比如[/opt/app](file:///opt/app)(默认为`${user.dir}`)| -|loader.args|main方法的默认参数(以空格分割)| -|loader.main|要启动的main类名称,比如`com.app.Application`| -|loader.config.name|属性文件名,比如loader(默认为application)| -|loader.config.location|属性文件路径,比如`classpath:loader.properties`(默认为application.properties)| -|loader.system|布尔标识,表明所有的属性都应该添加到系统属性中(默认为false)| +|`loader.path`|逗号分隔的classpath,比如`lib,${HOME}/app/lib`。前面的条目优先,就像`javac`命令行中的常规`-classpath`一样。| +|`loader.home`|用于解析`loader.path`中的相对路径。例如,给定`loader.path=lib`,那么`${loader.home}/lib`是一个类路径位置(以及该目录中的所有 jar文件)。这个属性也用于定位`loader.properties`文件,就像下面的例子`/opt/app`,它的默认值是`${user.dir}`。| +|`loader.args`|main方法的默认参数(以空格分隔)| +|`loader.main`|要启动的main类名称,比如`com.app.Application`| +|`loader.config.name`|属性文件名,比如loader(默认为application)| +|`loader.config.location`|属性文件路径,比如`classpath:loader.properties`(默认为application.properties)| +|`loader.system`|布尔标识,表明所有的属性都应该添加到系统属性中(默认为false)| -Manifest实体keys通过大写单词首字母及将分隔符从"."改为"-"(比如`Loader-Path`)来进行格式化。`loader.main`是个特例,它是通过查找manifest的`Start-Class`,这样也兼容JarLauncher。 +当指定为环境变量或清单条目时,应使用以下名称: -环境变量可以大写字母并且用下划线代替句号。 +|键|清单条目|环境变量| +|----|:-----|:-----| +|`loader.path`|`Loader-Path`|`LOADER_PATH`| +|`loader.home`|`Loader-Home`|`LOADER_HOME`| +|`loader.args`|`Loader-Args`|`LOADER_ARGS`| +|`loader.main`|`Start-Class`|`LOADER_MAIN`| +|`loader.config.location`|`Loader-Config-Location`|`LOADER_CONFIG_LOCATION`| +|`loader.system`|`Loader-System`|`LOADER_SYSTEM`| -* `loader.home`是其他属性文件(覆盖默认)的目录位置,只要没有指定`loader.config.location`。 -* `loader.path`可以包含目录(递归地扫描jar和zip文件),存档路径或通配符模式(针对默认的JVM行为)。 -* 占位符在使用前会被系统和环境变量加上属性文件本身的值替换掉。 +**注** 构建插件在胖子jar构建时,会自动将`Main-Class`属性移动到`Start-Class`。如果使用这个,请指定要启动的类的名称,使用`Main-Class`属性而省略`Start-Class`。 + +以下规则适用于使用`PropertiesLauncher`工作: + +- `loader.properties`在`loader.home`中搜索,然后在类路径的根目录中搜索,然后在`classpath:/BOOT-INF/classes`中搜索。首先使用的是存在该名称的文件的第一个位置。 +- `loader.home`是一个额外的属性文件的目录位置(覆盖了默认值),只有在没有指定`loader.config.location`时才会使用。 +- `loader.path`可以包含目录(递归地扫描jar和zip文件)、归档路径、归档中的目录(例如,`dependencies.jar!/lib`)或通配符模式(用于默认的JVM行为)。存档路径可以是相对于`loader.home`或文件系统中任何带有`jar:file:`前缀的地方。 +- `loader.path`(如果为空) 默认为`BOOT-INF/lib`(意思是本地目录,如果从归档中运行,则为嵌套目录)。因此,当没有提供额外的配置时,`PropertiesLauncher`的行为与`JarLauncher`相同。 +- `loader.path`不能用来配置`loader.properties`的位置(当启动`PropertiesLauncher`时,用于搜索后者的类路径是JVM的类路径)。 +- 在使用前,从System和环境变量加上properties文件本身的所有值上进行占位符替换。 +- 对属性的搜索顺序(在不止一个地方查找是有意义的)是环境变量、系统属性、`loader.properties`和档案清单。 From 991008b075ea0cdf15a55e36291109b0131b4345 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E7=83=AD=E5=BF=83=E5=B8=82=E6=B0=91=E9=92=9F=E5=B0=8F?= =?UTF-8?q?=E5=BC=BA?= Date: Tue, 21 Apr 2020 10:15:26 +0800 Subject: [PATCH 861/865] Update and rename E.5. Executable jar restrictions.md to E.5. Executable Jar Restrictions.md --- X. Appendices/E.5. Executable Jar Restrictions.md | 6 ++++++ X. Appendices/E.5. Executable jar restrictions.md | 4 ---- 2 files changed, 6 insertions(+), 4 deletions(-) create mode 100644 X. Appendices/E.5. Executable Jar Restrictions.md delete mode 100644 X. Appendices/E.5. Executable jar restrictions.md diff --git a/X. Appendices/E.5. Executable Jar Restrictions.md b/X. Appendices/E.5. Executable Jar Restrictions.md new file mode 100644 index 00000000..b9902647 --- /dev/null +++ b/X. Appendices/E.5. Executable Jar Restrictions.md @@ -0,0 +1,6 @@ +### 附录 E.5. 可执行jar的限制 + +在使用Spring Boot Loader打包的应用程序时,您需要考虑以下限制: + +- Zip条目压缩:嵌套jar的`ZipEntry`必须通过使用`ZipEntry.STORED`方法保存。这是必要的,这样我们就可以直接搜索到嵌套jar中的单个内容。嵌套jar文件本身的内容仍然可以被压缩,外部jar中的任何其他条目也可以被压缩。 +- 系统类加载器:已启动的应用程序在加载类时应该使用`Thread.getContextClassLoader()`(大多数库和框架默认都是这样做的)。试图用`ClassLoader.getSystemClassLoader()`加载嵌套的jar类会失败,`java.util.Logging`总是使用系统类加载器。为此,你应该考虑使用不同的日志实现。 diff --git a/X. Appendices/E.5. Executable jar restrictions.md b/X. Appendices/E.5. Executable jar restrictions.md deleted file mode 100644 index 556a8b33..00000000 --- a/X. Appendices/E.5. Executable jar restrictions.md +++ /dev/null @@ -1,4 +0,0 @@ -### 附录 E.5. 可执行jar的限制 - -当使用Spring Boot Loader打包的应用时有一些你需要考虑的限制。 - From 5f47b32874a7cbb21b039b8a55f6458037dbcd58 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E7=83=AD=E5=BF=83=E5=B8=82=E6=B0=91=E9=92=9F=E5=B0=8F?= =?UTF-8?q?=E5=BC=BA?= Date: Tue, 21 Apr 2020 10:16:04 +0800 Subject: [PATCH 862/865] Delete E.5.1. Zip entry compression.md --- X. Appendices/E.5.1. Zip entry compression.md | 3 --- 1 file changed, 3 deletions(-) delete mode 100644 X. Appendices/E.5.1. Zip entry compression.md diff --git a/X. Appendices/E.5.1. Zip entry compression.md b/X. Appendices/E.5.1. Zip entry compression.md deleted file mode 100644 index b5236529..00000000 --- a/X. Appendices/E.5.1. Zip entry compression.md +++ /dev/null @@ -1,3 +0,0 @@ -### 附录 E.5.1 Zip实体压缩 - -对于一个嵌套jar的ZipEntry必须使用`ZipEntry.STORED`方法保存。这是需要的,这样我们可以直接查找嵌套jar中的个别内容。嵌套jar的内容本身可以仍旧被压缩,正如外部jar的其他任何实体。 From 581d4ff1f781fa78e0f226857a37543f502b717f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E7=83=AD=E5=BF=83=E5=B8=82=E6=B0=91=E9=92=9F=E5=B0=8F?= =?UTF-8?q?=E5=BC=BA?= Date: Tue, 21 Apr 2020 10:16:22 +0800 Subject: [PATCH 863/865] Delete E.5.2. System ClassLoader.md --- X. Appendices/E.5.2. System ClassLoader.md | 3 --- 1 file changed, 3 deletions(-) delete mode 100644 X. Appendices/E.5.2. System ClassLoader.md diff --git a/X. Appendices/E.5.2. System ClassLoader.md b/X. Appendices/E.5.2. System ClassLoader.md deleted file mode 100644 index e23fef6b..00000000 --- a/X. Appendices/E.5.2. System ClassLoader.md +++ /dev/null @@ -1,3 +0,0 @@ -### 附录 E.5.2. 系统ClassLoader - -启动的应用在加载类时应该使用`Thread.getContextClassLoader()`(多数库和框架都默认这样做)。尝试通过`ClassLoader.getSystemClassLoader()`加载嵌套的类将失败。请注意`java.util.Logging`总是使用系统类加载器,由于这个原因你需要考虑一个不同的日志实现。 From 414cd4bb6dabf71fdc948ca244eec260ce2efcdc Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E7=83=AD=E5=BF=83=E5=B8=82=E6=B0=91=E9=92=9F=E5=B0=8F?= =?UTF-8?q?=E5=BC=BA?= Date: Tue, 21 Apr 2020 10:18:33 +0800 Subject: [PATCH 864/865] Update and rename E.6. Alternative single jar solutions.md to E.6. Alternative Single Jar Solutions.md --- X. Appendices/E.6. Alternative Single Jar Solutions.md | 7 +++++++ X. Appendices/E.6. Alternative single jar solutions.md | 7 ------- 2 files changed, 7 insertions(+), 7 deletions(-) create mode 100644 X. Appendices/E.6. Alternative Single Jar Solutions.md delete mode 100644 X. Appendices/E.6. Alternative single jar solutions.md diff --git a/X. Appendices/E.6. Alternative Single Jar Solutions.md b/X. Appendices/E.6. Alternative Single Jar Solutions.md new file mode 100644 index 00000000..add39309 --- /dev/null +++ b/X. Appendices/E.6. Alternative Single Jar Solutions.md @@ -0,0 +1,7 @@ +### 附录 E.6. 可替代的单一jar解决方案 + +如果之前的限制造成你不能使用Spring Boot Loader,那可以考虑以下的替代方案: + +* [Maven Shade Plugin](https://maven.apache.org/plugins/maven-shade-plugin/) +* [JarClassLoader](http://www.jdotsoft.com/JarClassLoader.php) +* [OneJar](http://one-jar.sourceforge.net/) diff --git a/X. Appendices/E.6. Alternative single jar solutions.md b/X. Appendices/E.6. Alternative single jar solutions.md deleted file mode 100644 index e13a24f8..00000000 --- a/X. Appendices/E.6. Alternative single jar solutions.md +++ /dev/null @@ -1,7 +0,0 @@ -### 附录 E.6. 可替代的单一jar解决方案 - -如果以上限制造成你不能使用Spring Boot Loader,那可以考虑以下的替代方案: - -* [Maven Shade Plugin](http://maven.apache.org/plugins/maven-shade-plugin/) -* [JarClassLoader](http://www.jdotsoft.com/JarClassLoader.php) -* [OneJar](http://one-jar.sourceforge.net/) From b408d4ab14aa728f0715848ffa9fd0ca01f485e7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E7=83=AD=E5=BF=83=E5=B8=82=E6=B0=91=E9=92=9F=E5=B0=8F?= =?UTF-8?q?=E5=BC=BA?= Date: Tue, 21 Apr 2020 10:45:20 +0800 Subject: [PATCH 865/865] Update F. Dependency versions.md --- X. Appendices/F. Dependency versions.md | 686 +++++++++++++++++++++++- 1 file changed, 685 insertions(+), 1 deletion(-) diff --git a/X. Appendices/F. Dependency versions.md b/X. Appendices/F. Dependency versions.md index c5d44295..6c684b2c 100644 --- a/X. Appendices/F. Dependency versions.md +++ b/X. Appendices/F. Dependency versions.md @@ -1,3 +1,687 @@ ### 附录 F. 依赖版本 -下面的表格提供了详尽的依赖版本信息,这些版本由Spring Boot自身的CLI,Maven的依赖管理(dependency management)和Gradle插件提供。当你声明一个对以下artifacts的依赖而没有声明版本时,将使用下面表格中列出的版本。 +下表提供了Spring Boot在其CLI(命令行接口)、Maven依赖关系管理和Gradle插件中提供的所有依赖版本的详细信息。当你在没有声明版本的情况下声明对这些artifact中的一个依赖关系时,将使用表中列出的版本。 + +|Group ID|Artifact ID|版本| +|----|:-----|:-----| +|antlr|antlr|2.7.7| +|ch.qos.logback|logback-access|1.2.3| +|ch.qos.logback|logback-classic|1.2.3| +|ch.qos.logback|logback-core|1.2.3| +|com.atomikos|transactions-jdbc|4.0.6| +|com.atomikos|transactions-jms|4.0.6| +|com.atomikos|transactions-jta|4.0.6| +|com.couchbase.client|couchbase-spring-cache|2.1.0| +|com.couchbase.client|java-client|2.5.5| +|com.datastax.cassandra|cassandra-driver-core|3.4.0| +|com.datastax.cassandra|cassandra-driver-mapping|3.4.0| +|com.fasterxml|classmate|1.3.4| +|com.fasterxml.jackson.core|jackson-annotations|2.9.0| +|com.fasterxml.jackson.core|jackson-core|2.9.4| +|com.fasterxml.jackson.core|jackson-databind|2.9.4| +|com.fasterxml.jackson.dataformat|jackson-dataformat-avro|2.9.4| +|com.fasterxml.jackson.dataformat|jackson-dataformat-cbor|2.9.4| +|com.fasterxml.jackson.dataformat|jackson-dataformat-csv|2.9.4| +|com.fasterxml.jackson.dataformat|jackson-dataformat-ion|2.9.4| +|com.fasterxml.jackson.dataformat|jackson-dataformat-properties|2.9.4| +|com.fasterxml.jackson.dataformat|jackson-dataformat-protobuf|2.9.4| +|com.fasterxml.jackson.dataformat|jackson-dataformat-smile|2.9.4| +|com.fasterxml.jackson.dataformat|jackson-dataformat-xml|2.9.4| +|com.fasterxml.jackson.dataformat|jackson-dataformat-yaml|2.9.4| +|com.fasterxml.jackson.datatype|jackson-datatype-guava|2.9.4| +|com.fasterxml.jackson.datatype|jackson-datatype-hibernate3|2.9.4| +|com.fasterxml.jackson.datatype|jackson-datatype-hibernate4|2.9.4| +|com.fasterxml.jackson.datatype|jackson-datatype-hibernate5|2.9.4| +|com.fasterxml.jackson.datatype|jackson-datatype-hppc|2.9.4| +|com.fasterxml.jackson.datatype|jackson-datatype-jaxrs|2.9.4| +|com.fasterxml.jackson.datatype|jackson-datatype-jdk8|2.9.4| +|com.fasterxml.jackson.datatype|jackson-datatype-joda|2.9.4| +|com.fasterxml.jackson.datatype|jackson-datatype-json-org|2.9.4| +|com.fasterxml.jackson.datatype|jackson-datatype-jsr310|2.9.4| +|com.fasterxml.jackson.datatype|jackson-datatype-jsr353|2.9.4| +|com.fasterxml.jackson.datatype|jackson-datatype-pcollections|2.9.4| +|com.fasterxml.jackson.jaxrs|jackson-jaxrs-base|2.9.4| +|com.fasterxml.jackson.jaxrs|jackson-jaxrs-cbor-provider|2.9.4| +|com.fasterxml.jackson.jaxrs|jackson-jaxrs-json-provider|2.9.4| +|com.fasterxml.jackson.jaxrs|jackson-jaxrs-smile-provider|2.9.4| +|com.fasterxml.jackson.jaxrs|jackson-jaxrs-xml-provider|2.9.4| +|com.fasterxml.jackson.jaxrs|jackson-jaxrs-yaml-provider|2.9.4| +|com.fasterxml.jackson.jr|jackson-jr-all|2.9.4| +|com.fasterxml.jackson.jr|jackson-jr-objects|2.9.4| +|com.fasterxml.jackson.jr|jackson-jr-retrofit2|2.9.4| +|com.fasterxml.jackson.jr|jackson-jr-stree|2.9.4| +|com.fasterxml.jackson.module|jackson-module-afterburner|2.9.4| +|com.fasterxml.jackson.module|jackson-module-guice|2.9.4| +|com.fasterxml.jackson.module|jackson-module-jaxb-annotations|2.9.4| +|com.fasterxml.jackson.module|jackson-module-jsonSchema|2.9.4| +|com.fasterxml.jackson.module|jackson-module-kotlin|2.9.4| +|com.fasterxml.jackson.module|jackson-module-mrbean|2.9.4| +|com.fasterxml.jackson.module|jackson-module-osgi|2.9.4| +|com.fasterxml.jackson.module|jackson-module-parameter-names|2.9.4| +|com.fasterxml.jackson.module|jackson-module-paranamer|2.9.4| +|com.fasterxml.jackson.module|jackson-module-scala_2.10|2.9.4| +|com.fasterxml.jackson.module|jackson-module-scala_2.11|2.9.4| +|com.fasterxml.jackson.module|jackson-module-scala_2.12|2.9.4| +|com.github.ben-manes.caffeine|caffeine|2.6.2| +|com.github.mxab.thymeleaf.extras|thymeleaf-extras-data-attribute|2.0.1| +|com.google.appengine|appengine-api-1.0-sdk|1.9.62| +|com.google.code.gson|gson|2.8.2| +|com.googlecode.json-simple|json-simple|1.1.1| +|com.h2database|h2|1.4.196| +|com.hazelcast|hazelcast|3.9.3| +|com.hazelcast|hazelcast-client|3.9.3| +|com.hazelcast|hazelcast-hibernate52|1.2.3| +|com.hazelcast|hazelcast-spring|3.9.3| +|com.jayway.jsonpath|json-path|2.4.0| +|com.jayway.jsonpath|json-path-assert|2.4.0| +|com.microsoft.sqlserver|mssql-jdbc|6.2.2.jre8| +|com.querydsl|querydsl-apt|4.1.4| +|com.querydsl|querydsl-collections|4.1.4| +|com.querydsl|querydsl-core|4.1.4| +|com.querydsl|querydsl-jpa|4.1.4| +|com.querydsl|querydsl-mongodb|4.1.4| +|com.rabbitmq|amqp-client|5.1.2| +|com.samskivert|jmustache|1.14| +|com.sendgrid|sendgrid-java|4.1.2| +|com.sun.mail|javax.mail|1.6.1| +|com.timgroup|java-statsd-client|3.1.0| +|com.unboundid|unboundid-ldapsdk|4.0.4| +|com.zaxxer|HikariCP|2.7.8| +|commons-codec|commons-codec|1.11| +|commons-pool|commons-pool|1.6| +|de.flapdoodle.embed|de.flapdoodle.embed.mongo|2.0.3| +|dom4j|dom4j|1.6.1| +|io.dropwizard.metrics|metrics-annotation|3.2.6| +|io.dropwizard.metrics|metrics-core|3.2.6| +|io.dropwizard.metrics|metrics-ehcache|3.2.6| +|io.dropwizard.metrics|metrics-ganglia|3.2.6| +|io.dropwizard.metrics|metrics-graphite|3.2.6| +|io.dropwizard.metrics|metrics-healthchecks|3.2.6| +|io.dropwizard.metrics|metrics-httpasyncclient|3.2.6| +|io.dropwizard.metrics|metrics-jdbi|3.2.6| +|io.dropwizard.metrics|metrics-jersey|3.2.6| +|io.dropwizard.metrics|metrics-jersey2|3.2.6| +|io.dropwizard.metrics|metrics-jetty8|3.2.6| +|io.dropwizard.metrics|metrics-jetty9|3.2.6| +|io.dropwizard.metrics|metrics-jetty9-legacy|3.2.6| +|io.dropwizard.metrics|metrics-json|3.2.6| +|io.dropwizard.metrics|metrics-jvm|3.2.6| +|io.dropwizard.metrics|metrics-log4j|3.2.6| +|io.dropwizard.metrics|metrics-log4j2|3.2.6| +|io.dropwizard.metrics|metrics-logback|3.2.6| +|io.dropwizard.metrics|metrics-servlet|3.2.6| +|io.dropwizard.metrics|metrics-servlets|3.2.6| +|io.lettuce|lettuce-core|5.0.2.RELEASE| +|io.micrometer|micrometer-core|1.0.1| +|io.micrometer|micrometer-registry-atlas|1.0.1| +|io.micrometer|micrometer-registry-datadog|1.0.1| +|io.micrometer|micrometer-registry-ganglia|1.0.1| +|io.micrometer|micrometer-registry-graphite|1.0.1| +|io.micrometer|micrometer-registry-influx|1.0.1| +|io.micrometer|micrometer-registry-jmx|1.0.1| +|io.micrometer|micrometer-registry-new-relic|1.0.1| +|io.micrometer|micrometer-registry-prometheus|1.0.1| +|io.micrometer|micrometer-registry-signalfx|1.0.1| +|io.micrometer|micrometer-registry-statsd|1.0.1| +|io.micrometer|micrometer-registry-wavefront|1.0.1| +|io.netty|netty-all|4.1.22.Final| +|io.netty|netty-buffer|4.1.22.Final| +|io.netty|netty-codec|4.1.22.Final| +|io.netty|netty-codec-dns|4.1.22.Final| +|io.netty|netty-codec-haproxy|4.1.22.Final| +|io.netty|netty-codec-http|4.1.22.Final| +|io.netty|netty-codec-http2|4.1.22.Final| +|io.netty|netty-codec-memcache|4.1.22.Final| +|io.netty|netty-codec-mqtt|4.1.22.Final| +|io.netty|netty-codec-redis|4.1.22.Final| +|io.netty|netty-codec-smtp|4.1.22.Final| +|io.netty|netty-codec-socks|4.1.22.Final| +|io.netty|netty-codec-stomp|4.1.22.Final| +|io.netty|netty-codec-xml|4.1.22.Final| +|io.netty|netty-common|4.1.22.Final| +|io.netty|netty-dev-tools|4.1.22.Final| +|io.netty|netty-example|4.1.22.Final| +|io.netty|netty-handler|4.1.22.Final| +|io.netty|netty-handler-proxy|4.1.22.Final| +|io.netty|netty-resolver|4.1.22.Final| +|io.netty|netty-resolver-dns|4.1.22.Final| +|io.netty|netty-transport|4.1.22.Final| +|io.netty|netty-transport-native-epoll|4.1.22.Final| +|io.netty|netty-transport-native-kqueue|4.1.22.Final| +|io.netty|netty-transport-native-unix-common|4.1.22.Final| +|io.netty|netty-transport-rxtx|4.1.22.Final| +|io.netty|netty-transport-sctp|4.1.22.Final| +|io.netty|netty-transport-udt|4.1.22.Final| +|io.projectreactor|reactor-core|3.1.5.RELEASE| +|io.projectreactor|reactor-test|3.1.5.RELEASE| +|io.projectreactor.addons|reactor-adapter|3.1.6.RELEASE| +|io.projectreactor.addons|reactor-extra|3.1.6.RELEASE| +|io.projectreactor.addons|reactor-logback|3.1.6.RELEASE| +|io.projectreactor.ipc|reactor-netty|0.7.5.RELEASE| +|io.projectreactor.kafka|reactor-kafka|1.0.0.RELEASE| +|io.reactivex|rxjava|1.3.6| +|io.reactivex|rxjava-reactive-streams|1.2.1| +|io.reactivex.rxjava2|rxjava|2.1.10| +|io.rest-assured|json-path|3.0.7| +|io.rest-assured|json-schema-validator|3.0.7| +|io.rest-assured|rest-assured|3.0.7| +|io.rest-assured|scala-support|3.0.7| +|io.rest-assured|spring-mock-mvc|3.0.7| +|io.rest-assured|xml-path|3.0.7| +|io.searchbox|jest|5.3.3| +|io.undertow|undertow-core|1.4.22.Final| +|io.undertow|undertow-servlet|1.4.22.Final| +|io.undertow|undertow-websockets-jsr|1.4.22.Final| +|javax.annotation|javax.annotation-api|1.3.2| +|javax.cache|cache-api|1.1.0| +|javax.jms|javax.jms-api|2.0.1| +|javax.json|javax.json-api|1.1.2| +|javax.json.bind|javax.json.bind-api|1| +|javax.mail|javax.mail-api|1.6.1| +|javax.money|money-api|1.0.1| +|javax.servlet|javax.servlet-api|3.1.0| +|javax.servlet|jstl|1.2| +|javax.transaction|javax.transaction-api|1.2| +|javax.validation|validation-api|2.0.1.Final| +|javax.xml.bind|jaxb-api|2.3.0| +|jaxen|jaxen|1.1.6| +|joda-time|joda-time|2.9.9| +|junit|junit|4.12| +|mysql|mysql-connector-java|5.1.45| +|net.bytebuddy|byte-buddy|1.7.10| +|net.bytebuddy|byte-buddy-agent|1.7.10| +|net.java.dev.jna|jna|4.5.1| +|net.java.dev.jna|jna-platform|4.5.1| +|net.sf.ehcache|ehcache|2.10.4| +|net.sourceforge.htmlunit|htmlunit|2.29| +|net.sourceforge.jtds|jtds|1.3.1| +|net.sourceforge.nekohtml|nekohtml|1.9.22| +|nz.net.ultraq.thymeleaf|thymeleaf-layout-dialect|2.3.0| +|org.apache.activemq|activemq-amqp|5.15.3| +|org.apache.activemq|activemq-blueprint|5.15.3| +|org.apache.activemq|activemq-broker|5.15.3| +|org.apache.activemq|activemq-camel|5.15.3| +|org.apache.activemq|activemq-client|5.15.3| +|org.apache.activemq|activemq-console|5.15.3| +|org.apache.activemq|activemq-http|5.15.3| +|org.apache.activemq|activemq-jaas|5.15.3| +|org.apache.activemq|activemq-jdbc-store|5.15.3| +|org.apache.activemq|activemq-jms-pool|5.15.3| +|org.apache.activemq|activemq-kahadb-store|5.15.3| +|org.apache.activemq|activemq-karaf|5.15.3| +|org.apache.activemq|activemq-leveldb-store|5.15.3| +|org.apache.activemq|activemq-log4j-appender|5.15.3| +|org.apache.activemq|activemq-mqtt|5.15.3| +|org.apache.activemq|activemq-openwire-generator|5.15.3| +|org.apache.activemq|activemq-openwire-legacy|5.15.3| +|org.apache.activemq|activemq-osgi|5.15.3| +|org.apache.activemq|activemq-partition|5.15.3| +|org.apache.activemq|activemq-pool|5.15.3| +|org.apache.activemq|activemq-ra|5.15.3| +|org.apache.activemq|activemq-run|5.15.3| +|org.apache.activemq|activemq-runtime-config|5.15.3| +|org.apache.activemq|activemq-shiro|5.15.3| +|org.apache.activemq|activemq-spring|5.15.3| +|org.apache.activemq|activemq-stomp|5.15.3| +|org.apache.activemq|activemq-web|5.15.3| +|org.apache.activemq|artemis-amqp-protocol|2.4.0| +|org.apache.activemq|artemis-commons|2.4.0| +|org.apache.activemq|artemis-core-client|2.4.0| +|org.apache.activemq|artemis-jms-client|2.4.0| +|org.apache.activemq|artemis-jms-server|2.4.0| +|org.apache.activemq|artemis-journal|2.4.0| +|org.apache.activemq|artemis-native|2.4.0| +|org.apache.activemq|artemis-selector|2.4.0| +|org.apache.activemq|artemis-server|2.4.0| +|org.apache.activemq|artemis-service-extensions|2.4.0| +|org.apache.commons|commons-dbcp2|2.2.0| +|org.apache.commons|commons-lang3|3.7| +|org.apache.commons|commons-pool2|2.5.0| +|org.apache.derby|derby|10.14.1.0| +|org.apache.httpcomponents|fluent-hc|4.5.5| +|org.apache.httpcomponents|httpasyncclient|4.1.3| +|org.apache.httpcomponents|httpclient|4.5.5| +|org.apache.httpcomponents|httpclient-cache|4.5.5| +|org.apache.httpcomponents|httpclient-osgi|4.5.5| +|org.apache.httpcomponents|httpclient-win|4.5.5| +|org.apache.httpcomponents|httpcore|4.4.9| +|org.apache.httpcomponents|httpcore-nio|4.4.9| +|org.apache.httpcomponents|httpmime|4.5.5| +|org.apache.johnzon|johnzon-jsonb|1.1.6| +|org.apache.logging.log4j|log4j-1.2-api|2.10.0| +|org.apache.logging.log4j|log4j-api|2.10.0| +|org.apache.logging.log4j|log4j-cassandra|2.10.0| +|org.apache.logging.log4j|log4j-core|2.10.0| +|org.apache.logging.log4j|log4j-couchdb|2.10.0| +|org.apache.logging.log4j|log4j-flume-ng|2.10.0| +|org.apache.logging.log4j|log4j-iostreams|2.10.0| +|org.apache.logging.log4j|log4j-jcl|2.10.0| +|org.apache.logging.log4j|log4j-jmx-gui|2.10.0| +|org.apache.logging.log4j|log4j-jul|2.10.0| +|org.apache.logging.log4j|log4j-liquibase|2.10.0| +|org.apache.logging.log4j|log4j-mongodb|2.10.0| +|org.apache.logging.log4j|log4j-slf4j-impl|2.10.0| +|org.apache.logging.log4j|log4j-taglib|2.10.0| +|org.apache.logging.log4j|log4j-to-slf4j|2.10.0| +|org.apache.logging.log4j|log4j-web|2.10.0| +|org.apache.solr|solr-analysis-extras|6.6.2| +|org.apache.solr|solr-analytics|6.6.2| +|org.apache.solr|solr-cell|6.6.2| +|org.apache.solr|solr-clustering|6.6.2| +|org.apache.solr|solr-core|6.6.2| +|org.apache.solr|solr-dataimporthandler|6.6.2| +|org.apache.solr|solr-dataimporthandler-extras|6.6.2| +|org.apache.solr|solr-langid|6.6.2| +|org.apache.solr|solr-solrj|6.6.2| +|org.apache.solr|solr-test-framework|6.6.2| +|org.apache.solr|solr-uima|6.6.2| +|org.apache.solr|solr-velocity|6.6.2| +|org.apache.tomcat|tomcat-annotations-api|8.5.28| +|org.apache.tomcat|tomcat-catalina-jmx-remote|8.5.28| +|org.apache.tomcat|tomcat-jdbc|8.5.28| +|org.apache.tomcat|tomcat-jsp-api|8.5.28| +|org.apache.tomcat.embed|tomcat-embed-core|8.5.28| +|org.apache.tomcat.embed|tomcat-embed-el|8.5.28| +|org.apache.tomcat.embed|tomcat-embed-jasper|8.5.28| +|org.apache.tomcat.embed|tomcat-embed-websocket|8.5.28| +|org.aspectj|aspectjrt|1.8.13| +|org.aspectj|aspectjtools|1.8.13| +|org.aspectj|aspectjweaver|1.8.13| +|org.assertj|assertj-core|3.9.1| +|org.codehaus.btm|btm|2.1.4| +|org.codehaus.groovy|groovy|2.4.13| +|org.codehaus.groovy|groovy-all|2.4.13| +|org.codehaus.groovy|groovy-ant|2.4.13| +|org.codehaus.groovy|groovy-bsf|2.4.13| +|org.codehaus.groovy|groovy-console|2.4.13| +|org.codehaus.groovy|groovy-docgenerator|2.4.13| +|org.codehaus.groovy|groovy-groovydoc|2.4.13| +|org.codehaus.groovy|groovy-groovysh|2.4.13| +|org.codehaus.groovy|groovy-jmx|2.4.13| +|org.codehaus.groovy|groovy-json|2.4.13| +|org.codehaus.groovy|groovy-jsr223|2.4.13| +|org.codehaus.groovy|groovy-nio|2.4.13| +|org.codehaus.groovy|groovy-servlet|2.4.13| +|org.codehaus.groovy|groovy-sql|2.4.13| +|org.codehaus.groovy|groovy-swing|2.4.13| +|org.codehaus.groovy|groovy-templates|2.4.13| +|org.codehaus.groovy|groovy-test|2.4.13| +|org.codehaus.groovy|groovy-testng|2.4.13| +|org.codehaus.groovy|groovy-xml|2.4.13| +|org.codehaus.janino|janino|3.0.8| +|org.eclipse.jetty|apache-jsp|9.4.8.v20171121| +|org.eclipse.jetty|apache-jstl|9.4.8.v20171121| +|org.eclipse.jetty|jetty-alpn-client|9.4.8.v20171121| +|org.eclipse.jetty|jetty-alpn-conscrypt-client|9.4.8.v20171121| +|org.eclipse.jetty|jetty-alpn-conscrypt-server|9.4.8.v20171121| +|org.eclipse.jetty|jetty-alpn-java-client|9.4.8.v20171121| +|org.eclipse.jetty|jetty-alpn-java-server|9.4.8.v20171121| +|org.eclipse.jetty|jetty-alpn-openjdk8-client|9.4.8.v20171121| +|org.eclipse.jetty|jetty-alpn-openjdk8-server|9.4.8.v20171121| +|org.eclipse.jetty|jetty-alpn-server|9.4.8.v20171121| +|org.eclipse.jetty|jetty-annotations|9.4.8.v20171121| +|org.eclipse.jetty|jetty-ant|9.4.8.v20171121| +|org.eclipse.jetty|jetty-client|9.4.8.v20171121| +|org.eclipse.jetty|jetty-continuation|9.4.8.v20171121| +|org.eclipse.jetty|jetty-deploy|9.4.8.v20171121| +|org.eclipse.jetty|jetty-distribution|9.4.8.v20171121| +|org.eclipse.jetty|jetty-hazelcast|9.4.8.v20171121| +|org.eclipse.jetty|jetty-home|9.4.8.v20171121| +|org.eclipse.jetty|jetty-http|9.4.8.v20171121| +|org.eclipse.jetty|jetty-http-spi|9.4.8.v20171121| +|org.eclipse.jetty|jetty-infinispan|9.4.8.v20171121| +|org.eclipse.jetty|jetty-io|9.4.8.v20171121| +|org.eclipse.jetty|jetty-jaas|9.4.8.v20171121| +|org.eclipse.jetty|jetty-jaspi|9.4.8.v20171121| +|org.eclipse.jetty|jetty-jmx|9.4.8.v20171121| +|org.eclipse.jetty|jetty-jndi|9.4.8.v20171121| +|org.eclipse.jetty|jetty-nosql|9.4.8.v20171121| +|org.eclipse.jetty|jetty-plus|9.4.8.v20171121| +|org.eclipse.jetty|jetty-proxy|9.4.8.v20171121| +|org.eclipse.jetty|jetty-quickstart|9.4.8.v20171121| +|org.eclipse.jetty|jetty-rewrite|9.4.8.v20171121| +|org.eclipse.jetty|jetty-security|9.4.8.v20171121| +|org.eclipse.jetty|jetty-server|9.4.8.v20171121| +|org.eclipse.jetty|jetty-servlet|9.4.8.v20171121| +|org.eclipse.jetty|jetty-servlets|9.4.8.v20171121| +|org.eclipse.jetty|jetty-spring|9.4.8.v20171121| +|org.eclipse.jetty|jetty-unixsocket|9.4.8.v20171121| +|org.eclipse.jetty|jetty-util|9.4.8.v20171121| +|org.eclipse.jetty|jetty-util-ajax|9.4.8.v20171121| +|org.eclipse.jetty|jetty-webapp|9.4.8.v20171121| +|org.eclipse.jetty|jetty-xml|9.4.8.v20171121| +|org.eclipse.jetty.cdi|cdi-core|9.4.8.v20171121| +|org.eclipse.jetty.cdi|cdi-full-servlet|9.4.8.v20171121| +|org.eclipse.jetty.cdi|cdi-servlet|9.4.8.v20171121| +|org.eclipse.jetty.fcgi|fcgi-client|9.4.8.v20171121| +|org.eclipse.jetty.fcgi|fcgi-server|9.4.8.v20171121| +|org.eclipse.jetty.gcloud|jetty-gcloud-session-manager|9.4.8.v20171121| +|org.eclipse.jetty.http2|http2-client|9.4.8.v20171121| +|org.eclipse.jetty.http2|http2-common|9.4.8.v20171121| +|org.eclipse.jetty.http2|http2-hpack|9.4.8.v20171121| +|org.eclipse.jetty.http2|http2-http-client-transport|9.4.8.v20171121| +|org.eclipse.jetty.http2|http2-server|9.4.8.v20171121| +|org.eclipse.jetty.memcached|jetty-memcached-sessions|9.4.8.v20171121| +|org.eclipse.jetty.orbit|javax.servlet.jsp|2.2.0.v201112011158| +|org.eclipse.jetty.osgi|jetty-httpservice|9.4.8.v20171121| +|org.eclipse.jetty.osgi|jetty-osgi-boot|9.4.8.v20171121| +|org.eclipse.jetty.osgi|jetty-osgi-boot-jsp|9.4.8.v20171121| +|org.eclipse.jetty.osgi|jetty-osgi-boot-warurl|9.4.8.v20171121| +|org.eclipse.jetty.websocket|javax-websocket-client-impl|9.4.8.v20171121| +|org.eclipse.jetty.websocket|javax-websocket-server-impl|9.4.8.v20171121| +|org.eclipse.jetty.websocket|websocket-api|9.4.8.v20171121| +|org.eclipse.jetty.websocket|websocket-client|9.4.8.v20171121| +|org.eclipse.jetty.websocket|websocket-common|9.4.8.v20171121| +|org.eclipse.jetty.websocket|websocket-server|9.4.8.v20171121| +|org.eclipse.jetty.websocket|websocket-servlet|9.4.8.v20171121| +|org.ehcache|ehcache|3.5.0| +|org.ehcache|ehcache-clustered|3.5.0| +|org.ehcache|ehcache-transactions|3.5.0| +|org.elasticsearch|elasticsearch|5.6.8| +|org.elasticsearch.client|transport|5.6.8| +|org.elasticsearch.plugin|transport-netty4-client|5.6.8| +|org.firebirdsql.jdbc|jaybird-jdk17|3.0.3| +|org.firebirdsql.jdbc|jaybird-jdk18|3.0.3| +|org.flywaydb|flyway-core|5.0.7| +|org.freemarker|freemarker|2.3.27-incubating| +|org.glassfish|javax.el|3.0.0| +|org.glassfish.jersey.containers|jersey-container-servlet|2.26| +|org.glassfish.jersey.containers|jersey-container-servlet-core|2.26| +|org.glassfish.jersey.core|jersey-client|2.26| +|org.glassfish.jersey.core|jersey-common|2.26| +|org.glassfish.jersey.core|jersey-server|2.26| +|org.glassfish.jersey.ext|jersey-bean-validation|2.26| +|org.glassfish.jersey.ext|jersey-entity-filtering|2.26| +|org.glassfish.jersey.ext|jersey-spring4|2.26| +|org.glassfish.jersey.media|jersey-media-jaxb|2.26| +|org.glassfish.jersey.media|jersey-media-json-jackson|2.26| +|org.glassfish.jersey.media|jersey-media-multipart|2.26| +|org.hamcrest|hamcrest-core|1.3| +|org.hamcrest|hamcrest-library|1.3| +|org.hibernate|hibernate-c3p0|5.2.14.Final| +|org.hibernate|hibernate-core|5.2.14.Final| +|org.hibernate|hibernate-ehcache|5.2.14.Final| +|org.hibernate|hibernate-entitymanager|5.2.14.Final| +|org.hibernate|hibernate-envers|5.2.14.Final| +|org.hibernate|hibernate-hikaricp|5.2.14.Final| +|org.hibernate|hibernate-infinispan|5.2.14.Final| +|org.hibernate|hibernate-java8|5.2.14.Final| +|org.hibernate|hibernate-jcache|5.2.14.Final| +|org.hibernate|hibernate-jpamodelgen|5.2.14.Final| +|org.hibernate|hibernate-proxool|5.2.14.Final| +|org.hibernate|hibernate-spatial|5.2.14.Final| +|org.hibernate|hibernate-testing|5.2.14.Final| +|org.hibernate.validator|hibernate-validator|6.0.7.Final| +|org.hibernate.validator|hibernate-validator-annotation-processor|6.0.7.Final| +|org.hsqldb|hsqldb|2.4.0| +|org.infinispan|infinispan-jcache|9.1.6.Final| +|org.infinispan|infinispan-spring4-common|9.1.6.Final| +|org.infinispan|infinispan-spring4-embedded|9.1.6.Final| +|org.influxdb|influxdb-java|2.9| +|org.jboss|jboss-transaction-spi|7.6.0.Final| +|org.jboss.logging|jboss-logging|3.3.2.Final| +|org.jboss.narayana.jta|jdbc|5.8.0.Final| +|org.jboss.narayana.jta|jms|5.8.0.Final| +|org.jboss.narayana.jta|jta|5.8.0.Final| +|org.jboss.narayana.jts|narayana-jts-integration|5.8.0.Final| +|org.jdom|jdom2|2.0.6| +|org.jetbrains.kotlin|kotlin-reflect|1.2.21| +|org.jetbrains.kotlin|kotlin-runtime|1.2.21| +|org.jetbrains.kotlin|kotlin-stdlib|1.2.21| +|org.jetbrains.kotlin|kotlin-stdlib-jdk7|1.2.21| +|org.jetbrains.kotlin|kotlin-stdlib-jdk8|1.2.21| +|org.jetbrains.kotlin|kotlin-stdlib-jre7|1.2.21| +|org.jetbrains.kotlin|kotlin-stdlib-jre8|1.2.21| +|org.jolokia|jolokia-core|1.5.0| +|org.jooq|jooq|3.10.5| +|org.jooq|jooq-codegen|3.10.5| +|org.jooq|jooq-meta|3.10.5| +|org.junit.jupiter|junit-jupiter-api|5.1.0| +|org.junit.jupiter|junit-jupiter-engine|5.1.0| +|org.liquibase|liquibase-core|3.5.5| +|org.mariadb.jdbc|mariadb-java-client|2.2.2| +|org.mockito|mockito-core|2.15.0| +|org.mockito|mockito-inline|2.15.0| +|org.mongodb|bson|3.6.3| +|org.mongodb|mongodb-driver|3.6.3| +|org.mongodb|mongodb-driver-async|3.6.3| +|org.mongodb|mongodb-driver-core|3.6.3| +|org.mongodb|mongodb-driver-reactivestreams|1.7.1| +|org.mongodb|mongo-java-driver|3.6.3| +|org.mortbay.jasper|apache-el|8.5.24.2| +|org.neo4j|neo4j-ogm-api|3.1.0| +|org.neo4j|neo4j-ogm-bolt-driver|3.1.0| +|org.neo4j|neo4j-ogm-core|3.1.0| +|org.neo4j|neo4j-ogm-http-driver|3.1.0| +|org.postgresql|postgresql|42.2.1| +|org.projectlombok|lombok|1.16.20| +|org.quartz-scheduler|quartz|2.3.0| +|org.reactivestreams|reactive-streams|1.0.2| +|org.seleniumhq.selenium|htmlunit-driver|2.29.2| +|org.seleniumhq.selenium|selenium-api|3.9.1| +|org.seleniumhq.selenium|selenium-chrome-driver|3.9.1| +|org.seleniumhq.selenium|selenium-edge-driver|3.9.1| +|org.seleniumhq.selenium|selenium-firefox-driver|3.9.1| +|org.seleniumhq.selenium|selenium-ie-driver|3.9.1| +|org.seleniumhq.selenium|selenium-java|3.9.1| +|org.seleniumhq.selenium|selenium-opera-driver|3.9.1| +|org.seleniumhq.selenium|selenium-remote-driver|3.9.1| +|org.seleniumhq.selenium|selenium-safari-driver|3.9.1| +|org.seleniumhq.selenium|selenium-support|3.9.1| +|org.skyscreamer|jsonassert|1.5.0| +|org.slf4j|jcl-over-slf4j|1.7.25| +|org.slf4j|jul-to-slf4j|1.7.25| +|org.slf4j|log4j-over-slf4j|1.7.25| +|org.slf4j|slf4j-api|1.7.25| +|org.slf4j|slf4j-ext|1.7.25| +|org.slf4j|slf4j-jcl|1.7.25| +|org.slf4j|slf4j-jdk14|1.7.25| +|org.slf4j|slf4j-log4j12|1.7.25| +|org.slf4j|slf4j-nop|1.7.25| +|org.slf4j|slf4j-simple|1.7.25| +|org.springframework|spring-aop|5.0.4.RELEASE| +|org.springframework|spring-aspects|5.0.4.RELEASE| +|org.springframework|spring-beans|5.0.4.RELEASE| +|org.springframework|spring-context|5.0.4.RELEASE| +|org.springframework|spring-context-indexer|5.0.4.RELEASE| +|org.springframework|spring-context-support|5.0.4.RELEASE| +|org.springframework|spring-core|5.0.4.RELEASE| +|org.springframework|spring-expression|5.0.4.RELEASE| +|org.springframework|spring-instrument|5.0.4.RELEASE| +|org.springframework|spring-jcl|5.0.4.RELEASE| +|org.springframework|spring-jdbc|5.0.4.RELEASE| +|org.springframework|spring-jms|5.0.4.RELEASE| +|org.springframework|spring-messaging|5.0.4.RELEASE| +|org.springframework|spring-orm|5.0.4.RELEASE| +|org.springframework|spring-oxm|5.0.4.RELEASE| +|org.springframework|spring-test|5.0.4.RELEASE| +|org.springframework|spring-tx|5.0.4.RELEASE| +|org.springframework|spring-web|5.0.4.RELEASE| +|org.springframework|spring-webflux|5.0.4.RELEASE| +|org.springframework|spring-webmvc|5.0.4.RELEASE| +|org.springframework|spring-websocket|5.0.4.RELEASE| +|org.springframework.amqp|spring-amqp|2.0.2.RELEASE| +|org.springframework.amqp|spring-rabbit|2.0.2.RELEASE| +|org.springframework.batch|spring-batch-core|4.0.0.RELEASE| +|org.springframework.batch|spring-batch-infrastructure|4.0.0.RELEASE| +|org.springframework.batch|spring-batch-integration|4.0.0.RELEASE| +|org.springframework.batch|spring-batch-test|4.0.0.RELEASE| +|org.springframework.boot|spring-boot|2.0.0.RELEASE| +|org.springframework.boot|spring-boot-actuator|2.0.0.RELEASE| +|org.springframework.boot|spring-boot-actuator-autoconfigure|2.0.0.RELEASE| +|org.springframework.boot|spring-boot-autoconfigure|2.0.0.RELEASE| +|org.springframework.boot|spring-boot-autoconfigure-processor|2.0.0.RELEASE| +|org.springframework.boot|spring-boot-configuration-metadata|2.0.0.RELEASE| +|org.springframework.boot|spring-boot-configuration-processor|2.0.0.RELEASE| +|org.springframework.boot|spring-boot-devtools|2.0.0.RELEASE| +|org.springframework.boot|spring-boot-loader|2.0.0.RELEASE| +|org.springframework.boot|spring-boot-loader-tools|2.0.0.RELEASE| +|org.springframework.boot|spring-boot-properties-migrator|2.0.0.RELEASE| +|org.springframework.boot|spring-boot-starter|2.0.0.RELEASE| +|org.springframework.boot|spring-boot-starter-activemq|2.0.0.RELEASE| +|org.springframework.boot|spring-boot-starter-actuator|2.0.0.RELEASE| +|org.springframework.boot|spring-boot-starter-amqp|2.0.0.RELEASE| +|org.springframework.boot|spring-boot-starter-aop|2.0.0.RELEASE| +|org.springframework.boot|spring-boot-starter-artemis|2.0.0.RELEASE| +|org.springframework.boot|spring-boot-starter-batch|2.0.0.RELEASE| +|org.springframework.boot|spring-boot-starter-cache|2.0.0.RELEASE| +|org.springframework.boot|spring-boot-starter-cloud-connectors|2.0.0.RELEASE| +|org.springframework.boot|spring-boot-starter-data-cassandra|2.0.0.RELEASE| +|org.springframework.boot|spring-boot-starter-data-cassandra-reactive|2.0.0.RELEASE| +|org.springframework.boot|spring-boot-starter-data-couchbase|2.0.0.RELEASE| +|org.springframework.boot|spring-boot-starter-data-couchbase-reactive|2.0.0.RELEASE| +|org.springframework.boot|spring-boot-starter-data-elasticsearch|2.0.0.RELEASE| +|org.springframework.boot|spring-boot-starter-data-jpa|2.0.0.RELEASE| +|org.springframework.boot|spring-boot-starter-data-ldap|2.0.0.RELEASE| +|org.springframework.boot|spring-boot-starter-data-mongodb|2.0.0.RELEASE| +|org.springframework.boot|spring-boot-starter-data-mongodb-reactive|2.0.0.RELEASE| +|org.springframework.boot|spring-boot-starter-data-neo4j|2.0.0.RELEASE| +|org.springframework.boot|spring-boot-starter-data-redis|2.0.0.RELEASE| +|org.springframework.boot|spring-boot-starter-data-redis-reactive|2.0.0.RELEASE| +|org.springframework.boot|spring-boot-starter-data-rest|2.0.0.RELEASE| +|org.springframework.boot|spring-boot-starter-data-solr|2.0.0.RELEASE| +|org.springframework.boot|spring-boot-starter-freemarker|2.0.0.RELEASE| +|org.springframework.boot|spring-boot-starter-groovy-templates|2.0.0.RELEASE| +|org.springframework.boot|spring-boot-starter-hateoas|2.0.0.RELEASE| +|org.springframework.boot|spring-boot-starter-integration|2.0.0.RELEASE| +|org.springframework.boot|spring-boot-starter-jdbc|2.0.0.RELEASE| +|org.springframework.boot|spring-boot-starter-jersey|2.0.0.RELEASE| +|org.springframework.boot|spring-boot-starter-jetty|2.0.0.RELEASE| +|org.springframework.boot|spring-boot-starter-jooq|2.0.0.RELEASE| +|org.springframework.boot|spring-boot-starter-json|2.0.0.RELEASE| +|org.springframework.boot|spring-boot-starter-jta-atomikos|2.0.0.RELEASE| +|org.springframework.boot|spring-boot-starter-jta-bitronix|2.0.0.RELEASE| +|org.springframework.boot|spring-boot-starter-jta-narayana|2.0.0.RELEASE| +|org.springframework.boot|spring-boot-starter-log4j2|2.0.0.RELEASE| +|org.springframework.boot|spring-boot-starter-logging|2.0.0.RELEASE| +|org.springframework.boot|spring-boot-starter-mail|2.0.0.RELEASE| +|org.springframework.boot|spring-boot-starter-mustache|2.0.0.RELEASE| +|org.springframework.boot|spring-boot-starter-quartz|2.0.0.RELEASE| +|org.springframework.boot|spring-boot-starter-reactor-netty|2.0.0.RELEASE| +|org.springframework.boot|spring-boot-starter-security|2.0.0.RELEASE| +|org.springframework.boot|spring-boot-starter-test|2.0.0.RELEASE| +|org.springframework.boot|spring-boot-starter-thymeleaf|2.0.0.RELEASE| +|org.springframework.boot|spring-boot-starter-tomcat|2.0.0.RELEASE| +|org.springframework.boot|spring-boot-starter-undertow|2.0.0.RELEASE| +|org.springframework.boot|spring-boot-starter-validation|2.0.0.RELEASE| +|org.springframework.boot|spring-boot-starter-web|2.0.0.RELEASE| +|org.springframework.boot|spring-boot-starter-webflux|2.0.0.RELEASE| +|org.springframework.boot|spring-boot-starter-web-services|2.0.0.RELEASE| +|org.springframework.boot|spring-boot-starter-websocket|2.0.0.RELEASE| +|org.springframework.boot|spring-boot-test|2.0.0.RELEASE| +|org.springframework.boot|spring-boot-test-autoconfigure|2.0.0.RELEASE| +|org.springframework.cloud|spring-cloud-cloudfoundry-connector|2.0.1.RELEASE| +|org.springframework.cloud|spring-cloud-connectors-core|2.0.1.RELEASE| +|org.springframework.cloud|spring-cloud-heroku-connector|2.0.1.RELEASE| +|org.springframework.cloud|spring-cloud-localconfig-connector|2.0.1.RELEASE| +|org.springframework.cloud|spring-cloud-spring-service-connector|2.0.1.RELEASE| +|org.springframework.data|spring-data-cassandra|2.0.5.RELEASE| +|org.springframework.data|spring-data-commons|2.0.5.RELEASE| +|org.springframework.data|spring-data-couchbase|3.0.5.RELEASE| +|org.springframework.data|spring-data-elasticsearch|3.0.5.RELEASE| +|org.springframework.data|spring-data-envers|2.0.5.RELEASE| +|org.springframework.data|spring-data-gemfire|2.0.5.RELEASE| +|org.springframework.data|spring-data-geode|2.0.5.RELEASE| +|org.springframework.data|spring-data-jpa|2.0.5.RELEASE| +|org.springframework.data|spring-data-keyvalue|2.0.5.RELEASE| +|org.springframework.data|spring-data-ldap|2.0.5.RELEASE| +|org.springframework.data|spring-data-mongodb|2.0.5.RELEASE| +|org.springframework.data|spring-data-mongodb-cross-store|2.0.5.RELEASE| +|org.springframework.data|spring-data-neo4j|5.0.5.RELEASE| +|org.springframework.data|spring-data-redis|2.0.5.RELEASE| +|org.springframework.data|spring-data-rest-core|3.0.5.RELEASE| +|org.springframework.data|spring-data-rest-hal-browser|3.0.5.RELEASE| +|org.springframework.data|spring-data-rest-webmvc|3.0.5.RELEASE| +|org.springframework.data|spring-data-solr|3.0.5.RELEASE| +|org.springframework.hateoas|spring-hateoas|0.24.0.RELEASE| +|org.springframework.integration|spring-integration-amqp|5.0.3.RELEASE| +|org.springframework.integration|spring-integration-core|5.0.3.RELEASE| +|org.springframework.integration|spring-integration-event|5.0.3.RELEASE| +|org.springframework.integration|spring-integration-feed|5.0.3.RELEASE| +|org.springframework.integration|spring-integration-file|5.0.3.RELEASE| +|org.springframework.integration|spring-integration-ftp|5.0.3.RELEASE| +|org.springframework.integration|spring-integration-gemfire|5.0.3.RELEASE| +|org.springframework.integration|spring-integration-groovy|5.0.3.RELEASE| +|org.springframework.integration|spring-integration-http|5.0.3.RELEASE| +|org.springframework.integration|spring-integration-ip|5.0.3.RELEASE| +|org.springframework.integration|spring-integration-jdbc|5.0.3.RELEASE| +|org.springframework.integration|spring-integration-jms|5.0.3.RELEASE| +|org.springframework.integration|spring-integration-jmx|5.0.3.RELEASE| +|org.springframework.integration|spring-integration-jpa|5.0.3.RELEASE| +|org.springframework.integration|spring-integration-mail|5.0.3.RELEASE| +|org.springframework.integration|spring-integration-mongodb|5.0.3.RELEASE| +|org.springframework.integration|spring-integration-mqtt|5.0.3.RELEASE| +|org.springframework.integration|spring-integration-redis|5.0.3.RELEASE| +|org.springframework.integration|spring-integration-rmi|5.0.3.RELEASE| +|org.springframework.integration|spring-integration-scripting|5.0.3.RELEASE| +|org.springframework.integration|spring-integration-security|5.0.3.RELEASE| +|org.springframework.integration|spring-integration-sftp|5.0.3.RELEASE| +|org.springframework.integration|spring-integration-stomp|5.0.3.RELEASE| +|org.springframework.integration|spring-integration-stream|5.0.3.RELEASE| +|org.springframework.integration|spring-integration-syslog|5.0.3.RELEASE| +|org.springframework.integration|spring-integration-test|5.0.3.RELEASE| +|org.springframework.integration|spring-integration-test-support|5.0.3.RELEASE| +|org.springframework.integration|spring-integration-twitter|5.0.3.RELEASE| +|org.springframework.integration|spring-integration-webflux|5.0.3.RELEASE| +|org.springframework.integration|spring-integration-websocket|5.0.3.RELEASE| +|org.springframework.integration|spring-integration-ws|5.0.3.RELEASE| +|org.springframework.integration|spring-integration-xml|5.0.3.RELEASE| +|org.springframework.integration|spring-integration-xmpp|5.0.3.RELEASE| +|org.springframework.integration|spring-integration-zookeeper|5.0.3.RELEASE| +|org.springframework.kafka|spring-kafka|2.1.4.RELEASE| +|org.springframework.kafka|spring-kafka-test|2.1.4.RELEASE| +|org.springframework.ldap|spring-ldap-core|2.3.2.RELEASE| +|org.springframework.ldap|spring-ldap-core-tiger|2.3.2.RELEASE| +|org.springframework.ldap|spring-ldap-ldif-batch|2.3.2.RELEASE| +|org.springframework.ldap|spring-ldap-ldif-core|2.3.2.RELEASE| +|org.springframework.ldap|spring-ldap-odm|2.3.2.RELEASE| +|org.springframework.ldap|spring-ldap-test|2.3.2.RELEASE| +|org.springframework.plugin|spring-plugin-core|1.2.0.RELEASE| +|org.springframework.plugin|spring-plugin-metadata|1.2.0.RELEASE| +|org.springframework.restdocs|spring-restdocs-asciidoctor|2.0.0.RELEASE| +|org.springframework.restdocs|spring-restdocs-core|2.0.0.RELEASE| +|org.springframework.restdocs|spring-restdocs-mockmvc|2.0.0.RELEASE| +|org.springframework.restdocs|spring-restdocs-restassured|2.0.0.RELEASE| +|org.springframework.restdocs|spring-restdocs-webtestclient|2.0.0.RELEASE| +|org.springframework.retry|spring-retry|1.2.2.RELEASE| +|org.springframework.security|spring-security-acl|5.0.3.RELEASE| +|org.springframework.security|spring-security-aspects|5.0.3.RELEASE| +|org.springframework.security|spring-security-cas|5.0.3.RELEASE| +|org.springframework.security|spring-security-config|5.0.3.RELEASE| +|org.springframework.security|spring-security-core|5.0.3.RELEASE| +|org.springframework.security|spring-security-crypto|5.0.3.RELEASE| +|org.springframework.security|spring-security-data|5.0.3.RELEASE| +|org.springframework.security|spring-security-ldap|5.0.3.RELEASE| +|org.springframework.security|spring-security-messaging|5.0.3.RELEASE| +|org.springframework.security|spring-security-oauth2-client|5.0.3.RELEASE| +|org.springframework.security|spring-security-oauth2-core|5.0.3.RELEASE| +|org.springframework.security|spring-security-oauth2-jose|5.0.3.RELEASE| +|org.springframework.security|spring-security-openid|5.0.3.RELEASE| +|org.springframework.security|spring-security-remoting|5.0.3.RELEASE| +|org.springframework.security|spring-security-taglibs|5.0.3.RELEASE| +|org.springframework.security|spring-security-test|5.0.3.RELEASE| +|org.springframework.security|spring-security-web|5.0.3.RELEASE| +|org.springframework.session|spring-session-core|2.0.2.RELEASE| +|org.springframework.session|spring-session-data-mongodb|2.0.2.RELEASE| +|org.springframework.session|spring-session-data-redis|2.0.2.RELEASE| +|org.springframework.session|spring-session-hazelcast|2.0.2.RELEASE| +|org.springframework.session|spring-session-jdbc|2.0.2.RELEASE| +|org.springframework.ws|spring-ws-core|3.0.0.RELEASE| +|org.springframework.ws|spring-ws-security|3.0.0.RELEASE| +|org.springframework.ws|spring-ws-support|3.0.0.RELEASE| +|org.springframework.ws|spring-ws-test|3.0.0.RELEASE| +|org.synchronoss.cloud|nio-multipart-parser|1.1.0| +|org.thymeleaf|thymeleaf|3.0.9.RELEASE| +|org.thymeleaf|thymeleaf-spring5|3.0.9.RELEASE| +|org.thymeleaf.extras|thymeleaf-extras-java8time|3.0.1.RELEASE| +|org.thymeleaf.extras|thymeleaf-extras-springsecurity4|3.0.2.RELEASE| +|org.webjars|hal-browser|3325375| +|org.webjars|webjars-locator-core|0.35| +|org.xerial|sqlite-jdbc|3.21.0.1| +|org.xmlunit|xmlunit-core|2.5.1| +|org.xmlunit|xmlunit-legacy|2.5.1| +|org.xmlunit|xmlunit-matchers|2.5.1| +|org.yaml|snakeyaml|1.19| +|redis.clients|jedis|2.9.0| +|wsdl4j|wsdl4j|1.6.3| +|xml-apis|xml-apis|1.4.01|