From 67479b63809aebd3f457f2952493549c7c71ba1a Mon Sep 17 00:00:00 2001 From: Andy Wilkinson Date: Tue, 2 Feb 2021 10:22:36 +0000 Subject: [PATCH 01/13] Add junit-platform-launcher dependency by convention Closes gh-25074 --- .../org/springframework/boot/build/JavaConventions.java | 7 ++++++- .../spring-boot-actuator-autoconfigure/build.gradle | 1 - spring-boot-project/spring-boot-actuator/build.gradle | 1 - spring-boot-project/spring-boot-autoconfigure/build.gradle | 1 - spring-boot-project/spring-boot-cli/build.gradle | 2 -- spring-boot-project/spring-boot-devtools/build.gradle | 1 - spring-boot-project/spring-boot-docs/build.gradle | 1 - .../spring-boot-properties-migrator/build.gradle | 2 -- .../spring-boot-test-autoconfigure/build.gradle | 2 -- spring-boot-project/spring-boot-test/build.gradle | 1 - .../spring-boot-tools/spring-boot-antlib/build.gradle | 2 -- .../spring-boot-autoconfigure-processor/build.gradle | 2 -- .../spring-boot-buildpack-platform/build.gradle | 4 +--- .../spring-boot-configuration-metadata/build.gradle | 2 -- .../spring-boot-configuration-processor/build.gradle | 2 -- .../spring-boot-gradle-plugin/build.gradle | 2 -- .../spring-boot-jarmode-layertools/build.gradle | 2 -- .../spring-boot-loader-tools/build.gradle | 2 -- .../spring-boot-tools/spring-boot-loader/build.gradle | 3 +-- .../spring-boot-maven-plugin/build.gradle | 2 -- .../spring-boot-test-support/build.gradle | 1 - spring-boot-project/spring-boot/build.gradle | 1 - .../spring-boot-deployment-tests/build.gradle | 2 -- .../spring-boot-configuration-processor-tests/build.gradle | 2 -- .../spring-boot-launch-script-tests/build.gradle | 2 -- .../spring-boot-loader-tests/build.gradle | 2 -- .../spring-boot-server-tests/build.gradle | 1 - .../spring-boot-smoke-test-activemq/build.gradle | 2 -- .../build.gradle | 1 - .../spring-boot-smoke-test-actuator-log4j2/build.gradle | 2 -- .../spring-boot-smoke-test-actuator-noweb/build.gradle | 2 -- .../spring-boot-smoke-test-actuator-ui/build.gradle | 2 -- .../spring-boot-smoke-test-actuator/build.gradle | 2 -- .../spring-boot-smoke-test-amqp/build.gradle | 2 -- .../spring-boot-smoke-test-animated-banner/build.gradle | 2 -- .../spring-boot-smoke-test-ant/build.gradle | 2 -- .../spring-boot-smoke-test-aop/build.gradle | 2 -- .../spring-boot-smoke-test-atmosphere/build.gradle | 2 -- .../spring-boot-smoke-test-batch/build.gradle | 4 +--- .../spring-boot-smoke-test-cache/build.gradle | 2 -- .../spring-boot-smoke-test-data-couchbase/build.gradle | 2 -- .../spring-boot-smoke-test-data-elasticsearch/build.gradle | 2 -- .../spring-boot-smoke-test-data-jdbc/build.gradle | 2 -- .../spring-boot-smoke-test-data-jpa/build.gradle | 2 -- .../spring-boot-smoke-test-data-ldap/build.gradle | 2 -- .../spring-boot-smoke-test-data-mongodb/build.gradle | 2 -- .../spring-boot-smoke-test-data-neo4j/build.gradle | 2 -- .../spring-boot-smoke-test-data-r2dbc-flyway/build.gradle | 2 -- .../build.gradle | 2 -- .../spring-boot-smoke-test-data-r2dbc/build.gradle | 2 -- .../spring-boot-smoke-test-data-redis/build.gradle | 2 -- .../spring-boot-smoke-test-data-rest/build.gradle | 1 - .../spring-boot-smoke-test-data-solr/build.gradle | 2 -- .../spring-boot-smoke-test-devtools/build.gradle | 2 -- .../spring-boot-smoke-test-flyway/build.gradle | 2 -- .../spring-boot-smoke-test-hateoas/build.gradle | 2 -- .../spring-boot-smoke-test-hazelcast4/build.gradle | 2 -- .../spring-boot-smoke-test-hibernate52/build.gradle | 2 -- .../spring-boot-smoke-test-integration/build.gradle | 2 -- .../spring-boot-smoke-test-jersey/build.gradle | 2 -- .../spring-boot-smoke-test-jetty-jsp/build.gradle | 2 -- .../spring-boot-smoke-test-jetty-ssl/build.gradle | 2 -- .../spring-boot-smoke-test-jetty/build.gradle | 2 -- .../spring-boot-smoke-test-jpa/build.gradle | 2 -- .../spring-boot-smoke-test-jta-atomikos/build.gradle | 2 -- .../spring-boot-smoke-test-jta-bitronix/build.gradle | 2 -- .../spring-boot-smoke-test-junit-jupiter/build.gradle | 2 -- .../spring-boot-smoke-test-junit-vintage/build.gradle | 2 -- .../spring-boot-smoke-test-kafka/build.gradle | 2 -- .../spring-boot-smoke-test-liquibase/build.gradle | 2 -- .../spring-boot-smoke-test-logback/build.gradle | 2 -- .../spring-boot-smoke-test-oauth2-client/build.gradle | 2 -- .../build.gradle | 2 -- .../spring-boot-smoke-test-parent-context/build.gradle | 2 -- .../spring-boot-smoke-test-profile/build.gradle | 2 -- .../build.gradle | 2 -- .../spring-boot-smoke-test-quartz/build.gradle | 2 -- .../build.gradle | 2 -- .../build.gradle | 2 -- .../spring-boot-smoke-test-rsocket/build.gradle | 2 -- .../build.gradle | 2 -- .../spring-boot-smoke-test-secure-jersey/build.gradle | 2 -- .../spring-boot-smoke-test-secure-webflux/build.gradle | 2 -- .../spring-boot-smoke-test-secure/build.gradle | 2 -- .../spring-boot-smoke-test-servlet/build.gradle | 1 - .../spring-boot-smoke-test-session-webflux/build.gradle | 2 -- .../spring-boot-smoke-test-session/build.gradle | 2 -- .../spring-boot-smoke-test-simple/build.gradle | 2 -- .../spring-boot-smoke-test-test-nomockito/build.gradle | 2 -- .../spring-boot-smoke-test-test/build.gradle | 2 -- .../spring-boot-smoke-test-testng/build.gradle | 2 -- .../spring-boot-smoke-test-tomcat-jsp/build.gradle | 2 -- .../build.gradle | 2 -- .../spring-boot-smoke-test-tomcat-ssl/build.gradle | 2 -- .../spring-boot-smoke-test-tomcat/build.gradle | 2 -- .../spring-boot-smoke-test-traditional/build.gradle | 2 -- .../spring-boot-smoke-test-undertow-ssl/build.gradle | 2 -- .../spring-boot-smoke-test-undertow/build.gradle | 2 -- .../spring-boot-smoke-test-war/build.gradle | 2 -- .../spring-boot-smoke-test-web-freemarker/build.gradle | 2 -- .../build.gradle | 2 -- .../spring-boot-smoke-test-web-jsp/build.gradle | 2 -- .../build.gradle | 2 -- .../spring-boot-smoke-test-web-mustache/build.gradle | 2 -- .../spring-boot-smoke-test-web-secure-custom/build.gradle | 2 -- .../spring-boot-smoke-test-web-secure-jdbc/build.gradle | 2 -- .../spring-boot-smoke-test-web-secure/build.gradle | 2 -- .../spring-boot-smoke-test-web-static/build.gradle | 2 -- .../spring-boot-smoke-test-web-ui/build.gradle | 2 -- .../spring-boot-smoke-test-webflux-coroutines/build.gradle | 2 -- .../spring-boot-smoke-test-webflux/build.gradle | 2 -- .../spring-boot-smoke-test-webservices/build.gradle | 2 -- .../spring-boot-smoke-test-websocket-jetty/build.gradle | 2 -- .../spring-boot-smoke-test-websocket-tomcat/build.gradle | 2 -- .../spring-boot-smoke-test-websocket-undertow/build.gradle | 2 -- .../spring-boot-smoke-test-xml/build.gradle | 2 -- 116 files changed, 9 insertions(+), 221 deletions(-) diff --git a/buildSrc/src/main/java/org/springframework/boot/build/JavaConventions.java b/buildSrc/src/main/java/org/springframework/boot/build/JavaConventions.java index 26fa4204e0c9..315542c6bf21 100644 --- a/buildSrc/src/main/java/org/springframework/boot/build/JavaConventions.java +++ b/buildSrc/src/main/java/org/springframework/boot/build/JavaConventions.java @@ -1,5 +1,5 @@ /* - * Copyright 2012-2020 the original author or authors. + * Copyright 2012-2021 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -59,6 +59,9 @@ * Checkstyle}, {@link TestFailuresPlugin Test Failures}, and {@link TestRetryPlugin Test * Retry} plugins are applied *
  • {@link Test} tasks are configured to use JUnit Platform and use a max heap of 1024M + *
  • A {@code testRuntimeOnly} dependency upon + * {@code org.junit.platform:junit-platform-launcher} is added to projects with the + * {@link JavaPlugin} applied *
  • {@link JavaCompile}, {@link Javadoc}, and {@link FormatTask} tasks are configured * to use UTF-8 encoding *
  • {@link JavaCompile} tasks are configured to use {@code -parameters} @@ -139,6 +142,8 @@ private void configureTestConventions(Project project) { test.useJUnitPlatform(); test.setMaxHeapSize("1024M"); }); + project.getPlugins().withType(JavaPlugin.class, (javaPlugin) -> project.getDependencies() + .add(JavaPlugin.TEST_RUNTIME_ONLY_CONFIGURATION_NAME, "org.junit.platform:junit-platform-launcher")); project.getPlugins().apply(TestRetryPlugin.class); project.getTasks().withType(Test.class, (test) -> project.getPlugins().withType(TestRetryPlugin.class, (testRetryPlugin) -> { diff --git a/spring-boot-project/spring-boot-actuator-autoconfigure/build.gradle b/spring-boot-project/spring-boot-actuator-autoconfigure/build.gradle index 62f2b090a638..3c46c896c09c 100644 --- a/spring-boot-project/spring-boot-actuator-autoconfigure/build.gradle +++ b/spring-boot-project/spring-boot-actuator-autoconfigure/build.gradle @@ -141,7 +141,6 @@ dependencies { testImplementation("org.springframework.security:spring-security-test") testImplementation("org.yaml:snakeyaml") - testRuntimeOnly("org.junit.platform:junit-platform-launcher") testRuntimeOnly("org.springframework.security:spring-security-oauth2-jose") testRuntimeOnly("org.springframework.security:spring-security-oauth2-resource-server") testRuntimeOnly("org.springframework.security:spring-security-saml2-service-provider") diff --git a/spring-boot-project/spring-boot-actuator/build.gradle b/spring-boot-project/spring-boot-actuator/build.gradle index cf11b3353862..00d4645ad555 100644 --- a/spring-boot-project/spring-boot-actuator/build.gradle +++ b/spring-boot-project/spring-boot-actuator/build.gradle @@ -87,6 +87,5 @@ dependencies { testRuntimeOnly("javax.xml.bind:jaxb-api") testRuntimeOnly("org.apache.tomcat.embed:tomcat-embed-el") testRuntimeOnly("org.glassfish.jersey.ext:jersey-spring5") - testRuntimeOnly("org.junit.platform:junit-platform-launcher") testRuntimeOnly("org.hsqldb:hsqldb") } diff --git a/spring-boot-project/spring-boot-autoconfigure/build.gradle b/spring-boot-project/spring-boot-autoconfigure/build.gradle index e51dec52d5d1..dfa61f39773e 100644 --- a/spring-boot-project/spring-boot-autoconfigure/build.gradle +++ b/spring-boot-project/spring-boot-autoconfigure/build.gradle @@ -186,5 +186,4 @@ dependencies { testImplementation("org.yaml:snakeyaml") testRuntimeOnly("org.jetbrains.kotlin:kotlin-reflect") - testRuntimeOnly("org.junit.platform:junit-platform-launcher") } diff --git a/spring-boot-project/spring-boot-cli/build.gradle b/spring-boot-project/spring-boot-cli/build.gradle index 57407dfe1859..d0aa87b86ff3 100644 --- a/spring-boot-project/spring-boot-cli/build.gradle +++ b/spring-boot-project/spring-boot-cli/build.gradle @@ -65,8 +65,6 @@ dependencies { testImplementation("org.mockito:mockito-core") testImplementation("org.springframework:spring-test") - testRuntimeOnly("org.junit.platform:junit-platform-launcher") - testRepository(project(path: ":spring-boot-project:spring-boot-starters:spring-boot-starter-actuator", configuration: "mavenRepository")) testRepository(project(path: ":spring-boot-project:spring-boot-starters:spring-boot-starter-amqp", configuration: "mavenRepository")) testRepository(project(path: ":spring-boot-project:spring-boot-starters:spring-boot-starter-aop", configuration: "mavenRepository")) diff --git a/spring-boot-project/spring-boot-devtools/build.gradle b/spring-boot-project/spring-boot-devtools/build.gradle index 7ddd849d5b18..b90a317e4742 100644 --- a/spring-boot-project/spring-boot-devtools/build.gradle +++ b/spring-boot-project/spring-boot-devtools/build.gradle @@ -72,7 +72,6 @@ dependencies { testImplementation("org.thymeleaf:thymeleaf-spring5") testImplementation("nz.net.ultraq.thymeleaf:thymeleaf-layout-dialect") - testRuntimeOnly("org.junit.platform:junit-platform-launcher") testRuntimeOnly("org.yaml:snakeyaml") } diff --git a/spring-boot-project/spring-boot-docs/build.gradle b/spring-boot-project/spring-boot-docs/build.gradle index e18142cf122e..74db9eb7f547 100644 --- a/spring-boot-project/spring-boot-docs/build.gradle +++ b/spring-boot-project/spring-boot-docs/build.gradle @@ -101,7 +101,6 @@ dependencies { testRuntimeOnly(project(":spring-boot-project:spring-boot-starters:spring-boot-starter-web")) testRuntimeOnly("com.h2database:h2") - testRuntimeOnly("org.junit.platform:junit-platform-launcher") testRuntimeOnly("org.springframework:spring-jdbc") testSlices(project(path: ":spring-boot-project:spring-boot-test-autoconfigure", configuration: "testSliceMetadata")) diff --git a/spring-boot-project/spring-boot-properties-migrator/build.gradle b/spring-boot-project/spring-boot-properties-migrator/build.gradle index a1362beadc79..cd9da1f879ac 100644 --- a/spring-boot-project/spring-boot-properties-migrator/build.gradle +++ b/spring-boot-project/spring-boot-properties-migrator/build.gradle @@ -14,6 +14,4 @@ dependencies { testImplementation("org.junit.jupiter:junit-jupiter") testImplementation("org.assertj:assertj-core") testImplementation("org.springframework:spring-test") - - testRuntimeOnly("org.junit.platform:junit-platform-launcher") } \ No newline at end of file diff --git a/spring-boot-project/spring-boot-test-autoconfigure/build.gradle b/spring-boot-project/spring-boot-test-autoconfigure/build.gradle index 3a0055d44810..a05afc1ba9ba 100644 --- a/spring-boot-project/spring-boot-test-autoconfigure/build.gradle +++ b/spring-boot-project/spring-boot-test-autoconfigure/build.gradle @@ -79,8 +79,6 @@ dependencies { testImplementation("org.testcontainers:neo4j") testImplementation("org.testcontainers:testcontainers") testImplementation("org.thymeleaf:thymeleaf") - - testRuntimeOnly("org.junit.platform:junit-platform-launcher") } configurations { diff --git a/spring-boot-project/spring-boot-test/build.gradle b/spring-boot-project/spring-boot-test/build.gradle index 778abc5a5299..4f44c73f1178 100644 --- a/spring-boot-project/spring-boot-test/build.gradle +++ b/spring-boot-project/spring-boot-test/build.gradle @@ -48,7 +48,6 @@ dependencies { testImplementation("org.springframework:spring-webmvc") testImplementation("org.testng:testng") - testRuntimeOnly("org.junit.platform:junit-platform-launcher") testRuntimeOnly("org.junit.vintage:junit-vintage-engine") } diff --git a/spring-boot-project/spring-boot-tools/spring-boot-antlib/build.gradle b/spring-boot-project/spring-boot-tools/spring-boot-antlib/build.gradle index 3135d39d6bdc..5d0e114fc81b 100644 --- a/spring-boot-project/spring-boot-tools/spring-boot-antlib/build.gradle +++ b/spring-boot-project/spring-boot-tools/spring-boot-antlib/build.gradle @@ -24,8 +24,6 @@ dependencies { implementation(project(":spring-boot-project:spring-boot-tools:spring-boot-loader-tools")) implementation("org.springframework:spring-core") - - testRuntimeOnly("org.junit.platform:junit-platform-launcher") } task copyIntegrationTestSources(type: Copy) { diff --git a/spring-boot-project/spring-boot-tools/spring-boot-autoconfigure-processor/build.gradle b/spring-boot-project/spring-boot-tools/spring-boot-autoconfigure-processor/build.gradle index c7f73c8f5210..800916d04d55 100644 --- a/spring-boot-project/spring-boot-tools/spring-boot-autoconfigure-processor/build.gradle +++ b/spring-boot-project/spring-boot-tools/spring-boot-autoconfigure-processor/build.gradle @@ -12,6 +12,4 @@ dependencies { testImplementation("org.assertj:assertj-core") testImplementation("org.springframework:spring-core") testImplementation("org.junit.jupiter:junit-jupiter") - - testRuntimeOnly("org.junit.platform:junit-platform-launcher") } diff --git a/spring-boot-project/spring-boot-tools/spring-boot-buildpack-platform/build.gradle b/spring-boot-project/spring-boot-tools/spring-boot-buildpack-platform/build.gradle index 2d6b063b7c8f..56a9bc77170e 100644 --- a/spring-boot-project/spring-boot-tools/spring-boot-buildpack-platform/build.gradle +++ b/spring-boot-project/spring-boot-tools/spring-boot-buildpack-platform/build.gradle @@ -13,7 +13,7 @@ dependencies { api("org.apache.commons:commons-compress:1.19") api("org.apache.httpcomponents:httpclient") api("org.springframework:spring-core") - + testImplementation(project(":spring-boot-project:spring-boot-tools:spring-boot-test-support")) testImplementation("com.jayway.jsonpath:json-path") testImplementation("org.assertj:assertj-core") @@ -23,6 +23,4 @@ dependencies { testImplementation("org.mockito:mockito-core") testImplementation("org.mockito:mockito-junit-jupiter") testImplementation("org.skyscreamer:jsonassert") - - testRuntimeOnly("org.junit.platform:junit-platform-launcher") } diff --git a/spring-boot-project/spring-boot-tools/spring-boot-configuration-metadata/build.gradle b/spring-boot-project/spring-boot-tools/spring-boot-configuration-metadata/build.gradle index 7e0a5160b6ef..1ceb415f3b0f 100644 --- a/spring-boot-project/spring-boot-tools/spring-boot-configuration-metadata/build.gradle +++ b/spring-boot-project/spring-boot-tools/spring-boot-configuration-metadata/build.gradle @@ -14,6 +14,4 @@ dependencies { testImplementation("org.junit.jupiter:junit-jupiter") testImplementation("org.assertj:assertj-core") testImplementation("org.springframework:spring-core") - - testRuntimeOnly("org.junit.platform:junit-platform-launcher") } diff --git a/spring-boot-project/spring-boot-tools/spring-boot-configuration-processor/build.gradle b/spring-boot-project/spring-boot-tools/spring-boot-configuration-processor/build.gradle index 15c710657a8c..92bec3c1d687 100644 --- a/spring-boot-project/spring-boot-tools/spring-boot-configuration-processor/build.gradle +++ b/spring-boot-project/spring-boot-tools/spring-boot-configuration-processor/build.gradle @@ -24,6 +24,4 @@ dependencies { testImplementation("org.mockito:mockito-core") testImplementation("org.projectlombok:lombok") testImplementation("org.springframework:spring-core") - - testRuntimeOnly("org.junit.platform:junit-platform-launcher") } diff --git a/spring-boot-project/spring-boot-tools/spring-boot-gradle-plugin/build.gradle b/spring-boot-project/spring-boot-tools/spring-boot-gradle-plugin/build.gradle index b16e91c3bf1d..603ff3916cc3 100644 --- a/spring-boot-project/spring-boot-tools/spring-boot-gradle-plugin/build.gradle +++ b/spring-boot-project/spring-boot-tools/spring-boot-gradle-plugin/build.gradle @@ -42,8 +42,6 @@ dependencies { testImplementation("org.junit.jupiter:junit-jupiter") testImplementation("org.mockito:mockito-core") testImplementation("org.testcontainers:testcontainers") - - testRuntimeOnly("org.junit.platform:junit-platform-launcher") } gradlePlugin { diff --git a/spring-boot-project/spring-boot-tools/spring-boot-jarmode-layertools/build.gradle b/spring-boot-project/spring-boot-tools/spring-boot-jarmode-layertools/build.gradle index 322812dd4767..b1863cbd7ee9 100644 --- a/spring-boot-project/spring-boot-tools/spring-boot-jarmode-layertools/build.gradle +++ b/spring-boot-project/spring-boot-tools/spring-boot-jarmode-layertools/build.gradle @@ -13,6 +13,4 @@ dependencies { testImplementation("org.assertj:assertj-core") testImplementation("org.junit.jupiter:junit-jupiter") testImplementation("org.mockito:mockito-core") - - testRuntimeOnly("org.junit.platform:junit-platform-launcher") } diff --git a/spring-boot-project/spring-boot-tools/spring-boot-loader-tools/build.gradle b/spring-boot-project/spring-boot-tools/spring-boot-loader-tools/build.gradle index 1b6fbdc8dce9..b48676b56cdb 100644 --- a/spring-boot-project/spring-boot-tools/spring-boot-loader-tools/build.gradle +++ b/spring-boot-project/spring-boot-tools/spring-boot-loader-tools/build.gradle @@ -31,8 +31,6 @@ dependencies { testImplementation("org.junit.jupiter:junit-jupiter") testImplementation("org.mockito:mockito-core") testImplementation("org.zeroturnaround:zt-zip:1.13") - - testRuntimeOnly("org.junit.platform:junit-platform-launcher") } sourceSets { diff --git a/spring-boot-project/spring-boot-tools/spring-boot-loader/build.gradle b/spring-boot-project/spring-boot-tools/spring-boot-loader/build.gradle index 62d85cc26d4e..fa85d4849ca1 100644 --- a/spring-boot-project/spring-boot-tools/spring-boot-loader/build.gradle +++ b/spring-boot-project/spring-boot-tools/spring-boot-loader/build.gradle @@ -18,7 +18,6 @@ dependencies { testRuntimeOnly("ch.qos.logback:logback-classic") testRuntimeOnly("org.bouncycastle:bcprov-jdk16:1.46") - testRuntimeOnly("org.junit.platform:junit-platform-launcher") testRuntimeOnly("org.slf4j:jcl-over-slf4j") testRuntimeOnly("org.springframework:spring-webmvc") -} +} \ No newline at end of file diff --git a/spring-boot-project/spring-boot-tools/spring-boot-maven-plugin/build.gradle b/spring-boot-project/spring-boot-tools/spring-boot-maven-plugin/build.gradle index b5f497273155..769a6cc499ed 100644 --- a/spring-boot-project/spring-boot-tools/spring-boot-maven-plugin/build.gradle +++ b/spring-boot-project/spring-boot-tools/spring-boot-maven-plugin/build.gradle @@ -40,8 +40,6 @@ dependencies { testImplementation("org.junit.jupiter:junit-jupiter") testImplementation("org.mockito:mockito-core") testImplementation("org.springframework:spring-core") - - testRuntimeOnly("org.junit.platform:junit-platform-launcher") } task syncSpringBootDependenciesBom(type: Sync) { diff --git a/spring-boot-project/spring-boot-tools/spring-boot-test-support/build.gradle b/spring-boot-project/spring-boot-tools/spring-boot-test-support/build.gradle index 9a1093a81ffc..1d7fe55ea944 100644 --- a/spring-boot-project/spring-boot-tools/spring-boot-test-support/build.gradle +++ b/spring-boot-project/spring-boot-tools/spring-boot-test-support/build.gradle @@ -35,5 +35,4 @@ dependencies { testImplementation("org.springframework:spring-context") testRuntimeOnly("org.hibernate.validator:hibernate-validator") - testRuntimeOnly("org.junit.platform:junit-platform-launcher") } diff --git a/spring-boot-project/spring-boot/build.gradle b/spring-boot-project/spring-boot/build.gradle index 7b4f63169e55..888b2d92f3d2 100644 --- a/spring-boot-project/spring-boot/build.gradle +++ b/spring-boot-project/spring-boot/build.gradle @@ -102,7 +102,6 @@ dependencies { testImplementation("org.springframework.data:spring-data-r2dbc") testImplementation("org.xerial:sqlite-jdbc") - testRuntimeOnly("org.junit.platform:junit-platform-launcher") testRuntimeOnly("org.testcontainers:jdbc") { exclude group: "javax.annotation", module: "javax.annotation-api" exclude group: "javax.xml.bind", module: "jaxb-api" diff --git a/spring-boot-tests/spring-boot-deployment-tests/build.gradle b/spring-boot-tests/spring-boot-deployment-tests/build.gradle index 390b2fdecfd0..738f63fcd1e5 100644 --- a/spring-boot-tests/spring-boot-deployment-tests/build.gradle +++ b/spring-boot-tests/spring-boot-deployment-tests/build.gradle @@ -27,8 +27,6 @@ dependencies { intTestImplementation("org.springframework:spring-web") providedRuntime(project(":spring-boot-project:spring-boot-starters:spring-boot-starter-tomcat")) - - testRuntimeOnly("org.junit.platform:junit-platform-launcher") } intTest { diff --git a/spring-boot-tests/spring-boot-integration-tests/spring-boot-configuration-processor-tests/build.gradle b/spring-boot-tests/spring-boot-integration-tests/spring-boot-configuration-processor-tests/build.gradle index e65a068f98de..d5345ed8988f 100644 --- a/spring-boot-tests/spring-boot-integration-tests/spring-boot-configuration-processor-tests/build.gradle +++ b/spring-boot-tests/spring-boot-integration-tests/spring-boot-configuration-processor-tests/build.gradle @@ -14,6 +14,4 @@ dependencies { testImplementation(project(":spring-boot-project:spring-boot-starters:spring-boot-starter-test")) testImplementation(project(":spring-boot-project:spring-boot-tools:spring-boot-configuration-metadata")) - - testRuntimeOnly("org.junit.platform:junit-platform-launcher") } \ No newline at end of file diff --git a/spring-boot-tests/spring-boot-integration-tests/spring-boot-launch-script-tests/build.gradle b/spring-boot-tests/spring-boot-integration-tests/spring-boot-launch-script-tests/build.gradle index 124920dc16e4..3e26f0e96db7 100644 --- a/spring-boot-tests/spring-boot-integration-tests/spring-boot-launch-script-tests/build.gradle +++ b/spring-boot-tests/spring-boot-integration-tests/spring-boot-launch-script-tests/build.gradle @@ -19,8 +19,6 @@ dependencies { intTestImplementation(project(":spring-boot-project:spring-boot-tools:spring-boot-test-support")) intTestImplementation(project(":spring-boot-project:spring-boot-starters:spring-boot-starter-test")) intTestImplementation("org.testcontainers:testcontainers") - - testRuntimeOnly("org.junit.platform:junit-platform-launcher") } task syncMavenRepository(type: Sync) { diff --git a/spring-boot-tests/spring-boot-integration-tests/spring-boot-loader-tests/build.gradle b/spring-boot-tests/spring-boot-integration-tests/spring-boot-loader-tests/build.gradle index 7dca5512502e..7a39e57c4673 100644 --- a/spring-boot-tests/spring-boot-integration-tests/spring-boot-loader-tests/build.gradle +++ b/spring-boot-tests/spring-boot-integration-tests/spring-boot-loader-tests/build.gradle @@ -20,8 +20,6 @@ dependencies { intTestImplementation(project(":spring-boot-project:spring-boot-starters:spring-boot-starter-test")) intTestImplementation("org.testcontainers:junit-jupiter") intTestImplementation("org.testcontainers:testcontainers") - - testRuntimeOnly("org.junit.platform:junit-platform-launcher") } task syncMavenRepository(type: Sync) { diff --git a/spring-boot-tests/spring-boot-integration-tests/spring-boot-server-tests/build.gradle b/spring-boot-tests/spring-boot-integration-tests/spring-boot-server-tests/build.gradle index 437a09e1d624..51210a793853 100644 --- a/spring-boot-tests/spring-boot-integration-tests/spring-boot-server-tests/build.gradle +++ b/spring-boot-tests/spring-boot-integration-tests/spring-boot-server-tests/build.gradle @@ -34,7 +34,6 @@ dependencies { testRepository(project(path: ":spring-boot-project:spring-boot-starters:spring-boot-starter-undertow", configuration: "mavenRepository")) testRuntimeOnly(project(":spring-boot-project:spring-boot-starters:spring-boot-starter-logging")) - testRuntimeOnly("org.junit.platform:junit-platform-launcher") } task prepareMavenBinaries(type: org.springframework.boot.build.mavenplugin.PrepareMavenBinaries) { diff --git a/spring-boot-tests/spring-boot-smoke-tests/spring-boot-smoke-test-activemq/build.gradle b/spring-boot-tests/spring-boot-smoke-tests/spring-boot-smoke-test-activemq/build.gradle index 1c6317df0fd2..aeb28b9cf374 100644 --- a/spring-boot-tests/spring-boot-smoke-tests/spring-boot-smoke-test-activemq/build.gradle +++ b/spring-boot-tests/spring-boot-smoke-tests/spring-boot-smoke-test-activemq/build.gradle @@ -9,6 +9,4 @@ dependencies { implementation(project(":spring-boot-project:spring-boot-starters:spring-boot-starter-activemq")) testImplementation(project(":spring-boot-project:spring-boot-starters:spring-boot-starter-test")) - - testRuntimeOnly("org.junit.platform:junit-platform-launcher") } \ No newline at end of file diff --git a/spring-boot-tests/spring-boot-smoke-tests/spring-boot-smoke-test-actuator-custom-security/build.gradle b/spring-boot-tests/spring-boot-smoke-tests/spring-boot-smoke-test-actuator-custom-security/build.gradle index f3eca092fab2..1d627427fcd6 100644 --- a/spring-boot-tests/spring-boot-smoke-tests/spring-boot-smoke-test-actuator-custom-security/build.gradle +++ b/spring-boot-tests/spring-boot-smoke-tests/spring-boot-smoke-test-actuator-custom-security/build.gradle @@ -16,5 +16,4 @@ dependencies { testImplementation(project(":spring-boot-project:spring-boot-starters:spring-boot-starter-test")) testRuntimeOnly("org.apache.httpcomponents:httpclient") - testRuntimeOnly("org.junit.platform:junit-platform-launcher") } \ No newline at end of file diff --git a/spring-boot-tests/spring-boot-smoke-tests/spring-boot-smoke-test-actuator-log4j2/build.gradle b/spring-boot-tests/spring-boot-smoke-tests/spring-boot-smoke-test-actuator-log4j2/build.gradle index 229268cc07ed..7b9701752062 100644 --- a/spring-boot-tests/spring-boot-smoke-tests/spring-boot-smoke-test-actuator-log4j2/build.gradle +++ b/spring-boot-tests/spring-boot-smoke-tests/spring-boot-smoke-test-actuator-log4j2/build.gradle @@ -17,6 +17,4 @@ dependencies { implementation(project(":spring-boot-project:spring-boot-starters:spring-boot-starter-web")) testImplementation(project(":spring-boot-project:spring-boot-starters:spring-boot-starter-test")) - - testRuntimeOnly("org.junit.platform:junit-platform-launcher") } \ No newline at end of file diff --git a/spring-boot-tests/spring-boot-smoke-tests/spring-boot-smoke-test-actuator-noweb/build.gradle b/spring-boot-tests/spring-boot-smoke-tests/spring-boot-smoke-test-actuator-noweb/build.gradle index 1f5f780b9eeb..4f215d7a02db 100644 --- a/spring-boot-tests/spring-boot-smoke-tests/spring-boot-smoke-test-actuator-noweb/build.gradle +++ b/spring-boot-tests/spring-boot-smoke-tests/spring-boot-smoke-test-actuator-noweb/build.gradle @@ -11,6 +11,4 @@ dependencies { implementation(project(":spring-boot-project:spring-boot-starters:spring-boot-starter-actuator")) testImplementation(project(":spring-boot-project:spring-boot-starters:spring-boot-starter-test")) - - testRuntimeOnly("org.junit.platform:junit-platform-launcher") } \ No newline at end of file diff --git a/spring-boot-tests/spring-boot-smoke-tests/spring-boot-smoke-test-actuator-ui/build.gradle b/spring-boot-tests/spring-boot-smoke-tests/spring-boot-smoke-test-actuator-ui/build.gradle index a8ef96871308..5f1fa1b6221d 100644 --- a/spring-boot-tests/spring-boot-smoke-tests/spring-boot-smoke-test-actuator-ui/build.gradle +++ b/spring-boot-tests/spring-boot-smoke-tests/spring-boot-smoke-test-actuator-ui/build.gradle @@ -12,6 +12,4 @@ dependencies { implementation(project(":spring-boot-project:spring-boot-starters:spring-boot-starter-web")) testImplementation(project(":spring-boot-project:spring-boot-starters:spring-boot-starter-test")) - - testRuntimeOnly("org.junit.platform:junit-platform-launcher") } \ No newline at end of file diff --git a/spring-boot-tests/spring-boot-smoke-tests/spring-boot-smoke-test-actuator/build.gradle b/spring-boot-tests/spring-boot-smoke-tests/spring-boot-smoke-test-actuator/build.gradle index 2b8e634f4574..2e151b5fd01a 100644 --- a/spring-boot-tests/spring-boot-smoke-tests/spring-boot-smoke-test-actuator/build.gradle +++ b/spring-boot-tests/spring-boot-smoke-tests/spring-boot-smoke-test-actuator/build.gradle @@ -15,7 +15,5 @@ dependencies { runtimeOnly("com.h2database:h2") testImplementation(project(":spring-boot-project:spring-boot-starters:spring-boot-starter-test")) - testRuntimeOnly("org.apache.httpcomponents:httpclient") - testRuntimeOnly("org.junit.platform:junit-platform-launcher") } \ No newline at end of file diff --git a/spring-boot-tests/spring-boot-smoke-tests/spring-boot-smoke-test-amqp/build.gradle b/spring-boot-tests/spring-boot-smoke-tests/spring-boot-smoke-test-amqp/build.gradle index d4d3bf953f22..691266ec9d27 100644 --- a/spring-boot-tests/spring-boot-smoke-tests/spring-boot-smoke-test-amqp/build.gradle +++ b/spring-boot-tests/spring-boot-smoke-tests/spring-boot-smoke-test-amqp/build.gradle @@ -7,6 +7,4 @@ description = "Spring Boot AMQP smoke test" dependencies { implementation(project(":spring-boot-project:spring-boot-starters:spring-boot-starter-amqp")) - - testRuntimeOnly("org.junit.platform:junit-platform-launcher") } \ No newline at end of file diff --git a/spring-boot-tests/spring-boot-smoke-tests/spring-boot-smoke-test-animated-banner/build.gradle b/spring-boot-tests/spring-boot-smoke-tests/spring-boot-smoke-test-animated-banner/build.gradle index cde9b42f1394..2b029afd2221 100644 --- a/spring-boot-tests/spring-boot-smoke-tests/spring-boot-smoke-test-animated-banner/build.gradle +++ b/spring-boot-tests/spring-boot-smoke-tests/spring-boot-smoke-test-animated-banner/build.gradle @@ -7,6 +7,4 @@ description = "Spring Boot animated banner smoke test" dependencies { implementation(project(":spring-boot-project:spring-boot-starters:spring-boot-starter")) - - testRuntimeOnly("org.junit.platform:junit-platform-launcher") } \ No newline at end of file diff --git a/spring-boot-tests/spring-boot-smoke-tests/spring-boot-smoke-test-ant/build.gradle b/spring-boot-tests/spring-boot-smoke-tests/spring-boot-smoke-test-ant/build.gradle index 0603061ba460..3efb8cdc8acf 100644 --- a/spring-boot-tests/spring-boot-smoke-tests/spring-boot-smoke-test-ant/build.gradle +++ b/spring-boot-tests/spring-boot-smoke-tests/spring-boot-smoke-test-ant/build.gradle @@ -37,8 +37,6 @@ dependencies { testImplementation("org.assertj:assertj-core") testImplementation("org.junit.jupiter:junit-jupiter") testImplementation("org.springframework:spring-core") - - testRuntimeOnly("org.junit.platform:junit-platform-launcher") } task syncTestRepository(type: Sync) { diff --git a/spring-boot-tests/spring-boot-smoke-tests/spring-boot-smoke-test-aop/build.gradle b/spring-boot-tests/spring-boot-smoke-tests/spring-boot-smoke-test-aop/build.gradle index de33ac75017a..92fc71db7a02 100644 --- a/spring-boot-tests/spring-boot-smoke-tests/spring-boot-smoke-test-aop/build.gradle +++ b/spring-boot-tests/spring-boot-smoke-tests/spring-boot-smoke-test-aop/build.gradle @@ -9,6 +9,4 @@ dependencies { implementation(project(":spring-boot-project:spring-boot-starters:spring-boot-starter-aop")) testImplementation(project(":spring-boot-project:spring-boot-starters:spring-boot-starter-test")) - - testRuntimeOnly("org.junit.platform:junit-platform-launcher") } \ No newline at end of file diff --git a/spring-boot-tests/spring-boot-smoke-tests/spring-boot-smoke-test-atmosphere/build.gradle b/spring-boot-tests/spring-boot-smoke-tests/spring-boot-smoke-test-atmosphere/build.gradle index f83e76c424f5..27f86bf5db09 100644 --- a/spring-boot-tests/spring-boot-smoke-tests/spring-boot-smoke-test-atmosphere/build.gradle +++ b/spring-boot-tests/spring-boot-smoke-tests/spring-boot-smoke-test-atmosphere/build.gradle @@ -14,6 +14,4 @@ dependencies { testImplementation(enforcedPlatform(project(":spring-boot-project:spring-boot-dependencies"))) testImplementation(project(":spring-boot-project:spring-boot-starters:spring-boot-starter-test")) testImplementation("org.springframework:spring-websocket") - - testRuntimeOnly("org.junit.platform:junit-platform-launcher") } \ No newline at end of file diff --git a/spring-boot-tests/spring-boot-smoke-tests/spring-boot-smoke-test-batch/build.gradle b/spring-boot-tests/spring-boot-smoke-tests/spring-boot-smoke-test-batch/build.gradle index d88dcf683560..8ad05121aa92 100644 --- a/spring-boot-tests/spring-boot-smoke-tests/spring-boot-smoke-test-batch/build.gradle +++ b/spring-boot-tests/spring-boot-smoke-tests/spring-boot-smoke-test-batch/build.gradle @@ -7,10 +7,8 @@ description = "Spring Boot Batch smoke test" dependencies { implementation(project(":spring-boot-project:spring-boot-starters:spring-boot-starter-batch")) - + runtimeOnly("org.hsqldb:hsqldb") testImplementation(project(":spring-boot-project:spring-boot-starters:spring-boot-starter-test")) - - testRuntimeOnly("org.junit.platform:junit-platform-launcher") } \ No newline at end of file diff --git a/spring-boot-tests/spring-boot-smoke-tests/spring-boot-smoke-test-cache/build.gradle b/spring-boot-tests/spring-boot-smoke-tests/spring-boot-smoke-test-cache/build.gradle index b5fdd75e5cf1..84e14c23b1fc 100644 --- a/spring-boot-tests/spring-boot-smoke-tests/spring-boot-smoke-test-cache/build.gradle +++ b/spring-boot-tests/spring-boot-smoke-tests/spring-boot-smoke-test-cache/build.gradle @@ -39,8 +39,6 @@ dependencies { testImplementation(project(":spring-boot-project:spring-boot-starters:spring-boot-starter-test")) - testRuntimeOnly("org.junit.platform:junit-platform-launcher") - if (project.hasProperty("cache")) { caches[project.getProperty("cache")].each { runtimeOnly it } } diff --git a/spring-boot-tests/spring-boot-smoke-tests/spring-boot-smoke-test-data-couchbase/build.gradle b/spring-boot-tests/spring-boot-smoke-tests/spring-boot-smoke-test-data-couchbase/build.gradle index 9700b96651fc..9f4ceffe3cf0 100644 --- a/spring-boot-tests/spring-boot-smoke-tests/spring-boot-smoke-test-data-couchbase/build.gradle +++ b/spring-boot-tests/spring-boot-smoke-tests/spring-boot-smoke-test-data-couchbase/build.gradle @@ -9,6 +9,4 @@ dependencies { implementation(project(":spring-boot-project:spring-boot-starters:spring-boot-starter-data-couchbase")) testImplementation(project(":spring-boot-project:spring-boot-starters:spring-boot-starter-test")) - - testRuntimeOnly("org.junit.platform:junit-platform-launcher") } diff --git a/spring-boot-tests/spring-boot-smoke-tests/spring-boot-smoke-test-data-elasticsearch/build.gradle b/spring-boot-tests/spring-boot-smoke-tests/spring-boot-smoke-test-data-elasticsearch/build.gradle index 4b39e977d132..20b46dc9149a 100644 --- a/spring-boot-tests/spring-boot-smoke-tests/spring-boot-smoke-test-data-elasticsearch/build.gradle +++ b/spring-boot-tests/spring-boot-smoke-tests/spring-boot-smoke-test-data-elasticsearch/build.gradle @@ -9,6 +9,4 @@ dependencies { implementation(project(":spring-boot-project:spring-boot-starters:spring-boot-starter-data-elasticsearch")) testImplementation(project(":spring-boot-project:spring-boot-starters:spring-boot-starter-test")) - - testRuntimeOnly("org.junit.platform:junit-platform-launcher") } diff --git a/spring-boot-tests/spring-boot-smoke-tests/spring-boot-smoke-test-data-jdbc/build.gradle b/spring-boot-tests/spring-boot-smoke-tests/spring-boot-smoke-test-data-jdbc/build.gradle index 73795b04f974..577447eabf24 100644 --- a/spring-boot-tests/spring-boot-smoke-tests/spring-boot-smoke-test-data-jdbc/build.gradle +++ b/spring-boot-tests/spring-boot-smoke-tests/spring-boot-smoke-test-data-jdbc/build.gradle @@ -12,6 +12,4 @@ dependencies { runtimeOnly("com.h2database:h2") testImplementation(project(":spring-boot-project:spring-boot-starters:spring-boot-starter-test")) - - testRuntimeOnly("org.junit.platform:junit-platform-launcher") } diff --git a/spring-boot-tests/spring-boot-smoke-tests/spring-boot-smoke-test-data-jpa/build.gradle b/spring-boot-tests/spring-boot-smoke-tests/spring-boot-smoke-test-data-jpa/build.gradle index 6c11ffa51cc0..d009a1eeb626 100644 --- a/spring-boot-tests/spring-boot-smoke-tests/spring-boot-smoke-test-data-jpa/build.gradle +++ b/spring-boot-tests/spring-boot-smoke-tests/spring-boot-smoke-test-data-jpa/build.gradle @@ -13,6 +13,4 @@ dependencies { runtimeOnly("com.h2database:h2") testImplementation(project(":spring-boot-project:spring-boot-starters:spring-boot-starter-test")) - - testRuntimeOnly("org.junit.platform:junit-platform-launcher") } diff --git a/spring-boot-tests/spring-boot-smoke-tests/spring-boot-smoke-test-data-ldap/build.gradle b/spring-boot-tests/spring-boot-smoke-tests/spring-boot-smoke-test-data-ldap/build.gradle index acf2a51047d1..0c9f1ed18a78 100644 --- a/spring-boot-tests/spring-boot-smoke-tests/spring-boot-smoke-test-data-ldap/build.gradle +++ b/spring-boot-tests/spring-boot-smoke-tests/spring-boot-smoke-test-data-ldap/build.gradle @@ -11,6 +11,4 @@ dependencies { runtimeOnly("com.unboundid:unboundid-ldapsdk") testImplementation(project(":spring-boot-project:spring-boot-starters:spring-boot-starter-test")) - - testRuntimeOnly("org.junit.platform:junit-platform-launcher") } diff --git a/spring-boot-tests/spring-boot-smoke-tests/spring-boot-smoke-test-data-mongodb/build.gradle b/spring-boot-tests/spring-boot-smoke-tests/spring-boot-smoke-test-data-mongodb/build.gradle index 59ccf3343433..1c429284208a 100644 --- a/spring-boot-tests/spring-boot-smoke-tests/spring-boot-smoke-test-data-mongodb/build.gradle +++ b/spring-boot-tests/spring-boot-smoke-tests/spring-boot-smoke-test-data-mongodb/build.gradle @@ -11,6 +11,4 @@ dependencies { runtimeOnly("de.flapdoodle.embed:de.flapdoodle.embed.mongo") testImplementation(project(":spring-boot-project:spring-boot-starters:spring-boot-starter-test")) - - testRuntimeOnly("org.junit.platform:junit-platform-launcher") } diff --git a/spring-boot-tests/spring-boot-smoke-tests/spring-boot-smoke-test-data-neo4j/build.gradle b/spring-boot-tests/spring-boot-smoke-tests/spring-boot-smoke-test-data-neo4j/build.gradle index bfd3e16ce865..233d3efeab12 100644 --- a/spring-boot-tests/spring-boot-smoke-tests/spring-boot-smoke-test-data-neo4j/build.gradle +++ b/spring-boot-tests/spring-boot-smoke-tests/spring-boot-smoke-test-data-neo4j/build.gradle @@ -9,6 +9,4 @@ dependencies { implementation(project(":spring-boot-project:spring-boot-starters:spring-boot-starter-data-neo4j")) testImplementation(project(":spring-boot-project:spring-boot-starters:spring-boot-starter-test")) - - testRuntimeOnly("org.junit.platform:junit-platform-launcher") } diff --git a/spring-boot-tests/spring-boot-smoke-tests/spring-boot-smoke-test-data-r2dbc-flyway/build.gradle b/spring-boot-tests/spring-boot-smoke-tests/spring-boot-smoke-test-data-r2dbc-flyway/build.gradle index 8fb897d24693..020bb3e9d9cf 100644 --- a/spring-boot-tests/spring-boot-smoke-tests/spring-boot-smoke-test-data-r2dbc-flyway/build.gradle +++ b/spring-boot-tests/spring-boot-smoke-tests/spring-boot-smoke-test-data-r2dbc-flyway/build.gradle @@ -21,6 +21,4 @@ dependencies { testImplementation("io.projectreactor:reactor-test") testImplementation("org.testcontainers:junit-jupiter") testImplementation("org.testcontainers:postgresql") - - testRuntimeOnly("org.junit.platform:junit-platform-launcher") } diff --git a/spring-boot-tests/spring-boot-smoke-tests/spring-boot-smoke-test-data-r2dbc-liquibase/build.gradle b/spring-boot-tests/spring-boot-smoke-tests/spring-boot-smoke-test-data-r2dbc-liquibase/build.gradle index ea28232ce291..b5decbc7adb7 100644 --- a/spring-boot-tests/spring-boot-smoke-tests/spring-boot-smoke-test-data-r2dbc-liquibase/build.gradle +++ b/spring-boot-tests/spring-boot-smoke-tests/spring-boot-smoke-test-data-r2dbc-liquibase/build.gradle @@ -21,6 +21,4 @@ dependencies { testImplementation("io.projectreactor:reactor-test") testImplementation("org.testcontainers:junit-jupiter") testImplementation("org.testcontainers:postgresql") - - testRuntimeOnly("org.junit.platform:junit-platform-launcher") } diff --git a/spring-boot-tests/spring-boot-smoke-tests/spring-boot-smoke-test-data-r2dbc/build.gradle b/spring-boot-tests/spring-boot-smoke-tests/spring-boot-smoke-test-data-r2dbc/build.gradle index aba0ce257263..c18db766961b 100644 --- a/spring-boot-tests/spring-boot-smoke-tests/spring-boot-smoke-test-data-r2dbc/build.gradle +++ b/spring-boot-tests/spring-boot-smoke-tests/spring-boot-smoke-test-data-r2dbc/build.gradle @@ -13,6 +13,4 @@ dependencies { runtimeOnly("io.r2dbc:r2dbc-h2") testImplementation(project(":spring-boot-project:spring-boot-starters:spring-boot-starter-test")) - - testRuntimeOnly("org.junit.platform:junit-platform-launcher") } diff --git a/spring-boot-tests/spring-boot-smoke-tests/spring-boot-smoke-test-data-redis/build.gradle b/spring-boot-tests/spring-boot-smoke-tests/spring-boot-smoke-test-data-redis/build.gradle index 5524f19aa6ec..2d304c6c05b0 100644 --- a/spring-boot-tests/spring-boot-smoke-tests/spring-boot-smoke-test-data-redis/build.gradle +++ b/spring-boot-tests/spring-boot-smoke-tests/spring-boot-smoke-test-data-redis/build.gradle @@ -9,6 +9,4 @@ dependencies { implementation(project(":spring-boot-project:spring-boot-starters:spring-boot-starter-data-redis")) testImplementation(project(":spring-boot-project:spring-boot-starters:spring-boot-starter-test")) - - testRuntimeOnly("org.junit.platform:junit-platform-launcher") } diff --git a/spring-boot-tests/spring-boot-smoke-tests/spring-boot-smoke-test-data-rest/build.gradle b/spring-boot-tests/spring-boot-smoke-tests/spring-boot-smoke-test-data-rest/build.gradle index d228f85d939e..b0e2be031049 100644 --- a/spring-boot-tests/spring-boot-smoke-tests/spring-boot-smoke-test-data-rest/build.gradle +++ b/spring-boot-tests/spring-boot-smoke-tests/spring-boot-smoke-test-data-rest/build.gradle @@ -17,5 +17,4 @@ dependencies { testImplementation(project(":spring-boot-project:spring-boot-starters:spring-boot-starter-test")) testRuntimeOnly("com.jayway.jsonpath:json-path") - testRuntimeOnly("org.junit.platform:junit-platform-launcher") } diff --git a/spring-boot-tests/spring-boot-smoke-tests/spring-boot-smoke-test-data-solr/build.gradle b/spring-boot-tests/spring-boot-smoke-tests/spring-boot-smoke-test-data-solr/build.gradle index 0183beeee916..73765ae56bf2 100644 --- a/spring-boot-tests/spring-boot-smoke-tests/spring-boot-smoke-test-data-solr/build.gradle +++ b/spring-boot-tests/spring-boot-smoke-tests/spring-boot-smoke-test-data-solr/build.gradle @@ -9,6 +9,4 @@ dependencies { implementation(project(":spring-boot-project:spring-boot-starters:spring-boot-starter-data-solr")) testImplementation(project(":spring-boot-project:spring-boot-starters:spring-boot-starter-test")) - - testRuntimeOnly("org.junit.platform:junit-platform-launcher") } diff --git a/spring-boot-tests/spring-boot-smoke-tests/spring-boot-smoke-test-devtools/build.gradle b/spring-boot-tests/spring-boot-smoke-tests/spring-boot-smoke-test-devtools/build.gradle index 197e81a4c187..e27a3d9b4c2c 100644 --- a/spring-boot-tests/spring-boot-smoke-tests/spring-boot-smoke-test-devtools/build.gradle +++ b/spring-boot-tests/spring-boot-smoke-tests/spring-boot-smoke-test-devtools/build.gradle @@ -17,6 +17,4 @@ dependencies { implementation(project(":spring-boot-project:spring-boot-starters:spring-boot-starter-web")) testImplementation(project(":spring-boot-project:spring-boot-starters:spring-boot-starter-test")) - - testRuntimeOnly("org.junit.platform:junit-platform-launcher") } diff --git a/spring-boot-tests/spring-boot-smoke-tests/spring-boot-smoke-test-flyway/build.gradle b/spring-boot-tests/spring-boot-smoke-tests/spring-boot-smoke-test-flyway/build.gradle index 2d67291bb56e..b04bc8a21dfb 100644 --- a/spring-boot-tests/spring-boot-smoke-tests/spring-boot-smoke-test-flyway/build.gradle +++ b/spring-boot-tests/spring-boot-smoke-tests/spring-boot-smoke-test-flyway/build.gradle @@ -14,6 +14,4 @@ dependencies { runtimeOnly("org.flywaydb:flyway-core") testImplementation(project(":spring-boot-project:spring-boot-starters:spring-boot-starter-test")) - - testRuntimeOnly("org.junit.platform:junit-platform-launcher") } diff --git a/spring-boot-tests/spring-boot-smoke-tests/spring-boot-smoke-test-hateoas/build.gradle b/spring-boot-tests/spring-boot-smoke-tests/spring-boot-smoke-test-hateoas/build.gradle index dc0900f09e58..e1f47ebeabc7 100644 --- a/spring-boot-tests/spring-boot-smoke-tests/spring-boot-smoke-test-hateoas/build.gradle +++ b/spring-boot-tests/spring-boot-smoke-tests/spring-boot-smoke-test-hateoas/build.gradle @@ -9,6 +9,4 @@ dependencies { implementation(project(":spring-boot-project:spring-boot-starters:spring-boot-starter-hateoas")) testImplementation(project(":spring-boot-project:spring-boot-starters:spring-boot-starter-test")) - - testRuntimeOnly("org.junit.platform:junit-platform-launcher") } diff --git a/spring-boot-tests/spring-boot-smoke-tests/spring-boot-smoke-test-hazelcast4/build.gradle b/spring-boot-tests/spring-boot-smoke-tests/spring-boot-smoke-test-hazelcast4/build.gradle index 4d079e6f083f..54d13f0e6b8d 100644 --- a/spring-boot-tests/spring-boot-smoke-tests/spring-boot-smoke-test-hazelcast4/build.gradle +++ b/spring-boot-tests/spring-boot-smoke-tests/spring-boot-smoke-test-hazelcast4/build.gradle @@ -21,6 +21,4 @@ dependencies { testImplementation(project(":spring-boot-project:spring-boot-starters:spring-boot-starter-test")) testImplementation(project(":spring-boot-project:spring-boot-starters:spring-boot-starter-webflux")) - - testRuntimeOnly("org.junit.platform:junit-platform-launcher") } diff --git a/spring-boot-tests/spring-boot-smoke-tests/spring-boot-smoke-test-hibernate52/build.gradle b/spring-boot-tests/spring-boot-smoke-tests/spring-boot-smoke-test-hibernate52/build.gradle index fff415813e7a..27369d6dc409 100644 --- a/spring-boot-tests/spring-boot-smoke-tests/spring-boot-smoke-test-hibernate52/build.gradle +++ b/spring-boot-tests/spring-boot-smoke-tests/spring-boot-smoke-test-hibernate52/build.gradle @@ -19,6 +19,4 @@ dependencies { runtimeOnly("com.h2database:h2") testImplementation(project(":spring-boot-project:spring-boot-starters:spring-boot-starter-test")) - - testRuntimeOnly("org.junit.platform:junit-platform-launcher") } diff --git a/spring-boot-tests/spring-boot-smoke-tests/spring-boot-smoke-test-integration/build.gradle b/spring-boot-tests/spring-boot-smoke-tests/spring-boot-smoke-test-integration/build.gradle index 75f709e9c3ff..a0506b33203a 100644 --- a/spring-boot-tests/spring-boot-smoke-tests/spring-boot-smoke-test-integration/build.gradle +++ b/spring-boot-tests/spring-boot-smoke-tests/spring-boot-smoke-test-integration/build.gradle @@ -13,6 +13,4 @@ dependencies { testImplementation(project(":spring-boot-project:spring-boot-starters:spring-boot-starter-test")) testImplementation("org.awaitility:awaitility") - - testRuntimeOnly("org.junit.platform:junit-platform-launcher") } diff --git a/spring-boot-tests/spring-boot-smoke-tests/spring-boot-smoke-test-jersey/build.gradle b/spring-boot-tests/spring-boot-smoke-tests/spring-boot-smoke-test-jersey/build.gradle index 17e90667fb96..f93f3fa6d5cc 100644 --- a/spring-boot-tests/spring-boot-smoke-tests/spring-boot-smoke-test-jersey/build.gradle +++ b/spring-boot-tests/spring-boot-smoke-tests/spring-boot-smoke-test-jersey/build.gradle @@ -15,6 +15,4 @@ dependencies { } testImplementation(project(":spring-boot-project:spring-boot-starters:spring-boot-starter-test")) - - testRuntimeOnly("org.junit.platform:junit-platform-launcher") } diff --git a/spring-boot-tests/spring-boot-smoke-tests/spring-boot-smoke-test-jetty-jsp/build.gradle b/spring-boot-tests/spring-boot-smoke-tests/spring-boot-smoke-test-jetty-jsp/build.gradle index 0ab1d2b0f8b9..5e16488338c6 100644 --- a/spring-boot-tests/spring-boot-smoke-tests/spring-boot-smoke-test-jetty-jsp/build.gradle +++ b/spring-boot-tests/spring-boot-smoke-tests/spring-boot-smoke-test-jetty-jsp/build.gradle @@ -27,6 +27,4 @@ dependencies { testImplementation(project(":spring-boot-project:spring-boot-starters:spring-boot-starter-test")) testImplementation(project(":spring-boot-project:spring-boot-starters:spring-boot-starter-jetty")) - - testRuntimeOnly("org.junit.platform:junit-platform-launcher") } diff --git a/spring-boot-tests/spring-boot-smoke-tests/spring-boot-smoke-test-jetty-ssl/build.gradle b/spring-boot-tests/spring-boot-smoke-tests/spring-boot-smoke-test-jetty-ssl/build.gradle index cef000460df1..b39afaf3ed44 100644 --- a/spring-boot-tests/spring-boot-smoke-tests/spring-boot-smoke-test-jetty-ssl/build.gradle +++ b/spring-boot-tests/spring-boot-smoke-tests/spring-boot-smoke-test-jetty-ssl/build.gradle @@ -14,6 +14,4 @@ dependencies { testImplementation(project(":spring-boot-project:spring-boot-starters:spring-boot-starter-test")) testRuntimeOnly("org.apache.httpcomponents:httpclient") - - testRuntimeOnly("org.junit.platform:junit-platform-launcher") } diff --git a/spring-boot-tests/spring-boot-smoke-tests/spring-boot-smoke-test-jetty/build.gradle b/spring-boot-tests/spring-boot-smoke-tests/spring-boot-smoke-test-jetty/build.gradle index b7272f158d48..b204e4a35e31 100644 --- a/spring-boot-tests/spring-boot-smoke-tests/spring-boot-smoke-test-jetty/build.gradle +++ b/spring-boot-tests/spring-boot-smoke-tests/spring-boot-smoke-test-jetty/build.gradle @@ -12,6 +12,4 @@ dependencies { implementation(project(":spring-boot-project:spring-boot-starters:spring-boot-starter-jetty")) testImplementation(project(":spring-boot-project:spring-boot-starters:spring-boot-starter-test")) - - testRuntimeOnly("org.junit.platform:junit-platform-launcher") } diff --git a/spring-boot-tests/spring-boot-smoke-tests/spring-boot-smoke-test-jpa/build.gradle b/spring-boot-tests/spring-boot-smoke-tests/spring-boot-smoke-test-jpa/build.gradle index 78717d0e64e5..f571bc0c59c8 100644 --- a/spring-boot-tests/spring-boot-smoke-tests/spring-boot-smoke-test-jpa/build.gradle +++ b/spring-boot-tests/spring-boot-smoke-tests/spring-boot-smoke-test-jpa/build.gradle @@ -22,6 +22,4 @@ dependencies { runtimeOnly("com.h2database:h2") testImplementation(project(":spring-boot-project:spring-boot-starters:spring-boot-starter-test")) - - testRuntimeOnly("org.junit.platform:junit-platform-launcher") } diff --git a/spring-boot-tests/spring-boot-smoke-tests/spring-boot-smoke-test-jta-atomikos/build.gradle b/spring-boot-tests/spring-boot-smoke-tests/spring-boot-smoke-test-jta-atomikos/build.gradle index 768a8884d2c6..3af4cc0d3b8f 100644 --- a/spring-boot-tests/spring-boot-smoke-tests/spring-boot-smoke-test-jta-atomikos/build.gradle +++ b/spring-boot-tests/spring-boot-smoke-tests/spring-boot-smoke-test-jta-atomikos/build.gradle @@ -20,6 +20,4 @@ dependencies { } testImplementation(project(":spring-boot-project:spring-boot-starters:spring-boot-starter-test")) - - testRuntimeOnly("org.junit.platform:junit-platform-launcher") } diff --git a/spring-boot-tests/spring-boot-smoke-tests/spring-boot-smoke-test-jta-bitronix/build.gradle b/spring-boot-tests/spring-boot-smoke-tests/spring-boot-smoke-test-jta-bitronix/build.gradle index 24b8b9c154e7..55e14c4ede80 100644 --- a/spring-boot-tests/spring-boot-smoke-tests/spring-boot-smoke-test-jta-bitronix/build.gradle +++ b/spring-boot-tests/spring-boot-smoke-tests/spring-boot-smoke-test-jta-bitronix/build.gradle @@ -20,6 +20,4 @@ dependencies { } testImplementation(project(":spring-boot-project:spring-boot-starters:spring-boot-starter-test")) - - testRuntimeOnly("org.junit.platform:junit-platform-launcher") } diff --git a/spring-boot-tests/spring-boot-smoke-tests/spring-boot-smoke-test-junit-jupiter/build.gradle b/spring-boot-tests/spring-boot-smoke-tests/spring-boot-smoke-test-junit-jupiter/build.gradle index 117ee9a8f3ad..f9e563f25095 100644 --- a/spring-boot-tests/spring-boot-smoke-tests/spring-boot-smoke-test-junit-jupiter/build.gradle +++ b/spring-boot-tests/spring-boot-smoke-tests/spring-boot-smoke-test-junit-jupiter/build.gradle @@ -11,8 +11,6 @@ dependencies { testImplementation(project(":spring-boot-project:spring-boot-starters:spring-boot-starter-test")) { exclude group: "org.junit.vintage" } - - testRuntimeOnly("org.junit.platform:junit-platform-launcher") } test { diff --git a/spring-boot-tests/spring-boot-smoke-tests/spring-boot-smoke-test-junit-vintage/build.gradle b/spring-boot-tests/spring-boot-smoke-tests/spring-boot-smoke-test-junit-vintage/build.gradle index 31faa39a56d0..8212bce053a5 100644 --- a/spring-boot-tests/spring-boot-smoke-tests/spring-boot-smoke-test-junit-vintage/build.gradle +++ b/spring-boot-tests/spring-boot-smoke-tests/spring-boot-smoke-test-junit-vintage/build.gradle @@ -9,8 +9,6 @@ dependencies { implementation(project(":spring-boot-project:spring-boot-starters:spring-boot-starter-web")) testImplementation(project(":spring-boot-project:spring-boot-starters:spring-boot-starter-test")) - - testRuntimeOnly("org.junit.platform:junit-platform-launcher") } test { diff --git a/spring-boot-tests/spring-boot-smoke-tests/spring-boot-smoke-test-kafka/build.gradle b/spring-boot-tests/spring-boot-smoke-tests/spring-boot-smoke-test-kafka/build.gradle index 7906ed30eb0a..33a82ff144bd 100644 --- a/spring-boot-tests/spring-boot-smoke-tests/spring-boot-smoke-test-kafka/build.gradle +++ b/spring-boot-tests/spring-boot-smoke-tests/spring-boot-smoke-test-kafka/build.gradle @@ -12,6 +12,4 @@ dependencies { testImplementation(project(":spring-boot-project:spring-boot-starters:spring-boot-starter-test")) testImplementation("org.awaitility:awaitility") testImplementation("org.springframework.kafka:spring-kafka-test") - - testRuntimeOnly("org.junit.platform:junit-platform-launcher") } diff --git a/spring-boot-tests/spring-boot-smoke-tests/spring-boot-smoke-test-liquibase/build.gradle b/spring-boot-tests/spring-boot-smoke-tests/spring-boot-smoke-test-liquibase/build.gradle index 2a44c5ad16ac..60ab8957b507 100644 --- a/spring-boot-tests/spring-boot-smoke-tests/spring-boot-smoke-test-liquibase/build.gradle +++ b/spring-boot-tests/spring-boot-smoke-tests/spring-boot-smoke-test-liquibase/build.gradle @@ -14,6 +14,4 @@ dependencies { runtimeOnly("com.h2database:h2") testImplementation(project(":spring-boot-project:spring-boot-starters:spring-boot-starter-test")) - - testRuntimeOnly("org.junit.platform:junit-platform-launcher") } diff --git a/spring-boot-tests/spring-boot-smoke-tests/spring-boot-smoke-test-logback/build.gradle b/spring-boot-tests/spring-boot-smoke-tests/spring-boot-smoke-test-logback/build.gradle index 698eb510e78b..d7fced445fe5 100644 --- a/spring-boot-tests/spring-boot-smoke-tests/spring-boot-smoke-test-logback/build.gradle +++ b/spring-boot-tests/spring-boot-smoke-tests/spring-boot-smoke-test-logback/build.gradle @@ -9,6 +9,4 @@ dependencies { implementation(project(":spring-boot-project:spring-boot-starters:spring-boot-starter")) testImplementation(project(":spring-boot-project:spring-boot-starters:spring-boot-starter-test")) - - testRuntimeOnly("org.junit.platform:junit-platform-launcher") } diff --git a/spring-boot-tests/spring-boot-smoke-tests/spring-boot-smoke-test-oauth2-client/build.gradle b/spring-boot-tests/spring-boot-smoke-tests/spring-boot-smoke-test-oauth2-client/build.gradle index 8156b9371fe1..9667845a0c97 100644 --- a/spring-boot-tests/spring-boot-smoke-tests/spring-boot-smoke-test-oauth2-client/build.gradle +++ b/spring-boot-tests/spring-boot-smoke-tests/spring-boot-smoke-test-oauth2-client/build.gradle @@ -11,6 +11,4 @@ dependencies { testImplementation(project(":spring-boot-project:spring-boot-starters:spring-boot-starter-test")) testImplementation("org.apache.httpcomponents:httpclient") - - testRuntimeOnly("org.junit.platform:junit-platform-launcher") } diff --git a/spring-boot-tests/spring-boot-smoke-tests/spring-boot-smoke-test-oauth2-resource-server/build.gradle b/spring-boot-tests/spring-boot-smoke-tests/spring-boot-smoke-test-oauth2-resource-server/build.gradle index 56ea47c5459f..aa4c52038605 100644 --- a/spring-boot-tests/spring-boot-smoke-tests/spring-boot-smoke-test-oauth2-resource-server/build.gradle +++ b/spring-boot-tests/spring-boot-smoke-tests/spring-boot-smoke-test-oauth2-resource-server/build.gradle @@ -11,6 +11,4 @@ dependencies { testImplementation(project(":spring-boot-project:spring-boot-starters:spring-boot-starter-test")) testImplementation("com.squareup.okhttp3:mockwebserver:3.9.0") - - testRuntimeOnly("org.junit.platform:junit-platform-launcher") } diff --git a/spring-boot-tests/spring-boot-smoke-tests/spring-boot-smoke-test-parent-context/build.gradle b/spring-boot-tests/spring-boot-smoke-tests/spring-boot-smoke-test-parent-context/build.gradle index 4df9cda681d9..1f174d0bc2b8 100644 --- a/spring-boot-tests/spring-boot-smoke-tests/spring-boot-smoke-test-parent-context/build.gradle +++ b/spring-boot-tests/spring-boot-smoke-tests/spring-boot-smoke-test-parent-context/build.gradle @@ -12,6 +12,4 @@ dependencies { testImplementation(project(":spring-boot-project:spring-boot-starters:spring-boot-starter-test")) testImplementation("org.awaitility:awaitility") - - testRuntimeOnly("org.junit.platform:junit-platform-launcher") } diff --git a/spring-boot-tests/spring-boot-smoke-tests/spring-boot-smoke-test-profile/build.gradle b/spring-boot-tests/spring-boot-smoke-tests/spring-boot-smoke-test-profile/build.gradle index bbffd501f38f..e85bae25e21b 100644 --- a/spring-boot-tests/spring-boot-smoke-tests/spring-boot-smoke-test-profile/build.gradle +++ b/spring-boot-tests/spring-boot-smoke-tests/spring-boot-smoke-test-profile/build.gradle @@ -9,6 +9,4 @@ dependencies { implementation(project(":spring-boot-project:spring-boot-starters:spring-boot-starter")) testImplementation(project(":spring-boot-project:spring-boot-starters:spring-boot-starter-test")) - - testRuntimeOnly("org.junit.platform:junit-platform-launcher") } diff --git a/spring-boot-tests/spring-boot-smoke-tests/spring-boot-smoke-test-property-validation/build.gradle b/spring-boot-tests/spring-boot-smoke-tests/spring-boot-smoke-test-property-validation/build.gradle index f587ef59129b..dd6a52edf931 100644 --- a/spring-boot-tests/spring-boot-smoke-tests/spring-boot-smoke-test-property-validation/build.gradle +++ b/spring-boot-tests/spring-boot-smoke-tests/spring-boot-smoke-test-property-validation/build.gradle @@ -11,6 +11,4 @@ dependencies { implementation(project(":spring-boot-project:spring-boot-starters:spring-boot-starter")) testImplementation(project(":spring-boot-project:spring-boot-starters:spring-boot-starter-test")) - - testRuntimeOnly("org.junit.platform:junit-platform-launcher") } diff --git a/spring-boot-tests/spring-boot-smoke-tests/spring-boot-smoke-test-quartz/build.gradle b/spring-boot-tests/spring-boot-smoke-tests/spring-boot-smoke-test-quartz/build.gradle index a72c5db2b2fb..f1d8cb6bd078 100644 --- a/spring-boot-tests/spring-boot-smoke-tests/spring-boot-smoke-test-quartz/build.gradle +++ b/spring-boot-tests/spring-boot-smoke-tests/spring-boot-smoke-test-quartz/build.gradle @@ -13,6 +13,4 @@ dependencies { testImplementation(project(":spring-boot-project:spring-boot-starters:spring-boot-starter-test")) testImplementation("org.awaitility:awaitility") - - testRuntimeOnly("org.junit.platform:junit-platform-launcher") } diff --git a/spring-boot-tests/spring-boot-smoke-tests/spring-boot-smoke-test-reactive-oauth2-client/build.gradle b/spring-boot-tests/spring-boot-smoke-tests/spring-boot-smoke-test-reactive-oauth2-client/build.gradle index 55bea7f7160a..890f42886877 100644 --- a/spring-boot-tests/spring-boot-smoke-tests/spring-boot-smoke-test-reactive-oauth2-client/build.gradle +++ b/spring-boot-tests/spring-boot-smoke-tests/spring-boot-smoke-test-reactive-oauth2-client/build.gradle @@ -12,6 +12,4 @@ dependencies { testImplementation(project(":spring-boot-project:spring-boot-starters:spring-boot-starter-test")) testImplementation("org.apache.httpcomponents:httpclient") - - testRuntimeOnly("org.junit.platform:junit-platform-launcher") } diff --git a/spring-boot-tests/spring-boot-smoke-tests/spring-boot-smoke-test-reactive-oauth2-resource-server/build.gradle b/spring-boot-tests/spring-boot-smoke-tests/spring-boot-smoke-test-reactive-oauth2-resource-server/build.gradle index bd0ed8c150f5..17d98b4895c2 100644 --- a/spring-boot-tests/spring-boot-smoke-tests/spring-boot-smoke-test-reactive-oauth2-resource-server/build.gradle +++ b/spring-boot-tests/spring-boot-smoke-tests/spring-boot-smoke-test-reactive-oauth2-resource-server/build.gradle @@ -11,6 +11,4 @@ dependencies { testImplementation(project(":spring-boot-project:spring-boot-starters:spring-boot-starter-test")) testImplementation("com.squareup.okhttp3:mockwebserver:3.9.0") - - testRuntimeOnly("org.junit.platform:junit-platform-launcher") } diff --git a/spring-boot-tests/spring-boot-smoke-tests/spring-boot-smoke-test-rsocket/build.gradle b/spring-boot-tests/spring-boot-smoke-tests/spring-boot-smoke-test-rsocket/build.gradle index d13d8ed2682c..3194511e54cb 100644 --- a/spring-boot-tests/spring-boot-smoke-tests/spring-boot-smoke-test-rsocket/build.gradle +++ b/spring-boot-tests/spring-boot-smoke-tests/spring-boot-smoke-test-rsocket/build.gradle @@ -12,6 +12,4 @@ dependencies { testImplementation(project(":spring-boot-project:spring-boot-starters:spring-boot-starter-test")) testImplementation("io.projectreactor:reactor-test") - - testRuntimeOnly("org.junit.platform:junit-platform-launcher") } diff --git a/spring-boot-tests/spring-boot-smoke-tests/spring-boot-smoke-test-saml2-service-provider/build.gradle b/spring-boot-tests/spring-boot-smoke-tests/spring-boot-smoke-test-saml2-service-provider/build.gradle index a3eef619ea6f..2a707f22f509 100644 --- a/spring-boot-tests/spring-boot-smoke-tests/spring-boot-smoke-test-saml2-service-provider/build.gradle +++ b/spring-boot-tests/spring-boot-smoke-tests/spring-boot-smoke-test-saml2-service-provider/build.gradle @@ -11,6 +11,4 @@ dependencies { implementation("org.springframework.security:spring-security-saml2-service-provider") testImplementation(project(":spring-boot-project:spring-boot-starters:spring-boot-starter-test")) - - testRuntimeOnly("org.junit.platform:junit-platform-launcher") } diff --git a/spring-boot-tests/spring-boot-smoke-tests/spring-boot-smoke-test-secure-jersey/build.gradle b/spring-boot-tests/spring-boot-smoke-tests/spring-boot-smoke-test-secure-jersey/build.gradle index ea90b135c687..f896b2b24685 100644 --- a/spring-boot-tests/spring-boot-smoke-tests/spring-boot-smoke-test-secure-jersey/build.gradle +++ b/spring-boot-tests/spring-boot-smoke-tests/spring-boot-smoke-test-secure-jersey/build.gradle @@ -12,6 +12,4 @@ dependencies { implementation("org.jolokia:jolokia-core") testImplementation(project(":spring-boot-project:spring-boot-starters:spring-boot-starter-test")) - - testRuntimeOnly("org.junit.platform:junit-platform-launcher") } diff --git a/spring-boot-tests/spring-boot-smoke-tests/spring-boot-smoke-test-secure-webflux/build.gradle b/spring-boot-tests/spring-boot-smoke-tests/spring-boot-smoke-test-secure-webflux/build.gradle index affb797e5cb5..08f52a225973 100644 --- a/spring-boot-tests/spring-boot-smoke-tests/spring-boot-smoke-test-secure-webflux/build.gradle +++ b/spring-boot-tests/spring-boot-smoke-tests/spring-boot-smoke-test-secure-webflux/build.gradle @@ -12,6 +12,4 @@ dependencies { testImplementation(project(":spring-boot-project:spring-boot-starters:spring-boot-starter-test")) testImplementation("io.projectreactor:reactor-test") - - testRuntimeOnly("org.junit.platform:junit-platform-launcher") } diff --git a/spring-boot-tests/spring-boot-smoke-tests/spring-boot-smoke-test-secure/build.gradle b/spring-boot-tests/spring-boot-smoke-tests/spring-boot-smoke-test-secure/build.gradle index 40e1ac12f156..13bc2d8953c4 100644 --- a/spring-boot-tests/spring-boot-smoke-tests/spring-boot-smoke-test-secure/build.gradle +++ b/spring-boot-tests/spring-boot-smoke-tests/spring-boot-smoke-test-secure/build.gradle @@ -9,6 +9,4 @@ dependencies { implementation(project(":spring-boot-project:spring-boot-starters:spring-boot-starter-security")) testImplementation(project(":spring-boot-project:spring-boot-starters:spring-boot-starter-test")) - - testRuntimeOnly("org.junit.platform:junit-platform-launcher") } diff --git a/spring-boot-tests/spring-boot-smoke-tests/spring-boot-smoke-test-servlet/build.gradle b/spring-boot-tests/spring-boot-smoke-tests/spring-boot-smoke-test-servlet/build.gradle index 74a5900f4697..ae5060934179 100644 --- a/spring-boot-tests/spring-boot-smoke-tests/spring-boot-smoke-test-servlet/build.gradle +++ b/spring-boot-tests/spring-boot-smoke-tests/spring-boot-smoke-test-servlet/build.gradle @@ -13,5 +13,4 @@ dependencies { testImplementation(project(":spring-boot-project:spring-boot-starters:spring-boot-starter-test")) testRuntimeOnly(project(":spring-boot-project:spring-boot-starters:spring-boot-starter-tomcat")) - testRuntimeOnly("org.junit.platform:junit-platform-launcher") } diff --git a/spring-boot-tests/spring-boot-smoke-tests/spring-boot-smoke-test-session-webflux/build.gradle b/spring-boot-tests/spring-boot-smoke-tests/spring-boot-smoke-test-session-webflux/build.gradle index 4cc5a8fbff7f..a90b4f9bc506 100644 --- a/spring-boot-tests/spring-boot-smoke-tests/spring-boot-smoke-test-session-webflux/build.gradle +++ b/spring-boot-tests/spring-boot-smoke-tests/spring-boot-smoke-test-session-webflux/build.gradle @@ -24,6 +24,4 @@ dependencies { sessionStores[project.findProperty("sessionStore") ?: "mongodb"].each { runtimeOnly it } testImplementation(project(":spring-boot-project:spring-boot-starters:spring-boot-starter-test")) - - testRuntimeOnly("org.junit.platform:junit-platform-launcher") } diff --git a/spring-boot-tests/spring-boot-smoke-tests/spring-boot-smoke-test-session/build.gradle b/spring-boot-tests/spring-boot-smoke-tests/spring-boot-smoke-test-session/build.gradle index eba7d8b5bd61..bd0ef38690d3 100644 --- a/spring-boot-tests/spring-boot-smoke-tests/spring-boot-smoke-test-session/build.gradle +++ b/spring-boot-tests/spring-boot-smoke-tests/spring-boot-smoke-test-session/build.gradle @@ -33,6 +33,4 @@ dependencies { sessionStores[project.findProperty("sessionStore") ?: "jdbc"].each { runtimeOnly it } testImplementation(project(":spring-boot-project:spring-boot-starters:spring-boot-starter-test")) - - testRuntimeOnly("org.junit.platform:junit-platform-launcher") } diff --git a/spring-boot-tests/spring-boot-smoke-tests/spring-boot-smoke-test-simple/build.gradle b/spring-boot-tests/spring-boot-smoke-tests/spring-boot-smoke-test-simple/build.gradle index a1dbf6d40732..d6690b607c48 100644 --- a/spring-boot-tests/spring-boot-smoke-tests/spring-boot-smoke-test-simple/build.gradle +++ b/spring-boot-tests/spring-boot-smoke-tests/spring-boot-smoke-test-simple/build.gradle @@ -13,6 +13,4 @@ dependencies { } testImplementation(project(":spring-boot-project:spring-boot-starters:spring-boot-starter-test")) - - testRuntimeOnly("org.junit.platform:junit-platform-launcher") } diff --git a/spring-boot-tests/spring-boot-smoke-tests/spring-boot-smoke-test-test-nomockito/build.gradle b/spring-boot-tests/spring-boot-smoke-tests/spring-boot-smoke-test-test-nomockito/build.gradle index ed7ec90ae529..40bd131be74d 100644 --- a/spring-boot-tests/spring-boot-smoke-tests/spring-boot-smoke-test-test-nomockito/build.gradle +++ b/spring-boot-tests/spring-boot-smoke-tests/spring-boot-smoke-test-test-nomockito/build.gradle @@ -15,6 +15,4 @@ dependencies { testImplementation("org.assertj:assertj-core") testImplementation("org.junit.jupiter:junit-jupiter") testImplementation("org.springframework:spring-test") - - testRuntimeOnly("org.junit.platform:junit-platform-launcher") } diff --git a/spring-boot-tests/spring-boot-smoke-tests/spring-boot-smoke-test-test/build.gradle b/spring-boot-tests/spring-boot-smoke-tests/spring-boot-smoke-test-test/build.gradle index ffb8c84dd0c5..bf71f2ad8f52 100644 --- a/spring-boot-tests/spring-boot-smoke-tests/spring-boot-smoke-test-test/build.gradle +++ b/spring-boot-tests/spring-boot-smoke-tests/spring-boot-smoke-test-test/build.gradle @@ -15,6 +15,4 @@ dependencies { testImplementation("org.seleniumhq.selenium:selenium-api") testImplementation("org.seleniumhq.selenium:htmlunit-driver") testImplementation("net.sourceforge.htmlunit:htmlunit") - - testRuntimeOnly("org.junit.platform:junit-platform-launcher") } diff --git a/spring-boot-tests/spring-boot-smoke-tests/spring-boot-smoke-test-testng/build.gradle b/spring-boot-tests/spring-boot-smoke-tests/spring-boot-smoke-test-testng/build.gradle index be4cb7ca5222..14bc6715cdd1 100644 --- a/spring-boot-tests/spring-boot-smoke-tests/spring-boot-smoke-test-testng/build.gradle +++ b/spring-boot-tests/spring-boot-smoke-tests/spring-boot-smoke-test-testng/build.gradle @@ -14,8 +14,6 @@ dependencies { testImplementation("org.assertj:assertj-core") testImplementation("org.springframework:spring-test") testImplementation("org.testng:testng:6.8.13") - - testRuntimeOnly("org.junit.platform:junit-platform-launcher") } test { diff --git a/spring-boot-tests/spring-boot-smoke-tests/spring-boot-smoke-test-tomcat-jsp/build.gradle b/spring-boot-tests/spring-boot-smoke-tests/spring-boot-smoke-test-tomcat-jsp/build.gradle index ae3644aba473..edfd6c56f8b1 100644 --- a/spring-boot-tests/spring-boot-smoke-tests/spring-boot-smoke-test-tomcat-jsp/build.gradle +++ b/spring-boot-tests/spring-boot-smoke-tests/spring-boot-smoke-test-tomcat-jsp/build.gradle @@ -19,6 +19,4 @@ dependencies { providedRuntime("org.apache.tomcat.embed:tomcat-embed-jasper") testImplementation(project(":spring-boot-project:spring-boot-starters:spring-boot-starter-test")) - - testRuntimeOnly("org.junit.platform:junit-platform-launcher") } diff --git a/spring-boot-tests/spring-boot-smoke-tests/spring-boot-smoke-test-tomcat-multi-connectors/build.gradle b/spring-boot-tests/spring-boot-smoke-tests/spring-boot-smoke-test-tomcat-multi-connectors/build.gradle index 4608f2d10728..a5d348812594 100644 --- a/spring-boot-tests/spring-boot-smoke-tests/spring-boot-smoke-test-tomcat-multi-connectors/build.gradle +++ b/spring-boot-tests/spring-boot-smoke-tests/spring-boot-smoke-test-tomcat-multi-connectors/build.gradle @@ -10,6 +10,4 @@ dependencies { testImplementation(project(":spring-boot-project:spring-boot-starters:spring-boot-starter-test")) testImplementation("org.apache.httpcomponents:httpclient") - - testRuntimeOnly("org.junit.platform:junit-platform-launcher") } diff --git a/spring-boot-tests/spring-boot-smoke-tests/spring-boot-smoke-test-tomcat-ssl/build.gradle b/spring-boot-tests/spring-boot-smoke-tests/spring-boot-smoke-test-tomcat-ssl/build.gradle index 32060d491c9e..cf32104bf8d9 100644 --- a/spring-boot-tests/spring-boot-smoke-tests/spring-boot-smoke-test-tomcat-ssl/build.gradle +++ b/spring-boot-tests/spring-boot-smoke-tests/spring-boot-smoke-test-tomcat-ssl/build.gradle @@ -10,6 +10,4 @@ dependencies { testImplementation(project(":spring-boot-project:spring-boot-starters:spring-boot-starter-test")) testImplementation("org.apache.httpcomponents:httpclient") - - testRuntimeOnly("org.junit.platform:junit-platform-launcher") } diff --git a/spring-boot-tests/spring-boot-smoke-tests/spring-boot-smoke-test-tomcat/build.gradle b/spring-boot-tests/spring-boot-smoke-tests/spring-boot-smoke-test-tomcat/build.gradle index 0bc12f506817..f5839181d10f 100644 --- a/spring-boot-tests/spring-boot-smoke-tests/spring-boot-smoke-test-tomcat/build.gradle +++ b/spring-boot-tests/spring-boot-smoke-tests/spring-boot-smoke-test-tomcat/build.gradle @@ -11,6 +11,4 @@ dependencies { implementation("org.springframework:spring-webmvc") testImplementation(project(":spring-boot-project:spring-boot-starters:spring-boot-starter-test")) - - testRuntimeOnly("org.junit.platform:junit-platform-launcher") } diff --git a/spring-boot-tests/spring-boot-smoke-tests/spring-boot-smoke-test-traditional/build.gradle b/spring-boot-tests/spring-boot-smoke-tests/spring-boot-smoke-test-traditional/build.gradle index 0a80fcb36786..bc16f0a0b814 100644 --- a/spring-boot-tests/spring-boot-smoke-tests/spring-boot-smoke-test-traditional/build.gradle +++ b/spring-boot-tests/spring-boot-smoke-tests/spring-boot-smoke-test-traditional/build.gradle @@ -20,6 +20,4 @@ dependencies { testImplementation(project(":spring-boot-project:spring-boot-starters:spring-boot-starter-test")) testImplementation("org.apache.httpcomponents:httpclient") - - testRuntimeOnly("org.junit.platform:junit-platform-launcher") } diff --git a/spring-boot-tests/spring-boot-smoke-tests/spring-boot-smoke-test-undertow-ssl/build.gradle b/spring-boot-tests/spring-boot-smoke-tests/spring-boot-smoke-test-undertow-ssl/build.gradle index 7c206ffe52de..2cf550b516f9 100644 --- a/spring-boot-tests/spring-boot-smoke-tests/spring-boot-smoke-test-undertow-ssl/build.gradle +++ b/spring-boot-tests/spring-boot-smoke-tests/spring-boot-smoke-test-undertow-ssl/build.gradle @@ -13,6 +13,4 @@ dependencies { testImplementation(project(":spring-boot-project:spring-boot-starters:spring-boot-starter-test")) testImplementation("org.apache.httpcomponents:httpclient") - - testRuntimeOnly("org.junit.platform:junit-platform-launcher") } diff --git a/spring-boot-tests/spring-boot-smoke-tests/spring-boot-smoke-test-undertow/build.gradle b/spring-boot-tests/spring-boot-smoke-tests/spring-boot-smoke-test-undertow/build.gradle index 0bb5a3a4fa35..e125db178981 100644 --- a/spring-boot-tests/spring-boot-smoke-tests/spring-boot-smoke-test-undertow/build.gradle +++ b/spring-boot-tests/spring-boot-smoke-tests/spring-boot-smoke-test-undertow/build.gradle @@ -12,6 +12,4 @@ dependencies { implementation(project(":spring-boot-project:spring-boot-starters:spring-boot-starter-undertow")) testImplementation(project(":spring-boot-project:spring-boot-starters:spring-boot-starter-test")) - - testRuntimeOnly("org.junit.platform:junit-platform-launcher") } diff --git a/spring-boot-tests/spring-boot-smoke-tests/spring-boot-smoke-test-war/build.gradle b/spring-boot-tests/spring-boot-smoke-tests/spring-boot-smoke-test-war/build.gradle index 1d80b78203ac..6aceb3d640bc 100644 --- a/spring-boot-tests/spring-boot-smoke-tests/spring-boot-smoke-test-war/build.gradle +++ b/spring-boot-tests/spring-boot-smoke-tests/spring-boot-smoke-test-war/build.gradle @@ -19,6 +19,4 @@ dependencies { providedCompile("jakarta.servlet:jakarta.servlet-api") testImplementation(project(":spring-boot-project:spring-boot-starters:spring-boot-starter-test")) - - testRuntimeOnly("org.junit.platform:junit-platform-launcher") } diff --git a/spring-boot-tests/spring-boot-smoke-tests/spring-boot-smoke-test-web-freemarker/build.gradle b/spring-boot-tests/spring-boot-smoke-tests/spring-boot-smoke-test-web-freemarker/build.gradle index 9185a2f3b1e5..c734861fd5c1 100644 --- a/spring-boot-tests/spring-boot-smoke-tests/spring-boot-smoke-test-web-freemarker/build.gradle +++ b/spring-boot-tests/spring-boot-smoke-tests/spring-boot-smoke-test-web-freemarker/build.gradle @@ -10,6 +10,4 @@ dependencies { implementation(project(":spring-boot-project:spring-boot-starters:spring-boot-starter-web")) testImplementation(project(":spring-boot-project:spring-boot-starters:spring-boot-starter-test")) - - testRuntimeOnly("org.junit.platform:junit-platform-launcher") } diff --git a/spring-boot-tests/spring-boot-smoke-tests/spring-boot-smoke-test-web-groovy-templates/build.gradle b/spring-boot-tests/spring-boot-smoke-tests/spring-boot-smoke-test-web-groovy-templates/build.gradle index 65bdd8d81013..88e11842cb18 100644 --- a/spring-boot-tests/spring-boot-smoke-tests/spring-boot-smoke-test-web-groovy-templates/build.gradle +++ b/spring-boot-tests/spring-boot-smoke-tests/spring-boot-smoke-test-web-groovy-templates/build.gradle @@ -13,6 +13,4 @@ dependencies { } testImplementation(project(":spring-boot-project:spring-boot-starters:spring-boot-starter-test")) - - testRuntimeOnly("org.junit.platform:junit-platform-launcher") } diff --git a/spring-boot-tests/spring-boot-smoke-tests/spring-boot-smoke-test-web-jsp/build.gradle b/spring-boot-tests/spring-boot-smoke-tests/spring-boot-smoke-test-web-jsp/build.gradle index 5bf259d6d512..6c1baf158855 100644 --- a/spring-boot-tests/spring-boot-smoke-tests/spring-boot-smoke-test-web-jsp/build.gradle +++ b/spring-boot-tests/spring-boot-smoke-tests/spring-boot-smoke-test-web-jsp/build.gradle @@ -19,6 +19,4 @@ dependencies { providedRuntime("org.apache.tomcat.embed:tomcat-embed-jasper") testImplementation(project(":spring-boot-project:spring-boot-starters:spring-boot-starter-test")) - - testRuntimeOnly("org.junit.platform:junit-platform-launcher") } diff --git a/spring-boot-tests/spring-boot-smoke-tests/spring-boot-smoke-test-web-method-security/build.gradle b/spring-boot-tests/spring-boot-smoke-tests/spring-boot-smoke-test-web-method-security/build.gradle index af3ac3f1a375..c588cce09dd9 100644 --- a/spring-boot-tests/spring-boot-smoke-tests/spring-boot-smoke-test-web-method-security/build.gradle +++ b/spring-boot-tests/spring-boot-smoke-tests/spring-boot-smoke-test-web-method-security/build.gradle @@ -12,6 +12,4 @@ dependencies { implementation(project(":spring-boot-project:spring-boot-starters:spring-boot-starter-web")) testImplementation(project(":spring-boot-project:spring-boot-starters:spring-boot-starter-test")) - - testRuntimeOnly("org.junit.platform:junit-platform-launcher") } diff --git a/spring-boot-tests/spring-boot-smoke-tests/spring-boot-smoke-test-web-mustache/build.gradle b/spring-boot-tests/spring-boot-smoke-tests/spring-boot-smoke-test-web-mustache/build.gradle index 1a212f595c7e..60950b2e735e 100644 --- a/spring-boot-tests/spring-boot-smoke-tests/spring-boot-smoke-test-web-mustache/build.gradle +++ b/spring-boot-tests/spring-boot-smoke-tests/spring-boot-smoke-test-web-mustache/build.gradle @@ -10,6 +10,4 @@ dependencies { implementation(project(":spring-boot-project:spring-boot-starters:spring-boot-starter-web")) testImplementation(project(":spring-boot-project:spring-boot-starters:spring-boot-starter-test")) - - testRuntimeOnly("org.junit.platform:junit-platform-launcher") } diff --git a/spring-boot-tests/spring-boot-smoke-tests/spring-boot-smoke-test-web-secure-custom/build.gradle b/spring-boot-tests/spring-boot-smoke-tests/spring-boot-smoke-test-web-secure-custom/build.gradle index 9932c3a295df..38dd5599c8f4 100644 --- a/spring-boot-tests/spring-boot-smoke-tests/spring-boot-smoke-test-web-secure-custom/build.gradle +++ b/spring-boot-tests/spring-boot-smoke-tests/spring-boot-smoke-test-web-secure-custom/build.gradle @@ -12,6 +12,4 @@ dependencies { testImplementation(project(":spring-boot-project:spring-boot-starters:spring-boot-starter-test")) testImplementation("org.apache.httpcomponents:httpclient") - - testRuntimeOnly("org.junit.platform:junit-platform-launcher") } diff --git a/spring-boot-tests/spring-boot-smoke-tests/spring-boot-smoke-test-web-secure-jdbc/build.gradle b/spring-boot-tests/spring-boot-smoke-tests/spring-boot-smoke-test-web-secure-jdbc/build.gradle index 5151e2afc047..1f9c274153a1 100644 --- a/spring-boot-tests/spring-boot-smoke-tests/spring-boot-smoke-test-web-secure-jdbc/build.gradle +++ b/spring-boot-tests/spring-boot-smoke-tests/spring-boot-smoke-test-web-secure-jdbc/build.gradle @@ -15,6 +15,4 @@ dependencies { testImplementation(project(":spring-boot-project:spring-boot-starters:spring-boot-starter-test")) testImplementation("org.apache.httpcomponents:httpclient") - - testRuntimeOnly("org.junit.platform:junit-platform-launcher") } diff --git a/spring-boot-tests/spring-boot-smoke-tests/spring-boot-smoke-test-web-secure/build.gradle b/spring-boot-tests/spring-boot-smoke-tests/spring-boot-smoke-test-web-secure/build.gradle index 55814d61dec4..8b3a7d1bbf95 100644 --- a/spring-boot-tests/spring-boot-smoke-tests/spring-boot-smoke-test-web-secure/build.gradle +++ b/spring-boot-tests/spring-boot-smoke-tests/spring-boot-smoke-test-web-secure/build.gradle @@ -13,6 +13,4 @@ dependencies { testImplementation(project(":spring-boot-project:spring-boot-starters:spring-boot-starter-test")) testImplementation("org.apache.httpcomponents:httpclient") - - testRuntimeOnly("org.junit.platform:junit-platform-launcher") } diff --git a/spring-boot-tests/spring-boot-smoke-tests/spring-boot-smoke-test-web-static/build.gradle b/spring-boot-tests/spring-boot-smoke-tests/spring-boot-smoke-test-web-static/build.gradle index 753340b96ddf..67236bd4716d 100644 --- a/spring-boot-tests/spring-boot-smoke-tests/spring-boot-smoke-test-web-static/build.gradle +++ b/spring-boot-tests/spring-boot-smoke-tests/spring-boot-smoke-test-web-static/build.gradle @@ -20,6 +20,4 @@ dependencies { runtimeOnly("org.webjars:jquery:2.0.3-1") testImplementation(project(":spring-boot-project:spring-boot-starters:spring-boot-starter-test")) - - testRuntimeOnly("org.junit.platform:junit-platform-launcher") } diff --git a/spring-boot-tests/spring-boot-smoke-tests/spring-boot-smoke-test-web-ui/build.gradle b/spring-boot-tests/spring-boot-smoke-tests/spring-boot-smoke-test-web-ui/build.gradle index 297dcd5dadff..388be0e26e43 100644 --- a/spring-boot-tests/spring-boot-smoke-tests/spring-boot-smoke-test-web-ui/build.gradle +++ b/spring-boot-tests/spring-boot-smoke-tests/spring-boot-smoke-test-web-ui/build.gradle @@ -11,6 +11,4 @@ dependencies { implementation(project(":spring-boot-project:spring-boot-starters:spring-boot-starter-validation")) testImplementation(project(":spring-boot-project:spring-boot-starters:spring-boot-starter-test")) - - testRuntimeOnly("org.junit.platform:junit-platform-launcher") } diff --git a/spring-boot-tests/spring-boot-smoke-tests/spring-boot-smoke-test-webflux-coroutines/build.gradle b/spring-boot-tests/spring-boot-smoke-tests/spring-boot-smoke-test-webflux-coroutines/build.gradle index 381c3526441c..8d38e295b893 100644 --- a/spring-boot-tests/spring-boot-smoke-tests/spring-boot-smoke-test-webflux-coroutines/build.gradle +++ b/spring-boot-tests/spring-boot-smoke-tests/spring-boot-smoke-test-webflux-coroutines/build.gradle @@ -27,6 +27,4 @@ dependencies { testImplementation(project(":spring-boot-project:spring-boot-starters:spring-boot-starter-test")) testImplementation("io.projectreactor:reactor-test") - - testRuntimeOnly("org.junit.platform:junit-platform-launcher") } diff --git a/spring-boot-tests/spring-boot-smoke-tests/spring-boot-smoke-test-webflux/build.gradle b/spring-boot-tests/spring-boot-smoke-tests/spring-boot-smoke-test-webflux/build.gradle index ec57092fc0b2..f0a6461ff720 100644 --- a/spring-boot-tests/spring-boot-smoke-tests/spring-boot-smoke-test-webflux/build.gradle +++ b/spring-boot-tests/spring-boot-smoke-tests/spring-boot-smoke-test-webflux/build.gradle @@ -11,6 +11,4 @@ dependencies { testImplementation(project(":spring-boot-project:spring-boot-starters:spring-boot-starter-test")) testImplementation("io.projectreactor:reactor-test") - - testRuntimeOnly("org.junit.platform:junit-platform-launcher") } diff --git a/spring-boot-tests/spring-boot-smoke-tests/spring-boot-smoke-test-webservices/build.gradle b/spring-boot-tests/spring-boot-smoke-tests/spring-boot-smoke-test-webservices/build.gradle index a3adf617b9a1..8fd51c9c9dbf 100644 --- a/spring-boot-tests/spring-boot-smoke-tests/spring-boot-smoke-test-webservices/build.gradle +++ b/spring-boot-tests/spring-boot-smoke-tests/spring-boot-smoke-test-webservices/build.gradle @@ -17,6 +17,4 @@ dependencies { } testImplementation(project(":spring-boot-project:spring-boot-starters:spring-boot-starter-test")) - - testRuntimeOnly("org.junit.platform:junit-platform-launcher") } diff --git a/spring-boot-tests/spring-boot-smoke-tests/spring-boot-smoke-test-websocket-jetty/build.gradle b/spring-boot-tests/spring-boot-smoke-tests/spring-boot-smoke-test-websocket-jetty/build.gradle index 0622ae3e74ef..58e1f903b5c6 100644 --- a/spring-boot-tests/spring-boot-smoke-tests/spring-boot-smoke-test-websocket-jetty/build.gradle +++ b/spring-boot-tests/spring-boot-smoke-tests/spring-boot-smoke-test-websocket-jetty/build.gradle @@ -12,6 +12,4 @@ dependencies { } testImplementation(project(":spring-boot-project:spring-boot-starters:spring-boot-starter-test")) - - testRuntimeOnly("org.junit.platform:junit-platform-launcher") } diff --git a/spring-boot-tests/spring-boot-smoke-tests/spring-boot-smoke-test-websocket-tomcat/build.gradle b/spring-boot-tests/spring-boot-smoke-tests/spring-boot-smoke-test-websocket-tomcat/build.gradle index b973e4c1db0c..e15f1c653aa9 100644 --- a/spring-boot-tests/spring-boot-smoke-tests/spring-boot-smoke-test-websocket-tomcat/build.gradle +++ b/spring-boot-tests/spring-boot-smoke-tests/spring-boot-smoke-test-websocket-tomcat/build.gradle @@ -9,6 +9,4 @@ dependencies { implementation(project(":spring-boot-project:spring-boot-starters:spring-boot-starter-websocket")) testImplementation(project(":spring-boot-project:spring-boot-starters:spring-boot-starter-test")) - - testRuntimeOnly("org.junit.platform:junit-platform-launcher") } diff --git a/spring-boot-tests/spring-boot-smoke-tests/spring-boot-smoke-test-websocket-undertow/build.gradle b/spring-boot-tests/spring-boot-smoke-tests/spring-boot-smoke-test-websocket-undertow/build.gradle index 9f4dbe00950f..9b3d85799f28 100644 --- a/spring-boot-tests/spring-boot-smoke-tests/spring-boot-smoke-test-websocket-undertow/build.gradle +++ b/spring-boot-tests/spring-boot-smoke-tests/spring-boot-smoke-test-websocket-undertow/build.gradle @@ -12,6 +12,4 @@ dependencies { } testImplementation(project(":spring-boot-project:spring-boot-starters:spring-boot-starter-test")) - - testRuntimeOnly("org.junit.platform:junit-platform-launcher") } diff --git a/spring-boot-tests/spring-boot-smoke-tests/spring-boot-smoke-test-xml/build.gradle b/spring-boot-tests/spring-boot-smoke-tests/spring-boot-smoke-test-xml/build.gradle index 8987b7753ab6..63103e966c72 100644 --- a/spring-boot-tests/spring-boot-smoke-tests/spring-boot-smoke-test-xml/build.gradle +++ b/spring-boot-tests/spring-boot-smoke-tests/spring-boot-smoke-test-xml/build.gradle @@ -9,6 +9,4 @@ dependencies { implementation(project(":spring-boot-project:spring-boot-starters:spring-boot-starter")) testImplementation(project(":spring-boot-project:spring-boot-starters:spring-boot-starter-test")) - - testRuntimeOnly("org.junit.platform:junit-platform-launcher") } From 91ccc2346263583dccb4e0efb85303dba28d9a34 Mon Sep 17 00:00:00 2001 From: Phillip Webb Date: Tue, 2 Feb 2021 11:20:32 -0800 Subject: [PATCH 02/13] Restructure spring-boot-docs packages Restructure the packages in `spring-boot-docs` so that they mirror the documentation sections. There are now three main packages: `springbootfeatures`, `productionreadyfeatures` and `howto`. Each of the main packages has a subpackage named after the section headings. Example code now uses consistent `// tag::` names and imports are applied using `[tag=*]` whenever possible. Test snippets have been moved to `src/main/java` so that only a single import attribute needs to be defined. Closes gh-25089 --- .../src/docs/asciidoc/attributes.adoc | 9 ++- .../src/docs/asciidoc/howto.adoc | 34 +++++----- .../asciidoc/production-ready-features.adoc | 12 ++-- .../docs/asciidoc/spring-boot-features.adoc | 62 +++++++++---------- .../MetricsHealthMicrometerExportExample.java | 8 +-- .../docs/howto/actuator/package-info.java | 20 ++++++ .../howto/batchapplications/package-info.java | 20 ++++++ .../boot/docs/howto/build/package-info.java | 20 ++++++ .../dataaccess}/BasicDataSourceExample.java | 8 +-- ...veSpringPhysicalNamingStrategyExample.java | 8 +-- .../CompleteTwoDataSourcesExample.java | 8 +-- .../ConfigurableDataSourceExample.java | 8 +-- .../HibernateSearchElasticsearchExample.java | 8 +-- .../HibernateSecondLevelCacheExample.java | 8 +-- .../R2dbcDatabaseInitializationExample.java | 8 +-- .../dataaccess}/SimpleDataSourceExample.java | 8 +-- .../SimpleTwoDataSourcesExample.java | 8 +-- .../docs/howto/dataaccess/package-info.java | 20 ++++++ .../databaseinitialization/package-info.java | 20 ++++++ .../TomcatLegacyCookieProcessorExample.java | 8 +-- .../TomcatMultipleConnectorsExample.java | 6 +- .../UndertowMultipleListenersExample.java | 6 +- .../embeddedwebservers/package-info.java | 20 ++++++ .../docs/howto/hotswapping/package-info.java | 20 ++++++ ...eactorNettyClientCustomizationExample.java | 8 +-- .../docs/howto/httpclients/package-info.java | 20 ++++++ .../JerseySetStatusOverSendErrorExample.java | 8 +-- .../boot/docs/howto/jersey/package-info.java | 20 ++++++ .../boot/docs/howto/logging/package-info.java | 20 ++++++ .../docs/howto/messaging/package-info.java | 20 ++++++ .../package-info.java | 20 ++++++ .../docs/howto/security/package-info.java | 20 ++++++ .../EnvironmentPostProcessorExample.java | 13 ++-- .../springbootapplication/package-info.java | 20 ++++++ .../docs/howto/springmvc/package-info.java | 20 ++++++ .../package-info.java | 20 ++++++ .../traditionaldeployment/package-info.java | 20 ++++++ .../auditing/package-info.java | 20 ++++++ .../CloudFoundryCustomContextPathExample.java | 8 +-- .../cloudfoundry/package-info.java | 20 ++++++ .../enabling/package-info.java | 21 +++++++ .../endpoints}/CustomEndpointExample.java | 12 +++- .../endpoints/package-info.java | 20 ++++++ .../httptracing/package-info.java | 20 ++++++ .../loggers/package-info.java | 20 ++++++ .../metrics/MetricsFilterBeanExample.java | 8 +-- .../MetricsMeterRegistryInjectionExample.java | 10 +-- .../SampleMeterBinderConfiguration.java | 8 +-- .../metrics/package-info.java | 20 ++++++ .../monitoring/http/package-info.java | 21 +++++++ .../monitoring/jmx/package-info.java | 21 +++++++ .../processmonitoring/package-info.java | 20 ++++++ .../caching/package-info.java | 20 ++++++ .../containerimages/package-info.java | 20 ++++++ .../UserService.java | 4 +- .../UserServiceAutoConfiguration.java | 6 +- .../package-info.java | 20 ++++++ .../email/package-info.java | 20 ++++++ .../constructorbinding}/AppIoProperties.java | 8 +-- .../javabeanbinding}/AppIoProperties.java | 8 +-- .../AppSystemProperties.java | 8 +-- .../javabeanbinding}/AppSystemProperties.java | 8 +-- .../package-info.java | 20 ++++++ .../gracefulshutdown/package-info.java | 20 ++++++ .../hazelcast/package-info.java | 20 ++++++ .../integration/package-info.java | 20 ++++++ .../internationalization/package-info.java | 20 ++++++ .../springbootfeatures/json/package-info.java | 20 ++++++ .../springbootfeatures/jta/package-info.java | 20 ++++++ .../kotlin/package-info.java | 20 ++++++ .../logging/package-info.java | 20 ++++++ .../messaging}/KafkaStreamsBeanExample.java | 8 +-- .../messaging/package-info.java | 20 ++++++ .../monitoring/jmx/package-info.java | 20 ++++++ ...hbaseCacheManagerCustomizationExample.java | 8 +-- ...eo4jReactiveTransactionManagerExample.java | 8 +-- ...RedisCacheManagerCustomizationExample.java | 8 +-- .../nosql/package-info.java | 20 ++++++ .../profiles/package-info.java | 20 ++++++ .../quartz/package-info.java | 20 ++++++ ...stTemplateBuilderCustomizationExample.java | 8 +-- ...RestTemplateProxyCustomizationExample.java | 8 +-- .../resttemplate/package-info.java | 21 +++++++ .../rsocket/package-info.java | 20 ++++++ .../CustomWebFluxSecurityExample.java | 8 +-- .../security/package-info.java | 20 ++++++ .../session/package-info.java | 20 ++++++ .../springapplication/ExitCodeExample.java} | 12 ++-- .../SpringApplicationBuilderExample.java | 8 +-- .../springapplication/package-info.java | 20 ++++++ .../springbootfeatures/sql/package-info.java | 20 ++++++ .../springbootfeatures/task/package-info.java | 20 ++++++ .../ApplicationArgumentsExampleTests.java | 8 +-- .../testing}/MockMvcExampleTests.java | 8 +-- .../MockWebTestClientExampleTests.java | 8 +-- .../testing}/OutputCaptureTests.java | 8 +-- ...andomPortTestRestTemplateExampleTests.java | 8 +-- .../RandomPortWebTestClientExampleTests.java | 8 +-- .../UserServiceAutoConfigurationTests.java | 6 +- .../testing}/jmx/SampleApp.java | 4 +- .../testing}/jmx/SampleJmxTests.java | 8 +-- .../testing/package-info.java | 20 ++++++ .../AdvancedConfigurationExample.java | 8 +-- .../restassured/UserDocumentationTests.java | 8 +-- .../AdvancedConfigurationExample.java | 8 +-- .../webclient/UsersDocumentationTests.java | 8 +-- .../SampleWebClientConfiguration.java | 4 +- .../webclient}/SampleWebClientTests.java | 8 +-- .../validation/package-info.java | 20 ++++++ .../TomcatServerCustomizerExample.java | 6 +- .../webapplications/package-info.java | 20 ++++++ .../webclient/package-info.java | 20 ++++++ .../websockets/package-info.java | 20 ++++++ ...mcatLegacyCookieProcessorExampleTests.java | 5 +- ...icsHealthMicrometerExportExampleTests.java | 4 +- .../BasicDataSourceExampleTests.java | 4 +- .../CompleteTwoDataSourcesExampleTests.java | 4 +- .../ConfigurableDataSourceExampleTests.java | 4 +- .../{jdbc => howto/dataaccess}/SampleApp.java | 4 +- .../SimpleDataSourceExampleTests.java | 4 +- .../SimpleTwoDataSourcesExampleTests.java | 4 +- .../EnvironmentPostProcessorExampleTests.java | 4 +- .../AppSystemPropertiesTests.java | 4 +- .../AppSystemPropertiesTests.java | 4 +- .../SpringApplicationBuilderExampleTests.java | 4 +- .../testing/OutputCaptureTestsTests.java | 26 ++++++++ ...serServiceAutoConfigurationTestsTests.java | 26 ++++++++ .../testing/jmx/SampleJmxTestsTests.java | 26 ++++++++ .../webclient/SampleWebClientTestsTests.java | 26 ++++++++ 129 files changed, 1540 insertions(+), 283 deletions(-) rename spring-boot-project/spring-boot-docs/src/main/java/org/springframework/boot/docs/{actuate/metrics => howto/actuator}/MetricsHealthMicrometerExportExample.java (91%) create mode 100644 spring-boot-project/spring-boot-docs/src/main/java/org/springframework/boot/docs/howto/actuator/package-info.java create mode 100644 spring-boot-project/spring-boot-docs/src/main/java/org/springframework/boot/docs/howto/batchapplications/package-info.java create mode 100644 spring-boot-project/spring-boot-docs/src/main/java/org/springframework/boot/docs/howto/build/package-info.java rename spring-boot-project/spring-boot-docs/src/main/java/org/springframework/boot/docs/{jdbc => howto/dataaccess}/BasicDataSourceExample.java (89%) rename spring-boot-project/spring-boot-docs/src/main/java/org/springframework/boot/docs/{jpa => howto/dataaccess}/CaseSensitiveSpringPhysicalNamingStrategyExample.java (88%) rename spring-boot-project/spring-boot-docs/src/main/java/org/springframework/boot/docs/{jdbc => howto/dataaccess}/CompleteTwoDataSourcesExample.java (93%) rename spring-boot-project/spring-boot-docs/src/main/java/org/springframework/boot/docs/{jdbc => howto/dataaccess}/ConfigurableDataSourceExample.java (92%) rename spring-boot-project/spring-boot-docs/src/main/java/org/springframework/boot/docs/{elasticsearch => howto/dataaccess}/HibernateSearchElasticsearchExample.java (89%) rename spring-boot-project/spring-boot-docs/src/main/java/org/springframework/boot/docs/{jpa => howto/dataaccess}/HibernateSecondLevelCacheExample.java (90%) rename spring-boot-project/spring-boot-docs/src/main/java/org/springframework/boot/docs/{r2dbc => howto/dataaccess}/R2dbcDatabaseInitializationExample.java (91%) rename spring-boot-project/spring-boot-docs/src/main/java/org/springframework/boot/docs/{jdbc => howto/dataaccess}/SimpleDataSourceExample.java (90%) rename spring-boot-project/spring-boot-docs/src/main/java/org/springframework/boot/docs/{jdbc => howto/dataaccess}/SimpleTwoDataSourcesExample.java (93%) create mode 100644 spring-boot-project/spring-boot-docs/src/main/java/org/springframework/boot/docs/howto/dataaccess/package-info.java create mode 100644 spring-boot-project/spring-boot-docs/src/main/java/org/springframework/boot/docs/howto/databaseinitialization/package-info.java rename spring-boot-project/spring-boot-docs/src/main/java/org/springframework/boot/docs/{context/embedded => howto/embeddedwebservers}/TomcatLegacyCookieProcessorExample.java (90%) rename spring-boot-project/spring-boot-docs/src/main/java/org/springframework/boot/docs/{context/embedded => howto/embeddedwebservers}/TomcatMultipleConnectorsExample.java (95%) rename spring-boot-project/spring-boot-docs/src/main/java/org/springframework/boot/docs/{context/embedded => howto/embeddedwebservers}/UndertowMultipleListenersExample.java (93%) create mode 100644 spring-boot-project/spring-boot-docs/src/main/java/org/springframework/boot/docs/howto/embeddedwebservers/package-info.java create mode 100644 spring-boot-project/spring-boot-docs/src/main/java/org/springframework/boot/docs/howto/hotswapping/package-info.java rename spring-boot-project/spring-boot-docs/src/main/java/org/springframework/boot/docs/{web/reactive/function/client => howto/httpclients}/ReactorNettyClientCustomizationExample.java (90%) create mode 100644 spring-boot-project/spring-boot-docs/src/main/java/org/springframework/boot/docs/howto/httpclients/package-info.java rename spring-boot-project/spring-boot-docs/src/main/java/org/springframework/boot/docs/{ => howto}/jersey/JerseySetStatusOverSendErrorExample.java (89%) create mode 100644 spring-boot-project/spring-boot-docs/src/main/java/org/springframework/boot/docs/howto/jersey/package-info.java create mode 100644 spring-boot-project/spring-boot-docs/src/main/java/org/springframework/boot/docs/howto/logging/package-info.java create mode 100644 spring-boot-project/spring-boot-docs/src/main/java/org/springframework/boot/docs/howto/messaging/package-info.java create mode 100644 spring-boot-project/spring-boot-docs/src/main/java/org/springframework/boot/docs/howto/propertiesandconfiguration/package-info.java create mode 100644 spring-boot-project/spring-boot-docs/src/main/java/org/springframework/boot/docs/howto/security/package-info.java rename spring-boot-project/spring-boot-docs/src/main/java/org/springframework/boot/docs/{context => howto/springbootapplication}/EnvironmentPostProcessorExample.java (87%) create mode 100644 spring-boot-project/spring-boot-docs/src/main/java/org/springframework/boot/docs/howto/springbootapplication/package-info.java create mode 100644 spring-boot-project/spring-boot-docs/src/main/java/org/springframework/boot/docs/howto/springmvc/package-info.java create mode 100644 spring-boot-project/spring-boot-docs/src/main/java/org/springframework/boot/docs/howto/testingwithspringsecurity/package-info.java create mode 100644 spring-boot-project/spring-boot-docs/src/main/java/org/springframework/boot/docs/howto/traditionaldeployment/package-info.java create mode 100644 spring-boot-project/spring-boot-docs/src/main/java/org/springframework/boot/docs/productionreadyfeatures/auditing/package-info.java rename spring-boot-project/spring-boot-docs/src/main/java/org/springframework/boot/docs/{ => productionreadyfeatures}/cloudfoundry/CloudFoundryCustomContextPathExample.java (94%) create mode 100644 spring-boot-project/spring-boot-docs/src/main/java/org/springframework/boot/docs/productionreadyfeatures/cloudfoundry/package-info.java create mode 100644 spring-boot-project/spring-boot-docs/src/main/java/org/springframework/boot/docs/productionreadyfeatures/enabling/package-info.java rename spring-boot-project/spring-boot-docs/src/main/java/org/springframework/boot/docs/{actuate/endpoint => productionreadyfeatures/endpoints}/CustomEndpointExample.java (85%) create mode 100644 spring-boot-project/spring-boot-docs/src/main/java/org/springframework/boot/docs/productionreadyfeatures/endpoints/package-info.java create mode 100644 spring-boot-project/spring-boot-docs/src/main/java/org/springframework/boot/docs/productionreadyfeatures/httptracing/package-info.java create mode 100644 spring-boot-project/spring-boot-docs/src/main/java/org/springframework/boot/docs/productionreadyfeatures/loggers/package-info.java rename spring-boot-project/spring-boot-docs/src/main/java/org/springframework/boot/docs/{actuate => productionreadyfeatures}/metrics/MetricsFilterBeanExample.java (87%) rename spring-boot-project/spring-boot-docs/src/main/java/org/springframework/boot/docs/{actuate => productionreadyfeatures}/metrics/MetricsMeterRegistryInjectionExample.java (86%) rename spring-boot-project/spring-boot-docs/src/main/java/org/springframework/boot/docs/{actuate => productionreadyfeatures}/metrics/SampleMeterBinderConfiguration.java (87%) create mode 100644 spring-boot-project/spring-boot-docs/src/main/java/org/springframework/boot/docs/productionreadyfeatures/metrics/package-info.java create mode 100644 spring-boot-project/spring-boot-docs/src/main/java/org/springframework/boot/docs/productionreadyfeatures/monitoring/http/package-info.java create mode 100644 spring-boot-project/spring-boot-docs/src/main/java/org/springframework/boot/docs/productionreadyfeatures/monitoring/jmx/package-info.java create mode 100644 spring-boot-project/spring-boot-docs/src/main/java/org/springframework/boot/docs/productionreadyfeatures/processmonitoring/package-info.java create mode 100644 spring-boot-project/spring-boot-docs/src/main/java/org/springframework/boot/docs/springbootfeatures/caching/package-info.java create mode 100644 spring-boot-project/spring-boot-docs/src/main/java/org/springframework/boot/docs/springbootfeatures/containerimages/package-info.java rename spring-boot-project/spring-boot-docs/src/main/java/org/springframework/boot/docs/{autoconfigure => springbootfeatures/creatingautoconfiguration}/UserService.java (85%) rename spring-boot-project/spring-boot-docs/src/main/java/org/springframework/boot/docs/{autoconfigure => springbootfeatures/creatingautoconfiguration}/UserServiceAutoConfiguration.java (85%) create mode 100644 spring-boot-project/spring-boot-docs/src/main/java/org/springframework/boot/docs/springbootfeatures/creatingautoconfiguration/package-info.java create mode 100644 spring-boot-project/spring-boot-docs/src/main/java/org/springframework/boot/docs/springbootfeatures/email/package-info.java rename spring-boot-project/spring-boot-docs/src/main/java/org/springframework/boot/docs/{context/properties/bind/constructor => springbootfeatures/externalizedconfiguration/datasize/constructorbinding}/AppIoProperties.java (89%) rename spring-boot-project/spring-boot-docs/src/main/java/org/springframework/boot/docs/{context/properties/bind/javabean => springbootfeatures/externalizedconfiguration/datasize/javabeanbinding}/AppIoProperties.java (88%) rename spring-boot-project/spring-boot-docs/src/main/java/org/springframework/boot/docs/{context/properties/bind/constructor => springbootfeatures/externalizedconfiguration/duration/constructorbinding}/AppSystemProperties.java (89%) rename spring-boot-project/spring-boot-docs/src/main/java/org/springframework/boot/docs/{context/properties/bind/javabean => springbootfeatures/externalizedconfiguration/duration/javabeanbinding}/AppSystemProperties.java (88%) create mode 100644 spring-boot-project/spring-boot-docs/src/main/java/org/springframework/boot/docs/springbootfeatures/externalizedconfiguration/package-info.java create mode 100644 spring-boot-project/spring-boot-docs/src/main/java/org/springframework/boot/docs/springbootfeatures/gracefulshutdown/package-info.java create mode 100644 spring-boot-project/spring-boot-docs/src/main/java/org/springframework/boot/docs/springbootfeatures/hazelcast/package-info.java create mode 100644 spring-boot-project/spring-boot-docs/src/main/java/org/springframework/boot/docs/springbootfeatures/integration/package-info.java create mode 100644 spring-boot-project/spring-boot-docs/src/main/java/org/springframework/boot/docs/springbootfeatures/internationalization/package-info.java create mode 100644 spring-boot-project/spring-boot-docs/src/main/java/org/springframework/boot/docs/springbootfeatures/json/package-info.java create mode 100644 spring-boot-project/spring-boot-docs/src/main/java/org/springframework/boot/docs/springbootfeatures/jta/package-info.java create mode 100644 spring-boot-project/spring-boot-docs/src/main/java/org/springframework/boot/docs/springbootfeatures/kotlin/package-info.java create mode 100644 spring-boot-project/spring-boot-docs/src/main/java/org/springframework/boot/docs/springbootfeatures/logging/package-info.java rename spring-boot-project/spring-boot-docs/src/main/java/org/springframework/boot/docs/{kafka => springbootfeatures/messaging}/KafkaStreamsBeanExample.java (91%) create mode 100644 spring-boot-project/spring-boot-docs/src/main/java/org/springframework/boot/docs/springbootfeatures/messaging/package-info.java create mode 100644 spring-boot-project/spring-boot-docs/src/main/java/org/springframework/boot/docs/springbootfeatures/monitoring/jmx/package-info.java rename spring-boot-project/spring-boot-docs/src/main/java/org/springframework/boot/docs/{cache => springbootfeatures/nosql}/CouchbaseCacheManagerCustomizationExample.java (91%) rename spring-boot-project/spring-boot-docs/src/main/java/org/springframework/boot/docs/{neo4j => springbootfeatures/nosql}/Neo4jReactiveTransactionManagerExample.java (90%) rename spring-boot-project/spring-boot-docs/src/main/java/org/springframework/boot/docs/{cache => springbootfeatures/nosql}/RedisCacheManagerCustomizationExample.java (90%) create mode 100644 spring-boot-project/spring-boot-docs/src/main/java/org/springframework/boot/docs/springbootfeatures/nosql/package-info.java create mode 100644 spring-boot-project/spring-boot-docs/src/main/java/org/springframework/boot/docs/springbootfeatures/profiles/package-info.java create mode 100644 spring-boot-project/spring-boot-docs/src/main/java/org/springframework/boot/docs/springbootfeatures/quartz/package-info.java rename spring-boot-project/spring-boot-docs/src/main/java/org/springframework/boot/docs/{web/client => springbootfeatures/resttemplate}/RestTemplateBuilderCustomizationExample.java (89%) rename spring-boot-project/spring-boot-docs/src/main/java/org/springframework/boot/docs/{web/client => springbootfeatures/resttemplate}/RestTemplateProxyCustomizationExample.java (92%) create mode 100644 spring-boot-project/spring-boot-docs/src/main/java/org/springframework/boot/docs/springbootfeatures/resttemplate/package-info.java create mode 100644 spring-boot-project/spring-boot-docs/src/main/java/org/springframework/boot/docs/springbootfeatures/rsocket/package-info.java rename spring-boot-project/spring-boot-docs/src/main/java/org/springframework/boot/docs/{web => springbootfeatures}/security/CustomWebFluxSecurityExample.java (90%) create mode 100644 spring-boot-project/spring-boot-docs/src/main/java/org/springframework/boot/docs/springbootfeatures/security/package-info.java create mode 100644 spring-boot-project/spring-boot-docs/src/main/java/org/springframework/boot/docs/springbootfeatures/session/package-info.java rename spring-boot-project/spring-boot-docs/src/main/java/org/springframework/boot/docs/{ExitCodeApplication.java => springbootfeatures/springapplication/ExitCodeExample.java} (83%) rename spring-boot-project/spring-boot-docs/src/main/java/org/springframework/boot/docs/{builder => springbootfeatures/springapplication}/SpringApplicationBuilderExample.java (87%) create mode 100644 spring-boot-project/spring-boot-docs/src/main/java/org/springframework/boot/docs/springbootfeatures/springapplication/package-info.java create mode 100644 spring-boot-project/spring-boot-docs/src/main/java/org/springframework/boot/docs/springbootfeatures/sql/package-info.java create mode 100644 spring-boot-project/spring-boot-docs/src/main/java/org/springframework/boot/docs/springbootfeatures/task/package-info.java rename spring-boot-project/spring-boot-docs/src/main/java/org/springframework/boot/docs/{test/context => springbootfeatures/testing}/ApplicationArgumentsExampleTests.java (88%) rename spring-boot-project/spring-boot-docs/src/main/java/org/springframework/boot/docs/{test/web => springbootfeatures/testing}/MockMvcExampleTests.java (90%) rename spring-boot-project/spring-boot-docs/src/main/java/org/springframework/boot/docs/{test/web => springbootfeatures/testing}/MockWebTestClientExampleTests.java (86%) rename spring-boot-project/spring-boot-docs/src/{test/java/org/springframework/boot/docs/test/system => main/java/org/springframework/boot/docs/springbootfeatures/testing}/OutputCaptureTests.java (88%) rename spring-boot-project/spring-boot-docs/src/main/java/org/springframework/boot/docs/{test/web => springbootfeatures/testing}/RandomPortTestRestTemplateExampleTests.java (88%) rename spring-boot-project/spring-boot-docs/src/main/java/org/springframework/boot/docs/{test/web => springbootfeatures/testing}/RandomPortWebTestClientExampleTests.java (88%) rename spring-boot-project/spring-boot-docs/src/{test/java/org/springframework/boot/docs/autoconfigure => main/java/org/springframework/boot/docs/springbootfeatures/testing}/UserServiceAutoConfigurationTests.java (88%) rename spring-boot-project/spring-boot-docs/src/{test/java/org/springframework/boot/docs => main/java/org/springframework/boot/docs/springbootfeatures/testing}/jmx/SampleApp.java (89%) rename spring-boot-project/spring-boot-docs/src/{test/java/org/springframework/boot/docs => main/java/org/springframework/boot/docs/springbootfeatures/testing}/jmx/SampleJmxTests.java (89%) create mode 100644 spring-boot-project/spring-boot-docs/src/main/java/org/springframework/boot/docs/springbootfeatures/testing/package-info.java rename spring-boot-project/spring-boot-docs/src/main/java/org/springframework/boot/docs/{test/autoconfigure => springbootfeatures/testing}/restdocs/restassured/AdvancedConfigurationExample.java (87%) rename spring-boot-project/spring-boot-docs/src/main/java/org/springframework/boot/docs/{test/autoconfigure => springbootfeatures/testing}/restdocs/restassured/UserDocumentationTests.java (89%) rename spring-boot-project/spring-boot-docs/src/main/java/org/springframework/boot/docs/{test/autoconfigure => springbootfeatures/testing}/restdocs/webclient/AdvancedConfigurationExample.java (86%) rename spring-boot-project/spring-boot-docs/src/main/java/org/springframework/boot/docs/{test/autoconfigure => springbootfeatures/testing}/restdocs/webclient/UsersDocumentationTests.java (88%) rename spring-boot-project/spring-boot-docs/src/{test/java/org/springframework/boot/docs/web/client => main/java/org/springframework/boot/docs/springbootfeatures/testing/webclient}/SampleWebClientConfiguration.java (93%) rename spring-boot-project/spring-boot-docs/src/{test/java/org/springframework/boot/docs/web/client => main/java/org/springframework/boot/docs/springbootfeatures/testing/webclient}/SampleWebClientTests.java (92%) create mode 100644 spring-boot-project/spring-boot-docs/src/main/java/org/springframework/boot/docs/springbootfeatures/validation/package-info.java rename spring-boot-project/spring-boot-docs/src/main/java/org/springframework/boot/docs/{context/embedded => springbootfeatures/webapplications}/TomcatServerCustomizerExample.java (92%) create mode 100644 spring-boot-project/spring-boot-docs/src/main/java/org/springframework/boot/docs/springbootfeatures/webapplications/package-info.java create mode 100644 spring-boot-project/spring-boot-docs/src/main/java/org/springframework/boot/docs/springbootfeatures/webclient/package-info.java create mode 100644 spring-boot-project/spring-boot-docs/src/main/java/org/springframework/boot/docs/springbootfeatures/websockets/package-info.java rename spring-boot-project/spring-boot-docs/src/test/java/org/springframework/boot/docs/{actuate/metrics => howto/actuator}/MetricsHealthMicrometerExportExampleTests.java (95%) rename spring-boot-project/spring-boot-docs/src/test/java/org/springframework/boot/docs/{jdbc => howto/dataaccess}/BasicDataSourceExampleTests.java (94%) rename spring-boot-project/spring-boot-docs/src/test/java/org/springframework/boot/docs/{jdbc => howto/dataaccess}/CompleteTwoDataSourcesExampleTests.java (94%) rename spring-boot-project/spring-boot-docs/src/test/java/org/springframework/boot/docs/{jdbc => howto/dataaccess}/ConfigurableDataSourceExampleTests.java (94%) rename spring-boot-project/spring-boot-docs/src/test/java/org/springframework/boot/docs/{jdbc => howto/dataaccess}/SampleApp.java (90%) rename spring-boot-project/spring-boot-docs/src/test/java/org/springframework/boot/docs/{jdbc => howto/dataaccess}/SimpleDataSourceExampleTests.java (94%) rename spring-boot-project/spring-boot-docs/src/test/java/org/springframework/boot/docs/{jdbc => howto/dataaccess}/SimpleTwoDataSourcesExampleTests.java (95%) rename spring-boot-project/spring-boot-docs/src/test/java/org/springframework/boot/docs/{context => howto/springbootapplication}/EnvironmentPostProcessorExampleTests.java (91%) rename spring-boot-project/spring-boot-docs/src/test/java/org/springframework/boot/docs/{context/properties/bind/javabean => springbootfeatures/externalizedconfiguration/duration/constructorbinding}/AppSystemPropertiesTests.java (94%) rename spring-boot-project/spring-boot-docs/src/test/java/org/springframework/boot/docs/{context/properties/bind/constructor => springbootfeatures/externalizedconfiguration/duration/javabeanbinding}/AppSystemPropertiesTests.java (94%) rename spring-boot-project/spring-boot-docs/src/test/java/org/springframework/boot/docs/{builder => springbootfeatures/springapplication}/SpringApplicationBuilderExampleTests.java (91%) create mode 100644 spring-boot-project/spring-boot-docs/src/test/java/org/springframework/boot/docs/springbootfeatures/testing/OutputCaptureTestsTests.java create mode 100644 spring-boot-project/spring-boot-docs/src/test/java/org/springframework/boot/docs/springbootfeatures/testing/UserServiceAutoConfigurationTestsTests.java create mode 100644 spring-boot-project/spring-boot-docs/src/test/java/org/springframework/boot/docs/springbootfeatures/testing/jmx/SampleJmxTestsTests.java create mode 100644 spring-boot-project/spring-boot-docs/src/test/java/org/springframework/boot/docs/springbootfeatures/testing/webclient/SampleWebClientTestsTests.java diff --git a/spring-boot-project/spring-boot-docs/src/docs/asciidoc/attributes.adoc b/spring-boot-project/spring-boot-docs/src/docs/asciidoc/attributes.adoc index ba0c8bc45ee8..ea14af6df87e 100644 --- a/spring-boot-project/spring-boot-docs/src/docs/asciidoc/attributes.adoc +++ b/spring-boot-project/spring-boot-docs/src/docs/asciidoc/attributes.adoc @@ -20,8 +20,10 @@ :github-issues: https://github.com/{github-repo}/issues/ :github-wiki: https://github.com/{github-repo}/wiki -:code-examples: ../main/java/org/springframework/boot/docs -:test-examples: ../test/java/org/springframework/boot/docs +:include: ../main/java/org/springframework/boot/docs +:include-springbootfeatures: {include}/springbootfeatures +:include-productionreadyfeatures: {include}/productionreadyfeatures +:include-howto: {include}/howto :spring-boot-code: https://github.com/{github-repo}/tree/{github-tag} :spring-boot-api: https://docs.spring.io/spring-boot/docs/{spring-boot-version}/api @@ -94,9 +96,6 @@ :spring-session: https://spring.io/projects/spring-session :spring-webservices-docs: https://docs.spring.io/spring-ws/docs/{spring-webservices-version}/reference/ - - - :ant-docs: https://ant.apache.org/manual :dependency-management-plugin-code: https://github.com/spring-gradle-plugins/dependency-management-plugin :gradle-docs: https://docs.gradle.org/current/userguide diff --git a/spring-boot-project/spring-boot-docs/src/docs/asciidoc/howto.adoc b/spring-boot-project/spring-boot-docs/src/docs/asciidoc/howto.adoc index becead5f7734..948369553ba1 100644 --- a/spring-boot-project/spring-boot-docs/src/docs/asciidoc/howto.adoc +++ b/spring-boot-project/spring-boot-docs/src/docs/asciidoc/howto.adoc @@ -95,7 +95,7 @@ For instance, the following example loads a YAML configuration file from the cla [source,java,indent=0] ---- -include::{code-examples}/context/EnvironmentPostProcessorExample.java[tag=example] +include::{include-howto}/springbootapplication/EnvironmentPostProcessorExample.java[tag=*] ---- TIP: The `Environment` has already been prepared with all the usual property sources that Spring Boot loads by default. @@ -931,7 +931,7 @@ You can add an `org.apache.catalina.connector.Connector` to the `TomcatServletWe [source,java,indent=0,subs="verbatim,quotes,attributes"] ---- -include::{code-examples}/context/embedded/TomcatMultipleConnectorsExample.java[tag=configuration] +include::{include-howto}/embeddedwebservers/TomcatMultipleConnectorsExample.java[tag=*] ---- @@ -951,7 +951,7 @@ To switch to the `LegacyCookieProcessor`, use an `WebServerFactoryCustomizer` be [source,java,indent=0] ---- -include::{code-examples}/context/embedded/TomcatLegacyCookieProcessorExample.java[tag=customizer] +include::{include-howto}/embeddedwebservers/TomcatLegacyCookieProcessorExample.java[tag=*] ---- @@ -978,7 +978,7 @@ Add an `UndertowBuilderCustomizer` to the `UndertowServletWebServerFactory` and [source,java,indent=0,subs="verbatim,quotes,attributes"] ---- -include::{code-examples}/context/embedded/UndertowMultipleListenersExample.java[tag=configuration] +include::{include-howto}/embeddedwebservers/UndertowMultipleListenersExample.java[tag=*] ---- @@ -1283,7 +1283,7 @@ The `jersey.config.server.response.setStatusOverSendError` property must be set [source,java,indent=0] ---- -include::{code-examples}/jersey/JerseySetStatusOverSendErrorExample.java[tag=resource-config] +include::{include-howto}/jersey/JerseySetStatusOverSendErrorExample.java[tag=*] ---- @@ -1326,7 +1326,7 @@ The following example configures `HttpComponentsClientRequestFactory` with an `H [source,java,indent=0] ---- -include::{code-examples}/web/client/RestTemplateProxyCustomizationExample.java[tag=customizer] +include::{include-springbootfeatures}/resttemplate/RestTemplateProxyCustomizationExample.java[tag=*] ---- [[howto-webclient-reactor-netty-customization]] @@ -1337,7 +1337,7 @@ The following example configures a 60 second connect timeout and adds a `ReadTim [source,java,indent=0] ---- -include::{code-examples}/web/reactive/function/client/ReactorNettyClientCustomizationExample.java[tag=custom-http-connector] +include::{include-howto}/httpclients/ReactorNettyClientCustomizationExample.java[tag=*] ---- TIP: Note the use of `ReactorResourceFactory` for the connection provider and event loop resources. @@ -1582,7 +1582,7 @@ The following example shows how to create a data source by using a `DataSourceBu [source,java,indent=0,subs="verbatim,quotes,attributes"] ---- -include::{code-examples}/jdbc/BasicDataSourceExample.java[tag=configuration] +include::{include-howto}/dataaccess/BasicDataSourceExample.java[tag=*] ---- To run an app with that `DataSource`, all you need is the connection information. @@ -1623,7 +1623,7 @@ The following example shows how create a `HikariDataSource` with `DataSourceBuil [source,java,indent=0,subs="verbatim,quotes,attributes"] ---- -include::{code-examples}/jdbc/SimpleDataSourceExample.java[tag=configuration] +include::{include-howto}/dataaccess/SimpleDataSourceExample.java[tag=*] ---- You can even go further by leveraging what `DataSourceProperties` does for you -- that is, by providing a default embedded database with a sensible username and password if no URL is provided. @@ -1633,7 +1633,7 @@ To avoid that, you can redefine a custom `DataSourceProperties` on your custom n [source,java,indent=0,subs="verbatim,quotes,attributes"] ---- -include::{code-examples}/jdbc/ConfigurableDataSourceExample.java[tag=configuration] +include::{include-howto}/dataaccess/ConfigurableDataSourceExample.java[tag=*] ---- This setup puts you _in sync_ with what Spring Boot does for you by default, except that a dedicated connection pool is chosen (in code) and its settings are exposed in the `app.datasource.configuration` sub namespace. @@ -1670,7 +1670,7 @@ In the following example, we provide the _exact_ same feature set as the auto-co [source,java,indent=0,subs="verbatim,quotes,attributes"] ---- -include::{code-examples}/jdbc/SimpleTwoDataSourcesExample.java[tag=configuration] +include::{include-howto}/dataaccess/SimpleTwoDataSourcesExample.java[tag=*] ---- TIP: `firstDataSourceProperties` has to be flagged as `@Primary` so that the database initializer feature uses your copy (if you use the initializer). @@ -1700,7 +1700,7 @@ You can apply the same concept to the secondary `DataSource` as well, as shown i [source,java,indent=0,subs="verbatim,quotes,attributes"] ---- -include::{code-examples}/jdbc/CompleteTwoDataSourcesExample.java[tag=configuration] +include::{include-howto}/dataaccess/CompleteTwoDataSourcesExample.java[tag=*] ---- The preceding example configures two data sources on custom namespaces with the same logic as Spring Boot would use in auto-configuration. @@ -1794,7 +1794,7 @@ This implementation provides the same table structure as Hibernate 4: all dots a [source,java,indent=0] ---- -include::{code-examples}/jpa/CaseSensitiveSpringPhysicalNamingStrategyExample.java[tag=naming-strategy] +include::{include-howto}/dataaccess/CaseSensitiveSpringPhysicalNamingStrategyExample.java[tag=*] ---- If you prefer to use Hibernate 5's default instead, set the following property: @@ -1828,7 +1828,7 @@ Then, add a `HibernatePropertiesCustomizer` bean as shown in the following examp [source,java,indent=0] ---- -include::{code-examples}/jpa/HibernateSecondLevelCacheExample.java[tag=configuration] +include::{include-howto}/dataaccess/HibernateSecondLevelCacheExample.java[tag=*] ---- This customizer will configure Hibernate to use the same `CacheManager` as the one that the application uses. @@ -1969,7 +1969,7 @@ For example, if you use Hibernate Search with Elasticsearch as its index manager [source,java,indent=0] ---- -include::{code-examples}/elasticsearch/HibernateSearchElasticsearchExample.java[tag=configuration] +include::{include-howto}/dataaccess/HibernateSearchElasticsearchExample.java[tag=*] ---- @@ -2066,7 +2066,7 @@ You can initialize the database on startup using SQL scripts as shown in the fol [source,java,indent=0] ---- -include::{code-examples}/r2dbc/R2dbcDatabaseInitializationExample.java[tag=configuration] +include::{include-howto}/dataaccess/R2dbcDatabaseInitializationExample.java[tag=*] ---- Alternatively, you can configure either <> or <> to configure a `DataSource` for you for the duration of the migration. @@ -2351,7 +2351,7 @@ The following example shows one way to write such an exporter: [source,java,indent=0,subs="verbatim,quotes,attributes"] ---- -include::{code-examples}/actuate/metrics/MetricsHealthMicrometerExportExample.java[tag=configuration] +include::{include-howto}/actuator/MetricsHealthMicrometerExportExample.java[tag=*] ---- diff --git a/spring-boot-project/spring-boot-docs/src/docs/asciidoc/production-ready-features.adoc b/spring-boot-project/spring-boot-docs/src/docs/asciidoc/production-ready-features.adoc index eb4cce878a9c..daa3d2e99acb 100644 --- a/spring-boot-project/spring-boot-docs/src/docs/asciidoc/production-ready-features.adoc +++ b/spring-boot-project/spring-boot-docs/src/docs/asciidoc/production-ready-features.adoc @@ -463,7 +463,7 @@ The following example exposes a read operation that returns a custom object: [source,java,indent=0] ---- -include::{code-examples}/actuate/endpoint/CustomEndpointExample.java[tag=read] +include::{include-productionreadyfeatures}/endpoints/CustomEndpointExample.java[tag=read] ---- You can also write technology-specific endpoints by using `@JmxEndpoint` or `@WebEndpoint`. @@ -500,7 +500,7 @@ This can be used to invoke a write operation that takes `String name` and `int c [source,java,indent=0] ---- -include::{code-examples}/actuate/endpoint/CustomEndpointExample.java[tag=write] +include::{include-productionreadyfeatures}/endpoints/CustomEndpointExample.java[tag=write] ---- TIP: Because endpoints are technology agnostic, only simple types can be specified in the method signature. @@ -2379,14 +2379,14 @@ To register custom metrics, inject `MeterRegistry` into your component, as shown [source,java,indent=0] ---- -include::{code-examples}/actuate/metrics/MetricsMeterRegistryInjectionExample.java[tag=component] +include::{include-productionreadyfeatures}/metrics/MetricsMeterRegistryInjectionExample.java[tag=*] ---- If your metrics depend on other beans, it is recommended that you use a `MeterBinder` to register them, as shown in the following example: [source,java,indent=0] ---- -include::{code-examples}/actuate/metrics/SampleMeterBinderConfiguration.java[tag=example] +include::{include-productionreadyfeatures}/metrics/SampleMeterBinderConfiguration.java[tag=*] ---- Using a `MeterBinder` ensures that the correct dependency relationships are set up and that the bean is available when the metric's value is retrieved. @@ -2404,7 +2404,7 @@ For example, if you want to rename the `mytag.region` tag to `mytag.area` for al [source,java,indent=0] ---- -include::{code-examples}/actuate/metrics/MetricsFilterBeanExample.java[tag=configuration] +include::{include-productionreadyfeatures}/metrics/MetricsFilterBeanExample.java[tag=*] ---- @@ -2622,7 +2622,7 @@ For Tomcat, the following configuration can be added: [source,java,indent=0] ---- -include::{code-examples}/cloudfoundry/CloudFoundryCustomContextPathExample.java[tag=configuration] +include::{include-productionreadyfeatures}/cloudfoundry/CloudFoundryCustomContextPathExample.java[tag=*] ---- diff --git a/spring-boot-project/spring-boot-docs/src/docs/asciidoc/spring-boot-features.adoc b/spring-boot-project/spring-boot-docs/src/docs/asciidoc/spring-boot-features.adoc index d39fd0e48c40..5659f9bb9bf5 100644 --- a/spring-boot-project/spring-boot-docs/src/docs/asciidoc/spring-boot-features.adoc +++ b/spring-boot-project/spring-boot-docs/src/docs/asciidoc/spring-boot-features.adoc @@ -195,7 +195,7 @@ The `SpringApplicationBuilder` lets you chain together multiple method calls and [source,java,indent=0] ---- -include::{code-examples}/builder/SpringApplicationBuilderExample.java[tag=hierarchy] +include::{include-springbootfeatures}/springapplication/SpringApplicationBuilderExample.java[tag=*] ---- NOTE: There are some restrictions when creating an `ApplicationContext` hierarchy. @@ -436,7 +436,7 @@ This exit code can then be passed to `System.exit()` to return it as a status co [source,java,indent=0] ---- -include::{code-examples}/ExitCodeApplication.java[tag=example] +include::{include-springbootfeatures}/springapplication/ExitCodeExample.java[tag=*] ---- Also, the `ExitCodeGenerator` interface may be implemented by exceptions. @@ -1673,7 +1673,7 @@ You may want to rename your custom `ConversionService` if it is not required for [[boot-features-external-config-conversion-duration]] -===== Converting durations +===== Converting Durations Spring Boot has dedicated support for expressing durations. If you expose a `java.time.Duration` property, the following formats in application properties are available: @@ -1685,7 +1685,7 @@ Consider the following example: [source,java,indent=0] ---- -include::{code-examples}/context/properties/bind/javabean/AppSystemProperties.java[tag=example] +include::{include-springbootfeatures}/externalizedconfiguration/duration/javabeanbinding/AppSystemProperties.java[tag=*] ---- To specify a session timeout of 30 seconds, `30`, `PT30S` and `30s` are all equivalent. @@ -1708,7 +1708,7 @@ If you prefer to use constructor binding, the same properties can be exposed, as [source,java,indent=0] ---- -include::{code-examples}/context/properties/bind/constructor/AppSystemProperties.java[tag=example] +include::{include-springbootfeatures}/externalizedconfiguration/duration/constructorbinding/AppSystemProperties.java[tag=*] ---- @@ -1749,7 +1749,7 @@ Consider the following example: [source,java,indent=0] ---- -include::{code-examples}/context/properties/bind/javabean/AppIoProperties.java[tag=example] +include::{include-springbootfeatures}/externalizedconfiguration/datasize/javabeanbinding/AppIoProperties.java[tag=*] ---- To specify a buffer size of 10 megabytes, `10` and `10MB` are equivalent. @@ -1770,7 +1770,7 @@ If you prefer to use constructor binding, the same properties can be exposed, as [source,java,indent=0] ---- -include::{code-examples}/context/properties/bind/constructor/AppIoProperties.java[tag=example] +include::{include-springbootfeatures}/externalizedconfiguration/datasize/constructorbinding/AppIoProperties.java[tag=*] ---- TIP: If you are upgrading a `Long` property, make sure to define the unit (using `@DataSizeUnit`) if it isn't bytes. @@ -3515,7 +3515,7 @@ The following example shows how to customize `TomcatServletWebServerFactory` tha [source,java,indent=0,subs="verbatim,quotes,attributes"] ---- -include::{code-examples}/context/embedded/TomcatServerCustomizerExample.java[tag=configuration] +include::{include-springbootfeatures}/webapplications/TomcatServerCustomizerExample.java[tag=*] ---- @@ -3769,7 +3769,7 @@ For example, you can customize your security configuration by adding something l [source,java,indent=0] ---- -include::{code-examples}/web/security/CustomWebFluxSecurityExample.java[tag=configuration] +include::{include-springbootfeatures}/security/CustomWebFluxSecurityExample.java[tag=*] ---- @@ -4924,7 +4924,7 @@ To enable transaction management, the following bean must be defined in your con [source,java,indent=0] ---- -include::{code-examples}/neo4j/Neo4jReactiveTransactionManagerExample.java[tag=configuration] +include::{include-springbootfeatures}/nosql/Neo4jReactiveTransactionManagerExample.java[tag=*] ---- ==== @@ -5609,7 +5609,7 @@ The following example shows a customizer that configures a specific entry expira [source,java,indent=0] ---- -include::{code-examples}/cache/CouchbaseCacheManagerCustomizationExample.java[tag=configuration] +include::{include-springbootfeatures}/nosql/CouchbaseCacheManagerCustomizationExample.java[tag=*] ---- @@ -5640,7 +5640,7 @@ The following example shows a customizer that configures a specific time to live [source,java,indent=0] ---- -include::{code-examples}/cache/RedisCacheManagerCustomizationExample.java[tag=configuration] +include::{include-springbootfeatures}/nosql//RedisCacheManagerCustomizationExample.java[tag=*] ---- @@ -6208,7 +6208,7 @@ To use the factory bean, wire `StreamsBuilder` into your `@Bean` as shown in the [source,java,indent=0] ---- -include::{code-examples}/kafka/KafkaStreamsBeanExample.java[tag=configuration] +include::{include-springbootfeatures}/messaging/KafkaStreamsBeanExample.java[tag=*] ---- By default, the streams managed by the `StreamBuilder` object it creates are started automatically. @@ -6363,7 +6363,7 @@ The following example shows a customizer that configures the use of a proxy for [source,java,indent=0] ---- -include::{code-examples}/web/client/RestTemplateProxyCustomizationExample.java[tag=customizer] +include::{include-springbootfeatures}/resttemplate/RestTemplateProxyCustomizationExample.java[tag=*] ---- Finally, you can also create your own `RestTemplateBuilder` bean. @@ -6372,7 +6372,7 @@ The following example exposes a `RestTemplateBuilder` with what Spring Boot woul [source,java,indent=0] ---- -include::{code-examples}/web/client/RestTemplateBuilderCustomizationExample.java[tag=customizer] +include::{include-springbootfeatures}/resttemplate/RestTemplateBuilderCustomizationExample.java[tag=*] ---- The most extreme (and rarely used) option is to create your own `RestTemplateBuilder` bean without using a configurer. @@ -7025,7 +7025,7 @@ have `@SpringBootTest` inject them using the `args` attribute. [source,java,indent=0] ---- -include::{code-examples}/test/context/ApplicationArgumentsExampleTests.java[tag=example] +include::{include-springbootfeatures}/testing/ApplicationArgumentsExampleTests.java[tag=*] ---- @@ -7037,7 +7037,7 @@ If you have web endpoints that you want to test against this mock environment, y [source,java,indent=0] ---- -include::{code-examples}/test/web/MockMvcExampleTests.java[tag=test-mock-mvc] +include::{include-springbootfeatures}/testing/MockMvcExampleTests.java[tag=*] ---- TIP: If you want to focus only on the web layer and not start a complete `ApplicationContext`, consider <>. @@ -7046,7 +7046,7 @@ Alternatively, you can configure a {spring-framework-docs}/testing.html#webtestc [source,java,indent=0] ---- -include::{code-examples}/test/web/MockWebTestClientExampleTests.java[tag=test-mock-web-test-client] +include::{include-springbootfeatures}/testing/MockWebTestClientExampleTests.java[tag=*] ---- [TIP] @@ -7071,7 +7071,7 @@ For convenience, tests that need to make REST calls to the started server can ad [source,java,indent=0] ---- -include::{code-examples}/test/web/RandomPortWebTestClientExampleTests.java[tag=test-random-port] +include::{include-springbootfeatures}/testing/RandomPortWebTestClientExampleTests.java[tag=*] ---- This setup requires `spring-webflux` on the classpath. @@ -7079,7 +7079,7 @@ If you can't or won't add webflux, Spring Boot also provides a `TestRestTemplate [source,java,indent=0] ---- -include::{code-examples}/test/web/RandomPortTestRestTemplateExampleTests.java[tag=test-random-port] +include::{include-springbootfeatures}/testing/RandomPortTestRestTemplateExampleTests.java[tag=*] ---- @@ -7098,7 +7098,7 @@ If such test needs access to an `MBeanServer`, consider marking it dirty as well [source,java,indent=0] ---- -include::{test-examples}/jmx/SampleJmxTests.java[tag=test] +include::{include-springbootfeatures}/testing/jmx/SampleJmxTests.java[tag=*] ---- @@ -7921,14 +7921,14 @@ You can inject it by using `@Autowired` and use it in your tests as you normally [source,java,indent=0] ---- -include::{code-examples}/test/autoconfigure/restdocs/webclient/UsersDocumentationTests.java[tag=source] +include::{include-springbootfeatures}/testing/restdocs/webclient/UsersDocumentationTests.java[tag=*] ---- If you require more control over Spring REST Docs configuration than offered by the attributes of `@AutoConfigureRestDocs`, you can use a `RestDocsWebTestClientConfigurationCustomizer` bean, as shown in the following example: [source,java,indent=0] ---- -include::{code-examples}/test/autoconfigure/restdocs/webclient/AdvancedConfigurationExample.java[tag=configuration] +include::{include-springbootfeatures}/testing/restdocs/webclient/AdvancedConfigurationExample.java[tag=*] ---- @@ -7940,14 +7940,14 @@ You can inject it by using `@Autowired` and use it in your tests as you normally [source,java,indent=0] ---- -include::{code-examples}/test/autoconfigure/restdocs/restassured/UserDocumentationTests.java[tag=source] +include::{include-springbootfeatures}/testing/restdocs/restassured/UserDocumentationTests.java[tag=*] ---- If you require more control over Spring REST Docs configuration than offered by the attributes of `@AutoConfigureRestDocs`, a `RestDocsRestAssuredConfigurationCustomizer` bean can be used, as shown in the following example: [source,java,indent=0] ---- -include::{code-examples}/test/autoconfigure/restdocs/restassured/AdvancedConfigurationExample.java[tag=configuration] +include::{include-springbootfeatures}/testing/restdocs/restassured/AdvancedConfigurationExample.java[tag=*] ---- @@ -8141,7 +8141,7 @@ To use add `@ExtendWith(OutputCaptureExtension.class)` and inject `CapturedOutpu [source,java,indent=0] ---- -include::{test-examples}/test/system/OutputCaptureTests.java[tag=test] +include::{include-springbootfeatures}/testing/OutputCaptureTests.java[tag=*] ---- @@ -8186,7 +8186,7 @@ Any URLs that do not specify a host and port automatically connect to the embedd [source,java,indent=0] ---- -include::{test-examples}/web/client/SampleWebClientTests.java[tag=test] +include::{include-springbootfeatures}/testing/webclient/SampleWebClientTests.java[tag=*] ---- @@ -8450,7 +8450,7 @@ The following example makes sure that `UserServiceAutoConfiguration` is always i [source,java,indent=0] ---- -include::{test-examples}/autoconfigure/UserServiceAutoConfigurationTests.java[tag=runner] +include::{include-springbootfeatures}/testing/UserServiceAutoConfigurationTests.java[tag=runner] ---- TIP: 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. @@ -8461,14 +8461,14 @@ Invoking `run` provides a callback context that can be used with `AssertJ`. [source,java,indent=0] ---- -include::{test-examples}/autoconfigure/UserServiceAutoConfigurationTests.java[tag=test-user-config] +include::{include-springbootfeatures}/testing/UserServiceAutoConfigurationTests.java[tag=test-user-config] ---- It is also possible to easily customize the `Environment`, as shown in the following example: [source,java,indent=0] ---- -include::{test-examples}/autoconfigure/UserServiceAutoConfigurationTests.java[tag=test-env] +include::{include-springbootfeatures}/testing/UserServiceAutoConfigurationTests.java[tag=test-env] ---- The runner can also be used to display the `ConditionEvaluationReport`. @@ -8502,7 +8502,7 @@ In the following example, we assert that if `UserService` is not present, the au [source,java,indent=0] ---- -include::{test-examples}/autoconfigure/UserServiceAutoConfigurationTests.java[tag=test-classloader] +include::{include-springbootfeatures}/testing/UserServiceAutoConfigurationTests.java[tag=test-classloader] ---- diff --git a/spring-boot-project/spring-boot-docs/src/main/java/org/springframework/boot/docs/actuate/metrics/MetricsHealthMicrometerExportExample.java b/spring-boot-project/spring-boot-docs/src/main/java/org/springframework/boot/docs/howto/actuator/MetricsHealthMicrometerExportExample.java similarity index 91% rename from spring-boot-project/spring-boot-docs/src/main/java/org/springframework/boot/docs/actuate/metrics/MetricsHealthMicrometerExportExample.java rename to spring-boot-project/spring-boot-docs/src/main/java/org/springframework/boot/docs/howto/actuator/MetricsHealthMicrometerExportExample.java index 531de976adb5..da10ce4cd940 100644 --- a/spring-boot-project/spring-boot-docs/src/main/java/org/springframework/boot/docs/actuate/metrics/MetricsHealthMicrometerExportExample.java +++ b/spring-boot-project/spring-boot-docs/src/main/java/org/springframework/boot/docs/howto/actuator/MetricsHealthMicrometerExportExample.java @@ -1,5 +1,5 @@ /* - * Copyright 2012-2020 the original author or authors. + * Copyright 2012-2021 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -14,7 +14,7 @@ * limitations under the License. */ -package org.springframework.boot.docs.actuate.metrics; +package org.springframework.boot.docs.howto.actuator; import io.micrometer.core.instrument.Gauge; import io.micrometer.core.instrument.MeterRegistry; @@ -31,7 +31,7 @@ */ public class MetricsHealthMicrometerExportExample { - // tag::configuration[] + // tag::code[] @Configuration public class HealthMetricsConfiguration { @@ -55,6 +55,6 @@ private int getStatusCode(HealthEndpoint health) { } } - // end::configuration[] + // end::code[] } diff --git a/spring-boot-project/spring-boot-docs/src/main/java/org/springframework/boot/docs/howto/actuator/package-info.java b/spring-boot-project/spring-boot-docs/src/main/java/org/springframework/boot/docs/howto/actuator/package-info.java new file mode 100644 index 000000000000..b48bb91aef86 --- /dev/null +++ b/spring-boot-project/spring-boot-docs/src/main/java/org/springframework/boot/docs/howto/actuator/package-info.java @@ -0,0 +1,20 @@ +/* + * Copyright 2012-2021 the original author or authors. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/** + * Examples for the "How-to - Actuator" section. + */ +package org.springframework.boot.docs.howto.actuator; diff --git a/spring-boot-project/spring-boot-docs/src/main/java/org/springframework/boot/docs/howto/batchapplications/package-info.java b/spring-boot-project/spring-boot-docs/src/main/java/org/springframework/boot/docs/howto/batchapplications/package-info.java new file mode 100644 index 000000000000..ea999e25c1d3 --- /dev/null +++ b/spring-boot-project/spring-boot-docs/src/main/java/org/springframework/boot/docs/howto/batchapplications/package-info.java @@ -0,0 +1,20 @@ +/* + * Copyright 2012-2021 the original author or authors. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/** + * Examples for the "How-to - Batch Applications" section. + */ +package org.springframework.boot.docs.howto.batchapplications; diff --git a/spring-boot-project/spring-boot-docs/src/main/java/org/springframework/boot/docs/howto/build/package-info.java b/spring-boot-project/spring-boot-docs/src/main/java/org/springframework/boot/docs/howto/build/package-info.java new file mode 100644 index 000000000000..d32b64581747 --- /dev/null +++ b/spring-boot-project/spring-boot-docs/src/main/java/org/springframework/boot/docs/howto/build/package-info.java @@ -0,0 +1,20 @@ +/* + * Copyright 2012-2021 the original author or authors. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/** + * Examples for the "How-to - Build" section. + */ +package org.springframework.boot.docs.howto.build; diff --git a/spring-boot-project/spring-boot-docs/src/main/java/org/springframework/boot/docs/jdbc/BasicDataSourceExample.java b/spring-boot-project/spring-boot-docs/src/main/java/org/springframework/boot/docs/howto/dataaccess/BasicDataSourceExample.java similarity index 89% rename from spring-boot-project/spring-boot-docs/src/main/java/org/springframework/boot/docs/jdbc/BasicDataSourceExample.java rename to spring-boot-project/spring-boot-docs/src/main/java/org/springframework/boot/docs/howto/dataaccess/BasicDataSourceExample.java index 674c361e64a5..7ffb6e38734c 100644 --- a/spring-boot-project/spring-boot-docs/src/main/java/org/springframework/boot/docs/jdbc/BasicDataSourceExample.java +++ b/spring-boot-project/spring-boot-docs/src/main/java/org/springframework/boot/docs/howto/dataaccess/BasicDataSourceExample.java @@ -1,5 +1,5 @@ /* - * Copyright 2012-2019 the original author or authors. + * Copyright 2012-2021 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -14,7 +14,7 @@ * limitations under the License. */ -package org.springframework.boot.docs.jdbc; +package org.springframework.boot.docs.howto.dataaccess; import javax.sql.DataSource; @@ -36,13 +36,13 @@ public class BasicDataSourceExample { @Configuration(proxyBeanMethods = false) public static class BasicDataSourceConfiguration { - // tag::configuration[] + // tag::code[] @Bean @ConfigurationProperties("app.datasource") public DataSource dataSource() { return DataSourceBuilder.create().build(); } - // end::configuration[] + // end::code[] } diff --git a/spring-boot-project/spring-boot-docs/src/main/java/org/springframework/boot/docs/jpa/CaseSensitiveSpringPhysicalNamingStrategyExample.java b/spring-boot-project/spring-boot-docs/src/main/java/org/springframework/boot/docs/howto/dataaccess/CaseSensitiveSpringPhysicalNamingStrategyExample.java similarity index 88% rename from spring-boot-project/spring-boot-docs/src/main/java/org/springframework/boot/docs/jpa/CaseSensitiveSpringPhysicalNamingStrategyExample.java rename to spring-boot-project/spring-boot-docs/src/main/java/org/springframework/boot/docs/howto/dataaccess/CaseSensitiveSpringPhysicalNamingStrategyExample.java index d8c34d71fd7b..27e44dd5c1d5 100644 --- a/spring-boot-project/spring-boot-docs/src/main/java/org/springframework/boot/docs/jpa/CaseSensitiveSpringPhysicalNamingStrategyExample.java +++ b/spring-boot-project/spring-boot-docs/src/main/java/org/springframework/boot/docs/howto/dataaccess/CaseSensitiveSpringPhysicalNamingStrategyExample.java @@ -1,5 +1,5 @@ /* - * Copyright 2012-2020 the original author or authors. + * Copyright 2012-2021 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -14,7 +14,7 @@ * limitations under the License. */ -package org.springframework.boot.docs.jpa; +package org.springframework.boot.docs.howto.dataaccess; import org.hibernate.engine.jdbc.env.spi.JdbcEnvironment; @@ -29,7 +29,7 @@ */ class CaseSensitiveSpringPhysicalNamingStrategyExample { - // tag::naming-strategy[] + // tag::code[] @Bean SpringPhysicalNamingStrategy caseSensitivePhysicalNamingStrategy() { return new SpringPhysicalNamingStrategy() { @@ -41,6 +41,6 @@ protected boolean isCaseInsensitive(JdbcEnvironment jdbcEnvironment) { }; } - // end::naming-strategy[] + // end::code[] } diff --git a/spring-boot-project/spring-boot-docs/src/main/java/org/springframework/boot/docs/jdbc/CompleteTwoDataSourcesExample.java b/spring-boot-project/spring-boot-docs/src/main/java/org/springframework/boot/docs/howto/dataaccess/CompleteTwoDataSourcesExample.java similarity index 93% rename from spring-boot-project/spring-boot-docs/src/main/java/org/springframework/boot/docs/jdbc/CompleteTwoDataSourcesExample.java rename to spring-boot-project/spring-boot-docs/src/main/java/org/springframework/boot/docs/howto/dataaccess/CompleteTwoDataSourcesExample.java index 7526b6331de5..824dc549078c 100644 --- a/spring-boot-project/spring-boot-docs/src/main/java/org/springframework/boot/docs/jdbc/CompleteTwoDataSourcesExample.java +++ b/spring-boot-project/spring-boot-docs/src/main/java/org/springframework/boot/docs/howto/dataaccess/CompleteTwoDataSourcesExample.java @@ -1,5 +1,5 @@ /* - * Copyright 2012-2019 the original author or authors. + * Copyright 2012-2021 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -14,7 +14,7 @@ * limitations under the License. */ -package org.springframework.boot.docs.jdbc; +package org.springframework.boot.docs.howto.dataaccess; import com.zaxxer.hikari.HikariDataSource; import org.apache.commons.dbcp2.BasicDataSource; @@ -39,7 +39,7 @@ public class CompleteTwoDataSourcesExample { @Configuration public static class CompleteDataSourcesConfiguration { - // tag::configuration[] + // tag::code[] @Bean @Primary @ConfigurationProperties("app.datasource.first") @@ -65,7 +65,7 @@ public DataSourceProperties secondDataSourceProperties() { public BasicDataSource secondDataSource() { return secondDataSourceProperties().initializeDataSourceBuilder().type(BasicDataSource.class).build(); } - // end::configuration[] + // end::code[] } diff --git a/spring-boot-project/spring-boot-docs/src/main/java/org/springframework/boot/docs/jdbc/ConfigurableDataSourceExample.java b/spring-boot-project/spring-boot-docs/src/main/java/org/springframework/boot/docs/howto/dataaccess/ConfigurableDataSourceExample.java similarity index 92% rename from spring-boot-project/spring-boot-docs/src/main/java/org/springframework/boot/docs/jdbc/ConfigurableDataSourceExample.java rename to spring-boot-project/spring-boot-docs/src/main/java/org/springframework/boot/docs/howto/dataaccess/ConfigurableDataSourceExample.java index e9517f752f71..ab38834a4c6d 100644 --- a/spring-boot-project/spring-boot-docs/src/main/java/org/springframework/boot/docs/jdbc/ConfigurableDataSourceExample.java +++ b/spring-boot-project/spring-boot-docs/src/main/java/org/springframework/boot/docs/howto/dataaccess/ConfigurableDataSourceExample.java @@ -1,5 +1,5 @@ /* - * Copyright 2012-2019 the original author or authors. + * Copyright 2012-2021 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -14,7 +14,7 @@ * limitations under the License. */ -package org.springframework.boot.docs.jdbc; +package org.springframework.boot.docs.howto.dataaccess; import javax.sql.DataSource; @@ -40,7 +40,7 @@ public class ConfigurableDataSourceExample { @Configuration(proxyBeanMethods = false) public static class ConfigurableDataSourceConfiguration { - // tag::configuration[] + // tag::code[] @Bean @Primary @ConfigurationProperties("app.datasource") @@ -53,7 +53,7 @@ public DataSourceProperties dataSourceProperties() { public HikariDataSource dataSource(DataSourceProperties properties) { return properties.initializeDataSourceBuilder().type(HikariDataSource.class).build(); } - // end::configuration[] + // end::code[] } diff --git a/spring-boot-project/spring-boot-docs/src/main/java/org/springframework/boot/docs/elasticsearch/HibernateSearchElasticsearchExample.java b/spring-boot-project/spring-boot-docs/src/main/java/org/springframework/boot/docs/howto/dataaccess/HibernateSearchElasticsearchExample.java similarity index 89% rename from spring-boot-project/spring-boot-docs/src/main/java/org/springframework/boot/docs/elasticsearch/HibernateSearchElasticsearchExample.java rename to spring-boot-project/spring-boot-docs/src/main/java/org/springframework/boot/docs/howto/dataaccess/HibernateSearchElasticsearchExample.java index 7cc9cd287a77..916a116b6bc8 100644 --- a/spring-boot-project/spring-boot-docs/src/main/java/org/springframework/boot/docs/elasticsearch/HibernateSearchElasticsearchExample.java +++ b/spring-boot-project/spring-boot-docs/src/main/java/org/springframework/boot/docs/howto/dataaccess/HibernateSearchElasticsearchExample.java @@ -1,5 +1,5 @@ /* - * Copyright 2012-2020 the original author or authors. + * Copyright 2012-2021 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -14,7 +14,7 @@ * limitations under the License. */ -package org.springframework.boot.docs.elasticsearch; +package org.springframework.boot.docs.howto.dataaccess; import javax.persistence.EntityManagerFactory; @@ -29,7 +29,7 @@ */ public class HibernateSearchElasticsearchExample { - // tag::configuration[] + // tag::code[] /** * {@link EntityManagerFactoryDependsOnPostProcessor} that ensures that * {@link EntityManagerFactory} beans depend on the {@code elasticsearchClient} bean. @@ -43,6 +43,6 @@ static class ElasticsearchEntityManagerFactoryDependsOnPostProcessor } } - // end::configuration[] + // end::code[] } diff --git a/spring-boot-project/spring-boot-docs/src/main/java/org/springframework/boot/docs/jpa/HibernateSecondLevelCacheExample.java b/spring-boot-project/spring-boot-docs/src/main/java/org/springframework/boot/docs/howto/dataaccess/HibernateSecondLevelCacheExample.java similarity index 90% rename from spring-boot-project/spring-boot-docs/src/main/java/org/springframework/boot/docs/jpa/HibernateSecondLevelCacheExample.java rename to spring-boot-project/spring-boot-docs/src/main/java/org/springframework/boot/docs/howto/dataaccess/HibernateSecondLevelCacheExample.java index 75c9bce2027f..b174e7a80234 100644 --- a/spring-boot-project/spring-boot-docs/src/main/java/org/springframework/boot/docs/jpa/HibernateSecondLevelCacheExample.java +++ b/spring-boot-project/spring-boot-docs/src/main/java/org/springframework/boot/docs/howto/dataaccess/HibernateSecondLevelCacheExample.java @@ -1,5 +1,5 @@ /* - * Copyright 2012-2019 the original author or authors. + * Copyright 2012-2021 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -14,7 +14,7 @@ * limitations under the License. */ -package org.springframework.boot.docs.jpa; +package org.springframework.boot.docs.howto.dataaccess; import org.hibernate.cache.jcache.ConfigSettings; @@ -28,7 +28,7 @@ * * @author Stephane Nicoll */ -// tag::configuration[] +// tag::code[] @Configuration(proxyBeanMethods = false) public class HibernateSecondLevelCacheExample { @@ -38,4 +38,4 @@ public HibernatePropertiesCustomizer hibernateSecondLevelCacheCustomizer(JCacheC } } -// end::configuration[] +// end::code[] diff --git a/spring-boot-project/spring-boot-docs/src/main/java/org/springframework/boot/docs/r2dbc/R2dbcDatabaseInitializationExample.java b/spring-boot-project/spring-boot-docs/src/main/java/org/springframework/boot/docs/howto/dataaccess/R2dbcDatabaseInitializationExample.java similarity index 91% rename from spring-boot-project/spring-boot-docs/src/main/java/org/springframework/boot/docs/r2dbc/R2dbcDatabaseInitializationExample.java rename to spring-boot-project/spring-boot-docs/src/main/java/org/springframework/boot/docs/howto/dataaccess/R2dbcDatabaseInitializationExample.java index e5236b2b916a..2dfd7b4a423c 100644 --- a/spring-boot-project/spring-boot-docs/src/main/java/org/springframework/boot/docs/r2dbc/R2dbcDatabaseInitializationExample.java +++ b/spring-boot-project/spring-boot-docs/src/main/java/org/springframework/boot/docs/howto/dataaccess/R2dbcDatabaseInitializationExample.java @@ -1,5 +1,5 @@ /* - * Copyright 2012-2020 the original author or authors. + * Copyright 2012-2021 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -14,7 +14,7 @@ * limitations under the License. */ -package org.springframework.boot.docs.r2dbc; +package org.springframework.boot.docs.howto.dataaccess; import io.r2dbc.spi.ConnectionFactory; @@ -32,7 +32,7 @@ */ public class R2dbcDatabaseInitializationExample { - // tag::configuration[] + // tag::code[] @Configuration(proxyBeanMethods = false) static class DatabaseInitializationConfiguration { @@ -45,6 +45,6 @@ void initializeDatabase(ConnectionFactory connectionFactory) { } } - // end::configuration[] + // end::code[] } diff --git a/spring-boot-project/spring-boot-docs/src/main/java/org/springframework/boot/docs/jdbc/SimpleDataSourceExample.java b/spring-boot-project/spring-boot-docs/src/main/java/org/springframework/boot/docs/howto/dataaccess/SimpleDataSourceExample.java similarity index 90% rename from spring-boot-project/spring-boot-docs/src/main/java/org/springframework/boot/docs/jdbc/SimpleDataSourceExample.java rename to spring-boot-project/spring-boot-docs/src/main/java/org/springframework/boot/docs/howto/dataaccess/SimpleDataSourceExample.java index 7dec69c4b2f5..3c55602513d3 100644 --- a/spring-boot-project/spring-boot-docs/src/main/java/org/springframework/boot/docs/jdbc/SimpleDataSourceExample.java +++ b/spring-boot-project/spring-boot-docs/src/main/java/org/springframework/boot/docs/howto/dataaccess/SimpleDataSourceExample.java @@ -1,5 +1,5 @@ /* - * Copyright 2012-2019 the original author or authors. + * Copyright 2012-2021 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -14,7 +14,7 @@ * limitations under the License. */ -package org.springframework.boot.docs.jdbc; +package org.springframework.boot.docs.howto.dataaccess; import javax.sql.DataSource; @@ -38,13 +38,13 @@ public class SimpleDataSourceExample { @Configuration(proxyBeanMethods = false) public static class SimpleDataSourceConfiguration { - // tag::configuration[] + // tag::code[] @Bean @ConfigurationProperties("app.datasource") public HikariDataSource dataSource() { return DataSourceBuilder.create().type(HikariDataSource.class).build(); } - // end::configuration[] + // end::code[] } diff --git a/spring-boot-project/spring-boot-docs/src/main/java/org/springframework/boot/docs/jdbc/SimpleTwoDataSourcesExample.java b/spring-boot-project/spring-boot-docs/src/main/java/org/springframework/boot/docs/howto/dataaccess/SimpleTwoDataSourcesExample.java similarity index 93% rename from spring-boot-project/spring-boot-docs/src/main/java/org/springframework/boot/docs/jdbc/SimpleTwoDataSourcesExample.java rename to spring-boot-project/spring-boot-docs/src/main/java/org/springframework/boot/docs/howto/dataaccess/SimpleTwoDataSourcesExample.java index 568d465da0c6..99d65575903a 100644 --- a/spring-boot-project/spring-boot-docs/src/main/java/org/springframework/boot/docs/jdbc/SimpleTwoDataSourcesExample.java +++ b/spring-boot-project/spring-boot-docs/src/main/java/org/springframework/boot/docs/howto/dataaccess/SimpleTwoDataSourcesExample.java @@ -1,5 +1,5 @@ /* - * Copyright 2012-2019 the original author or authors. + * Copyright 2012-2021 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -14,7 +14,7 @@ * limitations under the License. */ -package org.springframework.boot.docs.jdbc; +package org.springframework.boot.docs.howto.dataaccess; import javax.sql.DataSource; @@ -42,7 +42,7 @@ public class SimpleTwoDataSourcesExample { @Configuration public static class SimpleDataSourcesConfiguration { - // tag::configuration[] + // tag::code[] @Bean @Primary @ConfigurationProperties("app.datasource.first") @@ -62,7 +62,7 @@ public HikariDataSource firstDataSource() { public BasicDataSource secondDataSource() { return DataSourceBuilder.create().type(BasicDataSource.class).build(); } - // end::configuration[] + // end::code[] } diff --git a/spring-boot-project/spring-boot-docs/src/main/java/org/springframework/boot/docs/howto/dataaccess/package-info.java b/spring-boot-project/spring-boot-docs/src/main/java/org/springframework/boot/docs/howto/dataaccess/package-info.java new file mode 100644 index 000000000000..10e523a65964 --- /dev/null +++ b/spring-boot-project/spring-boot-docs/src/main/java/org/springframework/boot/docs/howto/dataaccess/package-info.java @@ -0,0 +1,20 @@ +/* + * Copyright 2012-2021 the original author or authors. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/** + * Examples for the "How-to - Data Access" section. + */ +package org.springframework.boot.docs.howto.dataaccess; diff --git a/spring-boot-project/spring-boot-docs/src/main/java/org/springframework/boot/docs/howto/databaseinitialization/package-info.java b/spring-boot-project/spring-boot-docs/src/main/java/org/springframework/boot/docs/howto/databaseinitialization/package-info.java new file mode 100644 index 000000000000..612af6947711 --- /dev/null +++ b/spring-boot-project/spring-boot-docs/src/main/java/org/springframework/boot/docs/howto/databaseinitialization/package-info.java @@ -0,0 +1,20 @@ +/* + * Copyright 2012-2021 the original author or authors. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/** + * Examples for the "How-to - Database Initialization" section. + */ +package org.springframework.boot.docs.howto.databaseinitialization; diff --git a/spring-boot-project/spring-boot-docs/src/main/java/org/springframework/boot/docs/context/embedded/TomcatLegacyCookieProcessorExample.java b/spring-boot-project/spring-boot-docs/src/main/java/org/springframework/boot/docs/howto/embeddedwebservers/TomcatLegacyCookieProcessorExample.java similarity index 90% rename from spring-boot-project/spring-boot-docs/src/main/java/org/springframework/boot/docs/context/embedded/TomcatLegacyCookieProcessorExample.java rename to spring-boot-project/spring-boot-docs/src/main/java/org/springframework/boot/docs/howto/embeddedwebservers/TomcatLegacyCookieProcessorExample.java index f2bb5d298aa6..557c4a0b4516 100644 --- a/spring-boot-project/spring-boot-docs/src/main/java/org/springframework/boot/docs/context/embedded/TomcatLegacyCookieProcessorExample.java +++ b/spring-boot-project/spring-boot-docs/src/main/java/org/springframework/boot/docs/howto/embeddedwebservers/TomcatLegacyCookieProcessorExample.java @@ -1,5 +1,5 @@ /* - * Copyright 2012-2019 the original author or authors. + * Copyright 2012-2021 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -14,7 +14,7 @@ * limitations under the License. */ -package org.springframework.boot.docs.context.embedded; +package org.springframework.boot.docs.howto.embeddedwebservers; import org.apache.tomcat.util.http.LegacyCookieProcessor; @@ -36,13 +36,13 @@ public class TomcatLegacyCookieProcessorExample { @Configuration(proxyBeanMethods = false) public static class LegacyCookieProcessorConfiguration { - // tag::customizer[] + // tag::code[] @Bean public WebServerFactoryCustomizer cookieProcessorCustomizer() { return (factory) -> factory .addContextCustomizers((context) -> context.setCookieProcessor(new LegacyCookieProcessor())); } - // end::customizer[] + // end::code[] } diff --git a/spring-boot-project/spring-boot-docs/src/main/java/org/springframework/boot/docs/context/embedded/TomcatMultipleConnectorsExample.java b/spring-boot-project/spring-boot-docs/src/main/java/org/springframework/boot/docs/howto/embeddedwebservers/TomcatMultipleConnectorsExample.java similarity index 95% rename from spring-boot-project/spring-boot-docs/src/main/java/org/springframework/boot/docs/context/embedded/TomcatMultipleConnectorsExample.java rename to spring-boot-project/spring-boot-docs/src/main/java/org/springframework/boot/docs/howto/embeddedwebservers/TomcatMultipleConnectorsExample.java index b584448ed5ec..9608308c8e45 100644 --- a/spring-boot-project/spring-boot-docs/src/main/java/org/springframework/boot/docs/context/embedded/TomcatMultipleConnectorsExample.java +++ b/spring-boot-project/spring-boot-docs/src/main/java/org/springframework/boot/docs/howto/embeddedwebservers/TomcatMultipleConnectorsExample.java @@ -14,7 +14,7 @@ * limitations under the License. */ -package org.springframework.boot.docs.context.embedded; +package org.springframework.boot.docs.howto.embeddedwebservers; import java.io.IOException; import java.net.URL; @@ -36,7 +36,7 @@ @Configuration(proxyBeanMethods = false) public class TomcatMultipleConnectorsExample { - // tag::configuration[] + // tag::code[] @Bean public WebServerFactoryCustomizer sslConnectorCustomizer() { return (tomcat) -> tomcat.addAdditionalTomcatConnectors(createSslConnector()); @@ -63,6 +63,6 @@ private Connector createSslConnector() { throw new IllegalStateException("Fail to create ssl connector", ex); } } - // end::configuration[] + // end::code[] } diff --git a/spring-boot-project/spring-boot-docs/src/main/java/org/springframework/boot/docs/context/embedded/UndertowMultipleListenersExample.java b/spring-boot-project/spring-boot-docs/src/main/java/org/springframework/boot/docs/howto/embeddedwebservers/UndertowMultipleListenersExample.java similarity index 93% rename from spring-boot-project/spring-boot-docs/src/main/java/org/springframework/boot/docs/context/embedded/UndertowMultipleListenersExample.java rename to spring-boot-project/spring-boot-docs/src/main/java/org/springframework/boot/docs/howto/embeddedwebservers/UndertowMultipleListenersExample.java index bad053f8a9f5..94f50f4e196b 100644 --- a/spring-boot-project/spring-boot-docs/src/main/java/org/springframework/boot/docs/context/embedded/UndertowMultipleListenersExample.java +++ b/spring-boot-project/spring-boot-docs/src/main/java/org/springframework/boot/docs/howto/embeddedwebservers/UndertowMultipleListenersExample.java @@ -14,7 +14,7 @@ * limitations under the License. */ -package org.springframework.boot.docs.context.embedded; +package org.springframework.boot.docs.howto.embeddedwebservers; import io.undertow.Undertow.Builder; @@ -32,7 +32,7 @@ @Configuration(proxyBeanMethods = false) public class UndertowMultipleListenersExample { - // tag::configuration[] + // tag::code[] @Bean public WebServerFactoryCustomizer undertowListenerCustomizer() { return (factory) -> { @@ -46,6 +46,6 @@ public void customize(Builder builder) { }); }; } - // end::configuration[] + // end::code[] } diff --git a/spring-boot-project/spring-boot-docs/src/main/java/org/springframework/boot/docs/howto/embeddedwebservers/package-info.java b/spring-boot-project/spring-boot-docs/src/main/java/org/springframework/boot/docs/howto/embeddedwebservers/package-info.java new file mode 100644 index 000000000000..39d341eda5ff --- /dev/null +++ b/spring-boot-project/spring-boot-docs/src/main/java/org/springframework/boot/docs/howto/embeddedwebservers/package-info.java @@ -0,0 +1,20 @@ +/* + * Copyright 2012-2021 the original author or authors. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/** + * Examples for the "How-to - Embedded Web Servers" section. + */ +package org.springframework.boot.docs.howto.embeddedwebservers; diff --git a/spring-boot-project/spring-boot-docs/src/main/java/org/springframework/boot/docs/howto/hotswapping/package-info.java b/spring-boot-project/spring-boot-docs/src/main/java/org/springframework/boot/docs/howto/hotswapping/package-info.java new file mode 100644 index 000000000000..e2a273bf01c9 --- /dev/null +++ b/spring-boot-project/spring-boot-docs/src/main/java/org/springframework/boot/docs/howto/hotswapping/package-info.java @@ -0,0 +1,20 @@ +/* + * Copyright 2012-2021 the original author or authors. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/** + * Examples for the "How-to - Hot Swapping" section. + */ +package org.springframework.boot.docs.howto.hotswapping; diff --git a/spring-boot-project/spring-boot-docs/src/main/java/org/springframework/boot/docs/web/reactive/function/client/ReactorNettyClientCustomizationExample.java b/spring-boot-project/spring-boot-docs/src/main/java/org/springframework/boot/docs/howto/httpclients/ReactorNettyClientCustomizationExample.java similarity index 90% rename from spring-boot-project/spring-boot-docs/src/main/java/org/springframework/boot/docs/web/reactive/function/client/ReactorNettyClientCustomizationExample.java rename to spring-boot-project/spring-boot-docs/src/main/java/org/springframework/boot/docs/howto/httpclients/ReactorNettyClientCustomizationExample.java index ff2e7f9541fe..6290717ab8bd 100644 --- a/spring-boot-project/spring-boot-docs/src/main/java/org/springframework/boot/docs/web/reactive/function/client/ReactorNettyClientCustomizationExample.java +++ b/spring-boot-project/spring-boot-docs/src/main/java/org/springframework/boot/docs/howto/httpclients/ReactorNettyClientCustomizationExample.java @@ -1,5 +1,5 @@ /* - * Copyright 2012-2020 the original author or authors. + * Copyright 2012-2021 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -14,7 +14,7 @@ * limitations under the License. */ -package org.springframework.boot.docs.web.reactive.function.client; +package org.springframework.boot.docs.howto.httpclients; import io.netty.channel.ChannelOption; import io.netty.handler.timeout.ReadTimeoutHandler; @@ -35,7 +35,7 @@ @Configuration(proxyBeanMethods = false) public class ReactorNettyClientCustomizationExample { - // tag::custom-http-connector[] + // tag::code[] @Bean ClientHttpConnector clientHttpConnector(ReactorResourceFactory resourceFactory) { HttpClient httpClient = HttpClient.create(resourceFactory.getConnectionProvider()) @@ -43,6 +43,6 @@ ClientHttpConnector clientHttpConnector(ReactorResourceFactory resourceFactory) .doOnConnected((connection) -> connection.addHandlerLast(new ReadTimeoutHandler(60))); return new ReactorClientHttpConnector(httpClient); } - // end::custom-http-connector[] + // end::code[] } diff --git a/spring-boot-project/spring-boot-docs/src/main/java/org/springframework/boot/docs/howto/httpclients/package-info.java b/spring-boot-project/spring-boot-docs/src/main/java/org/springframework/boot/docs/howto/httpclients/package-info.java new file mode 100644 index 000000000000..d27b0e13109b --- /dev/null +++ b/spring-boot-project/spring-boot-docs/src/main/java/org/springframework/boot/docs/howto/httpclients/package-info.java @@ -0,0 +1,20 @@ +/* + * Copyright 2012-2021 the original author or authors. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/** + * Examples for the "How-to - HTTP Clients" section. + */ +package org.springframework.boot.docs.howto.httpclients; diff --git a/spring-boot-project/spring-boot-docs/src/main/java/org/springframework/boot/docs/jersey/JerseySetStatusOverSendErrorExample.java b/spring-boot-project/spring-boot-docs/src/main/java/org/springframework/boot/docs/howto/jersey/JerseySetStatusOverSendErrorExample.java similarity index 89% rename from spring-boot-project/spring-boot-docs/src/main/java/org/springframework/boot/docs/jersey/JerseySetStatusOverSendErrorExample.java rename to spring-boot-project/spring-boot-docs/src/main/java/org/springframework/boot/docs/howto/jersey/JerseySetStatusOverSendErrorExample.java index 0874f9f0e7ca..6720bd3b9107 100644 --- a/spring-boot-project/spring-boot-docs/src/main/java/org/springframework/boot/docs/jersey/JerseySetStatusOverSendErrorExample.java +++ b/spring-boot-project/spring-boot-docs/src/main/java/org/springframework/boot/docs/howto/jersey/JerseySetStatusOverSendErrorExample.java @@ -1,5 +1,5 @@ /* - * Copyright 2012-2019 the original author or authors. + * Copyright 2012-2021 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -14,7 +14,7 @@ * limitations under the License. */ -package org.springframework.boot.docs.jersey; +package org.springframework.boot.docs.howto.jersey; import java.util.Collections; @@ -33,7 +33,7 @@ */ public class JerseySetStatusOverSendErrorExample { - // tag::resource-config[] + // tag::code[] @Component public class JerseyConfig extends ResourceConfig { @@ -43,7 +43,7 @@ public JerseyConfig() { } } - // end::resource-config[] + // end::code[] static class Endpoint { diff --git a/spring-boot-project/spring-boot-docs/src/main/java/org/springframework/boot/docs/howto/jersey/package-info.java b/spring-boot-project/spring-boot-docs/src/main/java/org/springframework/boot/docs/howto/jersey/package-info.java new file mode 100644 index 000000000000..ef3a388de67a --- /dev/null +++ b/spring-boot-project/spring-boot-docs/src/main/java/org/springframework/boot/docs/howto/jersey/package-info.java @@ -0,0 +1,20 @@ +/* + * Copyright 2012-2021 the original author or authors. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/** + * Examples for the "How-to - Jersey" section. + */ +package org.springframework.boot.docs.howto.jersey; diff --git a/spring-boot-project/spring-boot-docs/src/main/java/org/springframework/boot/docs/howto/logging/package-info.java b/spring-boot-project/spring-boot-docs/src/main/java/org/springframework/boot/docs/howto/logging/package-info.java new file mode 100644 index 000000000000..2fe9a206ea83 --- /dev/null +++ b/spring-boot-project/spring-boot-docs/src/main/java/org/springframework/boot/docs/howto/logging/package-info.java @@ -0,0 +1,20 @@ +/* + * Copyright 2012-2021 the original author or authors. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/** + * Examples for the "How-to - Logging" section. + */ +package org.springframework.boot.docs.howto.logging; diff --git a/spring-boot-project/spring-boot-docs/src/main/java/org/springframework/boot/docs/howto/messaging/package-info.java b/spring-boot-project/spring-boot-docs/src/main/java/org/springframework/boot/docs/howto/messaging/package-info.java new file mode 100644 index 000000000000..5dea09cf3e1c --- /dev/null +++ b/spring-boot-project/spring-boot-docs/src/main/java/org/springframework/boot/docs/howto/messaging/package-info.java @@ -0,0 +1,20 @@ +/* + * Copyright 2012-2021 the original author or authors. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/** + * Examples for the "How-to - Messaging" section. + */ +package org.springframework.boot.docs.howto.messaging; diff --git a/spring-boot-project/spring-boot-docs/src/main/java/org/springframework/boot/docs/howto/propertiesandconfiguration/package-info.java b/spring-boot-project/spring-boot-docs/src/main/java/org/springframework/boot/docs/howto/propertiesandconfiguration/package-info.java new file mode 100644 index 000000000000..dcfd0d12b2de --- /dev/null +++ b/spring-boot-project/spring-boot-docs/src/main/java/org/springframework/boot/docs/howto/propertiesandconfiguration/package-info.java @@ -0,0 +1,20 @@ +/* + * Copyright 2012-2021 the original author or authors. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/** + * Examples for the "How-to - Properties and Configuration" section. + */ +package org.springframework.boot.docs.howto.propertiesandconfiguration; diff --git a/spring-boot-project/spring-boot-docs/src/main/java/org/springframework/boot/docs/howto/security/package-info.java b/spring-boot-project/spring-boot-docs/src/main/java/org/springframework/boot/docs/howto/security/package-info.java new file mode 100644 index 000000000000..bd36bd612dd2 --- /dev/null +++ b/spring-boot-project/spring-boot-docs/src/main/java/org/springframework/boot/docs/howto/security/package-info.java @@ -0,0 +1,20 @@ +/* + * Copyright 2012-2021 the original author or authors. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/** + * Examples for the "How-to - Security" section. + */ +package org.springframework.boot.docs.howto.security; diff --git a/spring-boot-project/spring-boot-docs/src/main/java/org/springframework/boot/docs/context/EnvironmentPostProcessorExample.java b/spring-boot-project/spring-boot-docs/src/main/java/org/springframework/boot/docs/howto/springbootapplication/EnvironmentPostProcessorExample.java similarity index 87% rename from spring-boot-project/spring-boot-docs/src/main/java/org/springframework/boot/docs/context/EnvironmentPostProcessorExample.java rename to spring-boot-project/spring-boot-docs/src/main/java/org/springframework/boot/docs/howto/springbootapplication/EnvironmentPostProcessorExample.java index 2bfef078e9e8..3b7a90b764d5 100644 --- a/spring-boot-project/spring-boot-docs/src/main/java/org/springframework/boot/docs/context/EnvironmentPostProcessorExample.java +++ b/spring-boot-project/spring-boot-docs/src/main/java/org/springframework/boot/docs/howto/springbootapplication/EnvironmentPostProcessorExample.java @@ -1,5 +1,5 @@ /* - * Copyright 2012-2019 the original author or authors. + * Copyright 2012-2021 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -14,7 +14,7 @@ * limitations under the License. */ -package org.springframework.boot.docs.context; +package org.springframework.boot.docs.howto.springbootapplication; import java.io.IOException; @@ -25,13 +25,14 @@ import org.springframework.core.env.PropertySource; import org.springframework.core.io.ClassPathResource; import org.springframework.core.io.Resource; +import org.springframework.util.Assert; /** * An {@link EnvironmentPostProcessor} example that loads a YAML file. * * @author Stephane Nicoll */ -// tag::example[] +// tag::code[] public class EnvironmentPostProcessorExample implements EnvironmentPostProcessor { private final YamlPropertySourceLoader loader = new YamlPropertySourceLoader(); @@ -44,9 +45,7 @@ public void postProcessEnvironment(ConfigurableEnvironment environment, SpringAp } private PropertySource loadYaml(Resource path) { - if (!path.exists()) { - throw new IllegalArgumentException("Resource " + path + " does not exist"); - } + Assert.isTrue(path.exists(), () -> "Resource " + path + " does not exist"); try { return this.loader.load("custom-resource", path).get(0); } @@ -56,4 +55,4 @@ private PropertySource loadYaml(Resource path) { } } -// end::example[] +// end::code[] diff --git a/spring-boot-project/spring-boot-docs/src/main/java/org/springframework/boot/docs/howto/springbootapplication/package-info.java b/spring-boot-project/spring-boot-docs/src/main/java/org/springframework/boot/docs/howto/springbootapplication/package-info.java new file mode 100644 index 000000000000..7312f7df3a58 --- /dev/null +++ b/spring-boot-project/spring-boot-docs/src/main/java/org/springframework/boot/docs/howto/springbootapplication/package-info.java @@ -0,0 +1,20 @@ +/* + * Copyright 2012-2021 the original author or authors. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/** + * Examples for the "How-to - Spring Boot Application" section. + */ +package org.springframework.boot.docs.howto.springbootapplication; diff --git a/spring-boot-project/spring-boot-docs/src/main/java/org/springframework/boot/docs/howto/springmvc/package-info.java b/spring-boot-project/spring-boot-docs/src/main/java/org/springframework/boot/docs/howto/springmvc/package-info.java new file mode 100644 index 000000000000..3473857d6609 --- /dev/null +++ b/spring-boot-project/spring-boot-docs/src/main/java/org/springframework/boot/docs/howto/springmvc/package-info.java @@ -0,0 +1,20 @@ +/* + * Copyright 2012-2021 the original author or authors. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/** + * Examples for the "How-to - Spring MVC" section. + */ +package org.springframework.boot.docs.howto.springmvc; diff --git a/spring-boot-project/spring-boot-docs/src/main/java/org/springframework/boot/docs/howto/testingwithspringsecurity/package-info.java b/spring-boot-project/spring-boot-docs/src/main/java/org/springframework/boot/docs/howto/testingwithspringsecurity/package-info.java new file mode 100644 index 000000000000..6f0a7114c6da --- /dev/null +++ b/spring-boot-project/spring-boot-docs/src/main/java/org/springframework/boot/docs/howto/testingwithspringsecurity/package-info.java @@ -0,0 +1,20 @@ +/* + * Copyright 2012-2021 the original author or authors. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/** + * Examples for the "How-to - Testing with Spring Security" section. + */ +package org.springframework.boot.docs.howto.testingwithspringsecurity; diff --git a/spring-boot-project/spring-boot-docs/src/main/java/org/springframework/boot/docs/howto/traditionaldeployment/package-info.java b/spring-boot-project/spring-boot-docs/src/main/java/org/springframework/boot/docs/howto/traditionaldeployment/package-info.java new file mode 100644 index 000000000000..45cf58f6dc62 --- /dev/null +++ b/spring-boot-project/spring-boot-docs/src/main/java/org/springframework/boot/docs/howto/traditionaldeployment/package-info.java @@ -0,0 +1,20 @@ +/* + * Copyright 2012-2021 the original author or authors. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/** + * Examples for the "How-to - Traditional Deployment" section. + */ +package org.springframework.boot.docs.howto.traditionaldeployment; diff --git a/spring-boot-project/spring-boot-docs/src/main/java/org/springframework/boot/docs/productionreadyfeatures/auditing/package-info.java b/spring-boot-project/spring-boot-docs/src/main/java/org/springframework/boot/docs/productionreadyfeatures/auditing/package-info.java new file mode 100644 index 000000000000..66e57e05fa4a --- /dev/null +++ b/spring-boot-project/spring-boot-docs/src/main/java/org/springframework/boot/docs/productionreadyfeatures/auditing/package-info.java @@ -0,0 +1,20 @@ +/* + * Copyright 2012-2021 the original author or authors. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/** + * Examples for the "Production Ready Features - Auditing" section. + */ +package org.springframework.boot.docs.productionreadyfeatures.auditing; diff --git a/spring-boot-project/spring-boot-docs/src/main/java/org/springframework/boot/docs/cloudfoundry/CloudFoundryCustomContextPathExample.java b/spring-boot-project/spring-boot-docs/src/main/java/org/springframework/boot/docs/productionreadyfeatures/cloudfoundry/CloudFoundryCustomContextPathExample.java similarity index 94% rename from spring-boot-project/spring-boot-docs/src/main/java/org/springframework/boot/docs/cloudfoundry/CloudFoundryCustomContextPathExample.java rename to spring-boot-project/spring-boot-docs/src/main/java/org/springframework/boot/docs/productionreadyfeatures/cloudfoundry/CloudFoundryCustomContextPathExample.java index d1cbc15d5e45..f9d6fcd7eb8e 100644 --- a/spring-boot-project/spring-boot-docs/src/main/java/org/springframework/boot/docs/cloudfoundry/CloudFoundryCustomContextPathExample.java +++ b/spring-boot-project/spring-boot-docs/src/main/java/org/springframework/boot/docs/productionreadyfeatures/cloudfoundry/CloudFoundryCustomContextPathExample.java @@ -1,5 +1,5 @@ /* - * Copyright 2012-2019 the original author or authors. + * Copyright 2012-2021 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -14,7 +14,7 @@ * limitations under the License. */ -package org.springframework.boot.docs.cloudfoundry; +package org.springframework.boot.docs.productionreadyfeatures.cloudfoundry; import java.io.IOException; import java.util.Collections; @@ -44,7 +44,7 @@ @Configuration(proxyBeanMethods = false) public class CloudFoundryCustomContextPathExample { - // tag::configuration[] + // tag::code[] @Bean public TomcatServletWebServerFactory servletWebServerFactory() { return new TomcatServletWebServerFactory() { @@ -78,6 +78,6 @@ public void service(ServletRequest req, ServletResponse res) throws ServletExcep context.addServlet("cloudfoundry", servlet).addMapping("/*"); }; } - // end::configuration[] + // end::code[] } diff --git a/spring-boot-project/spring-boot-docs/src/main/java/org/springframework/boot/docs/productionreadyfeatures/cloudfoundry/package-info.java b/spring-boot-project/spring-boot-docs/src/main/java/org/springframework/boot/docs/productionreadyfeatures/cloudfoundry/package-info.java new file mode 100644 index 000000000000..07dedb276e0f --- /dev/null +++ b/spring-boot-project/spring-boot-docs/src/main/java/org/springframework/boot/docs/productionreadyfeatures/cloudfoundry/package-info.java @@ -0,0 +1,20 @@ +/* + * Copyright 2012-2021 the original author or authors. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/** + * Examples for the "Production Ready Features - Cloud Foundry Support" section. + */ +package org.springframework.boot.docs.productionreadyfeatures.cloudfoundry; diff --git a/spring-boot-project/spring-boot-docs/src/main/java/org/springframework/boot/docs/productionreadyfeatures/enabling/package-info.java b/spring-boot-project/spring-boot-docs/src/main/java/org/springframework/boot/docs/productionreadyfeatures/enabling/package-info.java new file mode 100644 index 000000000000..038f7fb39b48 --- /dev/null +++ b/spring-boot-project/spring-boot-docs/src/main/java/org/springframework/boot/docs/productionreadyfeatures/enabling/package-info.java @@ -0,0 +1,21 @@ +/* + * Copyright 2012-2021 the original author or authors. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/** + * Examples for the "Production Ready Features - Enabling Production Ready Features" + * section. + */ +package org.springframework.boot.docs.productionreadyfeatures.enabling; diff --git a/spring-boot-project/spring-boot-docs/src/main/java/org/springframework/boot/docs/actuate/endpoint/CustomEndpointExample.java b/spring-boot-project/spring-boot-docs/src/main/java/org/springframework/boot/docs/productionreadyfeatures/endpoints/CustomEndpointExample.java similarity index 85% rename from spring-boot-project/spring-boot-docs/src/main/java/org/springframework/boot/docs/actuate/endpoint/CustomEndpointExample.java rename to spring-boot-project/spring-boot-docs/src/main/java/org/springframework/boot/docs/productionreadyfeatures/endpoints/CustomEndpointExample.java index 78674d700ce5..a46938dd3098 100644 --- a/spring-boot-project/spring-boot-docs/src/main/java/org/springframework/boot/docs/actuate/endpoint/CustomEndpointExample.java +++ b/spring-boot-project/spring-boot-docs/src/main/java/org/springframework/boot/docs/productionreadyfeatures/endpoints/CustomEndpointExample.java @@ -1,5 +1,5 @@ /* - * Copyright 2012-2020 the original author or authors. + * Copyright 2012-2021 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -14,7 +14,7 @@ * limitations under the License. */ -package org.springframework.boot.docs.actuate.endpoint; +package org.springframework.boot.docs.productionreadyfeatures.endpoints; import org.springframework.boot.actuate.endpoint.annotation.Endpoint; import org.springframework.boot.actuate.endpoint.annotation.ReadOperation; @@ -53,6 +53,14 @@ public CustomData(String name, int counter) { this.counter = counter; } + public String getName() { + return this.name; + } + + public int getCounter() { + return this.counter; + } + } } diff --git a/spring-boot-project/spring-boot-docs/src/main/java/org/springframework/boot/docs/productionreadyfeatures/endpoints/package-info.java b/spring-boot-project/spring-boot-docs/src/main/java/org/springframework/boot/docs/productionreadyfeatures/endpoints/package-info.java new file mode 100644 index 000000000000..9f4ed9d93660 --- /dev/null +++ b/spring-boot-project/spring-boot-docs/src/main/java/org/springframework/boot/docs/productionreadyfeatures/endpoints/package-info.java @@ -0,0 +1,20 @@ +/* + * Copyright 2012-2021 the original author or authors. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/** + * Examples for the "Production Ready Features - Endpoints" section. + */ +package org.springframework.boot.docs.productionreadyfeatures.endpoints; diff --git a/spring-boot-project/spring-boot-docs/src/main/java/org/springframework/boot/docs/productionreadyfeatures/httptracing/package-info.java b/spring-boot-project/spring-boot-docs/src/main/java/org/springframework/boot/docs/productionreadyfeatures/httptracing/package-info.java new file mode 100644 index 000000000000..390de022b612 --- /dev/null +++ b/spring-boot-project/spring-boot-docs/src/main/java/org/springframework/boot/docs/productionreadyfeatures/httptracing/package-info.java @@ -0,0 +1,20 @@ +/* + * Copyright 2012-2021 the original author or authors. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/** + * Examples for the "Production Ready Features - HTTP Tracing" section. + */ +package org.springframework.boot.docs.productionreadyfeatures.httptracing; diff --git a/spring-boot-project/spring-boot-docs/src/main/java/org/springframework/boot/docs/productionreadyfeatures/loggers/package-info.java b/spring-boot-project/spring-boot-docs/src/main/java/org/springframework/boot/docs/productionreadyfeatures/loggers/package-info.java new file mode 100644 index 000000000000..bd125de90db2 --- /dev/null +++ b/spring-boot-project/spring-boot-docs/src/main/java/org/springframework/boot/docs/productionreadyfeatures/loggers/package-info.java @@ -0,0 +1,20 @@ +/* + * Copyright 2012-2021 the original author or authors. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/** + * Examples for the "Production Ready Features - Loggers" section. + */ +package org.springframework.boot.docs.productionreadyfeatures.loggers; diff --git a/spring-boot-project/spring-boot-docs/src/main/java/org/springframework/boot/docs/actuate/metrics/MetricsFilterBeanExample.java b/spring-boot-project/spring-boot-docs/src/main/java/org/springframework/boot/docs/productionreadyfeatures/metrics/MetricsFilterBeanExample.java similarity index 87% rename from spring-boot-project/spring-boot-docs/src/main/java/org/springframework/boot/docs/actuate/metrics/MetricsFilterBeanExample.java rename to spring-boot-project/spring-boot-docs/src/main/java/org/springframework/boot/docs/productionreadyfeatures/metrics/MetricsFilterBeanExample.java index 3c7be0c394b8..103ff1311e11 100644 --- a/spring-boot-project/spring-boot-docs/src/main/java/org/springframework/boot/docs/actuate/metrics/MetricsFilterBeanExample.java +++ b/spring-boot-project/spring-boot-docs/src/main/java/org/springframework/boot/docs/productionreadyfeatures/metrics/MetricsFilterBeanExample.java @@ -1,5 +1,5 @@ /* - * Copyright 2012-2019 the original author or authors. + * Copyright 2012-2021 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -14,7 +14,7 @@ * limitations under the License. */ -package org.springframework.boot.docs.actuate.metrics; +package org.springframework.boot.docs.productionreadyfeatures.metrics; import io.micrometer.core.instrument.config.MeterFilter; @@ -31,12 +31,12 @@ public class MetricsFilterBeanExample { @Configuration(proxyBeanMethods = false) public static class MetricsFilterExampleConfiguration { - // tag::configuration[] + // tag::code[] @Bean public MeterFilter renameRegionTagMeterFilter() { return MeterFilter.renameTag("com.example", "mytag.region", "mytag.area"); } - // end::configuration[] + // end::code[] } diff --git a/spring-boot-project/spring-boot-docs/src/main/java/org/springframework/boot/docs/actuate/metrics/MetricsMeterRegistryInjectionExample.java b/spring-boot-project/spring-boot-docs/src/main/java/org/springframework/boot/docs/productionreadyfeatures/metrics/MetricsMeterRegistryInjectionExample.java similarity index 86% rename from spring-boot-project/spring-boot-docs/src/main/java/org/springframework/boot/docs/actuate/metrics/MetricsMeterRegistryInjectionExample.java rename to spring-boot-project/spring-boot-docs/src/main/java/org/springframework/boot/docs/productionreadyfeatures/metrics/MetricsMeterRegistryInjectionExample.java index efb36a2e415c..3845936b0e65 100644 --- a/spring-boot-project/spring-boot-docs/src/main/java/org/springframework/boot/docs/actuate/metrics/MetricsMeterRegistryInjectionExample.java +++ b/spring-boot-project/spring-boot-docs/src/main/java/org/springframework/boot/docs/productionreadyfeatures/metrics/MetricsMeterRegistryInjectionExample.java @@ -1,5 +1,5 @@ /* - * Copyright 2012-2019 the original author or authors. + * Copyright 2012-2021 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -14,7 +14,7 @@ * limitations under the License. */ -package org.springframework.boot.docs.actuate.metrics; +package org.springframework.boot.docs.productionreadyfeatures.metrics; import java.util.List; import java.util.concurrent.CopyOnWriteArrayList; @@ -29,7 +29,7 @@ */ public class MetricsMeterRegistryInjectionExample { - // tag::component[] + // tag::code[] class Dictionary { private final List words = new CopyOnWriteArrayList<>(); @@ -38,9 +38,9 @@ class Dictionary { registry.gaugeCollectionSize("dictionary.size", Tags.empty(), this.words); } - // … + // ... } - // end::component[] + // end::code[] } diff --git a/spring-boot-project/spring-boot-docs/src/main/java/org/springframework/boot/docs/actuate/metrics/SampleMeterBinderConfiguration.java b/spring-boot-project/spring-boot-docs/src/main/java/org/springframework/boot/docs/productionreadyfeatures/metrics/SampleMeterBinderConfiguration.java similarity index 87% rename from spring-boot-project/spring-boot-docs/src/main/java/org/springframework/boot/docs/actuate/metrics/SampleMeterBinderConfiguration.java rename to spring-boot-project/spring-boot-docs/src/main/java/org/springframework/boot/docs/productionreadyfeatures/metrics/SampleMeterBinderConfiguration.java index 63931823d7cf..b289ab58cf38 100644 --- a/spring-boot-project/spring-boot-docs/src/main/java/org/springframework/boot/docs/actuate/metrics/SampleMeterBinderConfiguration.java +++ b/spring-boot-project/spring-boot-docs/src/main/java/org/springframework/boot/docs/productionreadyfeatures/metrics/SampleMeterBinderConfiguration.java @@ -1,5 +1,5 @@ /* - * Copyright 2012-2020 the original author or authors. + * Copyright 2012-2021 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -14,7 +14,7 @@ * limitations under the License. */ -package org.springframework.boot.docs.actuate.metrics; +package org.springframework.boot.docs.productionreadyfeatures.metrics; import io.micrometer.core.instrument.Gauge; import io.micrometer.core.instrument.binder.MeterBinder; @@ -28,12 +28,12 @@ */ public class SampleMeterBinderConfiguration { - // tag::example[] + // tag::code[] @Bean MeterBinder queueSize(Queue queue) { return (registry) -> Gauge.builder("queueSize", queue::size).register(registry); } - // end::example[] + // end::code[] static class Queue { diff --git a/spring-boot-project/spring-boot-docs/src/main/java/org/springframework/boot/docs/productionreadyfeatures/metrics/package-info.java b/spring-boot-project/spring-boot-docs/src/main/java/org/springframework/boot/docs/productionreadyfeatures/metrics/package-info.java new file mode 100644 index 000000000000..0db6b7dd4eb4 --- /dev/null +++ b/spring-boot-project/spring-boot-docs/src/main/java/org/springframework/boot/docs/productionreadyfeatures/metrics/package-info.java @@ -0,0 +1,20 @@ +/* + * Copyright 2012-2021 the original author or authors. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/** + * Examples for the "Production Ready Features - Metrics" section. + */ +package org.springframework.boot.docs.productionreadyfeatures.metrics; diff --git a/spring-boot-project/spring-boot-docs/src/main/java/org/springframework/boot/docs/productionreadyfeatures/monitoring/http/package-info.java b/spring-boot-project/spring-boot-docs/src/main/java/org/springframework/boot/docs/productionreadyfeatures/monitoring/http/package-info.java new file mode 100644 index 000000000000..b6856c0ea5f8 --- /dev/null +++ b/spring-boot-project/spring-boot-docs/src/main/java/org/springframework/boot/docs/productionreadyfeatures/monitoring/http/package-info.java @@ -0,0 +1,21 @@ +/* + * Copyright 2012-2021 the original author or authors. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/** + * Examples for the "Production Ready Features - Monitoring and Management overt HTTP" + * section. + */ +package org.springframework.boot.docs.productionreadyfeatures.monitoring.http; diff --git a/spring-boot-project/spring-boot-docs/src/main/java/org/springframework/boot/docs/productionreadyfeatures/monitoring/jmx/package-info.java b/spring-boot-project/spring-boot-docs/src/main/java/org/springframework/boot/docs/productionreadyfeatures/monitoring/jmx/package-info.java new file mode 100644 index 000000000000..4f30dd6082ff --- /dev/null +++ b/spring-boot-project/spring-boot-docs/src/main/java/org/springframework/boot/docs/productionreadyfeatures/monitoring/jmx/package-info.java @@ -0,0 +1,21 @@ +/* + * Copyright 2012-2021 the original author or authors. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/** + * Examples for the "Production Ready Features - Monitoring and Management overt JMX" + * section. + */ +package org.springframework.boot.docs.productionreadyfeatures.monitoring.jmx; diff --git a/spring-boot-project/spring-boot-docs/src/main/java/org/springframework/boot/docs/productionreadyfeatures/processmonitoring/package-info.java b/spring-boot-project/spring-boot-docs/src/main/java/org/springframework/boot/docs/productionreadyfeatures/processmonitoring/package-info.java new file mode 100644 index 000000000000..d785b52657e3 --- /dev/null +++ b/spring-boot-project/spring-boot-docs/src/main/java/org/springframework/boot/docs/productionreadyfeatures/processmonitoring/package-info.java @@ -0,0 +1,20 @@ +/* + * Copyright 2012-2021 the original author or authors. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/** + * Examples for the "Production Ready Features - Process Monitoring" section. + */ +package org.springframework.boot.docs.productionreadyfeatures.processmonitoring; diff --git a/spring-boot-project/spring-boot-docs/src/main/java/org/springframework/boot/docs/springbootfeatures/caching/package-info.java b/spring-boot-project/spring-boot-docs/src/main/java/org/springframework/boot/docs/springbootfeatures/caching/package-info.java new file mode 100644 index 000000000000..ddc23dfa4ecf --- /dev/null +++ b/spring-boot-project/spring-boot-docs/src/main/java/org/springframework/boot/docs/springbootfeatures/caching/package-info.java @@ -0,0 +1,20 @@ +/* + * Copyright 2012-2021 the original author or authors. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/** + * Examples for the "Spring Boot Features - Caching" section. + */ +package org.springframework.boot.docs.springbootfeatures.caching; diff --git a/spring-boot-project/spring-boot-docs/src/main/java/org/springframework/boot/docs/springbootfeatures/containerimages/package-info.java b/spring-boot-project/spring-boot-docs/src/main/java/org/springframework/boot/docs/springbootfeatures/containerimages/package-info.java new file mode 100644 index 000000000000..9f29fcca7041 --- /dev/null +++ b/spring-boot-project/spring-boot-docs/src/main/java/org/springframework/boot/docs/springbootfeatures/containerimages/package-info.java @@ -0,0 +1,20 @@ +/* + * Copyright 2012-2021 the original author or authors. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/** + * Examples for the "Spring Boot Features - Container Images" section. + */ +package org.springframework.boot.docs.springbootfeatures.containerimages; diff --git a/spring-boot-project/spring-boot-docs/src/main/java/org/springframework/boot/docs/autoconfigure/UserService.java b/spring-boot-project/spring-boot-docs/src/main/java/org/springframework/boot/docs/springbootfeatures/creatingautoconfiguration/UserService.java similarity index 85% rename from spring-boot-project/spring-boot-docs/src/main/java/org/springframework/boot/docs/autoconfigure/UserService.java rename to spring-boot-project/spring-boot-docs/src/main/java/org/springframework/boot/docs/springbootfeatures/creatingautoconfiguration/UserService.java index 4b089ca29ba8..028fe37b5f08 100644 --- a/spring-boot-project/spring-boot-docs/src/main/java/org/springframework/boot/docs/autoconfigure/UserService.java +++ b/spring-boot-project/spring-boot-docs/src/main/java/org/springframework/boot/docs/springbootfeatures/creatingautoconfiguration/UserService.java @@ -1,5 +1,5 @@ /* - * Copyright 2012-2019 the original author or authors. + * Copyright 2012-2021 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -14,7 +14,7 @@ * limitations under the License. */ -package org.springframework.boot.docs.autoconfigure; +package org.springframework.boot.docs.springbootfeatures.creatingautoconfiguration; /** * Sample service. diff --git a/spring-boot-project/spring-boot-docs/src/main/java/org/springframework/boot/docs/autoconfigure/UserServiceAutoConfiguration.java b/spring-boot-project/spring-boot-docs/src/main/java/org/springframework/boot/docs/springbootfeatures/creatingautoconfiguration/UserServiceAutoConfiguration.java similarity index 85% rename from spring-boot-project/spring-boot-docs/src/main/java/org/springframework/boot/docs/autoconfigure/UserServiceAutoConfiguration.java rename to spring-boot-project/spring-boot-docs/src/main/java/org/springframework/boot/docs/springbootfeatures/creatingautoconfiguration/UserServiceAutoConfiguration.java index 7566b78ad5c2..6b902d778bc7 100644 --- a/spring-boot-project/spring-boot-docs/src/main/java/org/springframework/boot/docs/autoconfigure/UserServiceAutoConfiguration.java +++ b/spring-boot-project/spring-boot-docs/src/main/java/org/springframework/boot/docs/springbootfeatures/creatingautoconfiguration/UserServiceAutoConfiguration.java @@ -1,5 +1,5 @@ /* - * Copyright 2012-2019 the original author or authors. + * Copyright 2012-2021 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -14,13 +14,13 @@ * limitations under the License. */ -package org.springframework.boot.docs.autoconfigure; +package org.springframework.boot.docs.springbootfeatures.creatingautoconfiguration; import org.springframework.boot.autoconfigure.condition.ConditionalOnClass; import org.springframework.boot.autoconfigure.condition.ConditionalOnMissingBean; import org.springframework.boot.context.properties.ConfigurationProperties; import org.springframework.boot.context.properties.EnableConfigurationProperties; -import org.springframework.boot.docs.autoconfigure.UserServiceAutoConfiguration.UserProperties; +import org.springframework.boot.docs.springbootfeatures.creatingautoconfiguration.UserServiceAutoConfiguration.UserProperties; import org.springframework.context.annotation.Bean; import org.springframework.context.annotation.Configuration; diff --git a/spring-boot-project/spring-boot-docs/src/main/java/org/springframework/boot/docs/springbootfeatures/creatingautoconfiguration/package-info.java b/spring-boot-project/spring-boot-docs/src/main/java/org/springframework/boot/docs/springbootfeatures/creatingautoconfiguration/package-info.java new file mode 100644 index 000000000000..07eacefd465f --- /dev/null +++ b/spring-boot-project/spring-boot-docs/src/main/java/org/springframework/boot/docs/springbootfeatures/creatingautoconfiguration/package-info.java @@ -0,0 +1,20 @@ +/* + * Copyright 2012-2021 the original author or authors. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/** + * Examples for the "Spring Boot Features - Creating Your Own Auto-Configuration" section. + */ +package org.springframework.boot.docs.springbootfeatures.creatingautoconfiguration; diff --git a/spring-boot-project/spring-boot-docs/src/main/java/org/springframework/boot/docs/springbootfeatures/email/package-info.java b/spring-boot-project/spring-boot-docs/src/main/java/org/springframework/boot/docs/springbootfeatures/email/package-info.java new file mode 100644 index 000000000000..b6bca4cd16e7 --- /dev/null +++ b/spring-boot-project/spring-boot-docs/src/main/java/org/springframework/boot/docs/springbootfeatures/email/package-info.java @@ -0,0 +1,20 @@ +/* + * Copyright 2012-2021 the original author or authors. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/** + * Examples for the "Spring Boot Features - Sending Email" section. + */ +package org.springframework.boot.docs.springbootfeatures.email; diff --git a/spring-boot-project/spring-boot-docs/src/main/java/org/springframework/boot/docs/context/properties/bind/constructor/AppIoProperties.java b/spring-boot-project/spring-boot-docs/src/main/java/org/springframework/boot/docs/springbootfeatures/externalizedconfiguration/datasize/constructorbinding/AppIoProperties.java similarity index 89% rename from spring-boot-project/spring-boot-docs/src/main/java/org/springframework/boot/docs/context/properties/bind/constructor/AppIoProperties.java rename to spring-boot-project/spring-boot-docs/src/main/java/org/springframework/boot/docs/springbootfeatures/externalizedconfiguration/datasize/constructorbinding/AppIoProperties.java index 86bcb9e76a55..b94754e06ad8 100644 --- a/spring-boot-project/spring-boot-docs/src/main/java/org/springframework/boot/docs/context/properties/bind/constructor/AppIoProperties.java +++ b/spring-boot-project/spring-boot-docs/src/main/java/org/springframework/boot/docs/springbootfeatures/externalizedconfiguration/datasize/constructorbinding/AppIoProperties.java @@ -1,5 +1,5 @@ /* - * Copyright 2012-2020 the original author or authors. + * Copyright 2012-2021 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -14,7 +14,7 @@ * limitations under the License. */ -package org.springframework.boot.docs.context.properties.bind.constructor; +package org.springframework.boot.docs.springbootfeatures.externalizedconfiguration.datasize.constructorbinding; import org.springframework.boot.context.properties.ConfigurationProperties; import org.springframework.boot.context.properties.ConstructorBinding; @@ -29,7 +29,7 @@ * * @author Stephane Nicoll */ -// tag::example[] +// tag::code[] @ConfigurationProperties("app.io") @ConstructorBinding public class AppIoProperties { @@ -53,4 +53,4 @@ public DataSize getSizeThreshold() { } } -// end::example[] +// end::code[] diff --git a/spring-boot-project/spring-boot-docs/src/main/java/org/springframework/boot/docs/context/properties/bind/javabean/AppIoProperties.java b/spring-boot-project/spring-boot-docs/src/main/java/org/springframework/boot/docs/springbootfeatures/externalizedconfiguration/datasize/javabeanbinding/AppIoProperties.java similarity index 88% rename from spring-boot-project/spring-boot-docs/src/main/java/org/springframework/boot/docs/context/properties/bind/javabean/AppIoProperties.java rename to spring-boot-project/spring-boot-docs/src/main/java/org/springframework/boot/docs/springbootfeatures/externalizedconfiguration/datasize/javabeanbinding/AppIoProperties.java index 15862ff55f48..7aba68682051 100644 --- a/spring-boot-project/spring-boot-docs/src/main/java/org/springframework/boot/docs/context/properties/bind/javabean/AppIoProperties.java +++ b/spring-boot-project/spring-boot-docs/src/main/java/org/springframework/boot/docs/springbootfeatures/externalizedconfiguration/datasize/javabeanbinding/AppIoProperties.java @@ -1,5 +1,5 @@ /* - * Copyright 2012-2020 the original author or authors. + * Copyright 2012-2021 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -14,7 +14,7 @@ * limitations under the License. */ -package org.springframework.boot.docs.context.properties.bind.javabean; +package org.springframework.boot.docs.springbootfeatures.externalizedconfiguration.datasize.javabeanbinding; import org.springframework.boot.context.properties.ConfigurationProperties; import org.springframework.boot.convert.DataSizeUnit; @@ -27,7 +27,7 @@ * * @author Stephane Nicoll */ -// tag::example[] +// tag::code[] @ConfigurationProperties("app.io") public class AppIoProperties { @@ -53,4 +53,4 @@ public void setSizeThreshold(DataSize sizeThreshold) { } } -// end::example[] +// end::code[] diff --git a/spring-boot-project/spring-boot-docs/src/main/java/org/springframework/boot/docs/context/properties/bind/constructor/AppSystemProperties.java b/spring-boot-project/spring-boot-docs/src/main/java/org/springframework/boot/docs/springbootfeatures/externalizedconfiguration/duration/constructorbinding/AppSystemProperties.java similarity index 89% rename from spring-boot-project/spring-boot-docs/src/main/java/org/springframework/boot/docs/context/properties/bind/constructor/AppSystemProperties.java rename to spring-boot-project/spring-boot-docs/src/main/java/org/springframework/boot/docs/springbootfeatures/externalizedconfiguration/duration/constructorbinding/AppSystemProperties.java index d30b635c839c..58089d7bb618 100644 --- a/spring-boot-project/spring-boot-docs/src/main/java/org/springframework/boot/docs/context/properties/bind/constructor/AppSystemProperties.java +++ b/spring-boot-project/spring-boot-docs/src/main/java/org/springframework/boot/docs/springbootfeatures/externalizedconfiguration/duration/constructorbinding/AppSystemProperties.java @@ -1,5 +1,5 @@ /* - * Copyright 2012-2020 the original author or authors. + * Copyright 2012-2021 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -14,7 +14,7 @@ * limitations under the License. */ -package org.springframework.boot.docs.context.properties.bind.constructor; +package org.springframework.boot.docs.springbootfeatures.externalizedconfiguration.duration.constructorbinding; import java.time.Duration; import java.time.temporal.ChronoUnit; @@ -30,7 +30,7 @@ * * @author Stephane Nicoll */ -// tag::example[] +// tag::code[] @ConfigurationProperties("app.system") @ConstructorBinding public class AppSystemProperties { @@ -54,4 +54,4 @@ public Duration getReadTimeout() { } } -// end::example[] +// end::code[] diff --git a/spring-boot-project/spring-boot-docs/src/main/java/org/springframework/boot/docs/context/properties/bind/javabean/AppSystemProperties.java b/spring-boot-project/spring-boot-docs/src/main/java/org/springframework/boot/docs/springbootfeatures/externalizedconfiguration/duration/javabeanbinding/AppSystemProperties.java similarity index 88% rename from spring-boot-project/spring-boot-docs/src/main/java/org/springframework/boot/docs/context/properties/bind/javabean/AppSystemProperties.java rename to spring-boot-project/spring-boot-docs/src/main/java/org/springframework/boot/docs/springbootfeatures/externalizedconfiguration/duration/javabeanbinding/AppSystemProperties.java index eca2bb440719..5ee4ef56ceb3 100644 --- a/spring-boot-project/spring-boot-docs/src/main/java/org/springframework/boot/docs/context/properties/bind/javabean/AppSystemProperties.java +++ b/spring-boot-project/spring-boot-docs/src/main/java/org/springframework/boot/docs/springbootfeatures/externalizedconfiguration/duration/javabeanbinding/AppSystemProperties.java @@ -1,5 +1,5 @@ /* - * Copyright 2012-2020 the original author or authors. + * Copyright 2012-2021 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -14,7 +14,7 @@ * limitations under the License. */ -package org.springframework.boot.docs.context.properties.bind.javabean; +package org.springframework.boot.docs.springbootfeatures.externalizedconfiguration.duration.javabeanbinding; import java.time.Duration; import java.time.temporal.ChronoUnit; @@ -28,7 +28,7 @@ * * @author Stephane Nicoll */ -// tag::example[] +// tag::code[] @ConfigurationProperties("app.system") public class AppSystemProperties { @@ -54,4 +54,4 @@ public void setReadTimeout(Duration readTimeout) { } } -// end::example[] +// end::code[] diff --git a/spring-boot-project/spring-boot-docs/src/main/java/org/springframework/boot/docs/springbootfeatures/externalizedconfiguration/package-info.java b/spring-boot-project/spring-boot-docs/src/main/java/org/springframework/boot/docs/springbootfeatures/externalizedconfiguration/package-info.java new file mode 100644 index 000000000000..7a663f72c9ef --- /dev/null +++ b/spring-boot-project/spring-boot-docs/src/main/java/org/springframework/boot/docs/springbootfeatures/externalizedconfiguration/package-info.java @@ -0,0 +1,20 @@ +/* + * Copyright 2012-2021 the original author or authors. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/** + * Examples for the "Spring Boot Features - Externalized Configuration" section. + */ +package org.springframework.boot.docs.springbootfeatures.externalizedconfiguration; diff --git a/spring-boot-project/spring-boot-docs/src/main/java/org/springframework/boot/docs/springbootfeatures/gracefulshutdown/package-info.java b/spring-boot-project/spring-boot-docs/src/main/java/org/springframework/boot/docs/springbootfeatures/gracefulshutdown/package-info.java new file mode 100644 index 000000000000..6d9a551294c1 --- /dev/null +++ b/spring-boot-project/spring-boot-docs/src/main/java/org/springframework/boot/docs/springbootfeatures/gracefulshutdown/package-info.java @@ -0,0 +1,20 @@ +/* + * Copyright 2012-2021 the original author or authors. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/** + * Examples for the "Spring Boot Features - Graceful Shutdown" section. + */ +package org.springframework.boot.docs.springbootfeatures.gracefulshutdown; diff --git a/spring-boot-project/spring-boot-docs/src/main/java/org/springframework/boot/docs/springbootfeatures/hazelcast/package-info.java b/spring-boot-project/spring-boot-docs/src/main/java/org/springframework/boot/docs/springbootfeatures/hazelcast/package-info.java new file mode 100644 index 000000000000..a3b310c68bef --- /dev/null +++ b/spring-boot-project/spring-boot-docs/src/main/java/org/springframework/boot/docs/springbootfeatures/hazelcast/package-info.java @@ -0,0 +1,20 @@ +/* + * Copyright 2012-2021 the original author or authors. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/** + * Examples for the "Spring Boot Features - Hazelcast" section. + */ +package org.springframework.boot.docs.springbootfeatures.hazelcast; diff --git a/spring-boot-project/spring-boot-docs/src/main/java/org/springframework/boot/docs/springbootfeatures/integration/package-info.java b/spring-boot-project/spring-boot-docs/src/main/java/org/springframework/boot/docs/springbootfeatures/integration/package-info.java new file mode 100644 index 000000000000..24ed40f48ca0 --- /dev/null +++ b/spring-boot-project/spring-boot-docs/src/main/java/org/springframework/boot/docs/springbootfeatures/integration/package-info.java @@ -0,0 +1,20 @@ +/* + * Copyright 2012-2021 the original author or authors. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/** + * Examples for the "Spring Boot Features - Spring Integration" section. + */ +package org.springframework.boot.docs.springbootfeatures.integration; diff --git a/spring-boot-project/spring-boot-docs/src/main/java/org/springframework/boot/docs/springbootfeatures/internationalization/package-info.java b/spring-boot-project/spring-boot-docs/src/main/java/org/springframework/boot/docs/springbootfeatures/internationalization/package-info.java new file mode 100644 index 000000000000..24086edc3b99 --- /dev/null +++ b/spring-boot-project/spring-boot-docs/src/main/java/org/springframework/boot/docs/springbootfeatures/internationalization/package-info.java @@ -0,0 +1,20 @@ +/* + * Copyright 2012-2021 the original author or authors. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/** + * Examples for the "Spring Boot Features - Internationalization" section. + */ +package org.springframework.boot.docs.springbootfeatures.internationalization; diff --git a/spring-boot-project/spring-boot-docs/src/main/java/org/springframework/boot/docs/springbootfeatures/json/package-info.java b/spring-boot-project/spring-boot-docs/src/main/java/org/springframework/boot/docs/springbootfeatures/json/package-info.java new file mode 100644 index 000000000000..6ed366df90c8 --- /dev/null +++ b/spring-boot-project/spring-boot-docs/src/main/java/org/springframework/boot/docs/springbootfeatures/json/package-info.java @@ -0,0 +1,20 @@ +/* + * Copyright 2012-2021 the original author or authors. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/** + * Examples for the "Spring Boot Features - JSON" section. + */ +package org.springframework.boot.docs.springbootfeatures.json; diff --git a/spring-boot-project/spring-boot-docs/src/main/java/org/springframework/boot/docs/springbootfeatures/jta/package-info.java b/spring-boot-project/spring-boot-docs/src/main/java/org/springframework/boot/docs/springbootfeatures/jta/package-info.java new file mode 100644 index 000000000000..ccd988187212 --- /dev/null +++ b/spring-boot-project/spring-boot-docs/src/main/java/org/springframework/boot/docs/springbootfeatures/jta/package-info.java @@ -0,0 +1,20 @@ +/* + * Copyright 2012-2021 the original author or authors. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/** + * Examples for the "Spring Boot Features - Distributed Transactions with JTA" section. + */ +package org.springframework.boot.docs.springbootfeatures.jta; diff --git a/spring-boot-project/spring-boot-docs/src/main/java/org/springframework/boot/docs/springbootfeatures/kotlin/package-info.java b/spring-boot-project/spring-boot-docs/src/main/java/org/springframework/boot/docs/springbootfeatures/kotlin/package-info.java new file mode 100644 index 000000000000..ff3d203b9de9 --- /dev/null +++ b/spring-boot-project/spring-boot-docs/src/main/java/org/springframework/boot/docs/springbootfeatures/kotlin/package-info.java @@ -0,0 +1,20 @@ +/* + * Copyright 2012-2021 the original author or authors. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/** + * Examples for the "Spring Boot Features - Kotlin" section. + */ +package org.springframework.boot.docs.springbootfeatures.kotlin; diff --git a/spring-boot-project/spring-boot-docs/src/main/java/org/springframework/boot/docs/springbootfeatures/logging/package-info.java b/spring-boot-project/spring-boot-docs/src/main/java/org/springframework/boot/docs/springbootfeatures/logging/package-info.java new file mode 100644 index 000000000000..e8ea52187db0 --- /dev/null +++ b/spring-boot-project/spring-boot-docs/src/main/java/org/springframework/boot/docs/springbootfeatures/logging/package-info.java @@ -0,0 +1,20 @@ +/* + * Copyright 2012-2021 the original author or authors. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/** + * Examples for the "Spring Boot Features - Logging" section. + */ +package org.springframework.boot.docs.springbootfeatures.logging; diff --git a/spring-boot-project/spring-boot-docs/src/main/java/org/springframework/boot/docs/kafka/KafkaStreamsBeanExample.java b/spring-boot-project/spring-boot-docs/src/main/java/org/springframework/boot/docs/springbootfeatures/messaging/KafkaStreamsBeanExample.java similarity index 91% rename from spring-boot-project/spring-boot-docs/src/main/java/org/springframework/boot/docs/kafka/KafkaStreamsBeanExample.java rename to spring-boot-project/spring-boot-docs/src/main/java/org/springframework/boot/docs/springbootfeatures/messaging/KafkaStreamsBeanExample.java index ebad610febf7..7575be40f3e1 100644 --- a/spring-boot-project/spring-boot-docs/src/main/java/org/springframework/boot/docs/kafka/KafkaStreamsBeanExample.java +++ b/spring-boot-project/spring-boot-docs/src/main/java/org/springframework/boot/docs/springbootfeatures/messaging/KafkaStreamsBeanExample.java @@ -1,5 +1,5 @@ /* - * Copyright 2012-2019 the original author or authors. + * Copyright 2012-2021 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -14,7 +14,7 @@ * limitations under the License. */ -package org.springframework.boot.docs.kafka; +package org.springframework.boot.docs.springbootfeatures.messaging; import org.apache.kafka.common.serialization.Serdes; import org.apache.kafka.streams.KeyValue; @@ -34,7 +34,7 @@ */ public class KafkaStreamsBeanExample { - // tag::configuration[] + // tag::code[] @Configuration(proxyBeanMethods = false) @EnableKafkaStreams public static class KafkaStreamsExampleConfiguration { @@ -48,6 +48,6 @@ public KStream kStream(StreamsBuilder streamsBuilder) { } } - // end::configuration[] + // end::code[] } diff --git a/spring-boot-project/spring-boot-docs/src/main/java/org/springframework/boot/docs/springbootfeatures/messaging/package-info.java b/spring-boot-project/spring-boot-docs/src/main/java/org/springframework/boot/docs/springbootfeatures/messaging/package-info.java new file mode 100644 index 000000000000..e90952c4743b --- /dev/null +++ b/spring-boot-project/spring-boot-docs/src/main/java/org/springframework/boot/docs/springbootfeatures/messaging/package-info.java @@ -0,0 +1,20 @@ +/* + * Copyright 2012-2021 the original author or authors. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/** + * Examples for the "Spring Boot Features - Messaging" section. + */ +package org.springframework.boot.docs.springbootfeatures.messaging; diff --git a/spring-boot-project/spring-boot-docs/src/main/java/org/springframework/boot/docs/springbootfeatures/monitoring/jmx/package-info.java b/spring-boot-project/spring-boot-docs/src/main/java/org/springframework/boot/docs/springbootfeatures/monitoring/jmx/package-info.java new file mode 100644 index 000000000000..9f29cd5082c6 --- /dev/null +++ b/spring-boot-project/spring-boot-docs/src/main/java/org/springframework/boot/docs/springbootfeatures/monitoring/jmx/package-info.java @@ -0,0 +1,20 @@ +/* + * Copyright 2012-2021 the original author or authors. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/** + * Examples for the "Spring Boot Features - Monitoring with JMX" section. + */ +package org.springframework.boot.docs.springbootfeatures.monitoring.jmx; diff --git a/spring-boot-project/spring-boot-docs/src/main/java/org/springframework/boot/docs/cache/CouchbaseCacheManagerCustomizationExample.java b/spring-boot-project/spring-boot-docs/src/main/java/org/springframework/boot/docs/springbootfeatures/nosql/CouchbaseCacheManagerCustomizationExample.java similarity index 91% rename from spring-boot-project/spring-boot-docs/src/main/java/org/springframework/boot/docs/cache/CouchbaseCacheManagerCustomizationExample.java rename to spring-boot-project/spring-boot-docs/src/main/java/org/springframework/boot/docs/springbootfeatures/nosql/CouchbaseCacheManagerCustomizationExample.java index 612a955c2c2d..987c87794628 100644 --- a/spring-boot-project/spring-boot-docs/src/main/java/org/springframework/boot/docs/cache/CouchbaseCacheManagerCustomizationExample.java +++ b/spring-boot-project/spring-boot-docs/src/main/java/org/springframework/boot/docs/springbootfeatures/nosql/CouchbaseCacheManagerCustomizationExample.java @@ -1,5 +1,5 @@ /* - * Copyright 2012-2020 the original author or authors. + * Copyright 2012-2021 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -14,7 +14,7 @@ * limitations under the License. */ -package org.springframework.boot.docs.cache; +package org.springframework.boot.docs.springbootfeatures.nosql; import java.time.Duration; @@ -32,7 +32,7 @@ @Configuration(proxyBeanMethods = false) public class CouchbaseCacheManagerCustomizationExample { - // tag::configuration[] + // tag::code[] @Bean public CouchbaseCacheManagerBuilderCustomizer myCouchbaseCacheManagerBuilderCustomizer() { return (builder) -> builder @@ -42,6 +42,6 @@ public CouchbaseCacheManagerBuilderCustomizer myCouchbaseCacheManagerBuilderCust CouchbaseCacheConfiguration.defaultCacheConfig().entryExpiry(Duration.ofMinutes(1))); } - // end::configuration[] + // end::code[] } diff --git a/spring-boot-project/spring-boot-docs/src/main/java/org/springframework/boot/docs/neo4j/Neo4jReactiveTransactionManagerExample.java b/spring-boot-project/spring-boot-docs/src/main/java/org/springframework/boot/docs/springbootfeatures/nosql/Neo4jReactiveTransactionManagerExample.java similarity index 90% rename from spring-boot-project/spring-boot-docs/src/main/java/org/springframework/boot/docs/neo4j/Neo4jReactiveTransactionManagerExample.java rename to spring-boot-project/spring-boot-docs/src/main/java/org/springframework/boot/docs/springbootfeatures/nosql/Neo4jReactiveTransactionManagerExample.java index 81a95ce5d674..24398a43f074 100644 --- a/spring-boot-project/spring-boot-docs/src/main/java/org/springframework/boot/docs/neo4j/Neo4jReactiveTransactionManagerExample.java +++ b/spring-boot-project/spring-boot-docs/src/main/java/org/springframework/boot/docs/springbootfeatures/nosql/Neo4jReactiveTransactionManagerExample.java @@ -1,5 +1,5 @@ /* - * Copyright 2012-2020 the original author or authors. + * Copyright 2012-2021 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -14,7 +14,7 @@ * limitations under the License. */ -package org.springframework.boot.docs.neo4j; +package org.springframework.boot.docs.springbootfeatures.nosql; import org.neo4j.driver.Driver; @@ -32,12 +32,12 @@ @Configuration(proxyBeanMethods = false) public class Neo4jReactiveTransactionManagerExample { - // tag::configuration[] + // tag::code[] @Bean public ReactiveNeo4jTransactionManager reactiveTransactionManager(Driver driver, ReactiveDatabaseSelectionProvider databaseNameProvider) { return new ReactiveNeo4jTransactionManager(driver, databaseNameProvider); } - // end::configuration[] + // end::code[] } diff --git a/spring-boot-project/spring-boot-docs/src/main/java/org/springframework/boot/docs/cache/RedisCacheManagerCustomizationExample.java b/spring-boot-project/spring-boot-docs/src/main/java/org/springframework/boot/docs/springbootfeatures/nosql/RedisCacheManagerCustomizationExample.java similarity index 90% rename from spring-boot-project/spring-boot-docs/src/main/java/org/springframework/boot/docs/cache/RedisCacheManagerCustomizationExample.java rename to spring-boot-project/spring-boot-docs/src/main/java/org/springframework/boot/docs/springbootfeatures/nosql/RedisCacheManagerCustomizationExample.java index 88f56fa93d86..fef562a29d0d 100644 --- a/spring-boot-project/spring-boot-docs/src/main/java/org/springframework/boot/docs/cache/RedisCacheManagerCustomizationExample.java +++ b/spring-boot-project/spring-boot-docs/src/main/java/org/springframework/boot/docs/springbootfeatures/nosql/RedisCacheManagerCustomizationExample.java @@ -1,5 +1,5 @@ /* - * Copyright 2012-2020 the original author or authors. + * Copyright 2012-2021 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -14,7 +14,7 @@ * limitations under the License. */ -package org.springframework.boot.docs.cache; +package org.springframework.boot.docs.springbootfeatures.nosql; import java.time.Duration; @@ -32,7 +32,7 @@ @Configuration(proxyBeanMethods = false) public class RedisCacheManagerCustomizationExample { - // tag::configuration[] + // tag::code[] @Bean public RedisCacheManagerBuilderCustomizer myRedisCacheManagerBuilderCustomizer() { return (builder) -> builder @@ -42,6 +42,6 @@ public RedisCacheManagerBuilderCustomizer myRedisCacheManagerBuilderCustomizer() RedisCacheConfiguration.defaultCacheConfig().entryTtl(Duration.ofMinutes(1))); } - // end::configuration[] + // end::code[] } diff --git a/spring-boot-project/spring-boot-docs/src/main/java/org/springframework/boot/docs/springbootfeatures/nosql/package-info.java b/spring-boot-project/spring-boot-docs/src/main/java/org/springframework/boot/docs/springbootfeatures/nosql/package-info.java new file mode 100644 index 000000000000..3602d3951901 --- /dev/null +++ b/spring-boot-project/spring-boot-docs/src/main/java/org/springframework/boot/docs/springbootfeatures/nosql/package-info.java @@ -0,0 +1,20 @@ +/* + * Copyright 2012-2021 the original author or authors. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/** + * Examples for the "Spring Boot Features - Working with NoSQL Technologies" section. + */ +package org.springframework.boot.docs.springbootfeatures.nosql; diff --git a/spring-boot-project/spring-boot-docs/src/main/java/org/springframework/boot/docs/springbootfeatures/profiles/package-info.java b/spring-boot-project/spring-boot-docs/src/main/java/org/springframework/boot/docs/springbootfeatures/profiles/package-info.java new file mode 100644 index 000000000000..9f29878c134f --- /dev/null +++ b/spring-boot-project/spring-boot-docs/src/main/java/org/springframework/boot/docs/springbootfeatures/profiles/package-info.java @@ -0,0 +1,20 @@ +/* + * Copyright 2012-2021 the original author or authors. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/** + * Examples for the "Spring Boot Features - Profiles" section. + */ +package org.springframework.boot.docs.springbootfeatures.profiles; diff --git a/spring-boot-project/spring-boot-docs/src/main/java/org/springframework/boot/docs/springbootfeatures/quartz/package-info.java b/spring-boot-project/spring-boot-docs/src/main/java/org/springframework/boot/docs/springbootfeatures/quartz/package-info.java new file mode 100644 index 000000000000..201bb165a3d0 --- /dev/null +++ b/spring-boot-project/spring-boot-docs/src/main/java/org/springframework/boot/docs/springbootfeatures/quartz/package-info.java @@ -0,0 +1,20 @@ +/* + * Copyright 2012-2021 the original author or authors. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/** + * Examples for the "Spring Boot Features - Quartz" section. + */ +package org.springframework.boot.docs.springbootfeatures.quartz; diff --git a/spring-boot-project/spring-boot-docs/src/main/java/org/springframework/boot/docs/web/client/RestTemplateBuilderCustomizationExample.java b/spring-boot-project/spring-boot-docs/src/main/java/org/springframework/boot/docs/springbootfeatures/resttemplate/RestTemplateBuilderCustomizationExample.java similarity index 89% rename from spring-boot-project/spring-boot-docs/src/main/java/org/springframework/boot/docs/web/client/RestTemplateBuilderCustomizationExample.java rename to spring-boot-project/spring-boot-docs/src/main/java/org/springframework/boot/docs/springbootfeatures/resttemplate/RestTemplateBuilderCustomizationExample.java index d67e4328a667..41f641abee30 100644 --- a/spring-boot-project/spring-boot-docs/src/main/java/org/springframework/boot/docs/web/client/RestTemplateBuilderCustomizationExample.java +++ b/spring-boot-project/spring-boot-docs/src/main/java/org/springframework/boot/docs/springbootfeatures/resttemplate/RestTemplateBuilderCustomizationExample.java @@ -1,5 +1,5 @@ /* - * Copyright 2012-2020 the original author or authors. + * Copyright 2012-2021 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -14,7 +14,7 @@ * limitations under the License. */ -package org.springframework.boot.docs.web.client; +package org.springframework.boot.docs.springbootfeatures.resttemplate; import java.time.Duration; @@ -32,12 +32,12 @@ @Configuration(proxyBeanMethods = false) public class RestTemplateBuilderCustomizationExample { - // tag::customizer[] + // tag::code[] @Bean public RestTemplateBuilder restTemplateBuilder(RestTemplateBuilderConfigurer configurer) { return configurer.configure(new RestTemplateBuilder()).setConnectTimeout(Duration.ofSeconds(5)) .setReadTimeout(Duration.ofSeconds(2)); } - // end::customizer[] + // end::code[] } diff --git a/spring-boot-project/spring-boot-docs/src/main/java/org/springframework/boot/docs/web/client/RestTemplateProxyCustomizationExample.java b/spring-boot-project/spring-boot-docs/src/main/java/org/springframework/boot/docs/springbootfeatures/resttemplate/RestTemplateProxyCustomizationExample.java similarity index 92% rename from spring-boot-project/spring-boot-docs/src/main/java/org/springframework/boot/docs/web/client/RestTemplateProxyCustomizationExample.java rename to spring-boot-project/spring-boot-docs/src/main/java/org/springframework/boot/docs/springbootfeatures/resttemplate/RestTemplateProxyCustomizationExample.java index ae9a13c66f59..4fb1170fd2bf 100644 --- a/spring-boot-project/spring-boot-docs/src/main/java/org/springframework/boot/docs/web/client/RestTemplateProxyCustomizationExample.java +++ b/spring-boot-project/spring-boot-docs/src/main/java/org/springframework/boot/docs/springbootfeatures/resttemplate/RestTemplateProxyCustomizationExample.java @@ -1,5 +1,5 @@ /* - * Copyright 2012-2019 the original author or authors. + * Copyright 2012-2021 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -14,7 +14,7 @@ * limitations under the License. */ -package org.springframework.boot.docs.web.client; +package org.springframework.boot.docs.springbootfeatures.resttemplate; import org.apache.http.HttpException; import org.apache.http.HttpHost; @@ -39,7 +39,7 @@ public class RestTemplateProxyCustomizationExample { * A {@link RestTemplateCustomizer} that applies an HttpComponents-based request * factory that is configured to use a proxy. */ - // tag::customizer[] + // tag::code[] static class ProxyCustomizer implements RestTemplateCustomizer { @Override @@ -61,6 +61,6 @@ public HttpHost determineProxy(HttpHost target, HttpRequest request, HttpContext } } - // end::customizer[] + // end::code[] } diff --git a/spring-boot-project/spring-boot-docs/src/main/java/org/springframework/boot/docs/springbootfeatures/resttemplate/package-info.java b/spring-boot-project/spring-boot-docs/src/main/java/org/springframework/boot/docs/springbootfeatures/resttemplate/package-info.java new file mode 100644 index 000000000000..7fd33321fcea --- /dev/null +++ b/spring-boot-project/spring-boot-docs/src/main/java/org/springframework/boot/docs/springbootfeatures/resttemplate/package-info.java @@ -0,0 +1,21 @@ +/* + * Copyright 2012-2021 the original author or authors. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/** + * Examples for the "Spring Boot Features - Calling REST Services with RestTemplate" + * section. + */ +package org.springframework.boot.docs.springbootfeatures.resttemplate; diff --git a/spring-boot-project/spring-boot-docs/src/main/java/org/springframework/boot/docs/springbootfeatures/rsocket/package-info.java b/spring-boot-project/spring-boot-docs/src/main/java/org/springframework/boot/docs/springbootfeatures/rsocket/package-info.java new file mode 100644 index 000000000000..abb639471647 --- /dev/null +++ b/spring-boot-project/spring-boot-docs/src/main/java/org/springframework/boot/docs/springbootfeatures/rsocket/package-info.java @@ -0,0 +1,20 @@ +/* + * Copyright 2012-2021 the original author or authors. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/** + * Examples for the "Spring Boot Features - RSocket" section. + */ +package org.springframework.boot.docs.springbootfeatures.rsocket; diff --git a/spring-boot-project/spring-boot-docs/src/main/java/org/springframework/boot/docs/web/security/CustomWebFluxSecurityExample.java b/spring-boot-project/spring-boot-docs/src/main/java/org/springframework/boot/docs/springbootfeatures/security/CustomWebFluxSecurityExample.java similarity index 90% rename from spring-boot-project/spring-boot-docs/src/main/java/org/springframework/boot/docs/web/security/CustomWebFluxSecurityExample.java rename to spring-boot-project/spring-boot-docs/src/main/java/org/springframework/boot/docs/springbootfeatures/security/CustomWebFluxSecurityExample.java index 9db671e57ec8..e82d72250a50 100644 --- a/spring-boot-project/spring-boot-docs/src/main/java/org/springframework/boot/docs/web/security/CustomWebFluxSecurityExample.java +++ b/spring-boot-project/spring-boot-docs/src/main/java/org/springframework/boot/docs/springbootfeatures/security/CustomWebFluxSecurityExample.java @@ -1,5 +1,5 @@ /* - * Copyright 2012-2019 the original author or authors. + * Copyright 2012-2021 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -14,7 +14,7 @@ * limitations under the License. */ -package org.springframework.boot.docs.web.security; +package org.springframework.boot.docs.springbootfeatures.security; import org.springframework.boot.autoconfigure.security.reactive.PathRequest; import org.springframework.context.annotation.Bean; @@ -31,7 +31,7 @@ public class CustomWebFluxSecurityExample { // @formatter:off - // tag::configuration[] + // tag::code[] @Bean public SecurityWebFilterChain springSecurityFilterChain(ServerHttpSecurity http) { return http @@ -42,7 +42,7 @@ public SecurityWebFilterChain springSecurityFilterChain(ServerHttpSecurity http) .formLogin().and() .build(); } - // end::configuration[] + // end::code[] // @formatter:on } diff --git a/spring-boot-project/spring-boot-docs/src/main/java/org/springframework/boot/docs/springbootfeatures/security/package-info.java b/spring-boot-project/spring-boot-docs/src/main/java/org/springframework/boot/docs/springbootfeatures/security/package-info.java new file mode 100644 index 000000000000..b2aa6cd5e0b0 --- /dev/null +++ b/spring-boot-project/spring-boot-docs/src/main/java/org/springframework/boot/docs/springbootfeatures/security/package-info.java @@ -0,0 +1,20 @@ +/* + * Copyright 2012-2021 the original author or authors. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/** + * Examples for the "Spring Boot Features - Security" section. + */ +package org.springframework.boot.docs.springbootfeatures.security; diff --git a/spring-boot-project/spring-boot-docs/src/main/java/org/springframework/boot/docs/springbootfeatures/session/package-info.java b/spring-boot-project/spring-boot-docs/src/main/java/org/springframework/boot/docs/springbootfeatures/session/package-info.java new file mode 100644 index 000000000000..e0b0be983452 --- /dev/null +++ b/spring-boot-project/spring-boot-docs/src/main/java/org/springframework/boot/docs/springbootfeatures/session/package-info.java @@ -0,0 +1,20 @@ +/* + * Copyright 2012-2021 the original author or authors. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/** + * Examples for the "Spring Boot Features - Spring Session" section. + */ +package org.springframework.boot.docs.springbootfeatures.session; diff --git a/spring-boot-project/spring-boot-docs/src/main/java/org/springframework/boot/docs/ExitCodeApplication.java b/spring-boot-project/spring-boot-docs/src/main/java/org/springframework/boot/docs/springbootfeatures/springapplication/ExitCodeExample.java similarity index 83% rename from spring-boot-project/spring-boot-docs/src/main/java/org/springframework/boot/docs/ExitCodeApplication.java rename to spring-boot-project/spring-boot-docs/src/main/java/org/springframework/boot/docs/springbootfeatures/springapplication/ExitCodeExample.java index 813c6ed09283..43c81fd2ecb7 100644 --- a/spring-boot-project/spring-boot-docs/src/main/java/org/springframework/boot/docs/ExitCodeApplication.java +++ b/spring-boot-project/spring-boot-docs/src/main/java/org/springframework/boot/docs/springbootfeatures/springapplication/ExitCodeExample.java @@ -1,5 +1,5 @@ /* - * Copyright 2012-2019 the original author or authors. + * Copyright 2012-2021 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -14,7 +14,7 @@ * limitations under the License. */ -package org.springframework.boot.docs; +package org.springframework.boot.docs.springbootfeatures.springapplication; import org.springframework.boot.ExitCodeGenerator; import org.springframework.boot.SpringApplication; @@ -26,9 +26,9 @@ * * @author Stephane Nicoll */ -// tag::example[] +// tag::code[] @SpringBootApplication -public class ExitCodeApplication { +public class ExitCodeExample { @Bean public ExitCodeGenerator exitCodeGenerator() { @@ -36,8 +36,8 @@ public ExitCodeGenerator exitCodeGenerator() { } public static void main(String[] args) { - System.exit(SpringApplication.exit(SpringApplication.run(ExitCodeApplication.class, args))); + System.exit(SpringApplication.exit(SpringApplication.run(ExitCodeExample.class, args))); } } -// end::example[] +// end::code[] diff --git a/spring-boot-project/spring-boot-docs/src/main/java/org/springframework/boot/docs/builder/SpringApplicationBuilderExample.java b/spring-boot-project/spring-boot-docs/src/main/java/org/springframework/boot/docs/springbootfeatures/springapplication/SpringApplicationBuilderExample.java similarity index 87% rename from spring-boot-project/spring-boot-docs/src/main/java/org/springframework/boot/docs/builder/SpringApplicationBuilderExample.java rename to spring-boot-project/spring-boot-docs/src/main/java/org/springframework/boot/docs/springbootfeatures/springapplication/SpringApplicationBuilderExample.java index d1944fff70bb..9d2225a99656 100644 --- a/spring-boot-project/spring-boot-docs/src/main/java/org/springframework/boot/docs/builder/SpringApplicationBuilderExample.java +++ b/spring-boot-project/spring-boot-docs/src/main/java/org/springframework/boot/docs/springbootfeatures/springapplication/SpringApplicationBuilderExample.java @@ -1,5 +1,5 @@ /* - * Copyright 2012-2019 the original author or authors. + * Copyright 2012-2021 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -14,7 +14,7 @@ * limitations under the License. */ -package org.springframework.boot.docs.builder; +package org.springframework.boot.docs.springbootfeatures.springapplication; import org.springframework.boot.Banner; import org.springframework.boot.builder.SpringApplicationBuilder; @@ -28,13 +28,13 @@ public class SpringApplicationBuilderExample { public void hierarchyWithDisabledBanner(String[] args) { // @formatter:off - // tag::hierarchy[] + // tag::code[] new SpringApplicationBuilder() .sources(Parent.class) .child(Application.class) .bannerMode(Banner.Mode.OFF) .run(args); - // end::hierarchy[] + // end::code[] // @formatter:on } diff --git a/spring-boot-project/spring-boot-docs/src/main/java/org/springframework/boot/docs/springbootfeatures/springapplication/package-info.java b/spring-boot-project/spring-boot-docs/src/main/java/org/springframework/boot/docs/springbootfeatures/springapplication/package-info.java new file mode 100644 index 000000000000..2af4c750ba93 --- /dev/null +++ b/spring-boot-project/spring-boot-docs/src/main/java/org/springframework/boot/docs/springbootfeatures/springapplication/package-info.java @@ -0,0 +1,20 @@ +/* + * Copyright 2012-2021 the original author or authors. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/** + * Examples for the "Spring Boot Features - SpringApplication" section. + */ +package org.springframework.boot.docs.springbootfeatures.springapplication; diff --git a/spring-boot-project/spring-boot-docs/src/main/java/org/springframework/boot/docs/springbootfeatures/sql/package-info.java b/spring-boot-project/spring-boot-docs/src/main/java/org/springframework/boot/docs/springbootfeatures/sql/package-info.java new file mode 100644 index 000000000000..9aad26329e1e --- /dev/null +++ b/spring-boot-project/spring-boot-docs/src/main/java/org/springframework/boot/docs/springbootfeatures/sql/package-info.java @@ -0,0 +1,20 @@ +/* + * Copyright 2012-2021 the original author or authors. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/** + * Examples for the "Spring Boot Features - Working with SQL Databases" section. + */ +package org.springframework.boot.docs.springbootfeatures.sql; diff --git a/spring-boot-project/spring-boot-docs/src/main/java/org/springframework/boot/docs/springbootfeatures/task/package-info.java b/spring-boot-project/spring-boot-docs/src/main/java/org/springframework/boot/docs/springbootfeatures/task/package-info.java new file mode 100644 index 000000000000..ee9d79667414 --- /dev/null +++ b/spring-boot-project/spring-boot-docs/src/main/java/org/springframework/boot/docs/springbootfeatures/task/package-info.java @@ -0,0 +1,20 @@ +/* + * Copyright 2012-2021 the original author or authors. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/** + * Examples for the "Spring Boot Features - Task Execution and Scheduling" section. + */ +package org.springframework.boot.docs.springbootfeatures.task; diff --git a/spring-boot-project/spring-boot-docs/src/main/java/org/springframework/boot/docs/test/context/ApplicationArgumentsExampleTests.java b/spring-boot-project/spring-boot-docs/src/main/java/org/springframework/boot/docs/springbootfeatures/testing/ApplicationArgumentsExampleTests.java similarity index 88% rename from spring-boot-project/spring-boot-docs/src/main/java/org/springframework/boot/docs/test/context/ApplicationArgumentsExampleTests.java rename to spring-boot-project/spring-boot-docs/src/main/java/org/springframework/boot/docs/springbootfeatures/testing/ApplicationArgumentsExampleTests.java index 79625817166c..5e309044c8d4 100644 --- a/spring-boot-project/spring-boot-docs/src/main/java/org/springframework/boot/docs/test/context/ApplicationArgumentsExampleTests.java +++ b/spring-boot-project/spring-boot-docs/src/main/java/org/springframework/boot/docs/springbootfeatures/testing/ApplicationArgumentsExampleTests.java @@ -1,5 +1,5 @@ /* - * Copyright 2012-2019 the original author or authors. + * Copyright 2012-2021 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -14,7 +14,7 @@ * limitations under the License. */ -package org.springframework.boot.docs.test.context; +package org.springframework.boot.docs.springbootfeatures.testing; import org.junit.jupiter.api.Test; @@ -24,7 +24,7 @@ import static org.assertj.core.api.Assertions.assertThat; -// tag::example[] +// tag::code[] @SpringBootTest(args = "--app.test=one") class ApplicationArgumentsExampleTests { @@ -35,4 +35,4 @@ void applicationArgumentsPopulated(@Autowired ApplicationArguments args) { } } -// end::example[] +// end::code[] diff --git a/spring-boot-project/spring-boot-docs/src/main/java/org/springframework/boot/docs/test/web/MockMvcExampleTests.java b/spring-boot-project/spring-boot-docs/src/main/java/org/springframework/boot/docs/springbootfeatures/testing/MockMvcExampleTests.java similarity index 90% rename from spring-boot-project/spring-boot-docs/src/main/java/org/springframework/boot/docs/test/web/MockMvcExampleTests.java rename to spring-boot-project/spring-boot-docs/src/main/java/org/springframework/boot/docs/springbootfeatures/testing/MockMvcExampleTests.java index e6e6738363ed..a660a8d3d1ee 100644 --- a/spring-boot-project/spring-boot-docs/src/main/java/org/springframework/boot/docs/test/web/MockMvcExampleTests.java +++ b/spring-boot-project/spring-boot-docs/src/main/java/org/springframework/boot/docs/springbootfeatures/testing/MockMvcExampleTests.java @@ -1,5 +1,5 @@ /* - * Copyright 2012-2019 the original author or authors. + * Copyright 2012-2021 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -14,9 +14,9 @@ * limitations under the License. */ -package org.springframework.boot.docs.test.web; +package org.springframework.boot.docs.springbootfeatures.testing; -// tag::test-mock-mvc[] +// tag::code[] import org.junit.jupiter.api.Test; @@ -39,4 +39,4 @@ void exampleTest(@Autowired MockMvc mvc) throws Exception { } } -// end::test-mock-mvc[] +// end::code[] diff --git a/spring-boot-project/spring-boot-docs/src/main/java/org/springframework/boot/docs/test/web/MockWebTestClientExampleTests.java b/spring-boot-project/spring-boot-docs/src/main/java/org/springframework/boot/docs/springbootfeatures/testing/MockWebTestClientExampleTests.java similarity index 86% rename from spring-boot-project/spring-boot-docs/src/main/java/org/springframework/boot/docs/test/web/MockWebTestClientExampleTests.java rename to spring-boot-project/spring-boot-docs/src/main/java/org/springframework/boot/docs/springbootfeatures/testing/MockWebTestClientExampleTests.java index 883f5ebd3822..f747b1b144c5 100644 --- a/spring-boot-project/spring-boot-docs/src/main/java/org/springframework/boot/docs/test/web/MockWebTestClientExampleTests.java +++ b/spring-boot-project/spring-boot-docs/src/main/java/org/springframework/boot/docs/springbootfeatures/testing/MockWebTestClientExampleTests.java @@ -1,5 +1,5 @@ /* - * Copyright 2012-2019 the original author or authors. + * Copyright 2012-2021 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -14,9 +14,9 @@ * limitations under the License. */ -package org.springframework.boot.docs.test.web; +package org.springframework.boot.docs.springbootfeatures.testing; -// tag::test-mock-web-test-client[] +// tag::code[] import org.junit.jupiter.api.Test; @@ -35,4 +35,4 @@ void exampleTest(@Autowired WebTestClient webClient) { } } -// end::test-mock-web-test-client[] +// end::code[] diff --git a/spring-boot-project/spring-boot-docs/src/test/java/org/springframework/boot/docs/test/system/OutputCaptureTests.java b/spring-boot-project/spring-boot-docs/src/main/java/org/springframework/boot/docs/springbootfeatures/testing/OutputCaptureTests.java similarity index 88% rename from spring-boot-project/spring-boot-docs/src/test/java/org/springframework/boot/docs/test/system/OutputCaptureTests.java rename to spring-boot-project/spring-boot-docs/src/main/java/org/springframework/boot/docs/springbootfeatures/testing/OutputCaptureTests.java index 8f9a3731fcee..8be3578e25ac 100644 --- a/spring-boot-project/spring-boot-docs/src/test/java/org/springframework/boot/docs/test/system/OutputCaptureTests.java +++ b/spring-boot-project/spring-boot-docs/src/main/java/org/springframework/boot/docs/springbootfeatures/testing/OutputCaptureTests.java @@ -1,5 +1,5 @@ /* - * Copyright 2012-2019 the original author or authors. + * Copyright 2012-2021 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -14,7 +14,7 @@ * limitations under the License. */ -package org.springframework.boot.docs.test.system; +package org.springframework.boot.docs.springbootfeatures.testing; import org.junit.jupiter.api.Test; import org.junit.jupiter.api.extension.ExtendWith; @@ -29,7 +29,7 @@ * * @author Stephane Nicoll */ -// tag::test[] +// tag::code[] @ExtendWith(OutputCaptureExtension.class) class OutputCaptureTests { @@ -40,4 +40,4 @@ void testName(CapturedOutput output) { } } -// end::test[] +// end::code[] diff --git a/spring-boot-project/spring-boot-docs/src/main/java/org/springframework/boot/docs/test/web/RandomPortTestRestTemplateExampleTests.java b/spring-boot-project/spring-boot-docs/src/main/java/org/springframework/boot/docs/springbootfeatures/testing/RandomPortTestRestTemplateExampleTests.java similarity index 88% rename from spring-boot-project/spring-boot-docs/src/main/java/org/springframework/boot/docs/test/web/RandomPortTestRestTemplateExampleTests.java rename to spring-boot-project/spring-boot-docs/src/main/java/org/springframework/boot/docs/springbootfeatures/testing/RandomPortTestRestTemplateExampleTests.java index 32a93ad3d10c..4eec421c8796 100644 --- a/spring-boot-project/spring-boot-docs/src/main/java/org/springframework/boot/docs/test/web/RandomPortTestRestTemplateExampleTests.java +++ b/spring-boot-project/spring-boot-docs/src/main/java/org/springframework/boot/docs/springbootfeatures/testing/RandomPortTestRestTemplateExampleTests.java @@ -1,5 +1,5 @@ /* - * Copyright 2012-2019 the original author or authors. + * Copyright 2012-2021 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -14,9 +14,9 @@ * limitations under the License. */ -package org.springframework.boot.docs.test.web; +package org.springframework.boot.docs.springbootfeatures.testing; -// tag::test-random-port[] +// tag::code[] import org.junit.jupiter.api.Test; @@ -37,4 +37,4 @@ void exampleTest(@Autowired TestRestTemplate restTemplate) { } } -// end::test-random-port[] +// end::code[] diff --git a/spring-boot-project/spring-boot-docs/src/main/java/org/springframework/boot/docs/test/web/RandomPortWebTestClientExampleTests.java b/spring-boot-project/spring-boot-docs/src/main/java/org/springframework/boot/docs/springbootfeatures/testing/RandomPortWebTestClientExampleTests.java similarity index 88% rename from spring-boot-project/spring-boot-docs/src/main/java/org/springframework/boot/docs/test/web/RandomPortWebTestClientExampleTests.java rename to spring-boot-project/spring-boot-docs/src/main/java/org/springframework/boot/docs/springbootfeatures/testing/RandomPortWebTestClientExampleTests.java index 9a800a3f3e46..727483248972 100644 --- a/spring-boot-project/spring-boot-docs/src/main/java/org/springframework/boot/docs/test/web/RandomPortWebTestClientExampleTests.java +++ b/spring-boot-project/spring-boot-docs/src/main/java/org/springframework/boot/docs/springbootfeatures/testing/RandomPortWebTestClientExampleTests.java @@ -1,5 +1,5 @@ /* - * Copyright 2012-2019 the original author or authors. + * Copyright 2012-2021 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -14,9 +14,9 @@ * limitations under the License. */ -package org.springframework.boot.docs.test.web; +package org.springframework.boot.docs.springbootfeatures.testing; -// tag::test-random-port[] +// tag::code[] import org.junit.jupiter.api.Test; @@ -34,4 +34,4 @@ void exampleTest(@Autowired WebTestClient webClient) { } } -// end::test-random-port[] +// end::code[] diff --git a/spring-boot-project/spring-boot-docs/src/test/java/org/springframework/boot/docs/autoconfigure/UserServiceAutoConfigurationTests.java b/spring-boot-project/spring-boot-docs/src/main/java/org/springframework/boot/docs/springbootfeatures/testing/UserServiceAutoConfigurationTests.java similarity index 88% rename from spring-boot-project/spring-boot-docs/src/test/java/org/springframework/boot/docs/autoconfigure/UserServiceAutoConfigurationTests.java rename to spring-boot-project/spring-boot-docs/src/main/java/org/springframework/boot/docs/springbootfeatures/testing/UserServiceAutoConfigurationTests.java index ddff07b9cf01..1ab6c8903a82 100644 --- a/spring-boot-project/spring-boot-docs/src/test/java/org/springframework/boot/docs/autoconfigure/UserServiceAutoConfigurationTests.java +++ b/spring-boot-project/spring-boot-docs/src/main/java/org/springframework/boot/docs/springbootfeatures/testing/UserServiceAutoConfigurationTests.java @@ -1,5 +1,5 @@ /* - * Copyright 2012-2019 the original author or authors. + * Copyright 2012-2021 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -14,11 +14,13 @@ * limitations under the License. */ -package org.springframework.boot.docs.autoconfigure; +package org.springframework.boot.docs.springbootfeatures.testing; import org.junit.jupiter.api.Test; import org.springframework.boot.autoconfigure.AutoConfigurations; +import org.springframework.boot.docs.springbootfeatures.creatingautoconfiguration.UserService; +import org.springframework.boot.docs.springbootfeatures.creatingautoconfiguration.UserServiceAutoConfiguration; import org.springframework.boot.test.context.FilteredClassLoader; import org.springframework.boot.test.context.runner.ApplicationContextRunner; import org.springframework.context.annotation.Bean; diff --git a/spring-boot-project/spring-boot-docs/src/test/java/org/springframework/boot/docs/jmx/SampleApp.java b/spring-boot-project/spring-boot-docs/src/main/java/org/springframework/boot/docs/springbootfeatures/testing/jmx/SampleApp.java similarity index 89% rename from spring-boot-project/spring-boot-docs/src/test/java/org/springframework/boot/docs/jmx/SampleApp.java rename to spring-boot-project/spring-boot-docs/src/main/java/org/springframework/boot/docs/springbootfeatures/testing/jmx/SampleApp.java index ea5ecad61ff7..71efc7caabf7 100644 --- a/spring-boot-project/spring-boot-docs/src/test/java/org/springframework/boot/docs/jmx/SampleApp.java +++ b/spring-boot-project/spring-boot-docs/src/main/java/org/springframework/boot/docs/springbootfeatures/testing/jmx/SampleApp.java @@ -1,5 +1,5 @@ /* - * Copyright 2012-2019 the original author or authors. + * Copyright 2012-2021 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -14,7 +14,7 @@ * limitations under the License. */ -package org.springframework.boot.docs.jmx; +package org.springframework.boot.docs.springbootfeatures.testing.jmx; import org.springframework.boot.SpringBootConfiguration; import org.springframework.boot.autoconfigure.ImportAutoConfiguration; diff --git a/spring-boot-project/spring-boot-docs/src/test/java/org/springframework/boot/docs/jmx/SampleJmxTests.java b/spring-boot-project/spring-boot-docs/src/main/java/org/springframework/boot/docs/springbootfeatures/testing/jmx/SampleJmxTests.java similarity index 89% rename from spring-boot-project/spring-boot-docs/src/test/java/org/springframework/boot/docs/jmx/SampleJmxTests.java rename to spring-boot-project/spring-boot-docs/src/main/java/org/springframework/boot/docs/springbootfeatures/testing/jmx/SampleJmxTests.java index c469e6daa32e..eefe5b29a606 100644 --- a/spring-boot-project/spring-boot-docs/src/test/java/org/springframework/boot/docs/jmx/SampleJmxTests.java +++ b/spring-boot-project/spring-boot-docs/src/main/java/org/springframework/boot/docs/springbootfeatures/testing/jmx/SampleJmxTests.java @@ -1,5 +1,5 @@ /* - * Copyright 2012-2019 the original author or authors. + * Copyright 2012-2021 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -14,7 +14,7 @@ * limitations under the License. */ -package org.springframework.boot.docs.jmx; +package org.springframework.boot.docs.springbootfeatures.testing.jmx; import javax.management.MBeanServer; @@ -32,7 +32,7 @@ * @author Stephane Nicoll */ @SuppressWarnings("unused") -// tag::test[] +// tag::code[] @ExtendWith(SpringExtension.class) @SpringBootTest(properties = "spring.jmx.enabled=true") @DirtiesContext @@ -47,4 +47,4 @@ void exampleTest() { } } -// end::test[] +// end::code[] diff --git a/spring-boot-project/spring-boot-docs/src/main/java/org/springframework/boot/docs/springbootfeatures/testing/package-info.java b/spring-boot-project/spring-boot-docs/src/main/java/org/springframework/boot/docs/springbootfeatures/testing/package-info.java new file mode 100644 index 000000000000..e499e9d77ac0 --- /dev/null +++ b/spring-boot-project/spring-boot-docs/src/main/java/org/springframework/boot/docs/springbootfeatures/testing/package-info.java @@ -0,0 +1,20 @@ +/* + * Copyright 2012-2021 the original author or authors. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/** + * Examples for the "Spring Boot Features - Testing" section. + */ +package org.springframework.boot.docs.springbootfeatures.testing; diff --git a/spring-boot-project/spring-boot-docs/src/main/java/org/springframework/boot/docs/test/autoconfigure/restdocs/restassured/AdvancedConfigurationExample.java b/spring-boot-project/spring-boot-docs/src/main/java/org/springframework/boot/docs/springbootfeatures/testing/restdocs/restassured/AdvancedConfigurationExample.java similarity index 87% rename from spring-boot-project/spring-boot-docs/src/main/java/org/springframework/boot/docs/test/autoconfigure/restdocs/restassured/AdvancedConfigurationExample.java rename to spring-boot-project/spring-boot-docs/src/main/java/org/springframework/boot/docs/springbootfeatures/testing/restdocs/restassured/AdvancedConfigurationExample.java index 1e3247b893fc..f1ffafff006e 100644 --- a/spring-boot-project/spring-boot-docs/src/main/java/org/springframework/boot/docs/test/autoconfigure/restdocs/restassured/AdvancedConfigurationExample.java +++ b/spring-boot-project/spring-boot-docs/src/main/java/org/springframework/boot/docs/springbootfeatures/testing/restdocs/restassured/AdvancedConfigurationExample.java @@ -1,5 +1,5 @@ /* - * Copyright 2012-2019 the original author or authors. + * Copyright 2012-2021 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -14,7 +14,7 @@ * limitations under the License. */ -package org.springframework.boot.docs.test.autoconfigure.restdocs.restassured; +package org.springframework.boot.docs.springbootfeatures.testing.restdocs.restassured; import org.springframework.boot.test.autoconfigure.restdocs.RestDocsRestAssuredConfigurationCustomizer; import org.springframework.boot.test.context.TestConfiguration; @@ -23,7 +23,7 @@ public class AdvancedConfigurationExample { - // tag::configuration[] + // tag::code[] @TestConfiguration(proxyBeanMethods = false) public static class CustomizationConfiguration implements RestDocsRestAssuredConfigurationCustomizer { @@ -33,6 +33,6 @@ public void customize(RestAssuredRestDocumentationConfigurer configurer) { } } - // end::configuration[] + // end::code[] } diff --git a/spring-boot-project/spring-boot-docs/src/main/java/org/springframework/boot/docs/test/autoconfigure/restdocs/restassured/UserDocumentationTests.java b/spring-boot-project/spring-boot-docs/src/main/java/org/springframework/boot/docs/springbootfeatures/testing/restdocs/restassured/UserDocumentationTests.java similarity index 89% rename from spring-boot-project/spring-boot-docs/src/main/java/org/springframework/boot/docs/test/autoconfigure/restdocs/restassured/UserDocumentationTests.java rename to spring-boot-project/spring-boot-docs/src/main/java/org/springframework/boot/docs/springbootfeatures/testing/restdocs/restassured/UserDocumentationTests.java index 84f2ec13230d..b2e48aac4e5a 100644 --- a/spring-boot-project/spring-boot-docs/src/main/java/org/springframework/boot/docs/test/autoconfigure/restdocs/restassured/UserDocumentationTests.java +++ b/spring-boot-project/spring-boot-docs/src/main/java/org/springframework/boot/docs/springbootfeatures/testing/restdocs/restassured/UserDocumentationTests.java @@ -1,5 +1,5 @@ /* - * Copyright 2012-2019 the original author or authors. + * Copyright 2012-2021 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -14,9 +14,9 @@ * limitations under the License. */ -package org.springframework.boot.docs.test.autoconfigure.restdocs.restassured; +package org.springframework.boot.docs.springbootfeatures.testing.restdocs.restassured; -// tag::source[] +// tag::code[] import io.restassured.specification.RequestSpecification; import org.junit.jupiter.api.Test; @@ -41,4 +41,4 @@ void listUsers(@Autowired RequestSpecification documentationSpec, @LocalServerPo } } -// end::source[] +// end::code[] diff --git a/spring-boot-project/spring-boot-docs/src/main/java/org/springframework/boot/docs/test/autoconfigure/restdocs/webclient/AdvancedConfigurationExample.java b/spring-boot-project/spring-boot-docs/src/main/java/org/springframework/boot/docs/springbootfeatures/testing/restdocs/webclient/AdvancedConfigurationExample.java similarity index 86% rename from spring-boot-project/spring-boot-docs/src/main/java/org/springframework/boot/docs/test/autoconfigure/restdocs/webclient/AdvancedConfigurationExample.java rename to spring-boot-project/spring-boot-docs/src/main/java/org/springframework/boot/docs/springbootfeatures/testing/restdocs/webclient/AdvancedConfigurationExample.java index a5b574a59dcb..bd38c93b3313 100644 --- a/spring-boot-project/spring-boot-docs/src/main/java/org/springframework/boot/docs/test/autoconfigure/restdocs/webclient/AdvancedConfigurationExample.java +++ b/spring-boot-project/spring-boot-docs/src/main/java/org/springframework/boot/docs/springbootfeatures/testing/restdocs/webclient/AdvancedConfigurationExample.java @@ -1,5 +1,5 @@ /* - * Copyright 2012-2019 the original author or authors. + * Copyright 2012-2021 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -14,7 +14,7 @@ * limitations under the License. */ -package org.springframework.boot.docs.test.autoconfigure.restdocs.webclient; +package org.springframework.boot.docs.springbootfeatures.testing.restdocs.webclient; import org.springframework.boot.test.autoconfigure.restdocs.RestDocsWebTestClientConfigurationCustomizer; import org.springframework.boot.test.context.TestConfiguration; @@ -22,7 +22,7 @@ public class AdvancedConfigurationExample { - // tag::configuration[] + // tag::code[] @TestConfiguration(proxyBeanMethods = false) public static class CustomizationConfiguration implements RestDocsWebTestClientConfigurationCustomizer { @@ -32,6 +32,6 @@ public void customize(WebTestClientRestDocumentationConfigurer configurer) { } } - // end::configuration[] + // end::code[] } diff --git a/spring-boot-project/spring-boot-docs/src/main/java/org/springframework/boot/docs/test/autoconfigure/restdocs/webclient/UsersDocumentationTests.java b/spring-boot-project/spring-boot-docs/src/main/java/org/springframework/boot/docs/springbootfeatures/testing/restdocs/webclient/UsersDocumentationTests.java similarity index 88% rename from spring-boot-project/spring-boot-docs/src/main/java/org/springframework/boot/docs/test/autoconfigure/restdocs/webclient/UsersDocumentationTests.java rename to spring-boot-project/spring-boot-docs/src/main/java/org/springframework/boot/docs/springbootfeatures/testing/restdocs/webclient/UsersDocumentationTests.java index 7f06bc090c13..f6ebbdb3c612 100644 --- a/spring-boot-project/spring-boot-docs/src/main/java/org/springframework/boot/docs/test/autoconfigure/restdocs/webclient/UsersDocumentationTests.java +++ b/spring-boot-project/spring-boot-docs/src/main/java/org/springframework/boot/docs/springbootfeatures/testing/restdocs/webclient/UsersDocumentationTests.java @@ -1,5 +1,5 @@ /* - * Copyright 2012-2019 the original author or authors. + * Copyright 2012-2021 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -14,9 +14,9 @@ * limitations under the License. */ -package org.springframework.boot.docs.test.autoconfigure.restdocs.webclient; +package org.springframework.boot.docs.springbootfeatures.testing.restdocs.webclient; -// tag::source[] +// tag::code[] import org.junit.jupiter.api.Test; import org.springframework.beans.factory.annotation.Autowired; @@ -40,4 +40,4 @@ void listUsers() { } } -// end::source[] +// end::code[] diff --git a/spring-boot-project/spring-boot-docs/src/test/java/org/springframework/boot/docs/web/client/SampleWebClientConfiguration.java b/spring-boot-project/spring-boot-docs/src/main/java/org/springframework/boot/docs/springbootfeatures/testing/webclient/SampleWebClientConfiguration.java similarity index 93% rename from spring-boot-project/spring-boot-docs/src/test/java/org/springframework/boot/docs/web/client/SampleWebClientConfiguration.java rename to spring-boot-project/spring-boot-docs/src/main/java/org/springframework/boot/docs/springbootfeatures/testing/webclient/SampleWebClientConfiguration.java index f96e46538bac..f242cb2a7686 100644 --- a/spring-boot-project/spring-boot-docs/src/test/java/org/springframework/boot/docs/web/client/SampleWebClientConfiguration.java +++ b/spring-boot-project/spring-boot-docs/src/main/java/org/springframework/boot/docs/springbootfeatures/testing/webclient/SampleWebClientConfiguration.java @@ -1,5 +1,5 @@ /* - * Copyright 2012-2019 the original author or authors. + * Copyright 2012-2021 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -14,7 +14,7 @@ * limitations under the License. */ -package org.springframework.boot.docs.web.client; +package org.springframework.boot.docs.springbootfeatures.testing.webclient; import java.net.URI; diff --git a/spring-boot-project/spring-boot-docs/src/test/java/org/springframework/boot/docs/web/client/SampleWebClientTests.java b/spring-boot-project/spring-boot-docs/src/main/java/org/springframework/boot/docs/springbootfeatures/testing/webclient/SampleWebClientTests.java similarity index 92% rename from spring-boot-project/spring-boot-docs/src/test/java/org/springframework/boot/docs/web/client/SampleWebClientTests.java rename to spring-boot-project/spring-boot-docs/src/main/java/org/springframework/boot/docs/springbootfeatures/testing/webclient/SampleWebClientTests.java index 117b892a3bda..bdbbb339fbbe 100644 --- a/spring-boot-project/spring-boot-docs/src/test/java/org/springframework/boot/docs/web/client/SampleWebClientTests.java +++ b/spring-boot-project/spring-boot-docs/src/main/java/org/springframework/boot/docs/springbootfeatures/testing/webclient/SampleWebClientTests.java @@ -1,5 +1,5 @@ /* - * Copyright 2012-2019 the original author or authors. + * Copyright 2012-2021 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -14,7 +14,7 @@ * limitations under the License. */ -package org.springframework.boot.docs.web.client; +package org.springframework.boot.docs.springbootfeatures.testing.webclient; import java.time.Duration; @@ -36,7 +36,7 @@ * * @author Stephane Nicoll */ -// tag::test[] +// tag::code[] @SpringBootTest(webEnvironment = WebEnvironment.RANDOM_PORT) class SampleWebClientTests { @@ -61,4 +61,4 @@ RestTemplateBuilder restTemplateBuilder() { } } -// end::test[] +// end::code[] diff --git a/spring-boot-project/spring-boot-docs/src/main/java/org/springframework/boot/docs/springbootfeatures/validation/package-info.java b/spring-boot-project/spring-boot-docs/src/main/java/org/springframework/boot/docs/springbootfeatures/validation/package-info.java new file mode 100644 index 000000000000..16b4e55655b7 --- /dev/null +++ b/spring-boot-project/spring-boot-docs/src/main/java/org/springframework/boot/docs/springbootfeatures/validation/package-info.java @@ -0,0 +1,20 @@ +/* + * Copyright 2012-2021 the original author or authors. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/** + * Examples for the "Spring Boot Features - Validation" section. + */ +package org.springframework.boot.docs.springbootfeatures.validation; diff --git a/spring-boot-project/spring-boot-docs/src/main/java/org/springframework/boot/docs/context/embedded/TomcatServerCustomizerExample.java b/spring-boot-project/spring-boot-docs/src/main/java/org/springframework/boot/docs/springbootfeatures/webapplications/TomcatServerCustomizerExample.java similarity index 92% rename from spring-boot-project/spring-boot-docs/src/main/java/org/springframework/boot/docs/context/embedded/TomcatServerCustomizerExample.java rename to spring-boot-project/spring-boot-docs/src/main/java/org/springframework/boot/docs/springbootfeatures/webapplications/TomcatServerCustomizerExample.java index 6e17bb63acbe..cab19252e762 100644 --- a/spring-boot-project/spring-boot-docs/src/main/java/org/springframework/boot/docs/context/embedded/TomcatServerCustomizerExample.java +++ b/spring-boot-project/spring-boot-docs/src/main/java/org/springframework/boot/docs/springbootfeatures/webapplications/TomcatServerCustomizerExample.java @@ -14,7 +14,7 @@ * limitations under the License. */ -package org.springframework.boot.docs.context.embedded; +package org.springframework.boot.docs.springbootfeatures.webapplications; import java.time.Duration; @@ -27,7 +27,7 @@ * * @author Stephane Nicoll */ -// tag::configuration[] +// tag::code[] @Component public class TomcatServerCustomizerExample implements WebServerFactoryCustomizer { @@ -38,4 +38,4 @@ public void customize(TomcatServletWebServerFactory server) { } } -// end::configuration[] +// end::code[] diff --git a/spring-boot-project/spring-boot-docs/src/main/java/org/springframework/boot/docs/springbootfeatures/webapplications/package-info.java b/spring-boot-project/spring-boot-docs/src/main/java/org/springframework/boot/docs/springbootfeatures/webapplications/package-info.java new file mode 100644 index 000000000000..ed5dd710ce0c --- /dev/null +++ b/spring-boot-project/spring-boot-docs/src/main/java/org/springframework/boot/docs/springbootfeatures/webapplications/package-info.java @@ -0,0 +1,20 @@ +/* + * Copyright 2012-2021 the original author or authors. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/** + * Examples for the "Spring Boot Features - Developing Web Applications" section. + */ +package org.springframework.boot.docs.springbootfeatures.webapplications; diff --git a/spring-boot-project/spring-boot-docs/src/main/java/org/springframework/boot/docs/springbootfeatures/webclient/package-info.java b/spring-boot-project/spring-boot-docs/src/main/java/org/springframework/boot/docs/springbootfeatures/webclient/package-info.java new file mode 100644 index 000000000000..991a5d5aaa42 --- /dev/null +++ b/spring-boot-project/spring-boot-docs/src/main/java/org/springframework/boot/docs/springbootfeatures/webclient/package-info.java @@ -0,0 +1,20 @@ +/* + * Copyright 2012-2021 the original author or authors. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/** + * Examples for the "Spring Boot Features - Calling REST Services with WebClient" section. + */ +package org.springframework.boot.docs.springbootfeatures.webclient; diff --git a/spring-boot-project/spring-boot-docs/src/main/java/org/springframework/boot/docs/springbootfeatures/websockets/package-info.java b/spring-boot-project/spring-boot-docs/src/main/java/org/springframework/boot/docs/springbootfeatures/websockets/package-info.java new file mode 100644 index 000000000000..71cf783a86ef --- /dev/null +++ b/spring-boot-project/spring-boot-docs/src/main/java/org/springframework/boot/docs/springbootfeatures/websockets/package-info.java @@ -0,0 +1,20 @@ +/* + * Copyright 2012-2021 the original author or authors. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/** + * Examples for the "Spring Boot Features - WebSockets" section. + */ +package org.springframework.boot.docs.springbootfeatures.websockets; diff --git a/spring-boot-project/spring-boot-docs/src/test/java/org/springframework/boot/docs/context/embedded/TomcatLegacyCookieProcessorExampleTests.java b/spring-boot-project/spring-boot-docs/src/test/java/org/springframework/boot/docs/context/embedded/TomcatLegacyCookieProcessorExampleTests.java index 5fd9dd02e3c3..320e206acd52 100644 --- a/spring-boot-project/spring-boot-docs/src/test/java/org/springframework/boot/docs/context/embedded/TomcatLegacyCookieProcessorExampleTests.java +++ b/spring-boot-project/spring-boot-docs/src/test/java/org/springframework/boot/docs/context/embedded/TomcatLegacyCookieProcessorExampleTests.java @@ -1,5 +1,5 @@ /* - * Copyright 2012-2019 the original author or authors. + * Copyright 2012-2021 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -21,7 +21,8 @@ import org.junit.jupiter.api.Test; import org.springframework.boot.SpringApplication; -import org.springframework.boot.docs.context.embedded.TomcatLegacyCookieProcessorExample.LegacyCookieProcessorConfiguration; +import org.springframework.boot.docs.howto.embeddedwebservers.TomcatLegacyCookieProcessorExample; +import org.springframework.boot.docs.howto.embeddedwebservers.TomcatLegacyCookieProcessorExample.LegacyCookieProcessorConfiguration; import org.springframework.boot.web.embedded.tomcat.TomcatServletWebServerFactory; import org.springframework.boot.web.embedded.tomcat.TomcatWebServer; import org.springframework.boot.web.server.WebServerFactoryCustomizerBeanPostProcessor; diff --git a/spring-boot-project/spring-boot-docs/src/test/java/org/springframework/boot/docs/actuate/metrics/MetricsHealthMicrometerExportExampleTests.java b/spring-boot-project/spring-boot-docs/src/test/java/org/springframework/boot/docs/howto/actuator/MetricsHealthMicrometerExportExampleTests.java similarity index 95% rename from spring-boot-project/spring-boot-docs/src/test/java/org/springframework/boot/docs/actuate/metrics/MetricsHealthMicrometerExportExampleTests.java rename to spring-boot-project/spring-boot-docs/src/test/java/org/springframework/boot/docs/howto/actuator/MetricsHealthMicrometerExportExampleTests.java index 0a55c60775a4..da851000f395 100644 --- a/spring-boot-project/spring-boot-docs/src/test/java/org/springframework/boot/docs/actuate/metrics/MetricsHealthMicrometerExportExampleTests.java +++ b/spring-boot-project/spring-boot-docs/src/test/java/org/springframework/boot/docs/howto/actuator/MetricsHealthMicrometerExportExampleTests.java @@ -1,5 +1,5 @@ /* - * Copyright 2012-2020 the original author or authors. + * Copyright 2012-2021 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -14,7 +14,7 @@ * limitations under the License. */ -package org.springframework.boot.docs.actuate.metrics; +package org.springframework.boot.docs.howto.actuator; import io.micrometer.core.instrument.Gauge; import io.micrometer.core.instrument.MeterRegistry; diff --git a/spring-boot-project/spring-boot-docs/src/test/java/org/springframework/boot/docs/jdbc/BasicDataSourceExampleTests.java b/spring-boot-project/spring-boot-docs/src/test/java/org/springframework/boot/docs/howto/dataaccess/BasicDataSourceExampleTests.java similarity index 94% rename from spring-boot-project/spring-boot-docs/src/test/java/org/springframework/boot/docs/jdbc/BasicDataSourceExampleTests.java rename to spring-boot-project/spring-boot-docs/src/test/java/org/springframework/boot/docs/howto/dataaccess/BasicDataSourceExampleTests.java index 2d441f5c4069..7053ef9b6fa0 100644 --- a/spring-boot-project/spring-boot-docs/src/test/java/org/springframework/boot/docs/jdbc/BasicDataSourceExampleTests.java +++ b/spring-boot-project/spring-boot-docs/src/test/java/org/springframework/boot/docs/howto/dataaccess/BasicDataSourceExampleTests.java @@ -1,5 +1,5 @@ /* - * Copyright 2012-2019 the original author or authors. + * Copyright 2012-2021 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -14,7 +14,7 @@ * limitations under the License. */ -package org.springframework.boot.docs.jdbc; +package org.springframework.boot.docs.howto.dataaccess; import java.sql.SQLException; diff --git a/spring-boot-project/spring-boot-docs/src/test/java/org/springframework/boot/docs/jdbc/CompleteTwoDataSourcesExampleTests.java b/spring-boot-project/spring-boot-docs/src/test/java/org/springframework/boot/docs/howto/dataaccess/CompleteTwoDataSourcesExampleTests.java similarity index 94% rename from spring-boot-project/spring-boot-docs/src/test/java/org/springframework/boot/docs/jdbc/CompleteTwoDataSourcesExampleTests.java rename to spring-boot-project/spring-boot-docs/src/test/java/org/springframework/boot/docs/howto/dataaccess/CompleteTwoDataSourcesExampleTests.java index 10a801536b2b..86b2ffd551f2 100644 --- a/spring-boot-project/spring-boot-docs/src/test/java/org/springframework/boot/docs/jdbc/CompleteTwoDataSourcesExampleTests.java +++ b/spring-boot-project/spring-boot-docs/src/test/java/org/springframework/boot/docs/howto/dataaccess/CompleteTwoDataSourcesExampleTests.java @@ -1,5 +1,5 @@ /* - * Copyright 2012-2019 the original author or authors. + * Copyright 2012-2021 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -14,7 +14,7 @@ * limitations under the License. */ -package org.springframework.boot.docs.jdbc; +package org.springframework.boot.docs.howto.dataaccess; import java.sql.SQLException; diff --git a/spring-boot-project/spring-boot-docs/src/test/java/org/springframework/boot/docs/jdbc/ConfigurableDataSourceExampleTests.java b/spring-boot-project/spring-boot-docs/src/test/java/org/springframework/boot/docs/howto/dataaccess/ConfigurableDataSourceExampleTests.java similarity index 94% rename from spring-boot-project/spring-boot-docs/src/test/java/org/springframework/boot/docs/jdbc/ConfigurableDataSourceExampleTests.java rename to spring-boot-project/spring-boot-docs/src/test/java/org/springframework/boot/docs/howto/dataaccess/ConfigurableDataSourceExampleTests.java index 0e290c19f434..caeea3d1c073 100644 --- a/spring-boot-project/spring-boot-docs/src/test/java/org/springframework/boot/docs/jdbc/ConfigurableDataSourceExampleTests.java +++ b/spring-boot-project/spring-boot-docs/src/test/java/org/springframework/boot/docs/howto/dataaccess/ConfigurableDataSourceExampleTests.java @@ -1,5 +1,5 @@ /* - * Copyright 2012-2019 the original author or authors. + * Copyright 2012-2021 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -14,7 +14,7 @@ * limitations under the License. */ -package org.springframework.boot.docs.jdbc; +package org.springframework.boot.docs.howto.dataaccess; import java.sql.SQLException; diff --git a/spring-boot-project/spring-boot-docs/src/test/java/org/springframework/boot/docs/jdbc/SampleApp.java b/spring-boot-project/spring-boot-docs/src/test/java/org/springframework/boot/docs/howto/dataaccess/SampleApp.java similarity index 90% rename from spring-boot-project/spring-boot-docs/src/test/java/org/springframework/boot/docs/jdbc/SampleApp.java rename to spring-boot-project/spring-boot-docs/src/test/java/org/springframework/boot/docs/howto/dataaccess/SampleApp.java index 442293507327..230ccc2ad7cb 100644 --- a/spring-boot-project/spring-boot-docs/src/test/java/org/springframework/boot/docs/jdbc/SampleApp.java +++ b/spring-boot-project/spring-boot-docs/src/test/java/org/springframework/boot/docs/howto/dataaccess/SampleApp.java @@ -1,5 +1,5 @@ /* - * Copyright 2012-2019 the original author or authors. + * Copyright 2012-2021 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -14,7 +14,7 @@ * limitations under the License. */ -package org.springframework.boot.docs.jdbc; +package org.springframework.boot.docs.howto.dataaccess; import javax.sql.DataSource; diff --git a/spring-boot-project/spring-boot-docs/src/test/java/org/springframework/boot/docs/jdbc/SimpleDataSourceExampleTests.java b/spring-boot-project/spring-boot-docs/src/test/java/org/springframework/boot/docs/howto/dataaccess/SimpleDataSourceExampleTests.java similarity index 94% rename from spring-boot-project/spring-boot-docs/src/test/java/org/springframework/boot/docs/jdbc/SimpleDataSourceExampleTests.java rename to spring-boot-project/spring-boot-docs/src/test/java/org/springframework/boot/docs/howto/dataaccess/SimpleDataSourceExampleTests.java index f64d9b876560..373790bcf1d2 100644 --- a/spring-boot-project/spring-boot-docs/src/test/java/org/springframework/boot/docs/jdbc/SimpleDataSourceExampleTests.java +++ b/spring-boot-project/spring-boot-docs/src/test/java/org/springframework/boot/docs/howto/dataaccess/SimpleDataSourceExampleTests.java @@ -1,5 +1,5 @@ /* - * Copyright 2012-2019 the original author or authors. + * Copyright 2012-2021 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -14,7 +14,7 @@ * limitations under the License. */ -package org.springframework.boot.docs.jdbc; +package org.springframework.boot.docs.howto.dataaccess; import java.sql.SQLException; diff --git a/spring-boot-project/spring-boot-docs/src/test/java/org/springframework/boot/docs/jdbc/SimpleTwoDataSourcesExampleTests.java b/spring-boot-project/spring-boot-docs/src/test/java/org/springframework/boot/docs/howto/dataaccess/SimpleTwoDataSourcesExampleTests.java similarity index 95% rename from spring-boot-project/spring-boot-docs/src/test/java/org/springframework/boot/docs/jdbc/SimpleTwoDataSourcesExampleTests.java rename to spring-boot-project/spring-boot-docs/src/test/java/org/springframework/boot/docs/howto/dataaccess/SimpleTwoDataSourcesExampleTests.java index 1866436a3915..bce2c431a051 100644 --- a/spring-boot-project/spring-boot-docs/src/test/java/org/springframework/boot/docs/jdbc/SimpleTwoDataSourcesExampleTests.java +++ b/spring-boot-project/spring-boot-docs/src/test/java/org/springframework/boot/docs/howto/dataaccess/SimpleTwoDataSourcesExampleTests.java @@ -1,5 +1,5 @@ /* - * Copyright 2012-2019 the original author or authors. + * Copyright 2012-2021 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -14,7 +14,7 @@ * limitations under the License. */ -package org.springframework.boot.docs.jdbc; +package org.springframework.boot.docs.howto.dataaccess; import java.sql.SQLException; diff --git a/spring-boot-project/spring-boot-docs/src/test/java/org/springframework/boot/docs/context/EnvironmentPostProcessorExampleTests.java b/spring-boot-project/spring-boot-docs/src/test/java/org/springframework/boot/docs/howto/springbootapplication/EnvironmentPostProcessorExampleTests.java similarity index 91% rename from spring-boot-project/spring-boot-docs/src/test/java/org/springframework/boot/docs/context/EnvironmentPostProcessorExampleTests.java rename to spring-boot-project/spring-boot-docs/src/test/java/org/springframework/boot/docs/howto/springbootapplication/EnvironmentPostProcessorExampleTests.java index 2dc4ff7f6f7c..931d8583c58e 100644 --- a/spring-boot-project/spring-boot-docs/src/test/java/org/springframework/boot/docs/context/EnvironmentPostProcessorExampleTests.java +++ b/spring-boot-project/spring-boot-docs/src/test/java/org/springframework/boot/docs/howto/springbootapplication/EnvironmentPostProcessorExampleTests.java @@ -1,5 +1,5 @@ /* - * Copyright 2012-2019 the original author or authors. + * Copyright 2012-2021 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -14,7 +14,7 @@ * limitations under the License. */ -package org.springframework.boot.docs.context; +package org.springframework.boot.docs.howto.springbootapplication; import org.junit.jupiter.api.Test; diff --git a/spring-boot-project/spring-boot-docs/src/test/java/org/springframework/boot/docs/context/properties/bind/javabean/AppSystemPropertiesTests.java b/spring-boot-project/spring-boot-docs/src/test/java/org/springframework/boot/docs/springbootfeatures/externalizedconfiguration/duration/constructorbinding/AppSystemPropertiesTests.java similarity index 94% rename from spring-boot-project/spring-boot-docs/src/test/java/org/springframework/boot/docs/context/properties/bind/javabean/AppSystemPropertiesTests.java rename to spring-boot-project/spring-boot-docs/src/test/java/org/springframework/boot/docs/springbootfeatures/externalizedconfiguration/duration/constructorbinding/AppSystemPropertiesTests.java index f9155f5a0cca..f2f76bee65e5 100644 --- a/spring-boot-project/spring-boot-docs/src/test/java/org/springframework/boot/docs/context/properties/bind/javabean/AppSystemPropertiesTests.java +++ b/spring-boot-project/spring-boot-docs/src/test/java/org/springframework/boot/docs/springbootfeatures/externalizedconfiguration/duration/constructorbinding/AppSystemPropertiesTests.java @@ -1,5 +1,5 @@ /* - * Copyright 2012-2020 the original author or authors. + * Copyright 2012-2021 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -14,7 +14,7 @@ * limitations under the License. */ -package org.springframework.boot.docs.context.properties.bind.javabean; +package org.springframework.boot.docs.springbootfeatures.externalizedconfiguration.duration.constructorbinding; import java.util.function.Consumer; diff --git a/spring-boot-project/spring-boot-docs/src/test/java/org/springframework/boot/docs/context/properties/bind/constructor/AppSystemPropertiesTests.java b/spring-boot-project/spring-boot-docs/src/test/java/org/springframework/boot/docs/springbootfeatures/externalizedconfiguration/duration/javabeanbinding/AppSystemPropertiesTests.java similarity index 94% rename from spring-boot-project/spring-boot-docs/src/test/java/org/springframework/boot/docs/context/properties/bind/constructor/AppSystemPropertiesTests.java rename to spring-boot-project/spring-boot-docs/src/test/java/org/springframework/boot/docs/springbootfeatures/externalizedconfiguration/duration/javabeanbinding/AppSystemPropertiesTests.java index f64e49589684..0d12e58e778d 100644 --- a/spring-boot-project/spring-boot-docs/src/test/java/org/springframework/boot/docs/context/properties/bind/constructor/AppSystemPropertiesTests.java +++ b/spring-boot-project/spring-boot-docs/src/test/java/org/springframework/boot/docs/springbootfeatures/externalizedconfiguration/duration/javabeanbinding/AppSystemPropertiesTests.java @@ -1,5 +1,5 @@ /* - * Copyright 2012-2020 the original author or authors. + * Copyright 2012-2021 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -14,7 +14,7 @@ * limitations under the License. */ -package org.springframework.boot.docs.context.properties.bind.constructor; +package org.springframework.boot.docs.springbootfeatures.externalizedconfiguration.duration.javabeanbinding; import java.util.function.Consumer; diff --git a/spring-boot-project/spring-boot-docs/src/test/java/org/springframework/boot/docs/builder/SpringApplicationBuilderExampleTests.java b/spring-boot-project/spring-boot-docs/src/test/java/org/springframework/boot/docs/springbootfeatures/springapplication/SpringApplicationBuilderExampleTests.java similarity index 91% rename from spring-boot-project/spring-boot-docs/src/test/java/org/springframework/boot/docs/builder/SpringApplicationBuilderExampleTests.java rename to spring-boot-project/spring-boot-docs/src/test/java/org/springframework/boot/docs/springbootfeatures/springapplication/SpringApplicationBuilderExampleTests.java index 3da2ba10d3e7..457b994fbaff 100644 --- a/spring-boot-project/spring-boot-docs/src/test/java/org/springframework/boot/docs/builder/SpringApplicationBuilderExampleTests.java +++ b/spring-boot-project/spring-boot-docs/src/test/java/org/springframework/boot/docs/springbootfeatures/springapplication/SpringApplicationBuilderExampleTests.java @@ -1,5 +1,5 @@ /* - * Copyright 2012-2019 the original author or authors. + * Copyright 2012-2021 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -14,7 +14,7 @@ * limitations under the License. */ -package org.springframework.boot.docs.builder; +package org.springframework.boot.docs.springbootfeatures.springapplication; import org.junit.jupiter.api.Test; import org.junit.jupiter.api.extension.ExtendWith; diff --git a/spring-boot-project/spring-boot-docs/src/test/java/org/springframework/boot/docs/springbootfeatures/testing/OutputCaptureTestsTests.java b/spring-boot-project/spring-boot-docs/src/test/java/org/springframework/boot/docs/springbootfeatures/testing/OutputCaptureTestsTests.java new file mode 100644 index 000000000000..e7b6389a6e71 --- /dev/null +++ b/spring-boot-project/spring-boot-docs/src/test/java/org/springframework/boot/docs/springbootfeatures/testing/OutputCaptureTestsTests.java @@ -0,0 +1,26 @@ +/* + * Copyright 2012-2021 the original author or authors. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package org.springframework.boot.docs.springbootfeatures.testing; + +/** + * Tests for {@link OutputCaptureTests}. + * + * @author Stephane Nicoll + */ +class OutputCaptureTestsTests extends OutputCaptureTests { + +} diff --git a/spring-boot-project/spring-boot-docs/src/test/java/org/springframework/boot/docs/springbootfeatures/testing/UserServiceAutoConfigurationTestsTests.java b/spring-boot-project/spring-boot-docs/src/test/java/org/springframework/boot/docs/springbootfeatures/testing/UserServiceAutoConfigurationTestsTests.java new file mode 100644 index 000000000000..7f00013f3d28 --- /dev/null +++ b/spring-boot-project/spring-boot-docs/src/test/java/org/springframework/boot/docs/springbootfeatures/testing/UserServiceAutoConfigurationTestsTests.java @@ -0,0 +1,26 @@ +/* + * Copyright 2012-2021 the original author or authors. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package org.springframework.boot.docs.springbootfeatures.testing; + +/** + * Tests for {@link UserServiceAutoConfigurationTests}. + * + * @author Stephane Nicoll + */ +class UserServiceAutoConfigurationTestsTests extends UserServiceAutoConfigurationTests { + +} diff --git a/spring-boot-project/spring-boot-docs/src/test/java/org/springframework/boot/docs/springbootfeatures/testing/jmx/SampleJmxTestsTests.java b/spring-boot-project/spring-boot-docs/src/test/java/org/springframework/boot/docs/springbootfeatures/testing/jmx/SampleJmxTestsTests.java new file mode 100644 index 000000000000..9729e9cff869 --- /dev/null +++ b/spring-boot-project/spring-boot-docs/src/test/java/org/springframework/boot/docs/springbootfeatures/testing/jmx/SampleJmxTestsTests.java @@ -0,0 +1,26 @@ +/* + * Copyright 2012-2021 the original author or authors. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package org.springframework.boot.docs.springbootfeatures.testing.jmx; + +/** + * Tests for SampleJmxTests + * + * @author Stephane Nicoll + */ +class SampleJmxTestsTests extends SampleJmxTests { + +} diff --git a/spring-boot-project/spring-boot-docs/src/test/java/org/springframework/boot/docs/springbootfeatures/testing/webclient/SampleWebClientTestsTests.java b/spring-boot-project/spring-boot-docs/src/test/java/org/springframework/boot/docs/springbootfeatures/testing/webclient/SampleWebClientTestsTests.java new file mode 100644 index 000000000000..323dddb0b371 --- /dev/null +++ b/spring-boot-project/spring-boot-docs/src/test/java/org/springframework/boot/docs/springbootfeatures/testing/webclient/SampleWebClientTestsTests.java @@ -0,0 +1,26 @@ +/* + * Copyright 2012-2021 the original author or authors. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package org.springframework.boot.docs.springbootfeatures.testing.webclient; + +/** + * Tests for {@link SampleWebClientTests}. + * + * @author Stephane Nicoll + */ +class SampleWebClientTestsTests extends SampleWebClientTests { + +} From 2a85427324803972516416941776c39fb45318fb Mon Sep 17 00:00:00 2001 From: Phillip Webb Date: Wed, 3 Feb 2021 11:47:59 -0800 Subject: [PATCH 03/13] Refine spring-boot-docs package restructure Refine the package restructure started in 91ccc23462 to help provide a solid foundation for code snippets. This commit renames many of the classes so that they no longer end in `Example`. It also removes some of the inner types that were previously used. Many tag comments have also been moved to ensure that `import` statements are available in the docs. Closes gh-25089 --- .../src/docs/asciidoc/howto.adoc | 34 ++++----- .../asciidoc/production-ready-features.adoc | 6 +- .../docs/asciidoc/spring-boot-features.adoc | 34 ++++----- ...ava => MetricsHealthMicrometerExport.java} | 12 +--- ...java => BasicDataSourceConfiguration.java} | 28 +++----- ...gPhysicalNamingStrategyConfiguration.java} | 14 ++-- ... => CompleteDataSourcesConfiguration.java} | 60 +++++++--------- .../CompleteTwoDataSourcesExample.java | 72 ------------------- .../ConfigurableDataSourceConfiguration.java | 45 ++++++++++++ ...ManagerFactoryDependsOnPostProcessor.java} | 28 +++----- ...bernateSecondLevelCacheConfiguration.java} | 9 +-- ...cDatabaseInitializationConfiguration.java} | 29 +++----- ...ava => SimpleDataSourceConfiguration.java} | 30 +++----- ...va => SimpleDataSourcesConfiguration.java} | 54 +++++++------- ...> LegacyCookieProcessorConfiguration.java} | 28 +++----- ...omcatMultipleConnectorsConfiguration.java} | 11 +-- ...dertowMultipleListenersConfiguration.java} | 25 ++----- ...omizeReactorNettyClientConfiguration.java} | 12 +--- ...> JerseySetStatusOverSendErrorConfig.java} | 31 +++----- ...a => ExampleEnvironmentPostProcessor.java} | 9 +-- ...oundryCustomContextPathConfiguration.java} | 13 ++-- .../endpoints/CustomEndpointExample.java | 5 -- ...e.java => MetricsFilterConfiguration.java} | 23 ++---- ...ava => MetricsMeterRegistryInjection.java} | 35 +++++---- .../SampleMeterBinderConfiguration.java | 17 ++--- .../constructorbinding/AppIoProperties.java | 8 +-- .../javabeanbinding/AppIoProperties.java | 8 +-- .../AppSystemProperties.java | 8 +-- .../javabeanbinding/AppSystemProperties.java | 8 +-- ...le.java => KafkaStreamsConfiguration.java} | 31 +++----- ...> CouchbaseCacheManagerConfiguration.java} | 12 +--- ...ctiveTransactionManagerConfiguration.java} | 12 +--- ...va => RedisCacheManagerConfiguration.java} | 12 +--- ... => RestTemplateBuilderConfiguration.java} | 12 +--- ....java => RestTemplateProxyCustomizer.java} | 47 ++++++------ ...> CustomWebFluxSecurityConfiguration.java} | 26 +++---- .../springapplication/ExitCodeExample.java | 7 +- .../SpringApplicationBuilderExample.java | 11 --- ...sts.java => ApplicationArgumentTests.java} | 4 +- ...MvcExampleTests.java => MockMvcTests.java} | 3 +- ...Tests.java => MockWebTestClientTests.java} | 3 +- .../testing/OutputCaptureTests.java | 7 +- ...a => RandomPortTestRestTemplateTests.java} | 3 +- ...java => RandomPortWebTestClientTests.java} | 3 +- .../UserService.java | 7 +- .../UserServiceAutoConfiguration.java | 9 +-- .../UserServiceAutoConfigurationTests.java | 7 -- .../testing/jmx/SampleApp.java | 6 -- .../testing/jmx/SampleJmxTests.java | 14 ++-- ...ava => AdvancedRestDocsConfiguration.java} | 18 ++--- ...ava => AdvancedRestDocsConfiguration.java} | 18 ++--- .../SampleWebClientConfiguration.java | 6 -- .../webclient/SampleWebClientTests.java | 9 +-- ...ample.java => TomcatServerCustomizer.java} | 12 +--- ...> MetricsHealthMicrometerExportTests.java} | 10 +-- ...=> BasicDataSourceConfigurationTests.java} | 6 +- ...ompleteDataSourcesConfigurationTests.java} | 6 +- ...igurableDataSourceConfigurationTests.java} | 6 +- ...> SimpleDataSourceConfigurationTests.java} | 6 +- ... SimpleDataSourcesConfigurationTests.java} | 6 +- ...acyCookieProcessorConfigurationTests.java} | 8 +-- ...ExampleEnvironmentPostProcessorTests.java} | 6 +- src/checkstyle/checkstyle-suppressions.xml | 2 +- 63 files changed, 364 insertions(+), 687 deletions(-) rename spring-boot-project/spring-boot-docs/src/main/java/org/springframework/boot/docs/howto/actuator/{MetricsHealthMicrometerExportExample.java => MetricsHealthMicrometerExport.java} (85%) rename spring-boot-project/spring-boot-docs/src/main/java/org/springframework/boot/docs/howto/dataaccess/{BasicDataSourceExample.java => BasicDataSourceConfiguration.java} (65%) rename spring-boot-project/spring-boot-docs/src/main/java/org/springframework/boot/docs/howto/dataaccess/{CaseSensitiveSpringPhysicalNamingStrategyExample.java => CaseSensitiveSpringPhysicalNamingStrategyConfiguration.java} (82%) rename spring-boot-project/spring-boot-docs/src/main/java/org/springframework/boot/docs/howto/dataaccess/{SimpleTwoDataSourcesExample.java => CompleteDataSourcesConfiguration.java} (50%) delete mode 100644 spring-boot-project/spring-boot-docs/src/main/java/org/springframework/boot/docs/howto/dataaccess/CompleteTwoDataSourcesExample.java create mode 100644 spring-boot-project/spring-boot-docs/src/main/java/org/springframework/boot/docs/howto/dataaccess/ConfigurableDataSourceConfiguration.java rename spring-boot-project/spring-boot-docs/src/main/java/org/springframework/boot/docs/howto/dataaccess/{HibernateSearchElasticsearchExample.java => ElasticsearchEntityManagerFactoryDependsOnPostProcessor.java} (57%) rename spring-boot-project/spring-boot-docs/src/main/java/org/springframework/boot/docs/howto/dataaccess/{HibernateSecondLevelCacheExample.java => HibernateSecondLevelCacheConfiguration.java} (88%) rename spring-boot-project/spring-boot-docs/src/main/java/org/springframework/boot/docs/howto/dataaccess/{R2dbcDatabaseInitializationExample.java => R2dbcDatabaseInitializationConfiguration.java} (62%) rename spring-boot-project/spring-boot-docs/src/main/java/org/springframework/boot/docs/howto/dataaccess/{SimpleDataSourceExample.java => SimpleDataSourceConfiguration.java} (63%) rename spring-boot-project/spring-boot-docs/src/main/java/org/springframework/boot/docs/howto/dataaccess/{ConfigurableDataSourceExample.java => SimpleDataSourcesConfiguration.java} (55%) rename spring-boot-project/spring-boot-docs/src/main/java/org/springframework/boot/docs/howto/embeddedwebservers/{TomcatLegacyCookieProcessorExample.java => LegacyCookieProcessorConfiguration.java} (61%) rename spring-boot-project/spring-boot-docs/src/main/java/org/springframework/boot/docs/howto/embeddedwebservers/{TomcatMultipleConnectorsExample.java => TomcatMultipleConnectorsConfiguration.java} (91%) rename spring-boot-project/spring-boot-docs/src/main/java/org/springframework/boot/docs/howto/embeddedwebservers/{UndertowMultipleListenersExample.java => UndertowMultipleListenersConfiguration.java} (70%) rename spring-boot-project/spring-boot-docs/src/main/java/org/springframework/boot/docs/howto/httpclients/{ReactorNettyClientCustomizationExample.java => CustomizeReactorNettyClientConfiguration.java} (85%) rename spring-boot-project/spring-boot-docs/src/main/java/org/springframework/boot/docs/howto/jersey/{JerseySetStatusOverSendErrorExample.java => JerseySetStatusOverSendErrorConfig.java} (57%) rename spring-boot-project/spring-boot-docs/src/main/java/org/springframework/boot/docs/howto/springbootapplication/{EnvironmentPostProcessorExample.java => ExampleEnvironmentPostProcessor.java} (91%) rename spring-boot-project/spring-boot-docs/src/main/java/org/springframework/boot/docs/productionreadyfeatures/cloudfoundry/{CloudFoundryCustomContextPathExample.java => CloudFoundryCustomContextPathConfiguration.java} (92%) rename spring-boot-project/spring-boot-docs/src/main/java/org/springframework/boot/docs/productionreadyfeatures/metrics/{MetricsFilterBeanExample.java => MetricsFilterConfiguration.java} (68%) rename spring-boot-project/spring-boot-docs/src/main/java/org/springframework/boot/docs/productionreadyfeatures/metrics/{MetricsMeterRegistryInjectionExample.java => MetricsMeterRegistryInjection.java} (61%) rename spring-boot-project/spring-boot-docs/src/main/java/org/springframework/boot/docs/springbootfeatures/messaging/{KafkaStreamsBeanExample.java => KafkaStreamsConfiguration.java} (66%) rename spring-boot-project/spring-boot-docs/src/main/java/org/springframework/boot/docs/springbootfeatures/nosql/{CouchbaseCacheManagerCustomizationExample.java => CouchbaseCacheManagerConfiguration.java} (85%) rename spring-boot-project/spring-boot-docs/src/main/java/org/springframework/boot/docs/springbootfeatures/nosql/{Neo4jReactiveTransactionManagerExample.java => Neo4jReactiveTransactionManagerConfiguration.java} (82%) rename spring-boot-project/spring-boot-docs/src/main/java/org/springframework/boot/docs/springbootfeatures/nosql/{RedisCacheManagerCustomizationExample.java => RedisCacheManagerConfiguration.java} (85%) rename spring-boot-project/spring-boot-docs/src/main/java/org/springframework/boot/docs/springbootfeatures/resttemplate/{RestTemplateBuilderCustomizationExample.java => RestTemplateBuilderConfiguration.java} (83%) rename spring-boot-project/spring-boot-docs/src/main/java/org/springframework/boot/docs/springbootfeatures/resttemplate/{RestTemplateProxyCustomizationExample.java => RestTemplateProxyCustomizer.java} (54%) rename spring-boot-project/spring-boot-docs/src/main/java/org/springframework/boot/docs/springbootfeatures/security/{CustomWebFluxSecurityExample.java => CustomWebFluxSecurityConfiguration.java} (72%) rename spring-boot-project/spring-boot-docs/src/main/java/org/springframework/boot/docs/springbootfeatures/testing/{ApplicationArgumentsExampleTests.java => ApplicationArgumentTests.java} (96%) rename spring-boot-project/spring-boot-docs/src/main/java/org/springframework/boot/docs/springbootfeatures/testing/{MockMvcExampleTests.java => MockMvcTests.java} (98%) rename spring-boot-project/spring-boot-docs/src/main/java/org/springframework/boot/docs/springbootfeatures/testing/{MockWebTestClientExampleTests.java => MockWebTestClientTests.java} (97%) rename spring-boot-project/spring-boot-docs/src/main/java/org/springframework/boot/docs/springbootfeatures/testing/{RandomPortTestRestTemplateExampleTests.java => RandomPortTestRestTemplateTests.java} (96%) rename spring-boot-project/spring-boot-docs/src/main/java/org/springframework/boot/docs/springbootfeatures/testing/{RandomPortWebTestClientExampleTests.java => RandomPortWebTestClientTests.java} (96%) rename spring-boot-project/spring-boot-docs/src/main/java/org/springframework/boot/docs/springbootfeatures/{creatingautoconfiguration => testing}/UserService.java (84%) rename spring-boot-project/spring-boot-docs/src/main/java/org/springframework/boot/docs/springbootfeatures/{creatingautoconfiguration => testing}/UserServiceAutoConfiguration.java (85%) rename spring-boot-project/spring-boot-docs/src/main/java/org/springframework/boot/docs/springbootfeatures/testing/restdocs/restassured/{AdvancedConfigurationExample.java => AdvancedRestDocsConfiguration.java} (72%) rename spring-boot-project/spring-boot-docs/src/main/java/org/springframework/boot/docs/springbootfeatures/testing/restdocs/webclient/{AdvancedConfigurationExample.java => AdvancedRestDocsConfiguration.java} (72%) rename spring-boot-project/spring-boot-docs/src/main/java/org/springframework/boot/docs/springbootfeatures/webapplications/{TomcatServerCustomizerExample.java => TomcatServerCustomizer.java} (73%) rename spring-boot-project/spring-boot-docs/src/test/java/org/springframework/boot/docs/howto/actuator/{MetricsHealthMicrometerExportExampleTests.java => MetricsHealthMicrometerExportTests.java} (89%) rename spring-boot-project/spring-boot-docs/src/test/java/org/springframework/boot/docs/howto/dataaccess/{BasicDataSourceExampleTests.java => BasicDataSourceConfigurationTests.java} (92%) rename spring-boot-project/spring-boot-docs/src/test/java/org/springframework/boot/docs/howto/dataaccess/{CompleteTwoDataSourcesExampleTests.java => CompleteDataSourcesConfigurationTests.java} (91%) rename spring-boot-project/spring-boot-docs/src/test/java/org/springframework/boot/docs/howto/dataaccess/{ConfigurableDataSourceExampleTests.java => ConfigurableDataSourceConfigurationTests.java} (91%) rename spring-boot-project/spring-boot-docs/src/test/java/org/springframework/boot/docs/howto/dataaccess/{SimpleDataSourceExampleTests.java => SimpleDataSourceConfigurationTests.java} (92%) rename spring-boot-project/spring-boot-docs/src/test/java/org/springframework/boot/docs/howto/dataaccess/{SimpleTwoDataSourcesExampleTests.java => SimpleDataSourcesConfigurationTests.java} (92%) rename spring-boot-project/spring-boot-docs/src/test/java/org/springframework/boot/docs/{context/embedded/TomcatLegacyCookieProcessorExampleTests.java => howto/embeddedwebservers/LegacyCookieProcessorConfigurationTests.java} (84%) rename spring-boot-project/spring-boot-docs/src/test/java/org/springframework/boot/docs/howto/springbootapplication/{EnvironmentPostProcessorExampleTests.java => ExampleEnvironmentPostProcessorTests.java} (89%) diff --git a/spring-boot-project/spring-boot-docs/src/docs/asciidoc/howto.adoc b/spring-boot-project/spring-boot-docs/src/docs/asciidoc/howto.adoc index 948369553ba1..c53af684b8e1 100644 --- a/spring-boot-project/spring-boot-docs/src/docs/asciidoc/howto.adoc +++ b/spring-boot-project/spring-boot-docs/src/docs/asciidoc/howto.adoc @@ -95,7 +95,7 @@ For instance, the following example loads a YAML configuration file from the cla [source,java,indent=0] ---- -include::{include-howto}/springbootapplication/EnvironmentPostProcessorExample.java[tag=*] +include::{include-howto}/springbootapplication/ExampleEnvironmentPostProcessor.java[tag=*] ---- TIP: The `Environment` has already been prepared with all the usual property sources that Spring Boot loads by default. @@ -931,7 +931,7 @@ You can add an `org.apache.catalina.connector.Connector` to the `TomcatServletWe [source,java,indent=0,subs="verbatim,quotes,attributes"] ---- -include::{include-howto}/embeddedwebservers/TomcatMultipleConnectorsExample.java[tag=*] +include::{include-howto}/embeddedwebservers/TomcatMultipleConnectorsConfiguration.java[tag=*] ---- @@ -951,7 +951,7 @@ To switch to the `LegacyCookieProcessor`, use an `WebServerFactoryCustomizer` be [source,java,indent=0] ---- -include::{include-howto}/embeddedwebservers/TomcatLegacyCookieProcessorExample.java[tag=*] +include::{include-howto}/embeddedwebservers/LegacyCookieProcessorConfiguration.java[tag=*] ---- @@ -978,7 +978,7 @@ Add an `UndertowBuilderCustomizer` to the `UndertowServletWebServerFactory` and [source,java,indent=0,subs="verbatim,quotes,attributes"] ---- -include::{include-howto}/embeddedwebservers/UndertowMultipleListenersExample.java[tag=*] +include::{include-howto}/embeddedwebservers/UndertowMultipleListenersConfiguration.java[tag=*] ---- @@ -1283,7 +1283,7 @@ The `jersey.config.server.response.setStatusOverSendError` property must be set [source,java,indent=0] ---- -include::{include-howto}/jersey/JerseySetStatusOverSendErrorExample.java[tag=*] +include::{include-howto}/jersey/JerseySetStatusOverSendErrorConfig.java[tag=*] ---- @@ -1326,7 +1326,7 @@ The following example configures `HttpComponentsClientRequestFactory` with an `H [source,java,indent=0] ---- -include::{include-springbootfeatures}/resttemplate/RestTemplateProxyCustomizationExample.java[tag=*] +include::{include-springbootfeatures}/resttemplate/RestTemplateProxyCustomizer.java[tag=*] ---- [[howto-webclient-reactor-netty-customization]] @@ -1337,7 +1337,7 @@ The following example configures a 60 second connect timeout and adds a `ReadTim [source,java,indent=0] ---- -include::{include-howto}/httpclients/ReactorNettyClientCustomizationExample.java[tag=*] +include::{include-howto}/httpclients/CustomizeReactorNettyClientConfiguration.java[tag=*] ---- TIP: Note the use of `ReactorResourceFactory` for the connection provider and event loop resources. @@ -1582,7 +1582,7 @@ The following example shows how to create a data source by using a `DataSourceBu [source,java,indent=0,subs="verbatim,quotes,attributes"] ---- -include::{include-howto}/dataaccess/BasicDataSourceExample.java[tag=*] +include::{include-howto}/dataaccess/BasicDataSourceConfiguration.java[tag=*] ---- To run an app with that `DataSource`, all you need is the connection information. @@ -1623,7 +1623,7 @@ The following example shows how create a `HikariDataSource` with `DataSourceBuil [source,java,indent=0,subs="verbatim,quotes,attributes"] ---- -include::{include-howto}/dataaccess/SimpleDataSourceExample.java[tag=*] +include::{include-howto}/dataaccess/SimpleDataSourceConfiguration.java[tag=*] ---- You can even go further by leveraging what `DataSourceProperties` does for you -- that is, by providing a default embedded database with a sensible username and password if no URL is provided. @@ -1633,7 +1633,7 @@ To avoid that, you can redefine a custom `DataSourceProperties` on your custom n [source,java,indent=0,subs="verbatim,quotes,attributes"] ---- -include::{include-howto}/dataaccess/ConfigurableDataSourceExample.java[tag=*] +include::{include-howto}/dataaccess/ConfigurableDataSourceConfiguration.java[tag=*] ---- This setup puts you _in sync_ with what Spring Boot does for you by default, except that a dedicated connection pool is chosen (in code) and its settings are exposed in the `app.datasource.configuration` sub namespace. @@ -1670,7 +1670,7 @@ In the following example, we provide the _exact_ same feature set as the auto-co [source,java,indent=0,subs="verbatim,quotes,attributes"] ---- -include::{include-howto}/dataaccess/SimpleTwoDataSourcesExample.java[tag=*] +include::{include-howto}/dataaccess/SimpleDataSourcesConfiguration.java[tag=*] ---- TIP: `firstDataSourceProperties` has to be flagged as `@Primary` so that the database initializer feature uses your copy (if you use the initializer). @@ -1700,7 +1700,7 @@ You can apply the same concept to the secondary `DataSource` as well, as shown i [source,java,indent=0,subs="verbatim,quotes,attributes"] ---- -include::{include-howto}/dataaccess/CompleteTwoDataSourcesExample.java[tag=*] +include::{include-howto}/dataaccess/CompleteDataSourcesConfiguration.java[tag=*] ---- The preceding example configures two data sources on custom namespaces with the same logic as Spring Boot would use in auto-configuration. @@ -1794,7 +1794,7 @@ This implementation provides the same table structure as Hibernate 4: all dots a [source,java,indent=0] ---- -include::{include-howto}/dataaccess/CaseSensitiveSpringPhysicalNamingStrategyExample.java[tag=*] +include::{include-howto}/dataaccess/CaseSensitiveSpringPhysicalNamingStrategyConfiguration.java[tag=*] ---- If you prefer to use Hibernate 5's default instead, set the following property: @@ -1828,7 +1828,7 @@ Then, add a `HibernatePropertiesCustomizer` bean as shown in the following examp [source,java,indent=0] ---- -include::{include-howto}/dataaccess/HibernateSecondLevelCacheExample.java[tag=*] +include::{include-howto}/dataaccess/HibernateSecondLevelCacheConfiguration.java[tag=*] ---- This customizer will configure Hibernate to use the same `CacheManager` as the one that the application uses. @@ -1969,7 +1969,7 @@ For example, if you use Hibernate Search with Elasticsearch as its index manager [source,java,indent=0] ---- -include::{include-howto}/dataaccess/HibernateSearchElasticsearchExample.java[tag=*] +include::{include-howto}/dataaccess/ElasticsearchEntityManagerFactoryDependsOnPostProcessor.java[tag=*] ---- @@ -2066,7 +2066,7 @@ You can initialize the database on startup using SQL scripts as shown in the fol [source,java,indent=0] ---- -include::{include-howto}/dataaccess/R2dbcDatabaseInitializationExample.java[tag=*] +include::{include-howto}/dataaccess/R2dbcDatabaseInitializationConfiguration.java[tag=*] ---- Alternatively, you can configure either <> or <> to configure a `DataSource` for you for the duration of the migration. @@ -2351,7 +2351,7 @@ The following example shows one way to write such an exporter: [source,java,indent=0,subs="verbatim,quotes,attributes"] ---- -include::{include-howto}/actuator/MetricsHealthMicrometerExportExample.java[tag=*] +include::{include-howto}/actuator/MetricsHealthMicrometerExport.java[tag=*] ---- diff --git a/spring-boot-project/spring-boot-docs/src/docs/asciidoc/production-ready-features.adoc b/spring-boot-project/spring-boot-docs/src/docs/asciidoc/production-ready-features.adoc index daa3d2e99acb..ff93c55db297 100644 --- a/spring-boot-project/spring-boot-docs/src/docs/asciidoc/production-ready-features.adoc +++ b/spring-boot-project/spring-boot-docs/src/docs/asciidoc/production-ready-features.adoc @@ -2379,7 +2379,7 @@ To register custom metrics, inject `MeterRegistry` into your component, as shown [source,java,indent=0] ---- -include::{include-productionreadyfeatures}/metrics/MetricsMeterRegistryInjectionExample.java[tag=*] +include::{include-productionreadyfeatures}/metrics/MetricsMeterRegistryInjection.java[tag=*] ---- If your metrics depend on other beans, it is recommended that you use a `MeterBinder` to register them, as shown in the following example: @@ -2404,7 +2404,7 @@ For example, if you want to rename the `mytag.region` tag to `mytag.area` for al [source,java,indent=0] ---- -include::{include-productionreadyfeatures}/metrics/MetricsFilterBeanExample.java[tag=*] +include::{include-productionreadyfeatures}/metrics/MetricsFilterConfiguration.java[tag=*] ---- @@ -2622,7 +2622,7 @@ For Tomcat, the following configuration can be added: [source,java,indent=0] ---- -include::{include-productionreadyfeatures}/cloudfoundry/CloudFoundryCustomContextPathExample.java[tag=*] +include::{include-productionreadyfeatures}/cloudfoundry/CloudFoundryCustomContextPathConfiguration.java[tag=*] ---- diff --git a/spring-boot-project/spring-boot-docs/src/docs/asciidoc/spring-boot-features.adoc b/spring-boot-project/spring-boot-docs/src/docs/asciidoc/spring-boot-features.adoc index 5659f9bb9bf5..8ae7b4e14625 100644 --- a/spring-boot-project/spring-boot-docs/src/docs/asciidoc/spring-boot-features.adoc +++ b/spring-boot-project/spring-boot-docs/src/docs/asciidoc/spring-boot-features.adoc @@ -597,7 +597,7 @@ This means that the JSON cannot override properties from lower order property so [[boot-features-external-config-files]] -=== External Application Properties [[boot-features-external-config-application-property-files]] +=== External Application Properties [[boot-features-external-config-application-property-files]] Spring Boot will automatically find and load `application.properties` and `application.yaml` files from the following locations when your application starts: . The classpath root @@ -1519,7 +1519,7 @@ The properties above will bind to a `Map` with `/key1`, `/key2` and `key3` as th The slash has been removed from `key3` because it wasn't surrounded by square brackets. You may also occasionally need to use the bracket notation if your `key` contains a `.` and you are binding to non-scalar value. -For example, binding `a.b=c` to `Map` will return a Map with the entry `{"a"={"b"="c"}}` where as `[a.b]=c` will return a Map with the entry `{"a.b"="c"}`. +For example, binding `a.b=c` to `Map` will return a Map with the entry `{"a"={"b"="c"}}` where as `[a.b]=c` will return a Map with the entry `{"a.b"="c"}`. @@ -3515,7 +3515,7 @@ The following example shows how to customize `TomcatServletWebServerFactory` tha [source,java,indent=0,subs="verbatim,quotes,attributes"] ---- -include::{include-springbootfeatures}/webapplications/TomcatServerCustomizerExample.java[tag=*] +include::{include-springbootfeatures}/webapplications/TomcatServerCustomizer.java[tag=*] ---- @@ -3769,7 +3769,7 @@ For example, you can customize your security configuration by adding something l [source,java,indent=0] ---- -include::{include-springbootfeatures}/security/CustomWebFluxSecurityExample.java[tag=*] +include::{include-springbootfeatures}/security/CustomWebFluxSecurityConfiguration.java[tag=*] ---- @@ -4924,7 +4924,7 @@ To enable transaction management, the following bean must be defined in your con [source,java,indent=0] ---- -include::{include-springbootfeatures}/nosql/Neo4jReactiveTransactionManagerExample.java[tag=*] +include::{include-springbootfeatures}/nosql/Neo4jReactiveTransactionManagerConfiguration.java[tag=*] ---- ==== @@ -5609,7 +5609,7 @@ The following example shows a customizer that configures a specific entry expira [source,java,indent=0] ---- -include::{include-springbootfeatures}/nosql/CouchbaseCacheManagerCustomizationExample.java[tag=*] +include::{include-springbootfeatures}/nosql/CouchbaseCacheManagerConfiguration.java[tag=*] ---- @@ -5640,7 +5640,7 @@ The following example shows a customizer that configures a specific time to live [source,java,indent=0] ---- -include::{include-springbootfeatures}/nosql//RedisCacheManagerCustomizationExample.java[tag=*] +include::{include-springbootfeatures}/nosql/RedisCacheManagerConfiguration.java[tag=*] ---- @@ -6208,7 +6208,7 @@ To use the factory bean, wire `StreamsBuilder` into your `@Bean` as shown in the [source,java,indent=0] ---- -include::{include-springbootfeatures}/messaging/KafkaStreamsBeanExample.java[tag=*] +include::{include-springbootfeatures}/messaging/KafkaStreamsConfiguration.java[tag=*] ---- By default, the streams managed by the `StreamBuilder` object it creates are started automatically. @@ -6363,7 +6363,7 @@ The following example shows a customizer that configures the use of a proxy for [source,java,indent=0] ---- -include::{include-springbootfeatures}/resttemplate/RestTemplateProxyCustomizationExample.java[tag=*] +include::{include-springbootfeatures}/resttemplate/RestTemplateProxyCustomizer.java[tag=*] ---- Finally, you can also create your own `RestTemplateBuilder` bean. @@ -6372,7 +6372,7 @@ The following example exposes a `RestTemplateBuilder` with what Spring Boot woul [source,java,indent=0] ---- -include::{include-springbootfeatures}/resttemplate/RestTemplateBuilderCustomizationExample.java[tag=*] +include::{include-springbootfeatures}/resttemplate/RestTemplateBuilderConfiguration.java[tag=*] ---- The most extreme (and rarely used) option is to create your own `RestTemplateBuilder` bean without using a configurer. @@ -7025,7 +7025,7 @@ have `@SpringBootTest` inject them using the `args` attribute. [source,java,indent=0] ---- -include::{include-springbootfeatures}/testing/ApplicationArgumentsExampleTests.java[tag=*] +include::{include-springbootfeatures}/testing/ApplicationArgumentTests.java[tag=*] ---- @@ -7037,7 +7037,7 @@ If you have web endpoints that you want to test against this mock environment, y [source,java,indent=0] ---- -include::{include-springbootfeatures}/testing/MockMvcExampleTests.java[tag=*] +include::{include-springbootfeatures}/testing/MockMvcTests.java[tag=*] ---- TIP: If you want to focus only on the web layer and not start a complete `ApplicationContext`, consider <>. @@ -7046,7 +7046,7 @@ Alternatively, you can configure a {spring-framework-docs}/testing.html#webtestc [source,java,indent=0] ---- -include::{include-springbootfeatures}/testing/MockWebTestClientExampleTests.java[tag=*] +include::{include-springbootfeatures}/testing/MockWebTestClientTests.java[tag=*] ---- [TIP] @@ -7071,7 +7071,7 @@ For convenience, tests that need to make REST calls to the started server can ad [source,java,indent=0] ---- -include::{include-springbootfeatures}/testing/RandomPortWebTestClientExampleTests.java[tag=*] +include::{include-springbootfeatures}/testing/RandomPortWebTestClientTests.java[tag=*] ---- This setup requires `spring-webflux` on the classpath. @@ -7079,7 +7079,7 @@ If you can't or won't add webflux, Spring Boot also provides a `TestRestTemplate [source,java,indent=0] ---- -include::{include-springbootfeatures}/testing/RandomPortTestRestTemplateExampleTests.java[tag=*] +include::{include-springbootfeatures}/testing/RandomPortTestRestTemplateTests.java[tag=*] ---- @@ -7928,7 +7928,7 @@ If you require more control over Spring REST Docs configuration than offered by [source,java,indent=0] ---- -include::{include-springbootfeatures}/testing/restdocs/webclient/AdvancedConfigurationExample.java[tag=*] +include::{include-springbootfeatures}/testing/restdocs/webclient/AdvancedRestDocsConfiguration.java[tag=*] ---- @@ -7947,7 +7947,7 @@ If you require more control over Spring REST Docs configuration than offered by [source,java,indent=0] ---- -include::{include-springbootfeatures}/testing/restdocs/restassured/AdvancedConfigurationExample.java[tag=*] +include::{include-springbootfeatures}/testing/restdocs/restassured/AdvancedRestDocsConfiguration.java[tag=*] ---- diff --git a/spring-boot-project/spring-boot-docs/src/main/java/org/springframework/boot/docs/howto/actuator/MetricsHealthMicrometerExportExample.java b/spring-boot-project/spring-boot-docs/src/main/java/org/springframework/boot/docs/howto/actuator/MetricsHealthMicrometerExport.java similarity index 85% rename from spring-boot-project/spring-boot-docs/src/main/java/org/springframework/boot/docs/howto/actuator/MetricsHealthMicrometerExportExample.java rename to spring-boot-project/spring-boot-docs/src/main/java/org/springframework/boot/docs/howto/actuator/MetricsHealthMicrometerExport.java index da10ce4cd940..2813360f4766 100644 --- a/spring-boot-project/spring-boot-docs/src/main/java/org/springframework/boot/docs/howto/actuator/MetricsHealthMicrometerExportExample.java +++ b/spring-boot-project/spring-boot-docs/src/main/java/org/springframework/boot/docs/howto/actuator/MetricsHealthMicrometerExport.java @@ -16,22 +16,16 @@ package org.springframework.boot.docs.howto.actuator; +// tag::code[] import io.micrometer.core.instrument.Gauge; import io.micrometer.core.instrument.MeterRegistry; import org.springframework.boot.actuate.health.HealthEndpoint; -import org.springframework.boot.actuate.health.HealthIndicator; import org.springframework.boot.actuate.health.Status; import org.springframework.context.annotation.Configuration; -/** - * Example to show how to export {@link HealthIndicator} beans to a {@link MeterRegistry}. - * - * @author Phillip Webb - */ -public class MetricsHealthMicrometerExportExample { +public class MetricsHealthMicrometerExport { - // tag::code[] @Configuration public class HealthMetricsConfiguration { @@ -55,6 +49,6 @@ private int getStatusCode(HealthEndpoint health) { } } - // end::code[] } +// end::code[] diff --git a/spring-boot-project/spring-boot-docs/src/main/java/org/springframework/boot/docs/howto/dataaccess/BasicDataSourceExample.java b/spring-boot-project/spring-boot-docs/src/main/java/org/springframework/boot/docs/howto/dataaccess/BasicDataSourceConfiguration.java similarity index 65% rename from spring-boot-project/spring-boot-docs/src/main/java/org/springframework/boot/docs/howto/dataaccess/BasicDataSourceExample.java rename to spring-boot-project/spring-boot-docs/src/main/java/org/springframework/boot/docs/howto/dataaccess/BasicDataSourceConfiguration.java index 7ffb6e38734c..fd3ca2c6d846 100644 --- a/spring-boot-project/spring-boot-docs/src/main/java/org/springframework/boot/docs/howto/dataaccess/BasicDataSourceExample.java +++ b/spring-boot-project/spring-boot-docs/src/main/java/org/springframework/boot/docs/howto/dataaccess/BasicDataSourceConfiguration.java @@ -16,6 +16,7 @@ package org.springframework.boot.docs.howto.dataaccess; +// tag::code[] import javax.sql.DataSource; import org.springframework.boot.context.properties.ConfigurationProperties; @@ -23,27 +24,14 @@ import org.springframework.context.annotation.Bean; import org.springframework.context.annotation.Configuration; -/** - * Example configuration for configuring a very basic custom {@link DataSource}. - * - * @author Stephane Nicoll - */ -public class BasicDataSourceExample { - - /** - * A configuration that exposes an empty {@link DataSource}. - */ - @Configuration(proxyBeanMethods = false) - public static class BasicDataSourceConfiguration { - - // tag::code[] - @Bean - @ConfigurationProperties("app.datasource") - public DataSource dataSource() { - return DataSourceBuilder.create().build(); - } - // end::code[] +@Configuration(proxyBeanMethods = false) +public class BasicDataSourceConfiguration { + @Bean + @ConfigurationProperties("app.datasource") + public DataSource dataSource() { + return DataSourceBuilder.create().build(); } } +// end::code[] diff --git a/spring-boot-project/spring-boot-docs/src/main/java/org/springframework/boot/docs/howto/dataaccess/CaseSensitiveSpringPhysicalNamingStrategyExample.java b/spring-boot-project/spring-boot-docs/src/main/java/org/springframework/boot/docs/howto/dataaccess/CaseSensitiveSpringPhysicalNamingStrategyConfiguration.java similarity index 82% rename from spring-boot-project/spring-boot-docs/src/main/java/org/springframework/boot/docs/howto/dataaccess/CaseSensitiveSpringPhysicalNamingStrategyExample.java rename to spring-boot-project/spring-boot-docs/src/main/java/org/springframework/boot/docs/howto/dataaccess/CaseSensitiveSpringPhysicalNamingStrategyConfiguration.java index 27e44dd5c1d5..52f00426e391 100644 --- a/spring-boot-project/spring-boot-docs/src/main/java/org/springframework/boot/docs/howto/dataaccess/CaseSensitiveSpringPhysicalNamingStrategyExample.java +++ b/spring-boot-project/spring-boot-docs/src/main/java/org/springframework/boot/docs/howto/dataaccess/CaseSensitiveSpringPhysicalNamingStrategyConfiguration.java @@ -16,20 +16,16 @@ package org.springframework.boot.docs.howto.dataaccess; +// tag::code[] import org.hibernate.engine.jdbc.env.spi.JdbcEnvironment; import org.springframework.boot.orm.jpa.hibernate.SpringPhysicalNamingStrategy; import org.springframework.context.annotation.Bean; +import org.springframework.context.annotation.Configuration; -/** - * Example configuration for defining a custom {@link SpringPhysicalNamingStrategy} that - * is case sensitive. - * - * @author Andy Wilkinson - */ -class CaseSensitiveSpringPhysicalNamingStrategyExample { +@Configuration +class CaseSensitiveSpringPhysicalNamingStrategyConfiguration { - // tag::code[] @Bean SpringPhysicalNamingStrategy caseSensitivePhysicalNamingStrategy() { return new SpringPhysicalNamingStrategy() { @@ -41,6 +37,6 @@ protected boolean isCaseInsensitive(JdbcEnvironment jdbcEnvironment) { }; } - // end::code[] } +// end::code[] diff --git a/spring-boot-project/spring-boot-docs/src/main/java/org/springframework/boot/docs/howto/dataaccess/SimpleTwoDataSourcesExample.java b/spring-boot-project/spring-boot-docs/src/main/java/org/springframework/boot/docs/howto/dataaccess/CompleteDataSourcesConfiguration.java similarity index 50% rename from spring-boot-project/spring-boot-docs/src/main/java/org/springframework/boot/docs/howto/dataaccess/SimpleTwoDataSourcesExample.java rename to spring-boot-project/spring-boot-docs/src/main/java/org/springframework/boot/docs/howto/dataaccess/CompleteDataSourcesConfiguration.java index 99d65575903a..e651b6d2a053 100644 --- a/spring-boot-project/spring-boot-docs/src/main/java/org/springframework/boot/docs/howto/dataaccess/SimpleTwoDataSourcesExample.java +++ b/spring-boot-project/spring-boot-docs/src/main/java/org/springframework/boot/docs/howto/dataaccess/CompleteDataSourcesConfiguration.java @@ -16,54 +16,44 @@ package org.springframework.boot.docs.howto.dataaccess; -import javax.sql.DataSource; - +// tag::code[] import com.zaxxer.hikari.HikariDataSource; import org.apache.commons.dbcp2.BasicDataSource; import org.springframework.boot.autoconfigure.jdbc.DataSourceProperties; import org.springframework.boot.context.properties.ConfigurationProperties; -import org.springframework.boot.jdbc.DataSourceBuilder; import org.springframework.context.annotation.Bean; import org.springframework.context.annotation.Configuration; import org.springframework.context.annotation.Primary; -/** - * Example configuration for configuring a configurable secondary {@link DataSource} while - * keeping the auto-configuration defaults for the primary one. - * - * @author Stephane Nicoll - */ -public class SimpleTwoDataSourcesExample { - - /** - * A simple configuration that exposes two data sources. - */ - @Configuration - public static class SimpleDataSourcesConfiguration { +@Configuration +public class CompleteDataSourcesConfiguration { - // tag::code[] - @Bean - @Primary - @ConfigurationProperties("app.datasource.first") - public DataSourceProperties firstDataSourceProperties() { - return new DataSourceProperties(); - } + @Bean + @Primary + @ConfigurationProperties("app.datasource.first") + public DataSourceProperties firstDataSourceProperties() { + return new DataSourceProperties(); + } - @Bean - @Primary - @ConfigurationProperties("app.datasource.first.configuration") - public HikariDataSource firstDataSource() { - return firstDataSourceProperties().initializeDataSourceBuilder().type(HikariDataSource.class).build(); - } + @Bean + @Primary + @ConfigurationProperties("app.datasource.first.configuration") + public HikariDataSource firstDataSource() { + return firstDataSourceProperties().initializeDataSourceBuilder().type(HikariDataSource.class).build(); + } - @Bean - @ConfigurationProperties("app.datasource.second") - public BasicDataSource secondDataSource() { - return DataSourceBuilder.create().type(BasicDataSource.class).build(); - } - // end::code[] + @Bean + @ConfigurationProperties("app.datasource.second") + public DataSourceProperties secondDataSourceProperties() { + return new DataSourceProperties(); + } + @Bean + @ConfigurationProperties("app.datasource.second.configuration") + public BasicDataSource secondDataSource() { + return secondDataSourceProperties().initializeDataSourceBuilder().type(BasicDataSource.class).build(); } } +// end::code[] diff --git a/spring-boot-project/spring-boot-docs/src/main/java/org/springframework/boot/docs/howto/dataaccess/CompleteTwoDataSourcesExample.java b/spring-boot-project/spring-boot-docs/src/main/java/org/springframework/boot/docs/howto/dataaccess/CompleteTwoDataSourcesExample.java deleted file mode 100644 index 824dc549078c..000000000000 --- a/spring-boot-project/spring-boot-docs/src/main/java/org/springframework/boot/docs/howto/dataaccess/CompleteTwoDataSourcesExample.java +++ /dev/null @@ -1,72 +0,0 @@ -/* - * Copyright 2012-2021 the original author or authors. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * https://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package org.springframework.boot.docs.howto.dataaccess; - -import com.zaxxer.hikari.HikariDataSource; -import org.apache.commons.dbcp2.BasicDataSource; - -import org.springframework.boot.autoconfigure.jdbc.DataSourceProperties; -import org.springframework.boot.context.properties.ConfigurationProperties; -import org.springframework.context.annotation.Bean; -import org.springframework.context.annotation.Configuration; -import org.springframework.context.annotation.Primary; - -/** - * Example configuration for configuring two data sources with what Spring Boot does in - * auto-configuration. - * - * @author Stephane Nicoll - */ -public class CompleteTwoDataSourcesExample { - - /** - * A complete configuration that exposes two data sources. - */ - @Configuration - public static class CompleteDataSourcesConfiguration { - - // tag::code[] - @Bean - @Primary - @ConfigurationProperties("app.datasource.first") - public DataSourceProperties firstDataSourceProperties() { - return new DataSourceProperties(); - } - - @Bean - @Primary - @ConfigurationProperties("app.datasource.first.configuration") - public HikariDataSource firstDataSource() { - return firstDataSourceProperties().initializeDataSourceBuilder().type(HikariDataSource.class).build(); - } - - @Bean - @ConfigurationProperties("app.datasource.second") - public DataSourceProperties secondDataSourceProperties() { - return new DataSourceProperties(); - } - - @Bean - @ConfigurationProperties("app.datasource.second.configuration") - public BasicDataSource secondDataSource() { - return secondDataSourceProperties().initializeDataSourceBuilder().type(BasicDataSource.class).build(); - } - // end::code[] - - } - -} diff --git a/spring-boot-project/spring-boot-docs/src/main/java/org/springframework/boot/docs/howto/dataaccess/ConfigurableDataSourceConfiguration.java b/spring-boot-project/spring-boot-docs/src/main/java/org/springframework/boot/docs/howto/dataaccess/ConfigurableDataSourceConfiguration.java new file mode 100644 index 000000000000..4f0af432f5e6 --- /dev/null +++ b/spring-boot-project/spring-boot-docs/src/main/java/org/springframework/boot/docs/howto/dataaccess/ConfigurableDataSourceConfiguration.java @@ -0,0 +1,45 @@ +/* + * Copyright 2012-2021 the original author or authors. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package org.springframework.boot.docs.howto.dataaccess; + +// tag::code[] +import com.zaxxer.hikari.HikariDataSource; + +import org.springframework.boot.autoconfigure.jdbc.DataSourceProperties; +import org.springframework.boot.context.properties.ConfigurationProperties; +import org.springframework.context.annotation.Bean; +import org.springframework.context.annotation.Configuration; +import org.springframework.context.annotation.Primary; + +@Configuration(proxyBeanMethods = false) +public class ConfigurableDataSourceConfiguration { + + @Bean + @Primary + @ConfigurationProperties("app.datasource") + public DataSourceProperties dataSourceProperties() { + return new DataSourceProperties(); + } + + @Bean + @ConfigurationProperties("app.datasource.configuration") + public HikariDataSource dataSource(DataSourceProperties properties) { + return properties.initializeDataSourceBuilder().type(HikariDataSource.class).build(); + } + +} +// end::code[] diff --git a/spring-boot-project/spring-boot-docs/src/main/java/org/springframework/boot/docs/howto/dataaccess/HibernateSearchElasticsearchExample.java b/spring-boot-project/spring-boot-docs/src/main/java/org/springframework/boot/docs/howto/dataaccess/ElasticsearchEntityManagerFactoryDependsOnPostProcessor.java similarity index 57% rename from spring-boot-project/spring-boot-docs/src/main/java/org/springframework/boot/docs/howto/dataaccess/HibernateSearchElasticsearchExample.java rename to spring-boot-project/spring-boot-docs/src/main/java/org/springframework/boot/docs/howto/dataaccess/ElasticsearchEntityManagerFactoryDependsOnPostProcessor.java index 916a116b6bc8..737ac85e316c 100644 --- a/spring-boot-project/spring-boot-docs/src/main/java/org/springframework/boot/docs/howto/dataaccess/HibernateSearchElasticsearchExample.java +++ b/spring-boot-project/spring-boot-docs/src/main/java/org/springframework/boot/docs/howto/dataaccess/ElasticsearchEntityManagerFactoryDependsOnPostProcessor.java @@ -16,33 +16,23 @@ package org.springframework.boot.docs.howto.dataaccess; +// tag::code[] import javax.persistence.EntityManagerFactory; import org.springframework.boot.autoconfigure.orm.jpa.EntityManagerFactoryDependsOnPostProcessor; import org.springframework.stereotype.Component; /** - * Example configuration for configuring Hibernate to depend on Elasticsearch so that - * Hibernate Search can use Elasticsearch as its index manager. - * - * @author Andy Wilkinson + * {@link EntityManagerFactoryDependsOnPostProcessor} that ensures that + * {@link EntityManagerFactory} beans depend on the {@code elasticsearchClient} bean. */ -public class HibernateSearchElasticsearchExample { - - // tag::code[] - /** - * {@link EntityManagerFactoryDependsOnPostProcessor} that ensures that - * {@link EntityManagerFactory} beans depend on the {@code elasticsearchClient} bean. - */ - @Component - static class ElasticsearchEntityManagerFactoryDependsOnPostProcessor - extends EntityManagerFactoryDependsOnPostProcessor { - - ElasticsearchEntityManagerFactoryDependsOnPostProcessor() { - super("elasticsearchClient"); - } +@Component +public class ElasticsearchEntityManagerFactoryDependsOnPostProcessor + extends EntityManagerFactoryDependsOnPostProcessor { + ElasticsearchEntityManagerFactoryDependsOnPostProcessor() { + super("elasticsearchClient"); } - // end::code[] } +// end::code[] diff --git a/spring-boot-project/spring-boot-docs/src/main/java/org/springframework/boot/docs/howto/dataaccess/HibernateSecondLevelCacheExample.java b/spring-boot-project/spring-boot-docs/src/main/java/org/springframework/boot/docs/howto/dataaccess/HibernateSecondLevelCacheConfiguration.java similarity index 88% rename from spring-boot-project/spring-boot-docs/src/main/java/org/springframework/boot/docs/howto/dataaccess/HibernateSecondLevelCacheExample.java rename to spring-boot-project/spring-boot-docs/src/main/java/org/springframework/boot/docs/howto/dataaccess/HibernateSecondLevelCacheConfiguration.java index b174e7a80234..e6fffd5302dd 100644 --- a/spring-boot-project/spring-boot-docs/src/main/java/org/springframework/boot/docs/howto/dataaccess/HibernateSecondLevelCacheExample.java +++ b/spring-boot-project/spring-boot-docs/src/main/java/org/springframework/boot/docs/howto/dataaccess/HibernateSecondLevelCacheConfiguration.java @@ -16,6 +16,7 @@ package org.springframework.boot.docs.howto.dataaccess; +// tag::code[] import org.hibernate.cache.jcache.ConfigSettings; import org.springframework.boot.autoconfigure.orm.jpa.HibernatePropertiesCustomizer; @@ -23,14 +24,8 @@ import org.springframework.context.annotation.Bean; import org.springframework.context.annotation.Configuration; -/** - * Example configuration of using JCache and Hibernate to enable second level caching. - * - * @author Stephane Nicoll - */ -// tag::code[] @Configuration(proxyBeanMethods = false) -public class HibernateSecondLevelCacheExample { +public class HibernateSecondLevelCacheConfiguration { @Bean public HibernatePropertiesCustomizer hibernateSecondLevelCacheCustomizer(JCacheCacheManager cacheManager) { diff --git a/spring-boot-project/spring-boot-docs/src/main/java/org/springframework/boot/docs/howto/dataaccess/R2dbcDatabaseInitializationExample.java b/spring-boot-project/spring-boot-docs/src/main/java/org/springframework/boot/docs/howto/dataaccess/R2dbcDatabaseInitializationConfiguration.java similarity index 62% rename from spring-boot-project/spring-boot-docs/src/main/java/org/springframework/boot/docs/howto/dataaccess/R2dbcDatabaseInitializationExample.java rename to spring-boot-project/spring-boot-docs/src/main/java/org/springframework/boot/docs/howto/dataaccess/R2dbcDatabaseInitializationConfiguration.java index 2dfd7b4a423c..01625798d3e3 100644 --- a/spring-boot-project/spring-boot-docs/src/main/java/org/springframework/boot/docs/howto/dataaccess/R2dbcDatabaseInitializationExample.java +++ b/spring-boot-project/spring-boot-docs/src/main/java/org/springframework/boot/docs/howto/dataaccess/R2dbcDatabaseInitializationConfiguration.java @@ -16,6 +16,7 @@ package org.springframework.boot.docs.howto.dataaccess; +// tag::code[] import io.r2dbc.spi.ConnectionFactory; import org.springframework.beans.factory.annotation.Autowired; @@ -25,26 +26,16 @@ import org.springframework.core.io.ResourceLoader; import org.springframework.r2dbc.connection.init.ResourceDatabasePopulator; -/** - * Example configuration for initializing a database using R2DBC. - * - * @author Stephane Nicoll - */ -public class R2dbcDatabaseInitializationExample { - - // tag::code[] - @Configuration(proxyBeanMethods = false) - static class DatabaseInitializationConfiguration { - - @Autowired - void initializeDatabase(ConnectionFactory connectionFactory) { - ResourceLoader resourceLoader = new DefaultResourceLoader(); - Resource[] scripts = new Resource[] { resourceLoader.getResource("classpath:schema.sql"), - resourceLoader.getResource("classpath:data.sql") }; - new ResourceDatabasePopulator(scripts).populate(connectionFactory).block(); - } +@Configuration(proxyBeanMethods = false) +public class R2dbcDatabaseInitializationConfiguration { + @Autowired + void initializeDatabase(ConnectionFactory connectionFactory) { + ResourceLoader resourceLoader = new DefaultResourceLoader(); + Resource[] scripts = new Resource[] { resourceLoader.getResource("classpath:schema.sql"), + resourceLoader.getResource("classpath:data.sql") }; + new ResourceDatabasePopulator(scripts).populate(connectionFactory).block(); } - // end::code[] } +// end::code[] diff --git a/spring-boot-project/spring-boot-docs/src/main/java/org/springframework/boot/docs/howto/dataaccess/SimpleDataSourceExample.java b/spring-boot-project/spring-boot-docs/src/main/java/org/springframework/boot/docs/howto/dataaccess/SimpleDataSourceConfiguration.java similarity index 63% rename from spring-boot-project/spring-boot-docs/src/main/java/org/springframework/boot/docs/howto/dataaccess/SimpleDataSourceExample.java rename to spring-boot-project/spring-boot-docs/src/main/java/org/springframework/boot/docs/howto/dataaccess/SimpleDataSourceConfiguration.java index 3c55602513d3..88df89cf2589 100644 --- a/spring-boot-project/spring-boot-docs/src/main/java/org/springframework/boot/docs/howto/dataaccess/SimpleDataSourceExample.java +++ b/spring-boot-project/spring-boot-docs/src/main/java/org/springframework/boot/docs/howto/dataaccess/SimpleDataSourceConfiguration.java @@ -16,8 +16,7 @@ package org.springframework.boot.docs.howto.dataaccess; -import javax.sql.DataSource; - +// tag::code[] import com.zaxxer.hikari.HikariDataSource; import org.springframework.boot.context.properties.ConfigurationProperties; @@ -25,27 +24,14 @@ import org.springframework.context.annotation.Bean; import org.springframework.context.annotation.Configuration; -/** - * Example configuration for configuring a simple {@link DataSource}. - * - * @author Stephane Nicoll - */ -public class SimpleDataSourceExample { - - /** - * A simple configuration that exposes dedicated settings. - */ - @Configuration(proxyBeanMethods = false) - public static class SimpleDataSourceConfiguration { - - // tag::code[] - @Bean - @ConfigurationProperties("app.datasource") - public HikariDataSource dataSource() { - return DataSourceBuilder.create().type(HikariDataSource.class).build(); - } - // end::code[] +@Configuration(proxyBeanMethods = false) +public class SimpleDataSourceConfiguration { + @Bean + @ConfigurationProperties("app.datasource") + public HikariDataSource dataSource() { + return DataSourceBuilder.create().type(HikariDataSource.class).build(); } } +// end::code[] diff --git a/spring-boot-project/spring-boot-docs/src/main/java/org/springframework/boot/docs/howto/dataaccess/ConfigurableDataSourceExample.java b/spring-boot-project/spring-boot-docs/src/main/java/org/springframework/boot/docs/howto/dataaccess/SimpleDataSourcesConfiguration.java similarity index 55% rename from spring-boot-project/spring-boot-docs/src/main/java/org/springframework/boot/docs/howto/dataaccess/ConfigurableDataSourceExample.java rename to spring-boot-project/spring-boot-docs/src/main/java/org/springframework/boot/docs/howto/dataaccess/SimpleDataSourcesConfiguration.java index ab38834a4c6d..434e97a290dc 100644 --- a/spring-boot-project/spring-boot-docs/src/main/java/org/springframework/boot/docs/howto/dataaccess/ConfigurableDataSourceExample.java +++ b/spring-boot-project/spring-boot-docs/src/main/java/org/springframework/boot/docs/howto/dataaccess/SimpleDataSourcesConfiguration.java @@ -16,45 +16,39 @@ package org.springframework.boot.docs.howto.dataaccess; -import javax.sql.DataSource; - +// tag::code[] import com.zaxxer.hikari.HikariDataSource; +import org.apache.commons.dbcp2.BasicDataSource; import org.springframework.boot.autoconfigure.jdbc.DataSourceProperties; import org.springframework.boot.context.properties.ConfigurationProperties; +import org.springframework.boot.jdbc.DataSourceBuilder; import org.springframework.context.annotation.Bean; import org.springframework.context.annotation.Configuration; import org.springframework.context.annotation.Primary; -/** - * Example configuration for configuring a configurable custom {@link DataSource}. - * - * @author Stephane Nicoll - */ -public class ConfigurableDataSourceExample { - - /** - * A configuration that defines dedicated settings and reuses - * {@link DataSourceProperties}. - */ - @Configuration(proxyBeanMethods = false) - public static class ConfigurableDataSourceConfiguration { - - // tag::code[] - @Bean - @Primary - @ConfigurationProperties("app.datasource") - public DataSourceProperties dataSourceProperties() { - return new DataSourceProperties(); - } - - @Bean - @ConfigurationProperties("app.datasource.configuration") - public HikariDataSource dataSource(DataSourceProperties properties) { - return properties.initializeDataSourceBuilder().type(HikariDataSource.class).build(); - } - // end::code[] +@Configuration +public class SimpleDataSourcesConfiguration { + + @Bean + @Primary + @ConfigurationProperties("app.datasource.first") + public DataSourceProperties firstDataSourceProperties() { + return new DataSourceProperties(); + } + + @Bean + @Primary + @ConfigurationProperties("app.datasource.first.configuration") + public HikariDataSource firstDataSource() { + return firstDataSourceProperties().initializeDataSourceBuilder().type(HikariDataSource.class).build(); + } + @Bean + @ConfigurationProperties("app.datasource.second") + public BasicDataSource secondDataSource() { + return DataSourceBuilder.create().type(BasicDataSource.class).build(); } } +// end::code[] diff --git a/spring-boot-project/spring-boot-docs/src/main/java/org/springframework/boot/docs/howto/embeddedwebservers/TomcatLegacyCookieProcessorExample.java b/spring-boot-project/spring-boot-docs/src/main/java/org/springframework/boot/docs/howto/embeddedwebservers/LegacyCookieProcessorConfiguration.java similarity index 61% rename from spring-boot-project/spring-boot-docs/src/main/java/org/springframework/boot/docs/howto/embeddedwebservers/TomcatLegacyCookieProcessorExample.java rename to spring-boot-project/spring-boot-docs/src/main/java/org/springframework/boot/docs/howto/embeddedwebservers/LegacyCookieProcessorConfiguration.java index 557c4a0b4516..4ccb9f6daefc 100644 --- a/spring-boot-project/spring-boot-docs/src/main/java/org/springframework/boot/docs/howto/embeddedwebservers/TomcatLegacyCookieProcessorExample.java +++ b/spring-boot-project/spring-boot-docs/src/main/java/org/springframework/boot/docs/howto/embeddedwebservers/LegacyCookieProcessorConfiguration.java @@ -16,6 +16,7 @@ package org.springframework.boot.docs.howto.embeddedwebservers; +// tag::code[] import org.apache.tomcat.util.http.LegacyCookieProcessor; import org.springframework.boot.web.embedded.tomcat.TomcatServletWebServerFactory; @@ -23,27 +24,14 @@ import org.springframework.context.annotation.Bean; import org.springframework.context.annotation.Configuration; -/** - * Example configuration for configuring Tomcat with to use {@link LegacyCookieProcessor}. - * - * @author Andy Wilkinson - */ -public class TomcatLegacyCookieProcessorExample { - - /** - * Configuration class that declares the required {@link WebServerFactoryCustomizer}. - */ - @Configuration(proxyBeanMethods = false) - public static class LegacyCookieProcessorConfiguration { - - // tag::code[] - @Bean - public WebServerFactoryCustomizer cookieProcessorCustomizer() { - return (factory) -> factory - .addContextCustomizers((context) -> context.setCookieProcessor(new LegacyCookieProcessor())); - } - // end::code[] +@Configuration(proxyBeanMethods = false) +public class LegacyCookieProcessorConfiguration { + @Bean + public WebServerFactoryCustomizer cookieProcessorCustomizer() { + return (factory) -> factory + .addContextCustomizers((context) -> context.setCookieProcessor(new LegacyCookieProcessor())); } } +// end::code[] diff --git a/spring-boot-project/spring-boot-docs/src/main/java/org/springframework/boot/docs/howto/embeddedwebservers/TomcatMultipleConnectorsExample.java b/spring-boot-project/spring-boot-docs/src/main/java/org/springframework/boot/docs/howto/embeddedwebservers/TomcatMultipleConnectorsConfiguration.java similarity index 91% rename from spring-boot-project/spring-boot-docs/src/main/java/org/springframework/boot/docs/howto/embeddedwebservers/TomcatMultipleConnectorsExample.java rename to spring-boot-project/spring-boot-docs/src/main/java/org/springframework/boot/docs/howto/embeddedwebservers/TomcatMultipleConnectorsConfiguration.java index 9608308c8e45..62569aeb198b 100644 --- a/spring-boot-project/spring-boot-docs/src/main/java/org/springframework/boot/docs/howto/embeddedwebservers/TomcatMultipleConnectorsExample.java +++ b/spring-boot-project/spring-boot-docs/src/main/java/org/springframework/boot/docs/howto/embeddedwebservers/TomcatMultipleConnectorsConfiguration.java @@ -16,6 +16,7 @@ package org.springframework.boot.docs.howto.embeddedwebservers; +// tag::code[] import java.io.IOException; import java.net.URL; @@ -28,15 +29,9 @@ import org.springframework.context.annotation.Configuration; import org.springframework.util.ResourceUtils; -/** - * Example configuration for configuring Tomcat with an additional {@link Connector}. - * - * @author Stephane Nicoll - */ @Configuration(proxyBeanMethods = false) -public class TomcatMultipleConnectorsExample { +public class TomcatMultipleConnectorsConfiguration { - // tag::code[] @Bean public WebServerFactoryCustomizer sslConnectorCustomizer() { return (tomcat) -> tomcat.addAdditionalTomcatConnectors(createSslConnector()); @@ -63,6 +58,6 @@ private Connector createSslConnector() { throw new IllegalStateException("Fail to create ssl connector", ex); } } - // end::code[] } +// end::code[] diff --git a/spring-boot-project/spring-boot-docs/src/main/java/org/springframework/boot/docs/howto/embeddedwebservers/UndertowMultipleListenersExample.java b/spring-boot-project/spring-boot-docs/src/main/java/org/springframework/boot/docs/howto/embeddedwebservers/UndertowMultipleListenersConfiguration.java similarity index 70% rename from spring-boot-project/spring-boot-docs/src/main/java/org/springframework/boot/docs/howto/embeddedwebservers/UndertowMultipleListenersExample.java rename to spring-boot-project/spring-boot-docs/src/main/java/org/springframework/boot/docs/howto/embeddedwebservers/UndertowMultipleListenersConfiguration.java index 94f50f4e196b..bed31b8b10ce 100644 --- a/spring-boot-project/spring-boot-docs/src/main/java/org/springframework/boot/docs/howto/embeddedwebservers/UndertowMultipleListenersExample.java +++ b/spring-boot-project/spring-boot-docs/src/main/java/org/springframework/boot/docs/howto/embeddedwebservers/UndertowMultipleListenersConfiguration.java @@ -18,34 +18,23 @@ import io.undertow.Undertow.Builder; -import org.springframework.boot.web.embedded.undertow.UndertowBuilderCustomizer; +//tag::code[] import org.springframework.boot.web.embedded.undertow.UndertowServletWebServerFactory; import org.springframework.boot.web.server.WebServerFactoryCustomizer; import org.springframework.context.annotation.Bean; import org.springframework.context.annotation.Configuration; -/** - * Example configuration for configuring Undertow with an additional listener. - * - * @author Stephane Nicoll - */ @Configuration(proxyBeanMethods = false) -public class UndertowMultipleListenersExample { +public class UndertowMultipleListenersConfiguration { - // tag::code[] @Bean public WebServerFactoryCustomizer undertowListenerCustomizer() { - return (factory) -> { - factory.addBuilderCustomizers(new UndertowBuilderCustomizer() { - - @Override - public void customize(Builder builder) { - builder.addHttpListener(8080, "0.0.0.0"); - } + return (factory) -> factory.addBuilderCustomizers(this::addHttpListener); + } - }); - }; + private Builder addHttpListener(Builder builder) { + return builder.addHttpListener(8080, "0.0.0.0"); } - // end::code[] } +// end::code[] diff --git a/spring-boot-project/spring-boot-docs/src/main/java/org/springframework/boot/docs/howto/httpclients/ReactorNettyClientCustomizationExample.java b/spring-boot-project/spring-boot-docs/src/main/java/org/springframework/boot/docs/howto/httpclients/CustomizeReactorNettyClientConfiguration.java similarity index 85% rename from spring-boot-project/spring-boot-docs/src/main/java/org/springframework/boot/docs/howto/httpclients/ReactorNettyClientCustomizationExample.java rename to spring-boot-project/spring-boot-docs/src/main/java/org/springframework/boot/docs/howto/httpclients/CustomizeReactorNettyClientConfiguration.java index 6290717ab8bd..d476add98580 100644 --- a/spring-boot-project/spring-boot-docs/src/main/java/org/springframework/boot/docs/howto/httpclients/ReactorNettyClientCustomizationExample.java +++ b/spring-boot-project/spring-boot-docs/src/main/java/org/springframework/boot/docs/howto/httpclients/CustomizeReactorNettyClientConfiguration.java @@ -16,6 +16,7 @@ package org.springframework.boot.docs.howto.httpclients; +// tag::code[] import io.netty.channel.ChannelOption; import io.netty.handler.timeout.ReadTimeoutHandler; import reactor.netty.http.client.HttpClient; @@ -25,17 +26,10 @@ import org.springframework.http.client.reactive.ClientHttpConnector; import org.springframework.http.client.reactive.ReactorClientHttpConnector; import org.springframework.http.client.reactive.ReactorResourceFactory; -import org.springframework.web.reactive.function.client.WebClient; -/** - * Example configuration for customizing the Reactor Netty-based {@link WebClient}. - * - * @author Andy Wilkinson - */ @Configuration(proxyBeanMethods = false) -public class ReactorNettyClientCustomizationExample { +public class CustomizeReactorNettyClientConfiguration { - // tag::code[] @Bean ClientHttpConnector clientHttpConnector(ReactorResourceFactory resourceFactory) { HttpClient httpClient = HttpClient.create(resourceFactory.getConnectionProvider()) @@ -43,6 +37,6 @@ ClientHttpConnector clientHttpConnector(ReactorResourceFactory resourceFactory) .doOnConnected((connection) -> connection.addHandlerLast(new ReadTimeoutHandler(60))); return new ReactorClientHttpConnector(httpClient); } - // end::code[] } +// end::code[] diff --git a/spring-boot-project/spring-boot-docs/src/main/java/org/springframework/boot/docs/howto/jersey/JerseySetStatusOverSendErrorExample.java b/spring-boot-project/spring-boot-docs/src/main/java/org/springframework/boot/docs/howto/jersey/JerseySetStatusOverSendErrorConfig.java similarity index 57% rename from spring-boot-project/spring-boot-docs/src/main/java/org/springframework/boot/docs/howto/jersey/JerseySetStatusOverSendErrorExample.java rename to spring-boot-project/spring-boot-docs/src/main/java/org/springframework/boot/docs/howto/jersey/JerseySetStatusOverSendErrorConfig.java index 6720bd3b9107..52a5be8ab525 100644 --- a/spring-boot-project/spring-boot-docs/src/main/java/org/springframework/boot/docs/howto/jersey/JerseySetStatusOverSendErrorExample.java +++ b/spring-boot-project/spring-boot-docs/src/main/java/org/springframework/boot/docs/howto/jersey/JerseySetStatusOverSendErrorConfig.java @@ -16,37 +16,24 @@ package org.springframework.boot.docs.howto.jersey; +// tag::code[] import java.util.Collections; -import javax.servlet.http.HttpServletResponse; - import org.glassfish.jersey.server.ResourceConfig; import org.springframework.stereotype.Component; -/** - * Example configuration for a Jersey {@link ResourceConfig} configured to use - * {@link HttpServletResponse#setStatus(int)} rather than - * {@link HttpServletResponse#sendError(int)}. - * - * @author Andy Wilkinson - */ -public class JerseySetStatusOverSendErrorExample { - - // tag::code[] - @Component - public class JerseyConfig extends ResourceConfig { - - public JerseyConfig() { - register(Endpoint.class); - setProperties(Collections.singletonMap("jersey.config.server.response.setStatusOverSendError", true)); - } +@Component +public class JerseySetStatusOverSendErrorConfig extends ResourceConfig { + public JerseySetStatusOverSendErrorConfig() { + register(Endpoint.class); + setProperties(Collections.singletonMap("jersey.config.server.response.setStatusOverSendError", true)); } - // end::code[] - static class Endpoint { +} +// end::code[] - } +class Endpoint { } diff --git a/spring-boot-project/spring-boot-docs/src/main/java/org/springframework/boot/docs/howto/springbootapplication/EnvironmentPostProcessorExample.java b/spring-boot-project/spring-boot-docs/src/main/java/org/springframework/boot/docs/howto/springbootapplication/ExampleEnvironmentPostProcessor.java similarity index 91% rename from spring-boot-project/spring-boot-docs/src/main/java/org/springframework/boot/docs/howto/springbootapplication/EnvironmentPostProcessorExample.java rename to spring-boot-project/spring-boot-docs/src/main/java/org/springframework/boot/docs/howto/springbootapplication/ExampleEnvironmentPostProcessor.java index 3b7a90b764d5..33c9ca51ea69 100644 --- a/spring-boot-project/spring-boot-docs/src/main/java/org/springframework/boot/docs/howto/springbootapplication/EnvironmentPostProcessorExample.java +++ b/spring-boot-project/spring-boot-docs/src/main/java/org/springframework/boot/docs/howto/springbootapplication/ExampleEnvironmentPostProcessor.java @@ -16,6 +16,7 @@ package org.springframework.boot.docs.howto.springbootapplication; +// tag::code[] import java.io.IOException; import org.springframework.boot.SpringApplication; @@ -27,13 +28,7 @@ import org.springframework.core.io.Resource; import org.springframework.util.Assert; -/** - * An {@link EnvironmentPostProcessor} example that loads a YAML file. - * - * @author Stephane Nicoll - */ -// tag::code[] -public class EnvironmentPostProcessorExample implements EnvironmentPostProcessor { +public class ExampleEnvironmentPostProcessor implements EnvironmentPostProcessor { private final YamlPropertySourceLoader loader = new YamlPropertySourceLoader(); diff --git a/spring-boot-project/spring-boot-docs/src/main/java/org/springframework/boot/docs/productionreadyfeatures/cloudfoundry/CloudFoundryCustomContextPathExample.java b/spring-boot-project/spring-boot-docs/src/main/java/org/springframework/boot/docs/productionreadyfeatures/cloudfoundry/CloudFoundryCustomContextPathConfiguration.java similarity index 92% rename from spring-boot-project/spring-boot-docs/src/main/java/org/springframework/boot/docs/productionreadyfeatures/cloudfoundry/CloudFoundryCustomContextPathExample.java rename to spring-boot-project/spring-boot-docs/src/main/java/org/springframework/boot/docs/productionreadyfeatures/cloudfoundry/CloudFoundryCustomContextPathConfiguration.java index f9d6fcd7eb8e..7264c032dbdd 100644 --- a/spring-boot-project/spring-boot-docs/src/main/java/org/springframework/boot/docs/productionreadyfeatures/cloudfoundry/CloudFoundryCustomContextPathExample.java +++ b/spring-boot-project/spring-boot-docs/src/main/java/org/springframework/boot/docs/productionreadyfeatures/cloudfoundry/CloudFoundryCustomContextPathConfiguration.java @@ -16,6 +16,7 @@ package org.springframework.boot.docs.productionreadyfeatures.cloudfoundry; +// tag::code[] import java.io.IOException; import java.util.Collections; @@ -36,15 +37,9 @@ import org.springframework.context.annotation.Bean; import org.springframework.context.annotation.Configuration; -/** - * Example configuration for custom context path in Cloud Foundry. - * - * @author Johnny Lim - */ @Configuration(proxyBeanMethods = false) -public class CloudFoundryCustomContextPathExample { +public class CloudFoundryCustomContextPathConfiguration { - // tag::code[] @Bean public TomcatServletWebServerFactory servletWebServerFactory() { return new TomcatServletWebServerFactory() { @@ -65,7 +60,7 @@ protected void prepareContext(Host host, ServletContextInitializer[] initializer } private ServletContainerInitializer getServletContextInitializer(String contextPath) { - return (c, context) -> { + return (classes, context) -> { Servlet servlet = new GenericServlet() { @Override @@ -78,6 +73,6 @@ public void service(ServletRequest req, ServletResponse res) throws ServletExcep context.addServlet("cloudfoundry", servlet).addMapping("/*"); }; } - // end::code[] } +// end::code[] diff --git a/spring-boot-project/spring-boot-docs/src/main/java/org/springframework/boot/docs/productionreadyfeatures/endpoints/CustomEndpointExample.java b/spring-boot-project/spring-boot-docs/src/main/java/org/springframework/boot/docs/productionreadyfeatures/endpoints/CustomEndpointExample.java index a46938dd3098..cb8135af13df 100644 --- a/spring-boot-project/spring-boot-docs/src/main/java/org/springframework/boot/docs/productionreadyfeatures/endpoints/CustomEndpointExample.java +++ b/spring-boot-project/spring-boot-docs/src/main/java/org/springframework/boot/docs/productionreadyfeatures/endpoints/CustomEndpointExample.java @@ -20,11 +20,6 @@ import org.springframework.boot.actuate.endpoint.annotation.ReadOperation; import org.springframework.boot.actuate.endpoint.annotation.WriteOperation; -/** - * An example of a custom actuator endpoint. - * - * @author Stephane Nicoll - */ @Endpoint(id = "custom") public class CustomEndpointExample { diff --git a/spring-boot-project/spring-boot-docs/src/main/java/org/springframework/boot/docs/productionreadyfeatures/metrics/MetricsFilterBeanExample.java b/spring-boot-project/spring-boot-docs/src/main/java/org/springframework/boot/docs/productionreadyfeatures/metrics/MetricsFilterConfiguration.java similarity index 68% rename from spring-boot-project/spring-boot-docs/src/main/java/org/springframework/boot/docs/productionreadyfeatures/metrics/MetricsFilterBeanExample.java rename to spring-boot-project/spring-boot-docs/src/main/java/org/springframework/boot/docs/productionreadyfeatures/metrics/MetricsFilterConfiguration.java index 103ff1311e11..b1d6e6335d7a 100644 --- a/spring-boot-project/spring-boot-docs/src/main/java/org/springframework/boot/docs/productionreadyfeatures/metrics/MetricsFilterBeanExample.java +++ b/spring-boot-project/spring-boot-docs/src/main/java/org/springframework/boot/docs/productionreadyfeatures/metrics/MetricsFilterConfiguration.java @@ -16,28 +16,19 @@ package org.springframework.boot.docs.productionreadyfeatures.metrics; +// tag::code[] import io.micrometer.core.instrument.config.MeterFilter; import org.springframework.context.annotation.Bean; import org.springframework.context.annotation.Configuration; -/** - * Example to show a {@link MeterFilter}. - * - * @author Phillip Webb - */ -public class MetricsFilterBeanExample { - - @Configuration(proxyBeanMethods = false) - public static class MetricsFilterExampleConfiguration { - - // tag::code[] - @Bean - public MeterFilter renameRegionTagMeterFilter() { - return MeterFilter.renameTag("com.example", "mytag.region", "mytag.area"); - } - // end::code[] +@Configuration(proxyBeanMethods = false) +public class MetricsFilterConfiguration { + @Bean + public MeterFilter renameRegionTagMeterFilter() { + return MeterFilter.renameTag("com.example", "mytag.region", "mytag.area"); } } +// end::code[] diff --git a/spring-boot-project/spring-boot-docs/src/main/java/org/springframework/boot/docs/productionreadyfeatures/metrics/MetricsMeterRegistryInjectionExample.java b/spring-boot-project/spring-boot-docs/src/main/java/org/springframework/boot/docs/productionreadyfeatures/metrics/MetricsMeterRegistryInjection.java similarity index 61% rename from spring-boot-project/spring-boot-docs/src/main/java/org/springframework/boot/docs/productionreadyfeatures/metrics/MetricsMeterRegistryInjectionExample.java rename to spring-boot-project/spring-boot-docs/src/main/java/org/springframework/boot/docs/productionreadyfeatures/metrics/MetricsMeterRegistryInjection.java index 3845936b0e65..093a7edac879 100644 --- a/spring-boot-project/spring-boot-docs/src/main/java/org/springframework/boot/docs/productionreadyfeatures/metrics/MetricsMeterRegistryInjectionExample.java +++ b/spring-boot-project/spring-boot-docs/src/main/java/org/springframework/boot/docs/productionreadyfeatures/metrics/MetricsMeterRegistryInjection.java @@ -16,31 +16,36 @@ package org.springframework.boot.docs.productionreadyfeatures.metrics; +//tag::code[] +import java.util.Collections; import java.util.List; -import java.util.concurrent.CopyOnWriteArrayList; import io.micrometer.core.instrument.MeterRegistry; import io.micrometer.core.instrument.Tags; -/** - * Example to show injection and use of a {@link MeterRegistry}. - * - * @author Andy Wilkinson - */ -public class MetricsMeterRegistryInjectionExample { +import org.springframework.stereotype.Component; - // tag::code[] - class Dictionary { +@Component +public class MetricsMeterRegistryInjection { - private final List words = new CopyOnWriteArrayList<>(); + private final Dictionary dictionary; - Dictionary(MeterRegistry registry) { - registry.gaugeCollectionSize("dictionary.size", Tags.empty(), this.words); - } + MetricsMeterRegistryInjection(MeterRegistry registry) { + this.dictionary = Dictionary.load(); + registry.gauge("dictionary.size", Tags.empty(), this.dictionary.getWords().size()); + } - // ... +} +// end::code[] + +class Dictionary { + + static Dictionary load() { + return new Dictionary(); + } + List getWords() { + return Collections.emptyList(); } - // end::code[] } diff --git a/spring-boot-project/spring-boot-docs/src/main/java/org/springframework/boot/docs/productionreadyfeatures/metrics/SampleMeterBinderConfiguration.java b/spring-boot-project/spring-boot-docs/src/main/java/org/springframework/boot/docs/productionreadyfeatures/metrics/SampleMeterBinderConfiguration.java index b289ab58cf38..18d28419d930 100644 --- a/spring-boot-project/spring-boot-docs/src/main/java/org/springframework/boot/docs/productionreadyfeatures/metrics/SampleMeterBinderConfiguration.java +++ b/spring-boot-project/spring-boot-docs/src/main/java/org/springframework/boot/docs/productionreadyfeatures/metrics/SampleMeterBinderConfiguration.java @@ -16,31 +16,26 @@ package org.springframework.boot.docs.productionreadyfeatures.metrics; +// tag::code[] import io.micrometer.core.instrument.Gauge; import io.micrometer.core.instrument.binder.MeterBinder; import org.springframework.context.annotation.Bean; -/** - * Example to show configuration of a custom {@link MeterBinder}. - * - * @author Andy Wilkinson - */ public class SampleMeterBinderConfiguration { - // tag::code[] @Bean MeterBinder queueSize(Queue queue) { return (registry) -> Gauge.builder("queueSize", queue::size).register(registry); } - // end::code[] - static class Queue { +} +// end::code[] - int size() { - return 5; - } +class Queue { + int size() { + return 5; } } diff --git a/spring-boot-project/spring-boot-docs/src/main/java/org/springframework/boot/docs/springbootfeatures/externalizedconfiguration/datasize/constructorbinding/AppIoProperties.java b/spring-boot-project/spring-boot-docs/src/main/java/org/springframework/boot/docs/springbootfeatures/externalizedconfiguration/datasize/constructorbinding/AppIoProperties.java index b94754e06ad8..ea1b16249e18 100644 --- a/spring-boot-project/spring-boot-docs/src/main/java/org/springframework/boot/docs/springbootfeatures/externalizedconfiguration/datasize/constructorbinding/AppIoProperties.java +++ b/spring-boot-project/spring-boot-docs/src/main/java/org/springframework/boot/docs/springbootfeatures/externalizedconfiguration/datasize/constructorbinding/AppIoProperties.java @@ -16,6 +16,7 @@ package org.springframework.boot.docs.springbootfeatures.externalizedconfiguration.datasize.constructorbinding; +// tag::code[] import org.springframework.boot.context.properties.ConfigurationProperties; import org.springframework.boot.context.properties.ConstructorBinding; import org.springframework.boot.context.properties.bind.DefaultValue; @@ -23,13 +24,6 @@ import org.springframework.util.unit.DataSize; import org.springframework.util.unit.DataUnit; -/** - * A {@link ConfigurationProperties @ConfigurationProperties} example that uses - * {@link DataSize}. - * - * @author Stephane Nicoll - */ -// tag::code[] @ConfigurationProperties("app.io") @ConstructorBinding public class AppIoProperties { diff --git a/spring-boot-project/spring-boot-docs/src/main/java/org/springframework/boot/docs/springbootfeatures/externalizedconfiguration/datasize/javabeanbinding/AppIoProperties.java b/spring-boot-project/spring-boot-docs/src/main/java/org/springframework/boot/docs/springbootfeatures/externalizedconfiguration/datasize/javabeanbinding/AppIoProperties.java index 7aba68682051..c69b097d7016 100644 --- a/spring-boot-project/spring-boot-docs/src/main/java/org/springframework/boot/docs/springbootfeatures/externalizedconfiguration/datasize/javabeanbinding/AppIoProperties.java +++ b/spring-boot-project/spring-boot-docs/src/main/java/org/springframework/boot/docs/springbootfeatures/externalizedconfiguration/datasize/javabeanbinding/AppIoProperties.java @@ -16,18 +16,12 @@ package org.springframework.boot.docs.springbootfeatures.externalizedconfiguration.datasize.javabeanbinding; +// tag::code[] import org.springframework.boot.context.properties.ConfigurationProperties; import org.springframework.boot.convert.DataSizeUnit; import org.springframework.util.unit.DataSize; import org.springframework.util.unit.DataUnit; -/** - * A {@link ConfigurationProperties @ConfigurationProperties} example that uses - * {@link DataSize}. - * - * @author Stephane Nicoll - */ -// tag::code[] @ConfigurationProperties("app.io") public class AppIoProperties { diff --git a/spring-boot-project/spring-boot-docs/src/main/java/org/springframework/boot/docs/springbootfeatures/externalizedconfiguration/duration/constructorbinding/AppSystemProperties.java b/spring-boot-project/spring-boot-docs/src/main/java/org/springframework/boot/docs/springbootfeatures/externalizedconfiguration/duration/constructorbinding/AppSystemProperties.java index 58089d7bb618..bdfb5a3bb64d 100644 --- a/spring-boot-project/spring-boot-docs/src/main/java/org/springframework/boot/docs/springbootfeatures/externalizedconfiguration/duration/constructorbinding/AppSystemProperties.java +++ b/spring-boot-project/spring-boot-docs/src/main/java/org/springframework/boot/docs/springbootfeatures/externalizedconfiguration/duration/constructorbinding/AppSystemProperties.java @@ -16,6 +16,7 @@ package org.springframework.boot.docs.springbootfeatures.externalizedconfiguration.duration.constructorbinding; +// tag::code[] import java.time.Duration; import java.time.temporal.ChronoUnit; @@ -24,13 +25,6 @@ import org.springframework.boot.context.properties.bind.DefaultValue; import org.springframework.boot.convert.DurationUnit; -/** - * A {@link ConfigurationProperties @ConfigurationProperties} example that uses - * {@link Duration}. - * - * @author Stephane Nicoll - */ -// tag::code[] @ConfigurationProperties("app.system") @ConstructorBinding public class AppSystemProperties { diff --git a/spring-boot-project/spring-boot-docs/src/main/java/org/springframework/boot/docs/springbootfeatures/externalizedconfiguration/duration/javabeanbinding/AppSystemProperties.java b/spring-boot-project/spring-boot-docs/src/main/java/org/springframework/boot/docs/springbootfeatures/externalizedconfiguration/duration/javabeanbinding/AppSystemProperties.java index 5ee4ef56ceb3..9aabcd46ecdb 100644 --- a/spring-boot-project/spring-boot-docs/src/main/java/org/springframework/boot/docs/springbootfeatures/externalizedconfiguration/duration/javabeanbinding/AppSystemProperties.java +++ b/spring-boot-project/spring-boot-docs/src/main/java/org/springframework/boot/docs/springbootfeatures/externalizedconfiguration/duration/javabeanbinding/AppSystemProperties.java @@ -16,19 +16,13 @@ package org.springframework.boot.docs.springbootfeatures.externalizedconfiguration.duration.javabeanbinding; +// tag::code[] import java.time.Duration; import java.time.temporal.ChronoUnit; import org.springframework.boot.context.properties.ConfigurationProperties; import org.springframework.boot.convert.DurationUnit; -/** - * A {@link ConfigurationProperties @ConfigurationProperties} example that uses - * {@link Duration}. - * - * @author Stephane Nicoll - */ -// tag::code[] @ConfigurationProperties("app.system") public class AppSystemProperties { diff --git a/spring-boot-project/spring-boot-docs/src/main/java/org/springframework/boot/docs/springbootfeatures/messaging/KafkaStreamsBeanExample.java b/spring-boot-project/spring-boot-docs/src/main/java/org/springframework/boot/docs/springbootfeatures/messaging/KafkaStreamsConfiguration.java similarity index 66% rename from spring-boot-project/spring-boot-docs/src/main/java/org/springframework/boot/docs/springbootfeatures/messaging/KafkaStreamsBeanExample.java rename to spring-boot-project/spring-boot-docs/src/main/java/org/springframework/boot/docs/springbootfeatures/messaging/KafkaStreamsConfiguration.java index 7575be40f3e1..2a4dbdd3055c 100644 --- a/spring-boot-project/spring-boot-docs/src/main/java/org/springframework/boot/docs/springbootfeatures/messaging/KafkaStreamsBeanExample.java +++ b/spring-boot-project/spring-boot-docs/src/main/java/org/springframework/boot/docs/springbootfeatures/messaging/KafkaStreamsConfiguration.java @@ -16,6 +16,7 @@ package org.springframework.boot.docs.springbootfeatures.messaging; +// tag::code[] import org.apache.kafka.common.serialization.Serdes; import org.apache.kafka.streams.KeyValue; import org.apache.kafka.streams.StreamsBuilder; @@ -27,27 +28,17 @@ import org.springframework.kafka.annotation.EnableKafkaStreams; import org.springframework.kafka.support.serializer.JsonSerde; -/** - * Example to show usage of {@link StreamsBuilder}. - * - * @author Stephane Nicoll - */ -public class KafkaStreamsBeanExample { - - // tag::code[] - @Configuration(proxyBeanMethods = false) - @EnableKafkaStreams - public static class KafkaStreamsExampleConfiguration { - - @Bean - public KStream kStream(StreamsBuilder streamsBuilder) { - KStream stream = streamsBuilder.stream("ks1In"); - stream.map((k, v) -> new KeyValue<>(k, v.toUpperCase())).to("ks1Out", - Produced.with(Serdes.Integer(), new JsonSerde<>())); - return stream; - } +@Configuration(proxyBeanMethods = false) +@EnableKafkaStreams +public class KafkaStreamsConfiguration { + @Bean + public KStream kStream(StreamsBuilder streamsBuilder) { + KStream stream = streamsBuilder.stream("ks1In"); + stream.map((k, v) -> new KeyValue<>(k, v.toUpperCase())).to("ks1Out", + Produced.with(Serdes.Integer(), new JsonSerde<>())); + return stream; } - // end::code[] } +// end::code[] diff --git a/spring-boot-project/spring-boot-docs/src/main/java/org/springframework/boot/docs/springbootfeatures/nosql/CouchbaseCacheManagerCustomizationExample.java b/spring-boot-project/spring-boot-docs/src/main/java/org/springframework/boot/docs/springbootfeatures/nosql/CouchbaseCacheManagerConfiguration.java similarity index 85% rename from spring-boot-project/spring-boot-docs/src/main/java/org/springframework/boot/docs/springbootfeatures/nosql/CouchbaseCacheManagerCustomizationExample.java rename to spring-boot-project/spring-boot-docs/src/main/java/org/springframework/boot/docs/springbootfeatures/nosql/CouchbaseCacheManagerConfiguration.java index 987c87794628..e130e09ce4fd 100644 --- a/spring-boot-project/spring-boot-docs/src/main/java/org/springframework/boot/docs/springbootfeatures/nosql/CouchbaseCacheManagerCustomizationExample.java +++ b/spring-boot-project/spring-boot-docs/src/main/java/org/springframework/boot/docs/springbootfeatures/nosql/CouchbaseCacheManagerConfiguration.java @@ -16,6 +16,7 @@ package org.springframework.boot.docs.springbootfeatures.nosql; +// tag::code[] import java.time.Duration; import org.springframework.boot.autoconfigure.cache.CouchbaseCacheManagerBuilderCustomizer; @@ -23,16 +24,9 @@ import org.springframework.context.annotation.Configuration; import org.springframework.data.couchbase.cache.CouchbaseCacheConfiguration; -/** - * An example how to customize {@code CouchbaseCacheManagerBuilder} via - * {@code CouchbaseCacheManagerBuilderCustomizer}. - * - * @author Dmytro Nosan - */ @Configuration(proxyBeanMethods = false) -public class CouchbaseCacheManagerCustomizationExample { +public class CouchbaseCacheManagerConfiguration { - // tag::code[] @Bean public CouchbaseCacheManagerBuilderCustomizer myCouchbaseCacheManagerBuilderCustomizer() { return (builder) -> builder @@ -42,6 +36,6 @@ public CouchbaseCacheManagerBuilderCustomizer myCouchbaseCacheManagerBuilderCust CouchbaseCacheConfiguration.defaultCacheConfig().entryExpiry(Duration.ofMinutes(1))); } - // end::code[] } +// end::code[] diff --git a/spring-boot-project/spring-boot-docs/src/main/java/org/springframework/boot/docs/springbootfeatures/nosql/Neo4jReactiveTransactionManagerExample.java b/spring-boot-project/spring-boot-docs/src/main/java/org/springframework/boot/docs/springbootfeatures/nosql/Neo4jReactiveTransactionManagerConfiguration.java similarity index 82% rename from spring-boot-project/spring-boot-docs/src/main/java/org/springframework/boot/docs/springbootfeatures/nosql/Neo4jReactiveTransactionManagerExample.java rename to spring-boot-project/spring-boot-docs/src/main/java/org/springframework/boot/docs/springbootfeatures/nosql/Neo4jReactiveTransactionManagerConfiguration.java index 24398a43f074..34ef8f4f5ed8 100644 --- a/spring-boot-project/spring-boot-docs/src/main/java/org/springframework/boot/docs/springbootfeatures/nosql/Neo4jReactiveTransactionManagerExample.java +++ b/spring-boot-project/spring-boot-docs/src/main/java/org/springframework/boot/docs/springbootfeatures/nosql/Neo4jReactiveTransactionManagerConfiguration.java @@ -16,28 +16,22 @@ package org.springframework.boot.docs.springbootfeatures.nosql; +// tag::code[] import org.neo4j.driver.Driver; import org.springframework.context.annotation.Bean; import org.springframework.context.annotation.Configuration; import org.springframework.data.neo4j.core.ReactiveDatabaseSelectionProvider; import org.springframework.data.neo4j.core.transaction.ReactiveNeo4jTransactionManager; -import org.springframework.transaction.ReactiveTransactionManager; -/** - * Example to show user-defined registration of a {@link ReactiveTransactionManager}. - * - * @author Stephane Nicoll - */ @Configuration(proxyBeanMethods = false) -public class Neo4jReactiveTransactionManagerExample { +public class Neo4jReactiveTransactionManagerConfiguration { - // tag::code[] @Bean public ReactiveNeo4jTransactionManager reactiveTransactionManager(Driver driver, ReactiveDatabaseSelectionProvider databaseNameProvider) { return new ReactiveNeo4jTransactionManager(driver, databaseNameProvider); } - // end::code[] } +// end::code[] diff --git a/spring-boot-project/spring-boot-docs/src/main/java/org/springframework/boot/docs/springbootfeatures/nosql/RedisCacheManagerCustomizationExample.java b/spring-boot-project/spring-boot-docs/src/main/java/org/springframework/boot/docs/springbootfeatures/nosql/RedisCacheManagerConfiguration.java similarity index 85% rename from spring-boot-project/spring-boot-docs/src/main/java/org/springframework/boot/docs/springbootfeatures/nosql/RedisCacheManagerCustomizationExample.java rename to spring-boot-project/spring-boot-docs/src/main/java/org/springframework/boot/docs/springbootfeatures/nosql/RedisCacheManagerConfiguration.java index fef562a29d0d..d3b0b9780426 100644 --- a/spring-boot-project/spring-boot-docs/src/main/java/org/springframework/boot/docs/springbootfeatures/nosql/RedisCacheManagerCustomizationExample.java +++ b/spring-boot-project/spring-boot-docs/src/main/java/org/springframework/boot/docs/springbootfeatures/nosql/RedisCacheManagerConfiguration.java @@ -16,6 +16,7 @@ package org.springframework.boot.docs.springbootfeatures.nosql; +// tag::code[] import java.time.Duration; import org.springframework.boot.autoconfigure.cache.RedisCacheManagerBuilderCustomizer; @@ -23,16 +24,9 @@ import org.springframework.context.annotation.Configuration; import org.springframework.data.redis.cache.RedisCacheConfiguration; -/** - * An example how to customize {@code RedisCacheManagerBuilder} via - * {@code RedisCacheManagerBuilderCustomizer}. - * - * @author Dmytro Nosan - */ @Configuration(proxyBeanMethods = false) -public class RedisCacheManagerCustomizationExample { +public class RedisCacheManagerConfiguration { - // tag::code[] @Bean public RedisCacheManagerBuilderCustomizer myRedisCacheManagerBuilderCustomizer() { return (builder) -> builder @@ -42,6 +36,6 @@ public RedisCacheManagerBuilderCustomizer myRedisCacheManagerBuilderCustomizer() RedisCacheConfiguration.defaultCacheConfig().entryTtl(Duration.ofMinutes(1))); } - // end::code[] } +// end::code[] diff --git a/spring-boot-project/spring-boot-docs/src/main/java/org/springframework/boot/docs/springbootfeatures/resttemplate/RestTemplateBuilderCustomizationExample.java b/spring-boot-project/spring-boot-docs/src/main/java/org/springframework/boot/docs/springbootfeatures/resttemplate/RestTemplateBuilderConfiguration.java similarity index 83% rename from spring-boot-project/spring-boot-docs/src/main/java/org/springframework/boot/docs/springbootfeatures/resttemplate/RestTemplateBuilderCustomizationExample.java rename to spring-boot-project/spring-boot-docs/src/main/java/org/springframework/boot/docs/springbootfeatures/resttemplate/RestTemplateBuilderConfiguration.java index 41f641abee30..7ad9628e7f7b 100644 --- a/spring-boot-project/spring-boot-docs/src/main/java/org/springframework/boot/docs/springbootfeatures/resttemplate/RestTemplateBuilderCustomizationExample.java +++ b/spring-boot-project/spring-boot-docs/src/main/java/org/springframework/boot/docs/springbootfeatures/resttemplate/RestTemplateBuilderConfiguration.java @@ -16,6 +16,7 @@ package org.springframework.boot.docs.springbootfeatures.resttemplate; +// tag::code[] import java.time.Duration; import org.springframework.boot.autoconfigure.web.client.RestTemplateBuilderConfigurer; @@ -23,21 +24,14 @@ import org.springframework.context.annotation.Bean; import org.springframework.context.annotation.Configuration; -/** - * Example configuration for using a {@link RestTemplateBuilderConfigurer} to configure a - * custom {@link RestTemplateBuilder}. - * - * @author Stephane Nicoll - */ @Configuration(proxyBeanMethods = false) -public class RestTemplateBuilderCustomizationExample { +public class RestTemplateBuilderConfiguration { - // tag::code[] @Bean public RestTemplateBuilder restTemplateBuilder(RestTemplateBuilderConfigurer configurer) { return configurer.configure(new RestTemplateBuilder()).setConnectTimeout(Duration.ofSeconds(5)) .setReadTimeout(Duration.ofSeconds(2)); } - // end::code[] } +// end::code[] diff --git a/spring-boot-project/spring-boot-docs/src/main/java/org/springframework/boot/docs/springbootfeatures/resttemplate/RestTemplateProxyCustomizationExample.java b/spring-boot-project/spring-boot-docs/src/main/java/org/springframework/boot/docs/springbootfeatures/resttemplate/RestTemplateProxyCustomizer.java similarity index 54% rename from spring-boot-project/spring-boot-docs/src/main/java/org/springframework/boot/docs/springbootfeatures/resttemplate/RestTemplateProxyCustomizationExample.java rename to spring-boot-project/spring-boot-docs/src/main/java/org/springframework/boot/docs/springbootfeatures/resttemplate/RestTemplateProxyCustomizer.java index 4fb1170fd2bf..37a06cb232a2 100644 --- a/spring-boot-project/spring-boot-docs/src/main/java/org/springframework/boot/docs/springbootfeatures/resttemplate/RestTemplateProxyCustomizationExample.java +++ b/spring-boot-project/spring-boot-docs/src/main/java/org/springframework/boot/docs/springbootfeatures/resttemplate/RestTemplateProxyCustomizer.java @@ -16,10 +16,12 @@ package org.springframework.boot.docs.springbootfeatures.resttemplate; +// tag::code[] import org.apache.http.HttpException; import org.apache.http.HttpHost; import org.apache.http.HttpRequest; import org.apache.http.client.HttpClient; +import org.apache.http.conn.routing.HttpRoutePlanner; import org.apache.http.impl.client.HttpClientBuilder; import org.apache.http.impl.conn.DefaultProxyRoutePlanner; import org.apache.http.protocol.HttpContext; @@ -28,39 +30,30 @@ import org.springframework.http.client.HttpComponentsClientHttpRequestFactory; import org.springframework.web.client.RestTemplate; -/** - * Example configuration for using a {@link RestTemplateCustomizer} to configure a proxy. - * - * @author Andy Wilkinson - */ -public class RestTemplateProxyCustomizationExample { +public class RestTemplateProxyCustomizer implements RestTemplateCustomizer { - /** - * A {@link RestTemplateCustomizer} that applies an HttpComponents-based request - * factory that is configured to use a proxy. - */ - // tag::code[] - static class ProxyCustomizer implements RestTemplateCustomizer { + @Override + public void customize(RestTemplate restTemplate) { + HttpRoutePlanner routePlanner = new CustomRoutePlanner(new HttpHost("proxy.example.com")); + HttpClient httpClient = HttpClientBuilder.create().setRoutePlanner(routePlanner).build(); + restTemplate.setRequestFactory(new HttpComponentsClientHttpRequestFactory(httpClient)); + } - @Override - public void customize(RestTemplate restTemplate) { - HttpHost proxy = new HttpHost("proxy.example.com"); - HttpClient httpClient = HttpClientBuilder.create().setRoutePlanner(new DefaultProxyRoutePlanner(proxy) { + static class CustomRoutePlanner extends DefaultProxyRoutePlanner { - @Override - public HttpHost determineProxy(HttpHost target, HttpRequest request, HttpContext context) - throws HttpException { - if (target.getHostName().equals("192.168.0.5")) { - return null; - } - return super.determineProxy(target, request, context); - } + CustomRoutePlanner(HttpHost proxy) { + super(proxy); + } - }).build(); - restTemplate.setRequestFactory(new HttpComponentsClientHttpRequestFactory(httpClient)); + @Override + public HttpHost determineProxy(HttpHost target, HttpRequest request, HttpContext context) throws HttpException { + if (target.getHostName().equals("192.168.0.5")) { + return null; + } + return super.determineProxy(target, request, context); } } - // end::code[] } +// end::code[] diff --git a/spring-boot-project/spring-boot-docs/src/main/java/org/springframework/boot/docs/springbootfeatures/security/CustomWebFluxSecurityExample.java b/spring-boot-project/spring-boot-docs/src/main/java/org/springframework/boot/docs/springbootfeatures/security/CustomWebFluxSecurityConfiguration.java similarity index 72% rename from spring-boot-project/spring-boot-docs/src/main/java/org/springframework/boot/docs/springbootfeatures/security/CustomWebFluxSecurityExample.java rename to spring-boot-project/spring-boot-docs/src/main/java/org/springframework/boot/docs/springbootfeatures/security/CustomWebFluxSecurityConfiguration.java index e82d72250a50..219e8feb9007 100644 --- a/spring-boot-project/spring-boot-docs/src/main/java/org/springframework/boot/docs/springbootfeatures/security/CustomWebFluxSecurityExample.java +++ b/spring-boot-project/spring-boot-docs/src/main/java/org/springframework/boot/docs/springbootfeatures/security/CustomWebFluxSecurityConfiguration.java @@ -16,33 +16,25 @@ package org.springframework.boot.docs.springbootfeatures.security; +// tag::code[] import org.springframework.boot.autoconfigure.security.reactive.PathRequest; import org.springframework.context.annotation.Bean; import org.springframework.context.annotation.Configuration; import org.springframework.security.config.web.server.ServerHttpSecurity; import org.springframework.security.web.server.SecurityWebFilterChain; -/** - * Example configuration for customizing security rules for a WebFlux application. - * - * @author Madhura Bhave - */ @Configuration(proxyBeanMethods = false) -public class CustomWebFluxSecurityExample { +public class CustomWebFluxSecurityConfiguration { - // @formatter:off - // tag::code[] @Bean public SecurityWebFilterChain springSecurityFilterChain(ServerHttpSecurity http) { - return http - .authorizeExchange() - .matchers(PathRequest.toStaticResources().atCommonLocations()).permitAll() - .pathMatchers("/foo", "/bar") - .authenticated().and() - .formLogin().and() - .build(); + http.authorizeExchange((spec) -> { + spec.matchers(PathRequest.toStaticResources().atCommonLocations()).permitAll(); + spec.pathMatchers("/foo", "/bar").authenticated(); + }); + http.formLogin(); + return http.build(); } - // end::code[] - // @formatter:on } +// end::code[] diff --git a/spring-boot-project/spring-boot-docs/src/main/java/org/springframework/boot/docs/springbootfeatures/springapplication/ExitCodeExample.java b/spring-boot-project/spring-boot-docs/src/main/java/org/springframework/boot/docs/springbootfeatures/springapplication/ExitCodeExample.java index 43c81fd2ecb7..ea8514b38fc1 100644 --- a/spring-boot-project/spring-boot-docs/src/main/java/org/springframework/boot/docs/springbootfeatures/springapplication/ExitCodeExample.java +++ b/spring-boot-project/spring-boot-docs/src/main/java/org/springframework/boot/docs/springbootfeatures/springapplication/ExitCodeExample.java @@ -16,17 +16,12 @@ package org.springframework.boot.docs.springbootfeatures.springapplication; +// tag::code[] import org.springframework.boot.ExitCodeGenerator; import org.springframework.boot.SpringApplication; import org.springframework.boot.autoconfigure.SpringBootApplication; import org.springframework.context.annotation.Bean; -/** - * Example configuration that illustrates the use of {@link ExitCodeGenerator}. - * - * @author Stephane Nicoll - */ -// tag::code[] @SpringBootApplication public class ExitCodeExample { diff --git a/spring-boot-project/spring-boot-docs/src/main/java/org/springframework/boot/docs/springbootfeatures/springapplication/SpringApplicationBuilderExample.java b/spring-boot-project/spring-boot-docs/src/main/java/org/springframework/boot/docs/springbootfeatures/springapplication/SpringApplicationBuilderExample.java index 9d2225a99656..84220a91446f 100644 --- a/spring-boot-project/spring-boot-docs/src/main/java/org/springframework/boot/docs/springbootfeatures/springapplication/SpringApplicationBuilderExample.java +++ b/spring-boot-project/spring-boot-docs/src/main/java/org/springframework/boot/docs/springbootfeatures/springapplication/SpringApplicationBuilderExample.java @@ -19,11 +19,6 @@ import org.springframework.boot.Banner; import org.springframework.boot.builder.SpringApplicationBuilder; -/** - * Examples of using {@link SpringApplicationBuilder}. - * - * @author Andy Wilkinson - */ public class SpringApplicationBuilderExample { public void hierarchyWithDisabledBanner(String[] args) { @@ -38,16 +33,10 @@ public void hierarchyWithDisabledBanner(String[] args) { // @formatter:on } - /** - * Parent application configuration. - */ static class Parent { } - /** - * Application configuration. - */ static class Application { } diff --git a/spring-boot-project/spring-boot-docs/src/main/java/org/springframework/boot/docs/springbootfeatures/testing/ApplicationArgumentsExampleTests.java b/spring-boot-project/spring-boot-docs/src/main/java/org/springframework/boot/docs/springbootfeatures/testing/ApplicationArgumentTests.java similarity index 96% rename from spring-boot-project/spring-boot-docs/src/main/java/org/springframework/boot/docs/springbootfeatures/testing/ApplicationArgumentsExampleTests.java rename to spring-boot-project/spring-boot-docs/src/main/java/org/springframework/boot/docs/springbootfeatures/testing/ApplicationArgumentTests.java index 5e309044c8d4..620cbad89ec0 100644 --- a/spring-boot-project/spring-boot-docs/src/main/java/org/springframework/boot/docs/springbootfeatures/testing/ApplicationArgumentsExampleTests.java +++ b/spring-boot-project/spring-boot-docs/src/main/java/org/springframework/boot/docs/springbootfeatures/testing/ApplicationArgumentTests.java @@ -16,6 +16,7 @@ package org.springframework.boot.docs.springbootfeatures.testing; +// tag::code[] import org.junit.jupiter.api.Test; import org.springframework.beans.factory.annotation.Autowired; @@ -24,9 +25,8 @@ import static org.assertj.core.api.Assertions.assertThat; -// tag::code[] @SpringBootTest(args = "--app.test=one") -class ApplicationArgumentsExampleTests { +class ApplicationArgumentTests { @Test void applicationArgumentsPopulated(@Autowired ApplicationArguments args) { diff --git a/spring-boot-project/spring-boot-docs/src/main/java/org/springframework/boot/docs/springbootfeatures/testing/MockMvcExampleTests.java b/spring-boot-project/spring-boot-docs/src/main/java/org/springframework/boot/docs/springbootfeatures/testing/MockMvcTests.java similarity index 98% rename from spring-boot-project/spring-boot-docs/src/main/java/org/springframework/boot/docs/springbootfeatures/testing/MockMvcExampleTests.java rename to spring-boot-project/spring-boot-docs/src/main/java/org/springframework/boot/docs/springbootfeatures/testing/MockMvcTests.java index a660a8d3d1ee..513a85336d7c 100644 --- a/spring-boot-project/spring-boot-docs/src/main/java/org/springframework/boot/docs/springbootfeatures/testing/MockMvcExampleTests.java +++ b/spring-boot-project/spring-boot-docs/src/main/java/org/springframework/boot/docs/springbootfeatures/testing/MockMvcTests.java @@ -17,7 +17,6 @@ package org.springframework.boot.docs.springbootfeatures.testing; // tag::code[] - import org.junit.jupiter.api.Test; import org.springframework.beans.factory.annotation.Autowired; @@ -31,7 +30,7 @@ @SpringBootTest @AutoConfigureMockMvc -class MockMvcExampleTests { +class MockMvcTests { @Test void exampleTest(@Autowired MockMvc mvc) throws Exception { diff --git a/spring-boot-project/spring-boot-docs/src/main/java/org/springframework/boot/docs/springbootfeatures/testing/MockWebTestClientExampleTests.java b/spring-boot-project/spring-boot-docs/src/main/java/org/springframework/boot/docs/springbootfeatures/testing/MockWebTestClientTests.java similarity index 97% rename from spring-boot-project/spring-boot-docs/src/main/java/org/springframework/boot/docs/springbootfeatures/testing/MockWebTestClientExampleTests.java rename to spring-boot-project/spring-boot-docs/src/main/java/org/springframework/boot/docs/springbootfeatures/testing/MockWebTestClientTests.java index f747b1b144c5..4a1ae58c0fb5 100644 --- a/spring-boot-project/spring-boot-docs/src/main/java/org/springframework/boot/docs/springbootfeatures/testing/MockWebTestClientExampleTests.java +++ b/spring-boot-project/spring-boot-docs/src/main/java/org/springframework/boot/docs/springbootfeatures/testing/MockWebTestClientTests.java @@ -17,7 +17,6 @@ package org.springframework.boot.docs.springbootfeatures.testing; // tag::code[] - import org.junit.jupiter.api.Test; import org.springframework.beans.factory.annotation.Autowired; @@ -27,7 +26,7 @@ @SpringBootTest @AutoConfigureWebTestClient -class MockWebTestClientExampleTests { +class MockWebTestClientTests { @Test void exampleTest(@Autowired WebTestClient webClient) { diff --git a/spring-boot-project/spring-boot-docs/src/main/java/org/springframework/boot/docs/springbootfeatures/testing/OutputCaptureTests.java b/spring-boot-project/spring-boot-docs/src/main/java/org/springframework/boot/docs/springbootfeatures/testing/OutputCaptureTests.java index 8be3578e25ac..bd5989d9a4ed 100644 --- a/spring-boot-project/spring-boot-docs/src/main/java/org/springframework/boot/docs/springbootfeatures/testing/OutputCaptureTests.java +++ b/spring-boot-project/spring-boot-docs/src/main/java/org/springframework/boot/docs/springbootfeatures/testing/OutputCaptureTests.java @@ -16,6 +16,7 @@ package org.springframework.boot.docs.springbootfeatures.testing; +// tag::code[] import org.junit.jupiter.api.Test; import org.junit.jupiter.api.extension.ExtendWith; @@ -24,12 +25,6 @@ import static org.assertj.core.api.Assertions.assertThat; -/** - * Sample showcasing the use of {@link CapturedOutput}. - * - * @author Stephane Nicoll - */ -// tag::code[] @ExtendWith(OutputCaptureExtension.class) class OutputCaptureTests { diff --git a/spring-boot-project/spring-boot-docs/src/main/java/org/springframework/boot/docs/springbootfeatures/testing/RandomPortTestRestTemplateExampleTests.java b/spring-boot-project/spring-boot-docs/src/main/java/org/springframework/boot/docs/springbootfeatures/testing/RandomPortTestRestTemplateTests.java similarity index 96% rename from spring-boot-project/spring-boot-docs/src/main/java/org/springframework/boot/docs/springbootfeatures/testing/RandomPortTestRestTemplateExampleTests.java rename to spring-boot-project/spring-boot-docs/src/main/java/org/springframework/boot/docs/springbootfeatures/testing/RandomPortTestRestTemplateTests.java index 4eec421c8796..3ba15b7e1d35 100644 --- a/spring-boot-project/spring-boot-docs/src/main/java/org/springframework/boot/docs/springbootfeatures/testing/RandomPortTestRestTemplateExampleTests.java +++ b/spring-boot-project/spring-boot-docs/src/main/java/org/springframework/boot/docs/springbootfeatures/testing/RandomPortTestRestTemplateTests.java @@ -17,7 +17,6 @@ package org.springframework.boot.docs.springbootfeatures.testing; // tag::code[] - import org.junit.jupiter.api.Test; import org.springframework.beans.factory.annotation.Autowired; @@ -28,7 +27,7 @@ import static org.assertj.core.api.Assertions.assertThat; @SpringBootTest(webEnvironment = WebEnvironment.RANDOM_PORT) -class RandomPortTestRestTemplateExampleTests { +class RandomPortTestRestTemplateTests { @Test void exampleTest(@Autowired TestRestTemplate restTemplate) { diff --git a/spring-boot-project/spring-boot-docs/src/main/java/org/springframework/boot/docs/springbootfeatures/testing/RandomPortWebTestClientExampleTests.java b/spring-boot-project/spring-boot-docs/src/main/java/org/springframework/boot/docs/springbootfeatures/testing/RandomPortWebTestClientTests.java similarity index 96% rename from spring-boot-project/spring-boot-docs/src/main/java/org/springframework/boot/docs/springbootfeatures/testing/RandomPortWebTestClientExampleTests.java rename to spring-boot-project/spring-boot-docs/src/main/java/org/springframework/boot/docs/springbootfeatures/testing/RandomPortWebTestClientTests.java index 727483248972..60ff61d2efd5 100644 --- a/spring-boot-project/spring-boot-docs/src/main/java/org/springframework/boot/docs/springbootfeatures/testing/RandomPortWebTestClientExampleTests.java +++ b/spring-boot-project/spring-boot-docs/src/main/java/org/springframework/boot/docs/springbootfeatures/testing/RandomPortWebTestClientTests.java @@ -17,7 +17,6 @@ package org.springframework.boot.docs.springbootfeatures.testing; // tag::code[] - import org.junit.jupiter.api.Test; import org.springframework.beans.factory.annotation.Autowired; @@ -26,7 +25,7 @@ import org.springframework.test.web.reactive.server.WebTestClient; @SpringBootTest(webEnvironment = WebEnvironment.RANDOM_PORT) -class RandomPortWebTestClientExampleTests { +class RandomPortWebTestClientTests { @Test void exampleTest(@Autowired WebTestClient webClient) { diff --git a/spring-boot-project/spring-boot-docs/src/main/java/org/springframework/boot/docs/springbootfeatures/creatingautoconfiguration/UserService.java b/spring-boot-project/spring-boot-docs/src/main/java/org/springframework/boot/docs/springbootfeatures/testing/UserService.java similarity index 84% rename from spring-boot-project/spring-boot-docs/src/main/java/org/springframework/boot/docs/springbootfeatures/creatingautoconfiguration/UserService.java rename to spring-boot-project/spring-boot-docs/src/main/java/org/springframework/boot/docs/springbootfeatures/testing/UserService.java index 028fe37b5f08..edc4e8363c20 100644 --- a/spring-boot-project/spring-boot-docs/src/main/java/org/springframework/boot/docs/springbootfeatures/creatingautoconfiguration/UserService.java +++ b/spring-boot-project/spring-boot-docs/src/main/java/org/springframework/boot/docs/springbootfeatures/testing/UserService.java @@ -14,13 +14,8 @@ * limitations under the License. */ -package org.springframework.boot.docs.springbootfeatures.creatingautoconfiguration; +package org.springframework.boot.docs.springbootfeatures.testing; -/** - * Sample service. - * - * @author Stephane Nicoll - */ public class UserService { private final String name; diff --git a/spring-boot-project/spring-boot-docs/src/main/java/org/springframework/boot/docs/springbootfeatures/creatingautoconfiguration/UserServiceAutoConfiguration.java b/spring-boot-project/spring-boot-docs/src/main/java/org/springframework/boot/docs/springbootfeatures/testing/UserServiceAutoConfiguration.java similarity index 85% rename from spring-boot-project/spring-boot-docs/src/main/java/org/springframework/boot/docs/springbootfeatures/creatingautoconfiguration/UserServiceAutoConfiguration.java rename to spring-boot-project/spring-boot-docs/src/main/java/org/springframework/boot/docs/springbootfeatures/testing/UserServiceAutoConfiguration.java index 6b902d778bc7..e84412028481 100644 --- a/spring-boot-project/spring-boot-docs/src/main/java/org/springframework/boot/docs/springbootfeatures/creatingautoconfiguration/UserServiceAutoConfiguration.java +++ b/spring-boot-project/spring-boot-docs/src/main/java/org/springframework/boot/docs/springbootfeatures/testing/UserServiceAutoConfiguration.java @@ -14,21 +14,16 @@ * limitations under the License. */ -package org.springframework.boot.docs.springbootfeatures.creatingautoconfiguration; +package org.springframework.boot.docs.springbootfeatures.testing; import org.springframework.boot.autoconfigure.condition.ConditionalOnClass; import org.springframework.boot.autoconfigure.condition.ConditionalOnMissingBean; import org.springframework.boot.context.properties.ConfigurationProperties; import org.springframework.boot.context.properties.EnableConfigurationProperties; -import org.springframework.boot.docs.springbootfeatures.creatingautoconfiguration.UserServiceAutoConfiguration.UserProperties; +import org.springframework.boot.docs.springbootfeatures.testing.UserServiceAutoConfiguration.UserProperties; import org.springframework.context.annotation.Bean; import org.springframework.context.annotation.Configuration; -/** - * Sample auto-configuration. - * - * @author Stephane Nicoll - */ @Configuration(proxyBeanMethods = false) @ConditionalOnClass(UserService.class) @EnableConfigurationProperties(UserProperties.class) diff --git a/spring-boot-project/spring-boot-docs/src/main/java/org/springframework/boot/docs/springbootfeatures/testing/UserServiceAutoConfigurationTests.java b/spring-boot-project/spring-boot-docs/src/main/java/org/springframework/boot/docs/springbootfeatures/testing/UserServiceAutoConfigurationTests.java index 1ab6c8903a82..3250a45467c0 100644 --- a/spring-boot-project/spring-boot-docs/src/main/java/org/springframework/boot/docs/springbootfeatures/testing/UserServiceAutoConfigurationTests.java +++ b/spring-boot-project/spring-boot-docs/src/main/java/org/springframework/boot/docs/springbootfeatures/testing/UserServiceAutoConfigurationTests.java @@ -19,8 +19,6 @@ import org.junit.jupiter.api.Test; import org.springframework.boot.autoconfigure.AutoConfigurations; -import org.springframework.boot.docs.springbootfeatures.creatingautoconfiguration.UserService; -import org.springframework.boot.docs.springbootfeatures.creatingautoconfiguration.UserServiceAutoConfiguration; import org.springframework.boot.test.context.FilteredClassLoader; import org.springframework.boot.test.context.runner.ApplicationContextRunner; import org.springframework.context.annotation.Bean; @@ -28,11 +26,6 @@ import static org.assertj.core.api.Assertions.assertThat; -/** - * Tests for {@link UserServiceAutoConfiguration}. - * - * @author Stephane Nicoll - */ class UserServiceAutoConfigurationTests { // tag::runner[] diff --git a/spring-boot-project/spring-boot-docs/src/main/java/org/springframework/boot/docs/springbootfeatures/testing/jmx/SampleApp.java b/spring-boot-project/spring-boot-docs/src/main/java/org/springframework/boot/docs/springbootfeatures/testing/jmx/SampleApp.java index 71efc7caabf7..0edc242b2f01 100644 --- a/spring-boot-project/spring-boot-docs/src/main/java/org/springframework/boot/docs/springbootfeatures/testing/jmx/SampleApp.java +++ b/spring-boot-project/spring-boot-docs/src/main/java/org/springframework/boot/docs/springbootfeatures/testing/jmx/SampleApp.java @@ -20,12 +20,6 @@ import org.springframework.boot.autoconfigure.ImportAutoConfiguration; import org.springframework.boot.autoconfigure.jmx.JmxAutoConfiguration; -/** - * A sample {@link SpringBootConfiguration @ConfigurationProperties} that only enables JMX - * auto-configuration. - * - * @author Stephane Nicoll - */ @SpringBootConfiguration @ImportAutoConfiguration(JmxAutoConfiguration.class) public class SampleApp { diff --git a/spring-boot-project/spring-boot-docs/src/main/java/org/springframework/boot/docs/springbootfeatures/testing/jmx/SampleJmxTests.java b/spring-boot-project/spring-boot-docs/src/main/java/org/springframework/boot/docs/springbootfeatures/testing/jmx/SampleJmxTests.java index eefe5b29a606..74e695e3973c 100644 --- a/spring-boot-project/spring-boot-docs/src/main/java/org/springframework/boot/docs/springbootfeatures/testing/jmx/SampleJmxTests.java +++ b/spring-boot-project/spring-boot-docs/src/main/java/org/springframework/boot/docs/springbootfeatures/testing/jmx/SampleJmxTests.java @@ -16,7 +16,9 @@ package org.springframework.boot.docs.springbootfeatures.testing.jmx; +// tag::code[] import javax.management.MBeanServer; +import javax.management.MalformedObjectNameException; import org.junit.jupiter.api.Test; import org.junit.jupiter.api.extension.ExtendWith; @@ -26,13 +28,8 @@ import org.springframework.test.annotation.DirtiesContext; import org.springframework.test.context.junit.jupiter.SpringExtension; -/** - * Example integration test that uses JMX. - * - * @author Stephane Nicoll - */ -@SuppressWarnings("unused") -// tag::code[] +import static org.assertj.core.api.Assertions.assertThat; + @ExtendWith(SpringExtension.class) @SpringBootTest(properties = "spring.jmx.enabled=true") @DirtiesContext @@ -42,7 +39,8 @@ class SampleJmxTests { private MBeanServer mBeanServer; @Test - void exampleTest() { + void exampleTest() throws MalformedObjectNameException { + assertThat(this.mBeanServer.getDomains()).contains("java.lang"); // ... } diff --git a/spring-boot-project/spring-boot-docs/src/main/java/org/springframework/boot/docs/springbootfeatures/testing/restdocs/restassured/AdvancedConfigurationExample.java b/spring-boot-project/spring-boot-docs/src/main/java/org/springframework/boot/docs/springbootfeatures/testing/restdocs/restassured/AdvancedRestDocsConfiguration.java similarity index 72% rename from spring-boot-project/spring-boot-docs/src/main/java/org/springframework/boot/docs/springbootfeatures/testing/restdocs/restassured/AdvancedConfigurationExample.java rename to spring-boot-project/spring-boot-docs/src/main/java/org/springframework/boot/docs/springbootfeatures/testing/restdocs/restassured/AdvancedRestDocsConfiguration.java index f1ffafff006e..11bd10590671 100644 --- a/spring-boot-project/spring-boot-docs/src/main/java/org/springframework/boot/docs/springbootfeatures/testing/restdocs/restassured/AdvancedConfigurationExample.java +++ b/spring-boot-project/spring-boot-docs/src/main/java/org/springframework/boot/docs/springbootfeatures/testing/restdocs/restassured/AdvancedRestDocsConfiguration.java @@ -16,23 +16,19 @@ package org.springframework.boot.docs.springbootfeatures.testing.restdocs.restassured; +// tag::code[] import org.springframework.boot.test.autoconfigure.restdocs.RestDocsRestAssuredConfigurationCustomizer; import org.springframework.boot.test.context.TestConfiguration; import org.springframework.restdocs.restassured3.RestAssuredRestDocumentationConfigurer; import org.springframework.restdocs.templates.TemplateFormats; -public class AdvancedConfigurationExample { - - // tag::code[] - @TestConfiguration(proxyBeanMethods = false) - public static class CustomizationConfiguration implements RestDocsRestAssuredConfigurationCustomizer { - - @Override - public void customize(RestAssuredRestDocumentationConfigurer configurer) { - configurer.snippets().withTemplateFormat(TemplateFormats.markdown()); - } +@TestConfiguration(proxyBeanMethods = false) +public class AdvancedRestDocsConfiguration implements RestDocsRestAssuredConfigurationCustomizer { + @Override + public void customize(RestAssuredRestDocumentationConfigurer configurer) { + configurer.snippets().withTemplateFormat(TemplateFormats.markdown()); } - // end::code[] } +// end::code[] diff --git a/spring-boot-project/spring-boot-docs/src/main/java/org/springframework/boot/docs/springbootfeatures/testing/restdocs/webclient/AdvancedConfigurationExample.java b/spring-boot-project/spring-boot-docs/src/main/java/org/springframework/boot/docs/springbootfeatures/testing/restdocs/webclient/AdvancedRestDocsConfiguration.java similarity index 72% rename from spring-boot-project/spring-boot-docs/src/main/java/org/springframework/boot/docs/springbootfeatures/testing/restdocs/webclient/AdvancedConfigurationExample.java rename to spring-boot-project/spring-boot-docs/src/main/java/org/springframework/boot/docs/springbootfeatures/testing/restdocs/webclient/AdvancedRestDocsConfiguration.java index bd38c93b3313..16ca58f24673 100644 --- a/spring-boot-project/spring-boot-docs/src/main/java/org/springframework/boot/docs/springbootfeatures/testing/restdocs/webclient/AdvancedConfigurationExample.java +++ b/spring-boot-project/spring-boot-docs/src/main/java/org/springframework/boot/docs/springbootfeatures/testing/restdocs/webclient/AdvancedRestDocsConfiguration.java @@ -16,22 +16,18 @@ package org.springframework.boot.docs.springbootfeatures.testing.restdocs.webclient; +// tag::code[] import org.springframework.boot.test.autoconfigure.restdocs.RestDocsWebTestClientConfigurationCustomizer; import org.springframework.boot.test.context.TestConfiguration; import org.springframework.restdocs.webtestclient.WebTestClientRestDocumentationConfigurer; -public class AdvancedConfigurationExample { - - // tag::code[] - @TestConfiguration(proxyBeanMethods = false) - public static class CustomizationConfiguration implements RestDocsWebTestClientConfigurationCustomizer { - - @Override - public void customize(WebTestClientRestDocumentationConfigurer configurer) { - configurer.snippets().withEncoding("UTF-8"); - } +@TestConfiguration(proxyBeanMethods = false) +public class AdvancedRestDocsConfiguration implements RestDocsWebTestClientConfigurationCustomizer { + @Override + public void customize(WebTestClientRestDocumentationConfigurer configurer) { + configurer.snippets().withEncoding("UTF-8"); } - // end::code[] } +// end::code[] diff --git a/spring-boot-project/spring-boot-docs/src/main/java/org/springframework/boot/docs/springbootfeatures/testing/webclient/SampleWebClientConfiguration.java b/spring-boot-project/spring-boot-docs/src/main/java/org/springframework/boot/docs/springbootfeatures/testing/webclient/SampleWebClientConfiguration.java index f242cb2a7686..099f5ae35095 100644 --- a/spring-boot-project/spring-boot-docs/src/main/java/org/springframework/boot/docs/springbootfeatures/testing/webclient/SampleWebClientConfiguration.java +++ b/spring-boot-project/spring-boot-docs/src/main/java/org/springframework/boot/docs/springbootfeatures/testing/webclient/SampleWebClientConfiguration.java @@ -28,12 +28,6 @@ import org.springframework.web.bind.annotation.RequestMapping; import org.springframework.web.bind.annotation.RestController; -/** - * A sample {@link SpringBootConfiguration @ConfigurationProperties} with an example - * controller. - * - * @author Stephane Nicoll - */ @SpringBootConfiguration @ImportAutoConfiguration({ ServletWebServerFactoryAutoConfiguration.class, DispatcherServletAutoConfiguration.class, JacksonAutoConfiguration.class, HttpMessageConvertersAutoConfiguration.class }) diff --git a/spring-boot-project/spring-boot-docs/src/main/java/org/springframework/boot/docs/springbootfeatures/testing/webclient/SampleWebClientTests.java b/spring-boot-project/spring-boot-docs/src/main/java/org/springframework/boot/docs/springbootfeatures/testing/webclient/SampleWebClientTests.java index bdbbb339fbbe..d5535f4cf036 100644 --- a/spring-boot-project/spring-boot-docs/src/main/java/org/springframework/boot/docs/springbootfeatures/testing/webclient/SampleWebClientTests.java +++ b/spring-boot-project/spring-boot-docs/src/main/java/org/springframework/boot/docs/springbootfeatures/testing/webclient/SampleWebClientTests.java @@ -16,6 +16,7 @@ package org.springframework.boot.docs.springbootfeatures.testing.webclient; +// tag::code[] import java.time.Duration; import org.junit.jupiter.api.Test; @@ -31,12 +32,6 @@ import static org.assertj.core.api.Assertions.assertThat; -/** - * Example integration test that uses {@link TestRestTemplate}. - * - * @author Stephane Nicoll - */ -// tag::code[] @SpringBootTest(webEnvironment = WebEnvironment.RANDOM_PORT) class SampleWebClientTests { @@ -50,7 +45,7 @@ void testRequest() { } @TestConfiguration(proxyBeanMethods = false) - static class Config { + static class RestTemplateBuilderConfiguration { @Bean RestTemplateBuilder restTemplateBuilder() { diff --git a/spring-boot-project/spring-boot-docs/src/main/java/org/springframework/boot/docs/springbootfeatures/webapplications/TomcatServerCustomizerExample.java b/spring-boot-project/spring-boot-docs/src/main/java/org/springframework/boot/docs/springbootfeatures/webapplications/TomcatServerCustomizer.java similarity index 73% rename from spring-boot-project/spring-boot-docs/src/main/java/org/springframework/boot/docs/springbootfeatures/webapplications/TomcatServerCustomizerExample.java rename to spring-boot-project/spring-boot-docs/src/main/java/org/springframework/boot/docs/springbootfeatures/webapplications/TomcatServerCustomizer.java index cab19252e762..49cbd9a0fb12 100644 --- a/spring-boot-project/spring-boot-docs/src/main/java/org/springframework/boot/docs/springbootfeatures/webapplications/TomcatServerCustomizerExample.java +++ b/spring-boot-project/spring-boot-docs/src/main/java/org/springframework/boot/docs/springbootfeatures/webapplications/TomcatServerCustomizer.java @@ -16,25 +16,19 @@ package org.springframework.boot.docs.springbootfeatures.webapplications; +// tag::code[] import java.time.Duration; import org.springframework.boot.web.embedded.tomcat.TomcatServletWebServerFactory; import org.springframework.boot.web.server.WebServerFactoryCustomizer; import org.springframework.stereotype.Component; -/** - * Example of a {@link WebServerFactoryCustomizer} that uses a more narrowed server type. - * - * @author Stephane Nicoll - */ -// tag::code[] @Component -public class TomcatServerCustomizerExample implements WebServerFactoryCustomizer { +public class TomcatServerCustomizer implements WebServerFactoryCustomizer { @Override public void customize(TomcatServletWebServerFactory server) { - server.addConnectorCustomizers( - (tomcatConnector) -> tomcatConnector.setAsyncTimeout(Duration.ofSeconds(20).toMillis())); + server.addConnectorCustomizers((connector) -> connector.setAsyncTimeout(Duration.ofSeconds(20).toMillis())); } } diff --git a/spring-boot-project/spring-boot-docs/src/test/java/org/springframework/boot/docs/howto/actuator/MetricsHealthMicrometerExportExampleTests.java b/spring-boot-project/spring-boot-docs/src/test/java/org/springframework/boot/docs/howto/actuator/MetricsHealthMicrometerExportTests.java similarity index 89% rename from spring-boot-project/spring-boot-docs/src/test/java/org/springframework/boot/docs/howto/actuator/MetricsHealthMicrometerExportExampleTests.java rename to spring-boot-project/spring-boot-docs/src/test/java/org/springframework/boot/docs/howto/actuator/MetricsHealthMicrometerExportTests.java index da851000f395..f03001cec30f 100644 --- a/spring-boot-project/spring-boot-docs/src/test/java/org/springframework/boot/docs/howto/actuator/MetricsHealthMicrometerExportExampleTests.java +++ b/spring-boot-project/spring-boot-docs/src/test/java/org/springframework/boot/docs/howto/actuator/MetricsHealthMicrometerExportTests.java @@ -36,12 +36,12 @@ import static org.assertj.core.api.Assertions.assertThat; /** - * Tests for {@link MetricsHealthMicrometerExportExample}. + * Tests for {@link MetricsHealthMicrometerExport}. * * @author Phillip Webb */ @SpringBootTest -class MetricsHealthMicrometerExportExampleTests { +class MetricsHealthMicrometerExportTests { @Autowired private MeterRegistry registry; @@ -53,14 +53,14 @@ void registryExportsHealth() throws Exception { } @Configuration(proxyBeanMethods = false) - @Import(MetricsHealthMicrometerExportExample.HealthMetricsConfiguration.class) + @Import(MetricsHealthMicrometerExport.HealthMetricsConfiguration.class) @ImportAutoConfiguration(classes = { HealthContributorAutoConfiguration.class, MetricsAutoConfiguration.class, HealthEndpointAutoConfiguration.class }) static class Config { @Bean - MetricsHealthMicrometerExportExample example() { - return new MetricsHealthMicrometerExportExample(); + MetricsHealthMicrometerExport example() { + return new MetricsHealthMicrometerExport(); } @Bean diff --git a/spring-boot-project/spring-boot-docs/src/test/java/org/springframework/boot/docs/howto/dataaccess/BasicDataSourceExampleTests.java b/spring-boot-project/spring-boot-docs/src/test/java/org/springframework/boot/docs/howto/dataaccess/BasicDataSourceConfigurationTests.java similarity index 92% rename from spring-boot-project/spring-boot-docs/src/test/java/org/springframework/boot/docs/howto/dataaccess/BasicDataSourceExampleTests.java rename to spring-boot-project/spring-boot-docs/src/test/java/org/springframework/boot/docs/howto/dataaccess/BasicDataSourceConfigurationTests.java index 7053ef9b6fa0..a4b017ffca87 100644 --- a/spring-boot-project/spring-boot-docs/src/test/java/org/springframework/boot/docs/howto/dataaccess/BasicDataSourceExampleTests.java +++ b/spring-boot-project/spring-boot-docs/src/test/java/org/springframework/boot/docs/howto/dataaccess/BasicDataSourceConfigurationTests.java @@ -32,14 +32,14 @@ import static org.assertj.core.api.Assertions.assertThat; /** - * Test for {@link BasicDataSourceExample}. + * Test for {@link BasicDataSourceConfiguration}. * * @author Stephane Nicoll */ @ExtendWith(SpringExtension.class) @SpringBootTest(properties = "app.datasource.jdbcUrl=jdbc:h2:mem:basic;DB_CLOSE_DELAY=-1") -@Import(BasicDataSourceExample.BasicDataSourceConfiguration.class) -class BasicDataSourceExampleTests { +@Import(BasicDataSourceConfiguration.class) +class BasicDataSourceConfigurationTests { @Autowired private ApplicationContext context; diff --git a/spring-boot-project/spring-boot-docs/src/test/java/org/springframework/boot/docs/howto/dataaccess/CompleteTwoDataSourcesExampleTests.java b/spring-boot-project/spring-boot-docs/src/test/java/org/springframework/boot/docs/howto/dataaccess/CompleteDataSourcesConfigurationTests.java similarity index 91% rename from spring-boot-project/spring-boot-docs/src/test/java/org/springframework/boot/docs/howto/dataaccess/CompleteTwoDataSourcesExampleTests.java rename to spring-boot-project/spring-boot-docs/src/test/java/org/springframework/boot/docs/howto/dataaccess/CompleteDataSourcesConfigurationTests.java index 86b2ffd551f2..4a549830abe7 100644 --- a/spring-boot-project/spring-boot-docs/src/test/java/org/springframework/boot/docs/howto/dataaccess/CompleteTwoDataSourcesExampleTests.java +++ b/spring-boot-project/spring-boot-docs/src/test/java/org/springframework/boot/docs/howto/dataaccess/CompleteDataSourcesConfigurationTests.java @@ -32,14 +32,14 @@ import static org.assertj.core.api.Assertions.assertThat; /** - * Tests for {@link CompleteTwoDataSourcesExample}. + * Tests for {@link CompleteDataSourcesConfiguration}. * * @author Stephane Nicoll */ @ExtendWith(SpringExtension.class) @SpringBootTest -@Import(CompleteTwoDataSourcesExample.CompleteDataSourcesConfiguration.class) -class CompleteTwoDataSourcesExampleTests { +@Import(CompleteDataSourcesConfiguration.class) +class CompleteDataSourcesConfigurationTests { @Autowired private ApplicationContext context; diff --git a/spring-boot-project/spring-boot-docs/src/test/java/org/springframework/boot/docs/howto/dataaccess/ConfigurableDataSourceExampleTests.java b/spring-boot-project/spring-boot-docs/src/test/java/org/springframework/boot/docs/howto/dataaccess/ConfigurableDataSourceConfigurationTests.java similarity index 91% rename from spring-boot-project/spring-boot-docs/src/test/java/org/springframework/boot/docs/howto/dataaccess/ConfigurableDataSourceExampleTests.java rename to spring-boot-project/spring-boot-docs/src/test/java/org/springframework/boot/docs/howto/dataaccess/ConfigurableDataSourceConfigurationTests.java index caeea3d1c073..792a2ad853e8 100644 --- a/spring-boot-project/spring-boot-docs/src/test/java/org/springframework/boot/docs/howto/dataaccess/ConfigurableDataSourceExampleTests.java +++ b/spring-boot-project/spring-boot-docs/src/test/java/org/springframework/boot/docs/howto/dataaccess/ConfigurableDataSourceConfigurationTests.java @@ -33,15 +33,15 @@ import static org.assertj.core.api.Assertions.assertThat; /** - * Test for {@link SimpleDataSourceExample}. + * Test for {@link ConfigurableDataSourceConfiguration}. * * @author Stephane Nicoll */ @ExtendWith(SpringExtension.class) @SpringBootTest(properties = { "app.datasource.url=jdbc:h2:mem:configurable;DB_CLOSE_DELAY=-1", "app.datasource.configuration.maximum-pool-size=42" }) -@Import(ConfigurableDataSourceExample.ConfigurableDataSourceConfiguration.class) -class ConfigurableDataSourceExampleTests { +@Import(ConfigurableDataSourceConfiguration.class) +class ConfigurableDataSourceConfigurationTests { @Autowired private ApplicationContext context; diff --git a/spring-boot-project/spring-boot-docs/src/test/java/org/springframework/boot/docs/howto/dataaccess/SimpleDataSourceExampleTests.java b/spring-boot-project/spring-boot-docs/src/test/java/org/springframework/boot/docs/howto/dataaccess/SimpleDataSourceConfigurationTests.java similarity index 92% rename from spring-boot-project/spring-boot-docs/src/test/java/org/springframework/boot/docs/howto/dataaccess/SimpleDataSourceExampleTests.java rename to spring-boot-project/spring-boot-docs/src/test/java/org/springframework/boot/docs/howto/dataaccess/SimpleDataSourceConfigurationTests.java index 373790bcf1d2..35a387c09767 100644 --- a/spring-boot-project/spring-boot-docs/src/test/java/org/springframework/boot/docs/howto/dataaccess/SimpleDataSourceExampleTests.java +++ b/spring-boot-project/spring-boot-docs/src/test/java/org/springframework/boot/docs/howto/dataaccess/SimpleDataSourceConfigurationTests.java @@ -33,15 +33,15 @@ import static org.assertj.core.api.Assertions.assertThat; /** - * Test for {@link SimpleDataSourceExample}. + * Test for {@link SimpleDataSourceConfiguration}. * * @author Stephane Nicoll */ @ExtendWith(SpringExtension.class) @SpringBootTest(properties = { "app.datasource.jdbc-url=jdbc:h2:mem:simple;DB_CLOSE_DELAY=-1", "app.datasource.maximum-pool-size=42" }) -@Import(SimpleDataSourceExample.SimpleDataSourceConfiguration.class) -class SimpleDataSourceExampleTests { +@Import(SimpleDataSourceConfiguration.class) +class SimpleDataSourceConfigurationTests { @Autowired private ApplicationContext context; diff --git a/spring-boot-project/spring-boot-docs/src/test/java/org/springframework/boot/docs/howto/dataaccess/SimpleTwoDataSourcesExampleTests.java b/spring-boot-project/spring-boot-docs/src/test/java/org/springframework/boot/docs/howto/dataaccess/SimpleDataSourcesConfigurationTests.java similarity index 92% rename from spring-boot-project/spring-boot-docs/src/test/java/org/springframework/boot/docs/howto/dataaccess/SimpleTwoDataSourcesExampleTests.java rename to spring-boot-project/spring-boot-docs/src/test/java/org/springframework/boot/docs/howto/dataaccess/SimpleDataSourcesConfigurationTests.java index bce2c431a051..c44689301928 100644 --- a/spring-boot-project/spring-boot-docs/src/test/java/org/springframework/boot/docs/howto/dataaccess/SimpleTwoDataSourcesExampleTests.java +++ b/spring-boot-project/spring-boot-docs/src/test/java/org/springframework/boot/docs/howto/dataaccess/SimpleDataSourcesConfigurationTests.java @@ -33,15 +33,15 @@ import static org.assertj.core.api.Assertions.assertThat; /** - * Tests for {@link SimpleTwoDataSourcesExample}. + * Tests for {@link SimpleDataSourcesConfiguration}. * * @author Stephane Nicoll */ @ExtendWith(SpringExtension.class) @SpringBootTest(properties = { "app.datasource.second.url=jdbc:h2:mem:bar;DB_CLOSE_DELAY=-1", "app.datasource.second.max-total=42" }) -@Import(SimpleTwoDataSourcesExample.SimpleDataSourcesConfiguration.class) -class SimpleTwoDataSourcesExampleTests { +@Import(SimpleDataSourcesConfiguration.class) +class SimpleDataSourcesConfigurationTests { @Autowired private ApplicationContext context; diff --git a/spring-boot-project/spring-boot-docs/src/test/java/org/springframework/boot/docs/context/embedded/TomcatLegacyCookieProcessorExampleTests.java b/spring-boot-project/spring-boot-docs/src/test/java/org/springframework/boot/docs/howto/embeddedwebservers/LegacyCookieProcessorConfigurationTests.java similarity index 84% rename from spring-boot-project/spring-boot-docs/src/test/java/org/springframework/boot/docs/context/embedded/TomcatLegacyCookieProcessorExampleTests.java rename to spring-boot-project/spring-boot-docs/src/test/java/org/springframework/boot/docs/howto/embeddedwebservers/LegacyCookieProcessorConfigurationTests.java index 320e206acd52..db2bb9163321 100644 --- a/spring-boot-project/spring-boot-docs/src/test/java/org/springframework/boot/docs/context/embedded/TomcatLegacyCookieProcessorExampleTests.java +++ b/spring-boot-project/spring-boot-docs/src/test/java/org/springframework/boot/docs/howto/embeddedwebservers/LegacyCookieProcessorConfigurationTests.java @@ -14,15 +14,13 @@ * limitations under the License. */ -package org.springframework.boot.docs.context.embedded; +package org.springframework.boot.docs.howto.embeddedwebservers; import org.apache.catalina.Context; import org.apache.tomcat.util.http.LegacyCookieProcessor; import org.junit.jupiter.api.Test; import org.springframework.boot.SpringApplication; -import org.springframework.boot.docs.howto.embeddedwebservers.TomcatLegacyCookieProcessorExample; -import org.springframework.boot.docs.howto.embeddedwebservers.TomcatLegacyCookieProcessorExample.LegacyCookieProcessorConfiguration; import org.springframework.boot.web.embedded.tomcat.TomcatServletWebServerFactory; import org.springframework.boot.web.embedded.tomcat.TomcatWebServer; import org.springframework.boot.web.server.WebServerFactoryCustomizerBeanPostProcessor; @@ -33,11 +31,11 @@ import static org.assertj.core.api.Assertions.assertThat; /** - * Tests for {@link TomcatLegacyCookieProcessorExample}. + * Tests for {@link LegacyCookieProcessorConfiguration}. * * @author Andy Wilkinson */ -class TomcatLegacyCookieProcessorExampleTests { +class LegacyCookieProcessorConfigurationTests { @Test void cookieProcessorIsCustomized() { diff --git a/spring-boot-project/spring-boot-docs/src/test/java/org/springframework/boot/docs/howto/springbootapplication/EnvironmentPostProcessorExampleTests.java b/spring-boot-project/spring-boot-docs/src/test/java/org/springframework/boot/docs/howto/springbootapplication/ExampleEnvironmentPostProcessorTests.java similarity index 89% rename from spring-boot-project/spring-boot-docs/src/test/java/org/springframework/boot/docs/howto/springbootapplication/EnvironmentPostProcessorExampleTests.java rename to spring-boot-project/spring-boot-docs/src/test/java/org/springframework/boot/docs/howto/springbootapplication/ExampleEnvironmentPostProcessorTests.java index 931d8583c58e..139aa89a5f33 100644 --- a/spring-boot-project/spring-boot-docs/src/test/java/org/springframework/boot/docs/howto/springbootapplication/EnvironmentPostProcessorExampleTests.java +++ b/spring-boot-project/spring-boot-docs/src/test/java/org/springframework/boot/docs/howto/springbootapplication/ExampleEnvironmentPostProcessorTests.java @@ -24,18 +24,18 @@ import static org.assertj.core.api.Assertions.assertThat; /** - * Tests for {@link EnvironmentPostProcessorExample}. + * Tests for {@link ExampleEnvironmentPostProcessor}. * * @author Stephane Nicoll */ -class EnvironmentPostProcessorExampleTests { +class ExampleEnvironmentPostProcessorTests { private final StandardEnvironment environment = new StandardEnvironment(); @Test void applyEnvironmentPostProcessor() { assertThat(this.environment.containsProperty("test.foo.bar")).isFalse(); - new EnvironmentPostProcessorExample().postProcessEnvironment(this.environment, new SpringApplication()); + new ExampleEnvironmentPostProcessor().postProcessEnvironment(this.environment, new SpringApplication()); assertThat(this.environment.containsProperty("test.foo.bar")).isTrue(); assertThat(this.environment.getProperty("test.foo.bar")).isEqualTo("value"); } diff --git a/src/checkstyle/checkstyle-suppressions.xml b/src/checkstyle/checkstyle-suppressions.xml index 694a83ca8ff3..79ab47a5552a 100644 --- a/src/checkstyle/checkstyle-suppressions.xml +++ b/src/checkstyle/checkstyle-suppressions.xml @@ -17,7 +17,7 @@ - + From 073f8c4b239eaa720ddba32b2aaa10517e2f2221 Mon Sep 17 00:00:00 2001 From: Phillip Webb Date: Wed, 3 Feb 2021 16:20:32 -0800 Subject: [PATCH 04/13] Polish spring-boot-docs See gh-25089 --- .../spring-boot-docs/src/docs/asciidoc/howto.adoc | 2 +- .../src/docs/asciidoc/production-ready-features.adoc | 4 ++-- .../src/docs/asciidoc/spring-boot-features.adoc | 2 +- ...ntPostProcessor.java => MyEnvironmentPostProcessor.java} | 2 +- .../{CustomEndpointExample.java => CustomEndpoint.java} | 2 +- .../{ExitCodeExample.java => exitcode/MyApplication.java} | 6 +++--- ...essorTests.java => MyEnvironmentPostProcessorTests.java} | 6 +++--- 7 files changed, 12 insertions(+), 12 deletions(-) rename spring-boot-project/spring-boot-docs/src/main/java/org/springframework/boot/docs/howto/springbootapplication/{ExampleEnvironmentPostProcessor.java => MyEnvironmentPostProcessor.java} (95%) rename spring-boot-project/spring-boot-docs/src/main/java/org/springframework/boot/docs/productionreadyfeatures/endpoints/{CustomEndpointExample.java => CustomEndpoint.java} (97%) rename spring-boot-project/spring-boot-docs/src/main/java/org/springframework/boot/docs/springbootfeatures/springapplication/{ExitCodeExample.java => exitcode/MyApplication.java} (88%) rename spring-boot-project/spring-boot-docs/src/test/java/org/springframework/boot/docs/howto/springbootapplication/{ExampleEnvironmentPostProcessorTests.java => MyEnvironmentPostProcessorTests.java} (86%) diff --git a/spring-boot-project/spring-boot-docs/src/docs/asciidoc/howto.adoc b/spring-boot-project/spring-boot-docs/src/docs/asciidoc/howto.adoc index c53af684b8e1..b183f5f3bfbe 100644 --- a/spring-boot-project/spring-boot-docs/src/docs/asciidoc/howto.adoc +++ b/spring-boot-project/spring-boot-docs/src/docs/asciidoc/howto.adoc @@ -95,7 +95,7 @@ For instance, the following example loads a YAML configuration file from the cla [source,java,indent=0] ---- -include::{include-howto}/springbootapplication/ExampleEnvironmentPostProcessor.java[tag=*] +include::{include-howto}/springbootapplication/MyEnvironmentPostProcessor.java[tag=*] ---- TIP: The `Environment` has already been prepared with all the usual property sources that Spring Boot loads by default. diff --git a/spring-boot-project/spring-boot-docs/src/docs/asciidoc/production-ready-features.adoc b/spring-boot-project/spring-boot-docs/src/docs/asciidoc/production-ready-features.adoc index ff93c55db297..60d683371295 100644 --- a/spring-boot-project/spring-boot-docs/src/docs/asciidoc/production-ready-features.adoc +++ b/spring-boot-project/spring-boot-docs/src/docs/asciidoc/production-ready-features.adoc @@ -463,7 +463,7 @@ The following example exposes a read operation that returns a custom object: [source,java,indent=0] ---- -include::{include-productionreadyfeatures}/endpoints/CustomEndpointExample.java[tag=read] +include::{include-productionreadyfeatures}/endpoints/CustomEndpoint.java[tag=read] ---- You can also write technology-specific endpoints by using `@JmxEndpoint` or `@WebEndpoint`. @@ -500,7 +500,7 @@ This can be used to invoke a write operation that takes `String name` and `int c [source,java,indent=0] ---- -include::{include-productionreadyfeatures}/endpoints/CustomEndpointExample.java[tag=write] +include::{include-productionreadyfeatures}/endpoints/CustomEndpoint.java[tag=write] ---- TIP: Because endpoints are technology agnostic, only simple types can be specified in the method signature. diff --git a/spring-boot-project/spring-boot-docs/src/docs/asciidoc/spring-boot-features.adoc b/spring-boot-project/spring-boot-docs/src/docs/asciidoc/spring-boot-features.adoc index 8ae7b4e14625..88721e271f37 100644 --- a/spring-boot-project/spring-boot-docs/src/docs/asciidoc/spring-boot-features.adoc +++ b/spring-boot-project/spring-boot-docs/src/docs/asciidoc/spring-boot-features.adoc @@ -436,7 +436,7 @@ This exit code can then be passed to `System.exit()` to return it as a status co [source,java,indent=0] ---- -include::{include-springbootfeatures}/springapplication/ExitCodeExample.java[tag=*] +include::{include-springbootfeatures}/springapplication/exitcode/MyApplication.java[tag=*] ---- Also, the `ExitCodeGenerator` interface may be implemented by exceptions. diff --git a/spring-boot-project/spring-boot-docs/src/main/java/org/springframework/boot/docs/howto/springbootapplication/ExampleEnvironmentPostProcessor.java b/spring-boot-project/spring-boot-docs/src/main/java/org/springframework/boot/docs/howto/springbootapplication/MyEnvironmentPostProcessor.java similarity index 95% rename from spring-boot-project/spring-boot-docs/src/main/java/org/springframework/boot/docs/howto/springbootapplication/ExampleEnvironmentPostProcessor.java rename to spring-boot-project/spring-boot-docs/src/main/java/org/springframework/boot/docs/howto/springbootapplication/MyEnvironmentPostProcessor.java index 33c9ca51ea69..fc0e6b7066e0 100644 --- a/spring-boot-project/spring-boot-docs/src/main/java/org/springframework/boot/docs/howto/springbootapplication/ExampleEnvironmentPostProcessor.java +++ b/spring-boot-project/spring-boot-docs/src/main/java/org/springframework/boot/docs/howto/springbootapplication/MyEnvironmentPostProcessor.java @@ -28,7 +28,7 @@ import org.springframework.core.io.Resource; import org.springframework.util.Assert; -public class ExampleEnvironmentPostProcessor implements EnvironmentPostProcessor { +public class MyEnvironmentPostProcessor implements EnvironmentPostProcessor { private final YamlPropertySourceLoader loader = new YamlPropertySourceLoader(); diff --git a/spring-boot-project/spring-boot-docs/src/main/java/org/springframework/boot/docs/productionreadyfeatures/endpoints/CustomEndpointExample.java b/spring-boot-project/spring-boot-docs/src/main/java/org/springframework/boot/docs/productionreadyfeatures/endpoints/CustomEndpoint.java similarity index 97% rename from spring-boot-project/spring-boot-docs/src/main/java/org/springframework/boot/docs/productionreadyfeatures/endpoints/CustomEndpointExample.java rename to spring-boot-project/spring-boot-docs/src/main/java/org/springframework/boot/docs/productionreadyfeatures/endpoints/CustomEndpoint.java index cb8135af13df..b23bef3c3044 100644 --- a/spring-boot-project/spring-boot-docs/src/main/java/org/springframework/boot/docs/productionreadyfeatures/endpoints/CustomEndpointExample.java +++ b/spring-boot-project/spring-boot-docs/src/main/java/org/springframework/boot/docs/productionreadyfeatures/endpoints/CustomEndpoint.java @@ -21,7 +21,7 @@ import org.springframework.boot.actuate.endpoint.annotation.WriteOperation; @Endpoint(id = "custom") -public class CustomEndpointExample { +public class CustomEndpoint { // tag::read[] @ReadOperation diff --git a/spring-boot-project/spring-boot-docs/src/main/java/org/springframework/boot/docs/springbootfeatures/springapplication/ExitCodeExample.java b/spring-boot-project/spring-boot-docs/src/main/java/org/springframework/boot/docs/springbootfeatures/springapplication/exitcode/MyApplication.java similarity index 88% rename from spring-boot-project/spring-boot-docs/src/main/java/org/springframework/boot/docs/springbootfeatures/springapplication/ExitCodeExample.java rename to spring-boot-project/spring-boot-docs/src/main/java/org/springframework/boot/docs/springbootfeatures/springapplication/exitcode/MyApplication.java index ea8514b38fc1..aedb4ff14de9 100644 --- a/spring-boot-project/spring-boot-docs/src/main/java/org/springframework/boot/docs/springbootfeatures/springapplication/ExitCodeExample.java +++ b/spring-boot-project/spring-boot-docs/src/main/java/org/springframework/boot/docs/springbootfeatures/springapplication/exitcode/MyApplication.java @@ -14,7 +14,7 @@ * limitations under the License. */ -package org.springframework.boot.docs.springbootfeatures.springapplication; +package org.springframework.boot.docs.springbootfeatures.springapplication.exitcode; // tag::code[] import org.springframework.boot.ExitCodeGenerator; @@ -23,7 +23,7 @@ import org.springframework.context.annotation.Bean; @SpringBootApplication -public class ExitCodeExample { +public class MyApplication { @Bean public ExitCodeGenerator exitCodeGenerator() { @@ -31,7 +31,7 @@ public ExitCodeGenerator exitCodeGenerator() { } public static void main(String[] args) { - System.exit(SpringApplication.exit(SpringApplication.run(ExitCodeExample.class, args))); + System.exit(SpringApplication.exit(SpringApplication.run(MyApplication.class, args))); } } diff --git a/spring-boot-project/spring-boot-docs/src/test/java/org/springframework/boot/docs/howto/springbootapplication/ExampleEnvironmentPostProcessorTests.java b/spring-boot-project/spring-boot-docs/src/test/java/org/springframework/boot/docs/howto/springbootapplication/MyEnvironmentPostProcessorTests.java similarity index 86% rename from spring-boot-project/spring-boot-docs/src/test/java/org/springframework/boot/docs/howto/springbootapplication/ExampleEnvironmentPostProcessorTests.java rename to spring-boot-project/spring-boot-docs/src/test/java/org/springframework/boot/docs/howto/springbootapplication/MyEnvironmentPostProcessorTests.java index 139aa89a5f33..d43d86b81d19 100644 --- a/spring-boot-project/spring-boot-docs/src/test/java/org/springframework/boot/docs/howto/springbootapplication/ExampleEnvironmentPostProcessorTests.java +++ b/spring-boot-project/spring-boot-docs/src/test/java/org/springframework/boot/docs/howto/springbootapplication/MyEnvironmentPostProcessorTests.java @@ -24,18 +24,18 @@ import static org.assertj.core.api.Assertions.assertThat; /** - * Tests for {@link ExampleEnvironmentPostProcessor}. + * Tests for {@link MyEnvironmentPostProcessor}. * * @author Stephane Nicoll */ -class ExampleEnvironmentPostProcessorTests { +class MyEnvironmentPostProcessorTests { private final StandardEnvironment environment = new StandardEnvironment(); @Test void applyEnvironmentPostProcessor() { assertThat(this.environment.containsProperty("test.foo.bar")).isFalse(); - new ExampleEnvironmentPostProcessor().postProcessEnvironment(this.environment, new SpringApplication()); + new MyEnvironmentPostProcessor().postProcessEnvironment(this.environment, new SpringApplication()); assertThat(this.environment.containsProperty("test.foo.bar")).isTrue(); assertThat(this.environment.getProperty("test.foo.bar")).isEqualTo("value"); } From ae1be76cceadbb92529720a2fec8737e225f1c6e Mon Sep 17 00:00:00 2001 From: Phillip Webb Date: Wed, 3 Feb 2021 17:39:13 -0800 Subject: [PATCH 05/13] Add pending-extract attribute to source Add `pending-extract=true` to source blocks to help us identify those that need to be extracted to a real source file. See gh-6313 --- .../appendix-configuration-metadata.adoc | 10 +- .../src/docs/asciidoc/build-tool-plugins.adoc | 2 +- .../src/docs/asciidoc/deployment.adoc | 2 +- .../src/docs/asciidoc/getting-started.adoc | 2 +- .../src/docs/asciidoc/howto.adoc | 54 ++-- .../asciidoc/production-ready-features.adoc | 38 +-- .../src/docs/asciidoc/spring-boot-cli.adoc | 2 +- .../docs/asciidoc/spring-boot-features.adoc | 249 +++++++++--------- .../src/docs/asciidoc/using-spring-boot.adoc | 16 +- 9 files changed, 187 insertions(+), 188 deletions(-) diff --git a/spring-boot-project/spring-boot-docs/src/docs/asciidoc/appendix-configuration-metadata.adoc b/spring-boot-project/spring-boot-docs/src/docs/asciidoc/appendix-configuration-metadata.adoc index 0fbf46396881..0a8fa6f48722 100644 --- a/spring-boot-project/spring-boot-docs/src/docs/asciidoc/appendix-configuration-metadata.adoc +++ b/spring-boot-project/spring-boot-docs/src/docs/asciidoc/appendix-configuration-metadata.adoc @@ -220,7 +220,7 @@ Deprecation can also be specified declaratively in code by adding the `@Deprecat For instance, assume that the `app.acme.target` property was confusing and was renamed to `app.acme.name`. The following example shows how to handle that situation: -[source,java,indent=0] +[source,java,pending-extract=true,indent=0] ---- @ConfigurationProperties("app.acme") public class AcmeProperties { @@ -343,7 +343,7 @@ The special `.keys` and `.values` suffixes must refer to the keys and the values Assume a `sample.contexts` maps magic `String` values to an integer, as shown in the following example: -[source,java,indent=0] +[source,java,pending-extract=true,indent=0] ---- @ConfigurationProperties("sample") public class SampleProperties { @@ -762,7 +762,7 @@ The annotation processor also supports the use of the `@Data`, `@Getter`, and `@ Consider the following example: -[source,java,indent=0,subs="verbatim,attributes"] +[source,java,pending-extract=true,indent=0,subs="verbatim,attributes"] ---- @ConfigurationProperties(prefix="server") public class ServerProperties { @@ -799,7 +799,7 @@ Also, the annotation processor cannot auto-detect default values for ``Enum``s a For cases where the default value could not be detected, <> should be provided. Consider the following example: -[source,java,indent=0,subs="verbatim,quotes,attributes"] +[source,java,pending-extract=true,indent=0,subs="verbatim,quotes,attributes"] ---- @ConfigurationProperties(prefix = "acme.messaging") public class MessagingProperties { @@ -845,7 +845,7 @@ The annotation processor automatically considers inner classes as nested propert Rather than documenting the `ip` and `port` at the root of the namespace, we could create a sub-namespace for it. Consider the updated example: -[source,java,indent=0,subs="verbatim,quotes,attributes"] +[source,java,pending-extract=true,indent=0,subs="verbatim,quotes,attributes"] ---- @ConfigurationProperties(prefix="server") public class ServerProperties { diff --git a/spring-boot-project/spring-boot-docs/src/docs/asciidoc/build-tool-plugins.adoc b/spring-boot-project/spring-boot-docs/src/docs/asciidoc/build-tool-plugins.adoc index 9cb3488060ea..2b086d1dc341 100644 --- a/spring-boot-project/spring-boot-docs/src/docs/asciidoc/build-tool-plugins.adoc +++ b/spring-boot-project/spring-boot-docs/src/docs/asciidoc/build-tool-plugins.adoc @@ -223,7 +223,7 @@ An exception is thrown if more than one candidate is found. === Example Repackage Implementation The following example shows a typical repackage implementation: -[source,java,indent=0] +[source,java,pending-extract=true,indent=0] ---- Repackager repackager = new Repackager(sourceJarFile); repackager.setBackupSource(false); diff --git a/spring-boot-project/spring-boot-docs/src/docs/asciidoc/deployment.adoc b/spring-boot-project/spring-boot-docs/src/docs/asciidoc/deployment.adoc index 8a42e7eb9eff..d6879eee5ac0 100644 --- a/spring-boot-project/spring-boot-docs/src/docs/asciidoc/deployment.adoc +++ b/spring-boot-project/spring-boot-docs/src/docs/asciidoc/deployment.adoc @@ -135,7 +135,7 @@ Process-scoped environment variables are language agnostic. Environment variables do not always make for the easiest API, so Spring Boot automatically extracts them and flattens the data into properties that can be accessed through Spring's `Environment` abstraction, as shown in the following example: -[source,java,indent=0] +[source,java,pending-extract=true,indent=0] ---- @Component class MyBean implements EnvironmentAware { diff --git a/spring-boot-project/spring-boot-docs/src/docs/asciidoc/getting-started.adoc b/spring-boot-project/spring-boot-docs/src/docs/asciidoc/getting-started.adoc index d359898a112b..b030d52e22db 100644 --- a/spring-boot-project/spring-boot-docs/src/docs/asciidoc/getting-started.adoc +++ b/spring-boot-project/spring-boot-docs/src/docs/asciidoc/getting-started.adoc @@ -483,7 +483,7 @@ If you run `mvn dependency:tree` again, you see that there are now a number of a To finish our application, we need to create a single Java file. By default, Maven compiles sources from `src/main/java`, so you need to create that directory structure and then add a file named `src/main/java/Example.java` to contain the following code: -[source,java,indent=0] +[source,java,pending-extract=true,indent=0] ---- import org.springframework.boot.*; import org.springframework.boot.autoconfigure.*; diff --git a/spring-boot-project/spring-boot-docs/src/docs/asciidoc/howto.adoc b/spring-boot-project/spring-boot-docs/src/docs/asciidoc/howto.adoc index b183f5f3bfbe..481c0762e21f 100644 --- a/spring-boot-project/spring-boot-docs/src/docs/asciidoc/howto.adoc +++ b/spring-boot-project/spring-boot-docs/src/docs/asciidoc/howto.adoc @@ -239,7 +239,7 @@ Then the Spring Boot banner is not printed on startup, and the application is no Properties defined in external configuration override the values specified with the Java API, with the notable exception of the sources used to create the `ApplicationContext`. Consider the following application: -[source,java,indent=0] +[source,java,pending-extract=true,indent=0] ---- new SpringApplicationBuilder() .bannerMode(Banner.Mode.OFF) @@ -513,7 +513,7 @@ The best way to get that and be sure it has been initialized is to add a `@Bean` Tests that use `@SpringBootTest(webEnvironment=WebEnvironment.RANDOM_PORT)` can also inject the actual port into a field by using the `@LocalServerPort` annotation, as shown in the following example: -[source,java,indent=0,subs="verbatim,quotes,attributes"] +[source,java,pending-extract=true,indent=0,subs="verbatim,quotes,attributes"] ---- @SpringBootTest(webEnvironment=WebEnvironment.RANDOM_PORT) public class MyWebIntegrationTests { @@ -658,7 +658,7 @@ and instead apply a customizer specific to your choice of server: For Tomcat, we need to add an upgrade protocol: -[source,java,indent=0,subs="verbatim,quotes,attributes"] +[source,java,pending-extract=true,indent=0,subs="verbatim,quotes,attributes"] ---- @Bean public TomcatConnectorCustomizer connectorCustomizer() { @@ -668,7 +668,7 @@ For Tomcat, we need to add an upgrade protocol: For Jetty, we need to add a connection factory to the existing connector: -[source,java,indent=0,subs="verbatim,quotes,attributes"] +[source,java,pending-extract=true,indent=0,subs="verbatim,quotes,attributes"] ---- @Bean public JettyServerCustomizer serverCustomizer() { @@ -687,7 +687,7 @@ For Jetty, we need to add a connection factory to the existing connector: For Netty, we need to add `h2c` as a supported protocol: -[source,java,indent=0,subs="verbatim,quotes,attributes"] +[source,java,pending-extract=true,indent=0,subs="verbatim,quotes,attributes"] ---- @Bean public NettyServerCustomizer serverCustomizer() { @@ -697,7 +697,7 @@ For Netty, we need to add `h2c` as a supported protocol: For Undertow, we need to enable the HTTP2 option: -[source,java,indent=0,subs="verbatim,quotes,attributes"] +[source,java,pending-extract=true,indent=0,subs="verbatim,quotes,attributes"] ---- @Bean public UndertowBuilderCustomizer builderCustomizer() { @@ -721,7 +721,7 @@ You can declare such a component and get access to the server factory relevant t The example below is for Tomcat with the `spring-boot-starter-web` (Servlet stack): -[source,java,indent=0,subs="verbatim,quotes,attributes"] +[source,java,pending-extract=true,indent=0,subs="verbatim,quotes,attributes"] ---- @Component public class MyTomcatWebServerCustomizer @@ -802,7 +802,7 @@ Like any other Spring bean, you can define the order of Servlet filter beans; pl As <>, any `Servlet` or `Filter` beans are registered with the servlet container automatically. To disable registration of a particular `Filter` or `Servlet` bean, create a registration bean for it and mark it as disabled, as shown in the following example: -[source,java,indent=0,subs="verbatim,quotes,attributes"] +[source,java,pending-extract=true,indent=0,subs="verbatim,quotes,attributes"] ---- @Bean public FilterRegistrationBean registration(MyFilter filter) { @@ -987,7 +987,7 @@ include::{include-howto}/embeddedwebservers/UndertowMultipleListenersConfigurati === Create WebSocket Endpoints Using @ServerEndpoint If you want to use `@ServerEndpoint` in a Spring Boot application that used an embedded container, you must declare a single `ServerEndpointExporter` `@Bean`, as shown in the following example: -[source,java,indent=0,subs="verbatim,quotes,attributes"] +[source,java,pending-extract=true,indent=0,subs="verbatim,quotes,attributes"] ---- @Bean public ServerEndpointExporter serverEndpointExporter() { @@ -1012,7 +1012,7 @@ This section answers common questions about Spring MVC and Spring Boot. === Write a JSON REST Service Any Spring `@RestController` in a Spring Boot application should render JSON response by default as long as Jackson2 is on the classpath, as shown in the following example: -[source,java,indent=0,subs="verbatim,quotes,attributes"] +[source,java,pending-extract=true,indent=0,subs="verbatim,quotes,attributes"] ---- @RestController public class MyController { @@ -1046,7 +1046,7 @@ To use the Jackson XML renderer, add the following dependency to your project: If Jackson's XML extension is not available and JAXB is available, XML can be rendered with the additional requirement of having `MyThing` annotated as `@XmlRootElement`, as shown in the following example: -[source,java,indent=0,subs="verbatim,quotes,attributes"] +[source,java,pending-extract=true,indent=0,subs="verbatim,quotes,attributes"] ---- @XmlRootElement public class MyThing { @@ -1251,7 +1251,7 @@ For more detail, see the following sections: Spring Security provides support for running tests as a specific user. For example, the test in the snippet below will run with an authenticated user that has the `ADMIN` role. -[source,java,indent=0] +[source,java,pending-extract=true,indent=0] ---- @Test @WithMockUser(roles="ADMIN") @@ -1294,7 +1294,7 @@ To use Jersey alongside another web framework, such as Spring MVC, it should be First, configure Jersey to use a Filter rather than a Servlet by configuring the configprop:spring.jersey.type[] application property with a value of `filter`. Second, configure your `ResourceConfig` to forward requests that would have resulted in a 404, as shown in the following example. -[source,java,indent=0,subs="verbatim,quotes,attributes"] +[source,java,pending-extract=true,indent=0,subs="verbatim,quotes,attributes"] ---- @Component public class JerseyConfig extends ResourceConfig { @@ -1551,7 +1551,7 @@ If you need to externalize some settings, you can bind your `DataSource` to the The following example shows how to define a data source in a bean: -[source,java,indent=0,subs="verbatim,quotes,attributes"] +[source,java,pending-extract=true,indent=0,subs="verbatim,quotes,attributes"] ---- @Bean @ConfigurationProperties(prefix="app.datasource") @@ -1729,7 +1729,7 @@ For more about Spring Data, see the {spring-data}[Spring Data project page]. Spring Boot tries to guess the location of your `@Entity` definitions, based on the `@EnableAutoConfiguration` it finds. To get more control, you can use the `@EntityScan` annotation, as shown in the following example: -[source,java,indent=0,subs="verbatim,quotes,attributes"] +[source,java,pending-extract=true,indent=0,subs="verbatim,quotes,attributes"] ---- @Configuration(proxyBeanMethods = false) @EnableAutoConfiguration @@ -1806,7 +1806,7 @@ If you prefer to use Hibernate 5's default instead, set the following property: Alternatively, you can configure the following bean: -[source,java,indent=0,subs="verbatim,quotes,attributes"] +[source,java,pending-extract=true,indent=0,subs="verbatim,quotes,attributes"] ---- @Bean public PhysicalNamingStrategy physicalNamingStrategy() { @@ -1858,7 +1858,7 @@ Even if the default `EntityManagerFactory` works fine, you need to define a new You can use the `EntityManagerBuilder` provided by Spring Boot to help you to create one. Alternatively, you can use the `LocalContainerEntityManagerFactoryBean` directly from Spring ORM, as shown in the following example: -[source,java,indent=0,subs="verbatim,quotes,attributes"] +[source,java,pending-extract=true,indent=0,subs="verbatim,quotes,attributes"] ---- // add two data sources configured as above @@ -1896,7 +1896,7 @@ Alternatively, you might be able to use a JTA transaction manager that spans bot If you use Spring Data, you need to configure `@EnableJpaRepositories` accordingly, as shown in the following example: -[source,java,indent=0,subs="verbatim,quotes,attributes"] +[source,java,pending-extract=true,indent=0,subs="verbatim,quotes,attributes"] ---- @Configuration(proxyBeanMethods = false) @EnableJpaRepositories(basePackageClasses = Customer.class, @@ -2206,7 +2206,7 @@ If your JMS broker does not support transacted sessions, you have to disable the If you create your own `JmsListenerContainerFactory`, there is nothing to do, since, by default it cannot be transacted. If you want to use the `DefaultJmsListenerContainerFactoryConfigurer` to reuse Spring Boot's default, you can disable transacted sessions, as follows: -[source,java,indent=0] +[source,java,pending-extract=true,indent=0] ---- @Bean public DefaultJmsListenerContainerFactory jmsListenerContainerFactory( @@ -2399,7 +2399,7 @@ Alternatively, you can add the `RemoteIpValve` by customizing the `TomcatServlet To configure Spring Security to require a secure channel for all (or some) requests, consider adding your own `SecurityFilterChain` bean that adds the following `HttpSecurity` configuration: -[source,java,indent=0,subs="verbatim,quotes,attributes"] +[source,java,pending-extract=true,indent=0,subs="verbatim,quotes,attributes"] ---- @Bean public SecurityFilterChain securityFilterChain(HttpSecurity http) throws Exception { @@ -2798,7 +2798,7 @@ The first step in producing a deployable war file is to provide a `SpringBootSer Doing so makes use of Spring Framework's Servlet 3.0 support and lets you configure your application when it is launched by the servlet container. Typically, you should update your application's main class to extend `SpringBootServletInitializer`, as shown in the following example: -[source,java,indent=0,subs="verbatim,quotes,attributes"] +[source,java,pending-extract=true,indent=0,subs="verbatim,quotes,attributes"] ---- @SpringBootApplication public class Application extends SpringBootServletInitializer { @@ -2875,7 +2875,7 @@ See the https://spring.io/guides/gs/convert-jar-to-war/[Getting Started Guide on To create a deployable war by extending `SpringBootServletInitializer` (for example, in a class called `Application`) and adding the Spring Boot `@SpringBootApplication` annotation, use code similar to that shown in the following example: -[source,java,indent=0,subs="verbatim,quotes,attributes"] +[source,java,pending-extract=true,indent=0,subs="verbatim,quotes,attributes"] ---- @SpringBootApplication public class Application extends SpringBootServletInitializer { @@ -2908,7 +2908,7 @@ If you have other features in your application (for instance, using other servle Once the war file is working, you can make it executable by adding a `main` method to your `Application`, as shown in the following example: -[source,java,indent=0,subs="verbatim,quotes,attributes"] +[source,java,pending-extract=true,indent=0,subs="verbatim,quotes,attributes"] ---- public static void main(String[] args) { SpringApplication.run(Application.class, args); @@ -2919,7 +2919,7 @@ Once the war file is working, you can make it executable by adding a `main` meth ==== If you intend to start your application as a war or as an executable application, you need to share the customizations of the builder in a method that is both available to the `SpringBootServletInitializer` callback and in the `main` method in a class similar to the following: -[source,java,indent=0,subs="verbatim,quotes,attributes"] +[source,java,pending-extract=true,indent=0,subs="verbatim,quotes,attributes"] ---- @SpringBootApplication public class Application extends SpringBootServletInitializer { @@ -2969,7 +2969,7 @@ To deploy a Spring Boot application to WebLogic, you must ensure that your servl A typical initializer for WebLogic should resemble the following example: -[source,java,indent=0,subs="verbatim,quotes,attributes"] +[source,java,pending-extract=true,indent=0,subs="verbatim,quotes,attributes"] ---- import org.springframework.boot.autoconfigure.SpringBootApplication; import org.springframework.boot.web.servlet.support.SpringBootServletInitializer; @@ -3052,7 +3052,7 @@ It integrates with JUnit, allowing you to write a test class that can start up a Testcontainers is especially useful for writing integration tests that talk to a real backend service such as MySQL, MongoDB, Cassandra etc. Testcontainers can be used in a Spring Boot test as follows: -[source,java,indent=0,subs="verbatim,quotes,attributes"] +[source,java,pending-extract=true,indent=0,subs="verbatim,quotes,attributes"] ---- @SpringBootTest @Testcontainers @@ -3069,7 +3069,7 @@ In most cases, you will need to configure the application using details from the This can be done with a static `@DynamicPropertySource` method that allows adding dynamic property values to the Spring Environment. -[source,java,indent=0,subs="verbatim,quotes,attributes"] +[source,java,pending-extract=true,indent=0,subs="verbatim,quotes,attributes"] ---- @SpringBootTest @Testcontainers diff --git a/spring-boot-project/spring-boot-docs/src/docs/asciidoc/production-ready-features.adoc b/spring-boot-project/spring-boot-docs/src/docs/asciidoc/production-ready-features.adoc index 60d683371295..e3fd322882ab 100644 --- a/spring-boot-project/spring-boot-docs/src/docs/asciidoc/production-ready-features.adoc +++ b/spring-boot-project/spring-boot-docs/src/docs/asciidoc/production-ready-features.adoc @@ -357,7 +357,7 @@ If you wish to configure custom security for HTTP endpoints, for example, only a A typical Spring Security configuration might look something like the following example: -[source,java,indent=0] +[source,java,pending-extract=true,indent=0] ---- @Bean public SecurityFilterChain securityFilterChain(HttpSecurity http) throws Exception { @@ -386,7 +386,7 @@ You can do so by changing the configprop:management.endpoints.web.exposure.inclu 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: -[source,java,indent=0] +[source,java,pending-extract=true,indent=0] ---- @Bean public SecurityFilterChain securityFilterChain(HttpSecurity http) throws Exception { @@ -776,7 +776,7 @@ You need to provide an implementation of the `health()` method and return a `Hea The `Health` response should include a status and can optionally include additional details to be displayed. The following code shows a sample `HealthIndicator` implementation: -[source,java,indent=0] +[source,java,pending-extract=true,indent=0] ---- import org.springframework.boot.actuate.health.Health; import org.springframework.boot.actuate.health.HealthIndicator; @@ -870,7 +870,7 @@ If you need to register a regular `HealthContributor`, you should wrap it using To provide custom health information from a reactive API, you can register Spring beans that implement the {spring-boot-actuator-module-code}/health/ReactiveHealthIndicator.java[`ReactiveHealthIndicator`] interface. The following code shows a sample `ReactiveHealthIndicator` implementation: -[source,java,indent=0] +[source,java,pending-extract=true,indent=0] ---- @Component public class MyReactiveHealthIndicator implements ReactiveHealthIndicator { @@ -1226,7 +1226,7 @@ To provide custom application information, you can register Spring beans that im The following example contributes an `example` entry with a single value: -[source,java,indent=0] +[source,java,pending-extract=true,indent=0] ---- import java.util.Collections; @@ -1612,7 +1612,7 @@ Spring Boot will also add any auto-configured registries to the global static co 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: -[source,java,indent=0] +[source,java,pending-extract=true,indent=0] ---- @Bean MeterRegistryCustomizer metricsCommonTags() { @@ -1622,7 +1622,7 @@ You can register any number of `MeterRegistryCustomizer` beans to further config You can apply customizations to particular registry implementations by being more specific about the generic type: -[source,java,indent=0] +[source,java,pending-extract=true,indent=0] ---- @Bean MeterRegistryCustomizer graphiteMetricsNamingConvention() { @@ -1780,12 +1780,12 @@ Micrometer provides a default `HierarchicalNameMapper` that governs how a dimens TIP: To take control over this behaviour, define your `GraphiteMeterRegistry` and supply your own `HierarchicalNameMapper`. An auto-configured `GraphiteConfig` and `Clock` beans are provided unless you define your own: -[source,java] +[source,java,pending-extract=true,indent=0] ---- -@Bean -public GraphiteMeterRegistry graphiteMeterRegistry(GraphiteConfig config, Clock clock) { - return new GraphiteMeterRegistry(config, clock, MY_HIERARCHICAL_MAPPER); -} + @Bean + public GraphiteMeterRegistry graphiteMeterRegistry(GraphiteConfig config, Clock clock) { + return new GraphiteMeterRegistry(config, clock, MY_HIERARCHICAL_MAPPER); + } ---- @@ -1855,12 +1855,12 @@ Micrometer provides a default `HierarchicalNameMapper` that governs how a dimens TIP: To take control over this behaviour, define your `JmxMeterRegistry` and supply your own `HierarchicalNameMapper`. An auto-configured `JmxConfig` and `Clock` beans are provided unless you define your own: -[source,java] +[source,java,pending-extract=true,indent=0] ---- -@Bean -public JmxMeterRegistry jmxMeterRegistry(JmxConfig config, Clock clock) { - return new JmxMeterRegistry(config, clock, MY_HIERARCHICAL_MAPPER); -} + @Bean + public JmxMeterRegistry jmxMeterRegistry(JmxConfig config, Clock clock) { + return new JmxMeterRegistry(config, clock, MY_HIERARCHICAL_MAPPER); + } ---- @@ -2128,7 +2128,7 @@ Auto-configuration enables the instrumentation of requests handled by Spring MVC When `management.metrics.web.server.request.autotime.enabled` is `true`, this instrumentation occurs for all requests. Alternatively, when set to `false`, you can enable instrumentation by adding `@Timed` to a request-handling method: -[source,java,indent=0] +[source,java,pending-extract=true,indent=0] ---- @RestController @Timed <1> @@ -2217,7 +2217,7 @@ When Micrometer's `micrometer-jersey2` module is on the classpath, auto-configur When `management.metrics.web.server.request.autotime.enabled` is `true`, this instrumentation occurs for all requests. Alternatively, when set to `false`, you can enable instrumentation by adding `@Timed` to a request-handling method: -[source,java,indent=0] +[source,java,pending-extract=true,indent=0] ---- @Component @Path("/api/people") diff --git a/spring-boot-project/spring-boot-docs/src/docs/asciidoc/spring-boot-cli.adoc b/spring-boot-project/spring-boot-docs/src/docs/asciidoc/spring-boot-cli.adoc index 33fbb59ef58d..dfd82eda5e5e 100644 --- a/spring-boot-project/spring-boot-docs/src/docs/asciidoc/spring-boot-cli.adoc +++ b/spring-boot-project/spring-boot-docs/src/docs/asciidoc/spring-boot-cli.adoc @@ -209,7 +209,7 @@ The preceding declaration picks up `custom-bom-1.0.0.pom` in a Maven repository When you specify multiple BOMs, they are applied in the order in which you declare them, as shown in the following example: -[source,java,indent=0] +[source,java,pending-extract=true,indent=0] ---- @DependencyManagementBom(["com.example.custom-bom:1.0.0", "com.example.another-bom:1.0.0"]) diff --git a/spring-boot-project/spring-boot-docs/src/docs/asciidoc/spring-boot-features.adoc b/spring-boot-project/spring-boot-docs/src/docs/asciidoc/spring-boot-features.adoc index 88721e271f37..86ae9c684fe2 100644 --- a/spring-boot-project/spring-boot-docs/src/docs/asciidoc/spring-boot-features.adoc +++ b/spring-boot-project/spring-boot-docs/src/docs/asciidoc/spring-boot-features.adoc @@ -13,7 +13,7 @@ If you have not already done so, you might want to read the "<` from `AcmeProperties`: -[source,java,indent=0] +[source,java,pending-extract=true,indent=0] ---- @ConfigurationProperties("acme") public class AcmeProperties { @@ -1784,7 +1784,7 @@ Spring Boot attempts to validate `@ConfigurationProperties` classes whenever the You can use JSR-303 `javax.validation` constraint annotations directly on your configuration class. To do so, ensure that a compliant JSR-303 implementation is on your classpath and then add constraint annotations to your fields, as shown in the following example: -[source,java,indent=0] +[source,java,pending-extract=true,indent=0] ---- @ConfigurationProperties(prefix="acme") @Validated @@ -1803,7 +1803,7 @@ TIP: You can also trigger validation by annotating the `@Bean` method that creat To ensure that validation is always triggered for nested properties, even when no properties are found, the associated field must be annotated with `@Valid`. The following example builds on the preceding `AcmeProperties` example: -[source,java,indent=0] +[source,java,pending-extract=true,indent=0] ---- @ConfigurationProperties(prefix="acme") @Validated @@ -1881,7 +1881,7 @@ If the value of a property from an application property file is a `SpEL` express Spring Profiles provide a way to segregate parts of your application configuration and make it be available only in certain environments. Any `@Component`, `@Configuration` or `@ConfigurationProperties` can be marked with `@Profile` to limit when it is loaded, as shown in the following example: -[source,java,indent=0] +[source,java,pending-extract=true,indent=0] ---- @Configuration(proxyBeanMethods = false) @Profile("production") @@ -2522,7 +2522,7 @@ Methods in your controller are mapped to HTTP by using `@RequestMapping` annotat The following code shows a typical `@RestController` that serves JSON data: -[source,java,indent=0] +[source,java,pending-extract=true,indent=0] ---- @RestController @RequestMapping(value="/users") @@ -2591,7 +2591,7 @@ By default, strings are encoded in `UTF-8`. If you need to add or customize converters, you can use Spring Boot's `HttpMessageConverters` class, as shown in the following listing: -[source,java,indent=0] +[source,java,pending-extract=true,indent=0] ---- import org.springframework.boot.autoconfigure.http.HttpMessageConverters; import org.springframework.context.annotation.*; @@ -2623,7 +2623,7 @@ Custom serializers are usually https://github.com/FasterXML/jackson-docs/wiki/Ja You can use the `@JsonComponent` annotation directly on `JsonSerializer`, `JsonDeserializer` or `KeyDeserializer` implementations. You can also use it on classes that contain serializers/deserializers as inner classes, as shown in the following example: -[source,java,indent=0] +[source,java,pending-extract=true,indent=0] ---- import java.io.*; import com.fasterxml.jackson.core.*; @@ -2888,7 +2888,7 @@ To do so, extend `BasicErrorController`, add a public method with a `@RequestMap You can also define a class annotated with `@ControllerAdvice` to customize the JSON document to return for a particular controller and/or exception type, as shown in the following example: -[source,java,indent=0,subs="verbatim,quotes,attributes"] +[source,java,pending-extract=true,indent=0,subs="verbatim,quotes,attributes"] ---- @ControllerAdvice(basePackageClasses = AcmeController.class) public class AcmeControllerAdvice extends ResponseEntityExceptionHandler { @@ -2953,7 +2953,7 @@ To map all `5xx` errors by using a FreeMarker template, your directory structure For more complex mappings, you can also add beans that implement the `ErrorViewResolver` interface, as shown in the following example: -[source,java,indent=0,subs="verbatim,quotes,attributes"] +[source,java,pending-extract=true,indent=0,subs="verbatim,quotes,attributes"] ---- public class MyErrorViewResolver implements ErrorViewResolver { @@ -2978,7 +2978,7 @@ The `ErrorController` then picks up any unhandled exceptions. For applications that do not use Spring MVC, you can use the `ErrorPageRegistrar` interface to directly register `ErrorPages`. This abstraction works directly with the underlying embedded servlet container and works even if you do not have a Spring MVC `DispatcherServlet`. -[source,java,indent=0,subs="verbatim,quotes,attributes"] +[source,java,pending-extract=true,indent=0,subs="verbatim,quotes,attributes"] ---- @Bean public ErrorPageRegistrar errorPageRegistrar(){ @@ -2999,7 +2999,7 @@ This abstraction works directly with the underlying embedded servlet container a NOTE: If you register an `ErrorPage` with a path that ends up being handled by a `Filter` (as is common with some non-Spring web frameworks, like Jersey and Wicket), then the `Filter` has to be explicitly registered as an `ERROR` dispatcher, as shown in the following example: -[source,java,indent=0,subs="verbatim,quotes,attributes"] +[source,java,pending-extract=true,indent=0,subs="verbatim,quotes,attributes"] ---- @Bean public FilterRegistrationBean myFilter() { @@ -3050,7 +3050,7 @@ As of version 4.2, Spring MVC {spring-framework-docs}/web.html#mvc-cors[supports Using {spring-framework-docs}/web.html#mvc-cors-controller[controller method CORS configuration] with {spring-framework-api}/web/bind/annotation/CrossOrigin.html[`@CrossOrigin`] annotations in your Spring Boot application does not require any specific configuration. {spring-framework-docs}/web.html#mvc-cors-global[Global CORS configuration] can be defined by registering a `WebMvcConfigurer` bean with a customized `addCorsMappings(CorsRegistry)` method, as shown in the following example: -[source,java,indent=0] +[source,java,pending-extract=true,indent=0] ---- @Configuration(proxyBeanMethods = false) public class MyConfiguration { @@ -3077,7 +3077,7 @@ Unlike Spring MVC, it does not require the Servlet API, is fully asynchronous an 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: -[source,java,indent=0] +[source,java,pending-extract=true,indent=0] ---- @RestController @RequestMapping("/users") @@ -3103,7 +3103,7 @@ The annotation-based one is quite close to the Spring MVC model, as shown in the "`WebFlux.fn`", the functional variant, separates the routing configuration from the actual handling of the requests, as shown in the following example: -[source,java,indent=0] +[source,java,pending-extract=true,indent=0] ---- @Configuration(proxyBeanMethods = false) public class RoutingConfiguration { @@ -3173,7 +3173,7 @@ For example, `+spring.jackson.*+` configuration keys are applied to the Jackson If you need to add or customize codecs, you can create a custom `CodecCustomizer` component, as shown in the following example: -[source,java,indent=0] +[source,java,pending-extract=true,indent=0] ---- import org.springframework.boot.web.codec.CodecCustomizer; @@ -3258,7 +3258,7 @@ 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: -[source,java,indent=0,subs="verbatim,quotes,attributes"] +[source,java,pending-extract=true,indent=0,subs="verbatim,quotes,attributes"] ---- public class CustomErrorWebExceptionHandler extends AbstractErrorWebExceptionHandler { @@ -3350,7 +3350,7 @@ Jersey has some native Spring support, so we also provide auto-configuration sup To get started with Jersey, include the `spring-boot-starter-jersey` as a dependency and then you need one `@Bean` of type `ResourceConfig` in which you register all the endpoints, as shown in the following example: -[source,java,indent=0,subs="verbatim,quotes,attributes"] +[source,java,pending-extract=true,indent=0,subs="verbatim,quotes,attributes"] ---- @Component public class JerseyConfig extends ResourceConfig { @@ -3370,7 +3370,7 @@ For more advanced customizations, you can also register an arbitrary number of b All the registered endpoints should be `@Components` with HTTP resource annotations (`@GET` and others), as shown in the following example: -[source,java,indent=0,subs="verbatim,quotes,attributes"] +[source,java,pending-extract=true,indent=0,subs="verbatim,quotes,attributes"] ---- @Component @Path("/hello") @@ -3493,7 +3493,7 @@ If you need to programmatically configure your embedded servlet container, you c `WebServerFactoryCustomizer` provides access to the `ConfigurableServletWebServerFactory`, which includes numerous customization setter methods. The following example shows programmatically setting the port: -[source,java,indent=0] +[source,java,pending-extract=true,indent=0] ---- import org.springframework.boot.web.server.WebServerFactoryCustomizer; import org.springframework.boot.web.servlet.server.ConfigurableServletWebServerFactory; @@ -3683,7 +3683,7 @@ This is done on purpose since this builder is stateful and you shouldn't create The following code shows a typical example: -[source,java,indent=0] +[source,java,pending-extract=true,indent=0] ---- @Service public class MyService { @@ -3767,7 +3767,7 @@ Spring Boot provides convenience methods that can be used to override access rul For example, you can customize your security configuration by adding something like: -[source,java,indent=0] +[source,java,pending-extract=true,indent=0] ---- include::{include-springbootfeatures}/security/CustomWebFluxSecurityConfiguration.java[tag=*] ---- @@ -3846,7 +3846,7 @@ By default, Spring Security's `OAuth2LoginAuthenticationFilter` only processes U If you want to customize the `redirect-uri` to use a different pattern, you need to provide configuration to process that custom pattern. For example, for servlet applications, you can add your own `SecurityFilterChain` that resembles the following: -[source,java,indent=0] +[source,java,pending-extract=true,indent=0] ---- @Bean public SecurityFilterChain securityFilterChain(HttpSecurity http) throws Exception { @@ -4170,7 +4170,7 @@ For example, the following section in `application.properties` shows how you can === Using JdbcTemplate Spring's `JdbcTemplate` and `NamedParameterJdbcTemplate` classes are auto-configured, and you can `@Autowire` them directly into your own beans, as shown in the following example: -[source,java,indent=0] +[source,java,pending-extract=true,indent=0] ---- import org.springframework.beans.factory.annotation.Autowired; import org.springframework.jdbc.core.JdbcTemplate; @@ -4230,7 +4230,7 @@ By default, all packages below your main configuration class (the one annotated Any classes annotated with `@Entity`, `@Embeddable`, or `@MappedSuperclass` are considered. A typical entity class resembles the following example: -[source,java,indent=0] +[source,java,pending-extract=true,indent=0] ---- package com.example.myapp.domain; @@ -4293,7 +4293,7 @@ If you use auto-configuration, repositories are searched from the package contai The following example shows a typical Spring Data repository interface definition: -[source,java,indent=0] +[source,java,pending-extract=true,indent=0] ---- package com.example.myapp.domain; @@ -4438,7 +4438,7 @@ The fluent API offered by jOOQ is initiated through the `org.jooq.DSLContext` in Spring Boot auto-configures a `DSLContext` as a Spring Bean and connects it to your application `DataSource`. To use the `DSLContext`, you can `@Autowire` it, as shown in the following example: -[source,java,indent=0] +[source,java,pending-extract=true,indent=0] ---- @Component public class JooqExample implements CommandLineRunner { @@ -4457,7 +4457,7 @@ TIP: The jOOQ manual tends to use a variable named `create` to hold the `DSLCont You can then use the `DSLContext` to construct your queries, as shown in the following example: -[source,java,indent=0] +[source,java,pending-extract=true,indent=0] ---- public List authorsBornAfter1980() { return this.create.selectFrom(AUTHOR) @@ -4512,7 +4512,7 @@ TIP: The "`How-to`" section includes a < cacheManagerCustomizer() { @@ -5844,7 +5844,7 @@ You can use the configprop:spring.jms.jndi-name[] property if you need to specif ==== Sending a Message Spring's `JmsTemplate` is auto-configured, and you can autowire it directly into your own beans, as shown in the following example: -[source,java,indent=0] +[source,java,pending-extract=true,indent=0] ---- import org.springframework.beans.factory.annotation.Autowired; import org.springframework.jms.core.JmsTemplate; @@ -5885,7 +5885,7 @@ This also includes sending response messages that have been performed on the sam The following component creates a listener endpoint on the `someQueue` destination: -[source,java,indent=0] +[source,java,pending-extract=true,indent=0] ---- @Component public class MyBean { @@ -5904,7 +5904,7 @@ If you need to create more `JmsListenerContainerFactory` instances or if you wan For instance, the following example exposes another factory that uses a specific `MessageConverter`: -[source,java,indent=0] +[source,java,pending-extract=true,indent=0] ---- @Configuration(proxyBeanMethods = false) static class JmsConfiguration { @@ -5924,8 +5924,7 @@ For instance, the following example exposes another factory that uses a specific Then you can use the factory in any `@JmsListener`-annotated method as follows: -[source,java,indent=0] -[subs="verbatim,quotes"] +[source,java,pending-extract=true,indent=0,subs="verbatim,quotes"] ---- @Component public class MyBean { @@ -5989,7 +5988,7 @@ TIP: See https://spring.io/blog/2010/06/14/understanding-amqp-the-protocol-used- ==== Sending a Message Spring's `AmqpTemplate` and `AmqpAdmin` are auto-configured, and you can autowire them directly into your own beans, as shown in the following example: -[source,java,indent=0] +[source,java,pending-extract=true,indent=0] ---- import org.springframework.amqp.core.AmqpAdmin; import org.springframework.amqp.core.AmqpTemplate; @@ -6045,7 +6044,7 @@ If a `MessageConverter` or a `MessageRecoverer` bean is defined, it is automatic The following sample component creates a listener endpoint on the `someQueue` queue: -[source,java,indent=0] +[source,java,pending-extract=true,indent=0] ---- @Component public class MyBean { @@ -6067,7 +6066,7 @@ Those two beans are exposed by the auto-configuration. For instance, the following configuration class exposes another factory that uses a specific `MessageConverter`: -[source,java,indent=0] +[source,java,pending-extract=true,indent=0] ---- @Configuration(proxyBeanMethods = false) static class RabbitConfiguration { @@ -6087,7 +6086,7 @@ For instance, the following configuration class exposes another factory that use Then you can use the factory in any `@RabbitListener`-annotated method, as follows: -[source,java,indent=0] +[source,java,pending-extract=true,indent=0] [subs="verbatim,quotes"] ---- @Component @@ -6140,7 +6139,7 @@ See {spring-boot-autoconfigure-module-code}/kafka/KafkaProperties.java[`KafkaPro ==== Sending a Message Spring's `KafkaTemplate` is auto-configured, and you can autowire it directly in your own beans, as shown in the following example: -[source,java,indent=0] +[source,java,pending-extract=true,indent=0] ---- @Component public class MyBean { @@ -6169,7 +6168,7 @@ If no `KafkaListenerContainerFactory` has been defined, a default one is automat The following component creates a listener endpoint on the `someTopic` topic: -[source,java,indent=0] +[source,java,pending-extract=true,indent=0] ---- @Component public class MyBean { @@ -6291,7 +6290,7 @@ There are several ways to do that: * Provide a system property to map embedded broker addresses into configprop:spring.kafka.bootstrap-servers[] in the test class: -[source,java,indent=0] +[source,java,pending-extract=true,indent=0] ---- static { System.setProperty(EmbeddedKafkaBroker.BROKER_LIST_PROPERTY, "spring.kafka.bootstrap-servers"); @@ -6300,7 +6299,7 @@ There are several ways to do that: * Configure a property name on the `@EmbeddedKafka` annotation: -[source,java,indent=0] +[source,java,pending-extract=true,indent=0] ---- @EmbeddedKafka(topics = "someTopic", bootstrapServersProperty = "spring.kafka.bootstrap-servers") @@ -6326,7 +6325,7 @@ The auto-configured `RestTemplateBuilder` ensures that sensible `HttpMessageConv The following code shows a typical example: -[source,java,indent=0] +[source,java,pending-extract=true,indent=0] ---- @Service public class MyService { @@ -6391,7 +6390,7 @@ Spring Boot is configuring that builder to share HTTP resources, reflect codecs The following code shows a typical example: -[source,java,indent=0] +[source,java,pending-extract=true,indent=0] ---- @Service public class MyService { @@ -6452,7 +6451,7 @@ Target classes with such annotated methods need to be annotated with the `@Valid For instance, the following service triggers the validation of the first argument, making sure its size is between 8 and 10: -[source,java,indent=0] +[source,java,pending-extract=true,indent=0] ---- @Service @Validated @@ -6552,7 +6551,7 @@ For consistency, the `jmsConnectionFactory` bean is also provided by using the b The following example shows how to inject `ConnectionFactory` instances: -[source,java,indent=0,subs="verbatim,quotes,attributes"] +[source,java,pending-extract=true,indent=0,subs="verbatim,quotes,attributes"] ---- // Inject the primary (XA aware) ConnectionFactory @Autowired @@ -6670,7 +6669,7 @@ If you need to customize the task executor, consider implementing `SchedulerFact Jobs can define setters to inject data map properties. Regular beans can also be injected in a similar manner, as shown in the following example: -[source,java,indent=0] +[source,java,pending-extract=true,indent=0] ---- public class SampleJob extends QuartzJobBean { @@ -6954,7 +6953,7 @@ If you have only Spring WebFlux, we'll detect that and configure a WebFlux-based If both are present, Spring MVC takes precedence. If you want to test a reactive web application in this scenario, you must set the configprop:spring.main.web-application-type[] property: -[source,java,indent=0] +[source,java,pending-extract=true,indent=0] ---- @SpringBootTest(properties = "spring.main.web-application-type=reactive") class MyWebFluxTests { ... } @@ -6998,7 +6997,7 @@ As we < assertThat(number.floatValue()).isCloseTo(0.15f, within(0.01f))); + assertThat(json.write(message)) + .extractingJsonPathNumberValue("@.test.numberValue") + .satisfies((number) -> assertThat(number.floatValue()).isCloseTo(0.15f, within(0.01f))); ---- @@ -7301,7 +7300,7 @@ Mock MVC offers a powerful way to quickly test MVC controllers without needing t TIP: You can also auto-configure `MockMvc` in a non-`@WebMvcTest` (such as `@SpringBootTest`) by annotating it with `@AutoConfigureMockMvc`. The following example uses `MockMvc`: -[source,java,indent=0] +[source,java,pending-extract=true,indent=0] ---- import org.junit.jupiter.api.*; import org.springframework.beans.factory.annotation.*; @@ -7338,7 +7337,7 @@ TIP: If you need to configure elements of the auto-configuration (for example, w If you use HtmlUnit or Selenium, auto-configuration also provides an HtmlUnit `WebClient` bean and/or a Selenium `WebDriver` bean. The following example uses HtmlUnit: -[source,java,indent=0] +[source,java,pending-extract=true,indent=0] ---- import com.gargoylesoftware.htmlunit.*; import org.junit.jupiter.api.*; @@ -7401,7 +7400,7 @@ Often, `@WebFluxTest` is limited to a single controller and used in combination TIP: You can also auto-configure `WebTestClient` in a non-`@WebFluxTest` (such as `@SpringBootTest`) by annotating it with `@AutoConfigureWebTestClient`. The following example shows a class that uses both `@WebFluxTest` and a `WebTestClient`: -[source,java,indent=0] +[source,java,pending-extract=true,indent=0] ---- import org.junit.jupiter.api.Test; @@ -7456,7 +7455,7 @@ TIP: A list of the auto-configuration settings that are enabled by `@DataCassand The following example shows a typical setup for using Cassandra tests in Spring Boot: -[source,java,indent=0] +[source,java,pending-extract=true,indent=0] ---- import org.springframework.beans.factory.annotation.Autowired; import org.springframework.boot.test.autoconfigure.data.cassandra.DataCassandraTest; @@ -7487,7 +7486,7 @@ By default, data JPA tests are transactional and roll back at the end of each te See the {spring-framework-docs}/testing.html#testcontext-tx-enabling-transactions[relevant section] in the Spring Framework Reference Documentation for more details. If that is not what you want, you can disable transaction management for a test or for the whole class as follows: -[source,java,indent=0] +[source,java,pending-extract=true,indent=0] ---- import org.junit.jupiter.api.Test; import org.springframework.boot.test.autoconfigure.orm.jpa.DataJpaTest; @@ -7506,7 +7505,7 @@ If you want to use `TestEntityManager` outside of `@DataJpaTest` instances, you A `JdbcTemplate` is also available if you need that. The following example shows the `@DataJpaTest` annotation in use: -[source,java,indent=0] +[source,java,pending-extract=true,indent=0] ---- import org.junit.jupiter.api.Test; import org.springframework.boot.test.autoconfigure.orm.jpa.*; @@ -7536,7 +7535,7 @@ The following example shows the `@DataJpaTest` annotation in use: In-memory embedded databases generally work well for tests, since they are fast and do not require any installation. If, however, you prefer to run tests against a real database you can use the `@AutoConfigureTestDatabase` annotation, as shown in the following example: -[source,java,indent=0] +[source,java,pending-extract=true,indent=0] ---- @DataJpaTest @AutoConfigureTestDatabase(replace=Replace.NONE) @@ -7562,7 +7561,7 @@ By default, JDBC tests are transactional and roll back at the end of each test. See the {spring-framework-docs}/testing.html#testcontext-tx-enabling-transactions[relevant section] in the Spring Framework Reference Documentation for more details. If that is not what you want, you can disable transaction management for a test or for the whole class, as follows: -[source,java,indent=0] +[source,java,pending-extract=true,indent=0] ---- import org.junit.jupiter.api.Test; import org.springframework.boot.test.autoconfigure.jdbc.JdbcTest; @@ -7613,7 +7612,7 @@ TIP: A list of the auto-configurations that are enabled by `@JooqTest` can be << `@JooqTest` configures a `DSLContext`. The following example shows the `@JooqTest` annotation in use: -[source,java,indent=0] +[source,java,pending-extract=true,indent=0] ---- import org.jooq.DSLContext; import org.junit.jupiter.api.Test; @@ -7644,7 +7643,7 @@ TIP: A list of the auto-configuration settings that are enabled by `@DataMongoTe The following class shows the `@DataMongoTest` annotation in use: -[source,java,indent=0] +[source,java,pending-extract=true,indent=0] ---- import org.springframework.beans.factory.annotation.Autowired; import org.springframework.boot.test.autoconfigure.data.mongo.DataMongoTest; @@ -7663,7 +7662,7 @@ The following class shows the `@DataMongoTest` annotation in use: In-memory embedded MongoDB generally works well for tests, since it is fast and does not require any developer installation. If, however, you prefer to run tests against a real MongoDB server, you should exclude the embedded MongoDB auto-configuration, as shown in the following example: -[source,java,indent=0] +[source,java,pending-extract=true,indent=0] ---- import org.springframework.boot.autoconfigure.mongo.embedded.EmbeddedMongoAutoConfiguration; import org.springframework.boot.test.autoconfigure.data.mongo.DataMongoTest; @@ -7688,7 +7687,7 @@ TIP: A list of the auto-configuration settings that are enabled by `@DataNeo4jTe The following example shows a typical setup for using Neo4J tests in Spring Boot: -[source,java,indent=0] +[source,java,pending-extract=true,indent=0] ---- import org.springframework.beans.factory.annotation.Autowired; import org.springframework.boot.test.autoconfigure.data.neo4j.DataNeo4jTest; @@ -7707,7 +7706,7 @@ By default, Data Neo4j tests are transactional and roll back at the end of each See the {spring-framework-docs}/testing.html#testcontext-tx-enabling-transactions[relevant section] in the Spring Framework Reference Documentation for more details. If that is not what you want, you can disable transaction management for a test or for the whole class, as follows: -[source,java,indent=0] +[source,java,pending-extract=true,indent=0] ---- import org.springframework.boot.test.autoconfigure.data.neo4j.DataNeo4jTest; import org.springframework.transaction.annotation.Propagation; @@ -7737,7 +7736,7 @@ TIP: A list of the auto-configuration settings that are enabled by `@DataRedisTe The following example shows the `@DataRedisTest` annotation in use: -[source,java,indent=0] +[source,java,pending-extract=true,indent=0] ---- import org.springframework.beans.factory.annotation.Autowired; import org.springframework.boot.test.autoconfigure.data.redis.DataRedisTest; @@ -7766,7 +7765,7 @@ TIP: A list of the auto-configuration settings that are enabled by `@DataLdapTes The following example shows the `@DataLdapTest` annotation in use: -[source,java,indent=0] +[source,java,pending-extract=true,indent=0] ---- import org.springframework.beans.factory.annotation.Autowired; import org.springframework.boot.test.autoconfigure.data.ldap.DataLdapTest; @@ -7785,7 +7784,7 @@ The following example shows the `@DataLdapTest` annotation in use: In-memory embedded LDAP generally works well for tests, since it is fast and does not require any developer installation. If, however, you prefer to run tests against a real LDAP server, you should exclude the embedded LDAP auto-configuration, as shown in the following example: -[source,java,indent=0] +[source,java,pending-extract=true,indent=0] ---- import org.springframework.boot.autoconfigure.ldap.embedded.EmbeddedLdapAutoConfiguration; import org.springframework.boot.test.autoconfigure.data.ldap.DataLdapTest; @@ -7809,7 +7808,7 @@ TIP: A list of the auto-configuration settings that are enabled by `@RestClientT The specific beans that you want to test should be specified by using the `value` or `components` attribute of `@RestClientTest`, as shown in the following example: -[source,java,indent=0] +[source,java,pending-extract=true,indent=0] ---- @RestClientTest(RemoteVehicleDetailsService.class) class ExampleRestClientTest { @@ -7849,7 +7848,7 @@ It can also be used to configure the host, scheme, and port that appears in any `@AutoConfigureRestDocs` customizes the `MockMvc` bean to use Spring REST Docs when testing Servlet-based web applications. You can inject it by using `@Autowired` and use it in your tests as you normally would when using Mock MVC and Spring REST Docs, as shown in the following example: -[source,java,indent=0] +[source,java,pending-extract=true,indent=0] ---- import org.junit.jupiter.api.Test; @@ -7881,7 +7880,7 @@ You can inject it by using `@Autowired` and use it in your tests as you normally If you require more control over Spring REST Docs configuration than offered by the attributes of `@AutoConfigureRestDocs`, you can use a `RestDocsMockMvcConfigurationCustomizer` bean, as shown in the following example: -[source,java,indent=0] +[source,java,pending-extract=true,indent=0] ---- @TestConfiguration static class CustomizationConfiguration @@ -7899,7 +7898,7 @@ If you want to make use of Spring REST Docs support for a parameterized output d The auto-configuration calls `alwaysDo` with this result handler, thereby causing each `MockMvc` call to automatically generate the default snippets. The following example shows a `RestDocumentationResultHandler` being defined: -[source,java,indent=0] +[source,java,pending-extract=true,indent=0] ---- @TestConfiguration(proxyBeanMethods = false) static class ResultHandlerConfiguration { @@ -7963,7 +7962,7 @@ TIP: A list of the auto-configuration settings that are enabled by `@WebServiceC The following example shows the `@WebServiceClientTest` annotation in use: -[source,java,indent=0] +[source,java,pending-extract=true,indent=0] ---- @WebServiceClientTest(ExampleWebServiceClient.class) class WebServiceClientIntegrationTests { @@ -7991,7 +7990,7 @@ The following example shows the `@WebServiceClientTest` annotation in use: Each slice provides one or more `@AutoConfigure...` annotations that namely defines the auto-configurations that should be included as part of a slice. Additional auto-configurations can be added on a test-by-test basis by creating a custom `@AutoConfigure...` annotation or by adding `@ImportAutoConfiguration` to the test as shown in the following example: -[source,java,indent=0] +[source,java,pending-extract=true,indent=0] ---- @JdbcTest @ImportAutoConfiguration(IntegrationAutoConfiguration.class) @@ -8022,7 +8021,7 @@ It then becomes important not to litter the application's main class with config Assume that you are using Spring Batch and you rely on the auto-configuration for it. You could define your `@SpringBootApplication` as follows: -[source,java,indent=0] +[source,java,pending-extract=true,indent=0] ---- @SpringBootApplication @EnableBatchProcessing @@ -8032,7 +8031,7 @@ You could define your `@SpringBootApplication` as follows: 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: -[source,java,indent=0] +[source,java,pending-extract=true,indent=0] ---- @Configuration(proxyBeanMethods = false) @EnableBatchProcessing @@ -8045,7 +8044,7 @@ The latter approach lets you enable it in one of your tests, if necessary, with Test slices exclude `@Configuration` classes from scanning. For example, for a `@WebMvcTest`, the following configuration will not include the given `WebMvcConfigurer` bean in the application context loaded by the test slice: -[source,java,indent=0] +[source,java,pending-extract=true,indent=0] ---- @Configuration public class WebConfiguration { @@ -8060,7 +8059,7 @@ For example, for a `@WebMvcTest`, the following configuration will not include t The configuration below will, however, cause the custom `WebMvcConfigurer` to be loaded by the test slice. -[source,java,indent=0] +[source,java,pending-extract=true,indent=0] ---- @Component public class TestWebMvcConfigurer implements WebMvcConfigurer { @@ -8072,7 +8071,7 @@ 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: -[source,java,indent=0] +[source,java,pending-extract=true,indent=0] ---- @SpringBootApplication @ComponentScan({ "com.example.app", "org.acme.another" }) @@ -8110,7 +8109,7 @@ A few test utility classes that are generally useful when testing your applicati `ConfigFileApplicationContextInitializer` is an `ApplicationContextInitializer` that you can apply to your tests to load Spring Boot `application.properties` files. You can use it when you do not need the full set of features provided by `@SpringBootTest`, as shown in the following example: -[source,java,indent=0] +[source,java,pending-extract=true,indent=0] ---- @ContextConfiguration(classes = Config.class, initializers = ConfigFileApplicationContextInitializer.class) @@ -8127,7 +8126,7 @@ For `@Value` support, you need to either additionally configure a `PropertySourc `TestPropertyValues` lets you quickly add properties to a `ConfigurableEnvironment` or `ConfigurableApplicationContext`. You can call it with `key=value` strings, as follows: -[source,java,indent=0] +[source,java,pending-extract=true,indent=0] ---- TestPropertyValues.of("org=Spring", "name=Boot").applyTo(env); ---- @@ -8164,7 +8163,7 @@ If you do use Apache's HTTP client, some additional test-friendly features are e `TestRestTemplate` can be instantiated directly in your integration tests, as shown in the following example: -[source,java,indent=0] +[source,java,pending-extract=true,indent=0] ---- public class MyTest { @@ -8237,7 +8236,7 @@ It does, however, auto-configure a `WebServiceTemplateBuilder`, which can be use The following code shows a typical example: -[source,java,indent=0] +[source,java,pending-extract=true,indent=0] ---- @Service public class MyService { @@ -8258,7 +8257,7 @@ The following code shows a typical example: By default, `WebServiceTemplateBuilder` detects a suitable HTTP-based `WebServiceMessageSender` using the available HTTP client libraries on the classpath. You can also customize read and connection timeouts as follows: -[source,java,indent=0] +[source,java,pending-extract=true,indent=0] ---- @Bean public WebServiceTemplate webServiceTemplate(WebServiceTemplateBuilder builder) { @@ -8347,7 +8346,7 @@ This mechanism does not apply the same way to `@Bean` methods where typically th To handle this scenario, a separate `@Configuration` class can be used to isolate the condition, as shown in the following example: -[source,java,indent=0] +[source,java,pending-extract=true,indent=0] ---- @Configuration(proxyBeanMethods = false) // Some conditions @@ -8380,7 +8379,7 @@ The `search` attribute lets you limit the `ApplicationContext` hierarchy that sh When placed on a `@Bean` method, the target type defaults to the return type of the method, as shown in the following example: -[source,java,indent=0] +[source,java,pending-extract=true,indent=0] ---- @Configuration(proxyBeanMethods = false) public class MyAutoConfiguration { @@ -8475,7 +8474,7 @@ The runner can also be used to display the `ConditionEvaluationReport`. The report can be printed at `INFO` or `DEBUG` level. The following example shows how to use the `ConditionEvaluationReportLoggingListener` to print the report in auto-configuration tests. -[source,java,indent=0] +[source,java,pending-extract=true,indent=0] ---- @Test void autoConfigTest() { @@ -8549,7 +8548,7 @@ As a rule of thumb, prefix all your keys with a namespace that you own (e.g. `ac Make sure that configuration keys are documented by adding field javadoc for each property, as shown in the following example: -[source,java,indent=0] +[source,java,pending-extract=true,indent=0] ---- @ConfigurationProperties("acme") public class AcmeProperties { diff --git a/spring-boot-project/spring-boot-docs/src/docs/asciidoc/using-spring-boot.adoc b/spring-boot-project/spring-boot-docs/src/docs/asciidoc/using-spring-boot.adoc index e66c218ae499..3e0d42f654bf 100644 --- a/spring-boot-project/spring-boot-docs/src/docs/asciidoc/using-spring-boot.adoc +++ b/spring-boot-project/spring-boot-docs/src/docs/asciidoc/using-spring-boot.adoc @@ -209,7 +209,7 @@ The following listing shows a typical layout: The `Application.java` file would declare the `main` method, along with the basic `@SpringBootApplication`, as follows: -[source,java,indent=0] +[source,java,pending-extract=true,indent=0] ---- package com.example.myapplication; @@ -282,7 +282,7 @@ Doing so enables debug logs for a selection of core loggers and logs a condition === Disabling Specific Auto-configuration Classes If you find that specific auto-configuration classes that you do not want are being applied, you can use the exclude attribute of `@SpringBootApplication` to disable them, as shown in the following example: -[source,java,indent=0] +[source,java,pending-extract=true,indent=0] ---- import org.springframework.boot.autoconfigure.*; import org.springframework.boot.autoconfigure.jdbc.*; @@ -313,7 +313,7 @@ All of your application components (`@Component`, `@Service`, `@Repository`, `@C The following example shows a `@Service` Bean that uses constructor injection to obtain a required `RiskAssessor` bean: -[source,java,indent=0] +[source,java,pending-extract=true,indent=0] ---- package com.example.service; @@ -337,7 +337,7 @@ The following example shows a `@Service` Bean that uses constructor injection to If a bean has one constructor, you can omit the `@Autowired`, as shown in the following example: -[source,java,indent=0] +[source,java,pending-extract=true,indent=0] ---- @Service public class DatabaseAccountService implements AccountService { @@ -366,7 +366,7 @@ A single `@SpringBootApplication` annotation can be used to enable those three f * `@ComponentScan`: enable `@Component` scan on the package where the application is located (see <>) * `@Configuration`: allow to register extra beans in the context or import additional configuration classes -[source,java,indent=0] +[source,java,pending-extract=true,indent=0] ---- package com.example.myapplication; @@ -390,7 +390,7 @@ NOTE: `@SpringBootApplication` also provides aliases to customize the attributes None of these features are mandatory and you may choose to replace this single annotation by any of the features that it enables. For instance, you may not want to use component scan or configuration properties scan in your application: -[source,java,indent=0] +[source,java,pending-extract=true,indent=0] ---- package com.example.myapplication; @@ -593,7 +593,7 @@ The way in which you cause the classpath to be updated depends on the IDE that y * In Eclipse, saving a modified file causes the classpath to be updated and triggers a restart. * In IntelliJ IDEA, building the project (`Build +->+ Build Project`) has the same effect. -* If using a build plugin, running `mvn compile` for Maven or `gradle build` for Gradle will trigger a restart. +* If using a build plugin, running `mvn compile` for Maven or `gradle build` for Gradle will trigger a restart. **** NOTE: If you are restarting with Maven or Gradle using the build plugin you must leave the `forking` set to `enabled`. @@ -677,7 +677,7 @@ In most cases, you can set this property in your `application.properties` (doing If you need to _completely_ disable restart support (for example, because it does not work with a specific library), you need to set the configprop:spring.devtools.restart.enabled[] `System` property to `false` before calling `SpringApplication.run(...)`, as shown in the following example: -[source,java,indent=0] +[source,java,pending-extract=true,indent=0] ---- public static void main(String[] args) { System.setProperty("spring.devtools.restart.enabled", "false"); From b2a51e4504e4072e4a75875a6eef4a7c12c487cb Mon Sep 17 00:00:00 2001 From: Phillip Webb Date: Wed, 3 Feb 2021 17:45:18 -0800 Subject: [PATCH 06/13] Polish asciidoctor formatting --- .../src/docs/asciidoc/spring-boot-features.adoc | 3 --- 1 file changed, 3 deletions(-) diff --git a/spring-boot-project/spring-boot-docs/src/docs/asciidoc/spring-boot-features.adoc b/spring-boot-project/spring-boot-docs/src/docs/asciidoc/spring-boot-features.adoc index 86ae9c684fe2..a8e5658c3c52 100644 --- a/spring-boot-project/spring-boot-docs/src/docs/asciidoc/spring-boot-features.adoc +++ b/spring-boot-project/spring-boot-docs/src/docs/asciidoc/spring-boot-features.adoc @@ -8901,14 +8901,12 @@ Disable launch script configuration when building a jar file that is intended to Here’s how you can launch your jar with a `layertools` jar mode: -[source] ---- $ java -Djarmode=layertools -jar my-app.jar ---- This will provide the following output: -[source] ---- Usage: java -Djarmode=layertools -jar my-app.jar @@ -8922,7 +8920,6 @@ Available commands: The `extract` command can be used to easily split the application into layers to be added to the dockerfile. Here's an example of a Dockerfile using `jarmode`. -[source] ---- FROM adoptopenjdk:11-jre-hotspot as builder WORKDIR application From 9f6f2d36df5ccda9c09301b91cc2d14d911776d2 Mon Sep 17 00:00:00 2001 From: Phillip Webb Date: Wed, 3 Feb 2021 17:52:40 -0800 Subject: [PATCH 07/13] Polish documented application logged output Update the documented application output based on the latest version. --- .../src/docs/asciidoc/spring-boot-features.adoc | 16 ++++++++++++---- 1 file changed, 12 insertions(+), 4 deletions(-) diff --git a/spring-boot-project/spring-boot-docs/src/docs/asciidoc/spring-boot-features.adoc b/spring-boot-project/spring-boot-docs/src/docs/asciidoc/spring-boot-features.adoc index a8e5658c3c52..5343e4a922dd 100644 --- a/spring-boot-project/spring-boot-docs/src/docs/asciidoc/spring-boot-features.adoc +++ b/spring-boot-project/spring-boot-docs/src/docs/asciidoc/spring-boot-features.adoc @@ -32,12 +32,20 @@ When your application starts, you should see something similar to the following =========|_|==============|___/=/_/_/_/ :: Spring Boot :: v{spring-boot-version} -2019-04-31 13:09:54.117 INFO 56603 --- [ main] o.s.b.s.app.SampleApplication : Starting SampleApplication v0.1.0 on mycomputer with PID 56603 (/apps/myapp.jar started by pwebb) -2019-04-31 13:09:54.166 INFO 56603 --- [ main] ationConfigServletWebServerApplicationContext : Refreshing org.springframework.boot.web.servlet.context.AnnotationConfigServletWebServerApplicationContext@6e5a8246: startup date [Wed Jul 31 00:08:16 PDT 2013]; root of context hierarchy -2019-04-01 13:09:56.912 INFO 41370 --- [ main] .t.TomcatServletWebServerFactory : Server initialized with port: 8080 -2019-04-01 13:09:57.501 INFO 41370 --- [ main] o.s.b.s.app.SampleApplication : Started SampleApplication in 2.992 seconds (JVM running for 3.658) +2021-02-03 10:33:25.224 INFO 17321 --- [ main] o.s.b.d.s.s.SpringAppplicationExample : Starting SpringAppplicationExample using Java 1.8.0_232 on mycomputer with PID 17321 (/apps/myjar.jar started by pwebb) +2021-02-03 10:33:25.226 INFO 17900 --- [ main] o.s.b.d.s.s.SpringAppplicationExample : No active profile set, falling back to default profiles: default +2021-02-03 10:33:26.046 INFO 17321 --- [ main] o.s.b.w.embedded.tomcat.TomcatWebServer : Tomcat initialized with port(s): 8080 (http) +2021-02-03 10:33:26.054 INFO 17900 --- [ main] o.apache.catalina.core.StandardService : Starting service [Tomcat] +2021-02-03 10:33:26.055 INFO 17900 --- [ main] org.apache.catalina.core.StandardEngine : Starting Servlet engine: [Apache Tomcat/9.0.41] +2021-02-03 10:33:26.097 INFO 17900 --- [ main] o.a.c.c.C.[Tomcat].[localhost].[/] : Initializing Spring embedded WebApplicationContext +2021-02-03 10:33:26.097 INFO 17900 --- [ main] w.s.c.ServletWebServerApplicationContext : Root WebApplicationContext: initialization completed in 821 ms +2021-02-03 10:33:26.144 INFO 17900 --- [ main] s.tomcat.SampleTomcatApplication : ServletContext initialized +2021-02-03 10:33:26.376 INFO 17900 --- [ main] o.s.b.w.embedded.tomcat.TomcatWebServer : Tomcat started on port(s): 8080 (http) with context path '' +2021-02-03 10:33:26.384 INFO 17900 --- [ main] o.s.b.d.s.s.SpringAppplicationExample : Started SampleTomcatApplication in 1.514 seconds (JVM running for 1.823) ---- + + By default, `INFO` logging messages are shown, including some relevant startup details, such as the user that launched the application. If you need a log level other than `INFO`, you can set it, as described in <>. The application version is determined using the implementation version from the main application class's package. From e0392c45583ce52c6ea7ef772d6fa52f8d5e45a9 Mon Sep 17 00:00:00 2001 From: Phillip Webb Date: Wed, 3 Feb 2021 17:51:32 -0800 Subject: [PATCH 08/13] Add additional dependencies for example code Add additional dependencies useful for the example code. See gh-6313 --- spring-boot-project/spring-boot-docs/build.gradle | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/spring-boot-project/spring-boot-docs/build.gradle b/spring-boot-project/spring-boot-docs/build.gradle index cb7dbd9c7907..2128ada0636a 100644 --- a/spring-boot-project/spring-boot-docs/build.gradle +++ b/spring-boot-project/spring-boot-docs/build.gradle @@ -69,17 +69,21 @@ dependencies { implementation(project(path: ":spring-boot-project:spring-boot-autoconfigure")) implementation(project(path: ":spring-boot-project:spring-boot-test")) implementation(project(path: ":spring-boot-project:spring-boot-test-autoconfigure")) + implementation("ch.qos.logback:logback-classic") implementation("com.zaxxer:HikariCP") implementation("io.micrometer:micrometer-core") implementation("io.projectreactor.netty:reactor-netty-http") implementation("io.undertow:undertow-core") + implementation("jakarta.annotation:jakarta.annotation-api") implementation("jakarta.servlet:jakarta.servlet-api") implementation("org.apache.commons:commons-dbcp2") implementation("org.apache.kafka:kafka-streams") + implementation("org.apache.logging.log4j:log4j-to-slf4j") implementation("org.apache.tomcat.embed:tomcat-embed-core") implementation("org.assertj:assertj-core") implementation("org.glassfish.jersey.core:jersey-server") implementation("org.hibernate:hibernate-jcache") + implementation("org.slf4j:jul-to-slf4j") implementation("org.springframework:spring-test") implementation("org.springframework:spring-web") implementation("org.springframework:spring-webflux") @@ -93,6 +97,7 @@ dependencies { implementation("org.springframework.security:spring-security-config") implementation("org.springframework.security:spring-security-web") implementation("org.junit.jupiter:junit-jupiter") + implementation("org.yaml:snakeyaml") mavenPluginDocumentation(project(path: ":spring-boot-project:spring-boot-tools:spring-boot-maven-plugin", configuration: "documentation")) From 0e326d6b0f35b3ab311d7e4eb14c44049f088897 Mon Sep 17 00:00:00 2001 From: Phillip Webb Date: Wed, 3 Feb 2021 17:53:29 -0800 Subject: [PATCH 09/13] Extract some code samples from docs See gh-6313 --- .../docs/asciidoc/spring-boot-features.adoc | 248 ++---------------- .../constructorbinding/AcmeProperties.java | 84 ++++++ .../nonnull/AcmeProperties.java | 84 ++++++ .../javabeanbinding/AcmeProperties.java | 91 +++++++ .../valueinjection/MyBean.java | 32 +++ .../ApplicationArgumentsExample.java | 38 +++ .../CommandLineRunnerExample.java | 32 +++ .../availability/LocalCacheVerifier.java | 48 ++++ .../availability/ReadinessStateExporter.java | 41 +++ .../main/custom/MyApplication.java | 34 +++ .../main/run/MyApplication.java | 31 +++ .../startup/MyApplication.java | 34 +++ 12 files changed, 571 insertions(+), 226 deletions(-) create mode 100644 spring-boot-project/spring-boot-docs/src/main/java/org/springframework/boot/docs/springbootfeatures/externalizedconfiguration/constructorbinding/AcmeProperties.java create mode 100644 spring-boot-project/spring-boot-docs/src/main/java/org/springframework/boot/docs/springbootfeatures/externalizedconfiguration/constructorbinding/nonnull/AcmeProperties.java create mode 100644 spring-boot-project/spring-boot-docs/src/main/java/org/springframework/boot/docs/springbootfeatures/externalizedconfiguration/javabeanbinding/AcmeProperties.java create mode 100644 spring-boot-project/spring-boot-docs/src/main/java/org/springframework/boot/docs/springbootfeatures/externalizedconfiguration/valueinjection/MyBean.java create mode 100644 spring-boot-project/spring-boot-docs/src/main/java/org/springframework/boot/docs/springbootfeatures/springapplication/ApplicationArgumentsExample.java create mode 100644 spring-boot-project/spring-boot-docs/src/main/java/org/springframework/boot/docs/springbootfeatures/springapplication/CommandLineRunnerExample.java create mode 100644 spring-boot-project/spring-boot-docs/src/main/java/org/springframework/boot/docs/springbootfeatures/springapplication/availability/LocalCacheVerifier.java create mode 100644 spring-boot-project/spring-boot-docs/src/main/java/org/springframework/boot/docs/springbootfeatures/springapplication/availability/ReadinessStateExporter.java create mode 100644 spring-boot-project/spring-boot-docs/src/main/java/org/springframework/boot/docs/springbootfeatures/springapplication/main/custom/MyApplication.java create mode 100644 spring-boot-project/spring-boot-docs/src/main/java/org/springframework/boot/docs/springbootfeatures/springapplication/main/run/MyApplication.java create mode 100644 spring-boot-project/spring-boot-docs/src/main/java/org/springframework/boot/docs/springbootfeatures/springapplication/startup/MyApplication.java diff --git a/spring-boot-project/spring-boot-docs/src/docs/asciidoc/spring-boot-features.adoc b/spring-boot-project/spring-boot-docs/src/docs/asciidoc/spring-boot-features.adoc index 5343e4a922dd..6123756b13b0 100644 --- a/spring-boot-project/spring-boot-docs/src/docs/asciidoc/spring-boot-features.adoc +++ b/spring-boot-project/spring-boot-docs/src/docs/asciidoc/spring-boot-features.adoc @@ -13,11 +13,9 @@ If you have not already done so, you might want to read the "< event) { - switch (event.getState()) { - case ACCEPTING_TRAFFIC: - // create file /tmp/healthy - break; - case REFUSING_TRAFFIC: - // remove file /tmp/healthy - break; - } - } - - } +include::{include-springbootfeatures}/springapplication/availability/ReadinessStateExporter.java[tag=*] ---- We can also update the state of the application, when the application breaks and cannot recover: -[source,java,pending-extract=true,indent=0] +[source,java,indent=0] ---- - @Component - public class LocalCacheVerifier { - - private final ApplicationEventPublisher eventPublisher; - - public LocalCacheVerifier(ApplicationEventPublisher eventPublisher) { - this.eventPublisher = eventPublisher; - } - - public void checkLocalCache() { - try { - //... - } - catch (CacheCompletelyBrokenException ex) { - AvailabilityChangeEvent.publish(this.eventPublisher, ex, LivenessState.BROKEN); - } - } - - } +include::{include-springbootfeatures}/springapplication/availability/LocalCacheVerifier.java[tag=*] ---- Spring Boot provides <>. @@ -380,23 +341,9 @@ TIP: It is often desirable to call `setWebApplicationType(WebApplicationType.NON If you need to access the application arguments that were passed to `SpringApplication.run(...)`, you can inject a `org.springframework.boot.ApplicationArguments` bean. The `ApplicationArguments` interface provides access to both the raw `String[]` arguments as well as parsed `option` and `non-option` arguments, as shown in the following example: -[source,java,pending-extract=true,indent=0] +[source,java,indent=0] ---- - import org.springframework.boot.*; - import org.springframework.beans.factory.annotation.*; - import org.springframework.stereotype.*; - - @Component - public class MyBean { - - @Autowired - public MyBean(ApplicationArguments args) { - boolean debug = args.containsOption("debug"); - List files = args.getNonOptionArgs(); - // if run with "--debug logfile.txt" debug=true, files=["logfile.txt"] - } - - } +include::{include-springbootfeatures}/springapplication/ApplicationArgumentsExample.java[tag=*] ---- TIP: Spring Boot also registers a `CommandLinePropertySource` with the Spring `Environment`. @@ -415,19 +362,9 @@ NOTE: This contract is well suited for tasks that should run after application s The `CommandLineRunner` interfaces provides access to application arguments as a string array, whereas the `ApplicationRunner` uses the `ApplicationArguments` interface discussed earlier. The following example shows a `CommandLineRunner` with a `run` method: -[source,java,pending-extract=true,indent=0] +[source,java,indent=0] ---- - import org.springframework.boot.*; - import org.springframework.stereotype.*; - - @Component - public class MyBean implements CommandLineRunner { - - public void run(String... args) { - // Do something... - } - - } +include::{include-springbootfeatures}/springapplication/CommandLineRunnerExample.java[tag=*] ---- If several `CommandLineRunner` or `ApplicationRunner` beans are defined that must be called in a specific order, you can additionally implement the `org.springframework.core.Ordered` interface or use the `org.springframework.core.annotation.Order` annotation. @@ -473,13 +410,9 @@ This data can be collected for profiling purposes, or just to have a better unde You can choose an `ApplicationStartup` implementation when setting up the `SpringApplication` instance. For example, to use the `BufferingApplicationStartup`, you could write: -[source,java,pending-extract=true,indent=0] +[source,java,indent=0] ---- - public static void main(String[] args) { - SpringApplication app = new SpringApplication(MySpringConfiguration.class); - app.setApplicationStartup(new BufferingApplicationStartup(2048)); - app.run(args); - } +include::{include-springbootfeatures}/springapplication/startup/MyApplication.java[tag=*] ---- The first available implementation, `FlightRecorderApplicationStartup` is provided by Spring Framework. @@ -532,20 +465,9 @@ Config data files are considered in the following order: To provide a concrete example, suppose you develop a `@Component` that uses a `name` property, as shown in the following example: -[source,java,pending-extract=true,indent=0] +[source,java,indent=0] ---- - import org.springframework.stereotype.*; - import org.springframework.beans.factory.annotation.*; - - @Component - public class MyBean { - - @Value("${name}") - private String name; - - // ... - - } +include::{include-springbootfeatures}/externalizedconfiguration/valueinjection/MyBean.java[tag=*] ---- On your application classpath (for example, inside your jar) you can have an `application.properties` file that provides a sensible default property value for `name`. @@ -1115,58 +1037,9 @@ TIP: See also the < roles = new ArrayList<>(Collections.singleton("USER")); - - public String getUsername() { ... } - - public void setUsername(String username) { ... } - - public String getPassword() { ... } - - public void setPassword(String password) { ... } - - public List getRoles() { ... } - - public void setRoles(List roles) { ... } - - } - } +include::{include-springbootfeatures}/externalizedconfiguration/javabeanbinding/AcmeProperties.java[tag=*] ---- The preceding POJO defines the following properties: @@ -1205,63 +1078,9 @@ Finally, only standard Java Bean properties are considered and binding on static ==== Constructor binding The example in the previous section can be rewritten in an immutable fashion as shown in the following example: -[source,java,pending-extract=true,indent=0] +[source,java,indent=0] ---- - package com.example; - - import java.net.InetAddress; - import java.util.List; - - import org.springframework.boot.context.properties.ConfigurationProperties; - import org.springframework.boot.context.properties.ConstructorBinding; - import org.springframework.boot.context.properties.bind.DefaultValue; - - @ConstructorBinding - @ConfigurationProperties("acme") - public class AcmeProperties { - - private final boolean enabled; - - private final InetAddress remoteAddress; - - private final Security security; - - public AcmeProperties(boolean enabled, InetAddress remoteAddress, Security security) { - this.enabled = enabled; - this.remoteAddress = remoteAddress; - this.security = security; - } - - public boolean isEnabled() { ... } - - public InetAddress getRemoteAddress() { ... } - - public Security getSecurity() { ... } - - public static class Security { - - private final String username; - - private final String password; - - private final List roles; - - public Security(String username, String password, - @DefaultValue("USER") List roles) { - this.username = username; - this.password = password; - this.roles = roles; - } - - public String getUsername() { ... } - - public String getPassword() { ... } - - public List getRoles() { ... } - - } - - } +include::{include-springbootfeatures}/externalizedconfiguration/constructorbinding/AcmeProperties.java[tag=*] ---- In this setup, the `@ConstructorBinding` annotation is used to indicate that constructor binding should be used. @@ -1273,32 +1092,9 @@ Default values can be specified using `@DefaultValue` and the same conversion se By default, if no properties are bound to `Security`, the `AcmeProperties` instance will contain a `null` value for `security`. If you wish you return a non-null instance of `Security` even when no properties are bound to it, you can use an empty `@DefaultValue` annotation to do so: -[source,java,pending-extract=true,indent=0] +[source,java,indent=0] ---- - package com.example; - import java.net.InetAddress; - import java.util.List; - - import org.springframework.boot.context.properties.ConfigurationProperties; - import org.springframework.boot.context.properties.ConstructorBinding; - import org.springframework.boot.context.properties.bind.DefaultValue; - - @ConstructorBinding - @ConfigurationProperties("acme") - public class AcmeProperties { - - private final boolean enabled; - - private final InetAddress remoteAddress; - - private final Security security; - - public AcmeProperties(boolean enabled, InetAddress remoteAddress, @DefaultValue Security security) { - this.enabled = enabled; - this.remoteAddress = remoteAddress; - this.security = security; - } - } +include::{include-springbootfeatures}/externalizedconfiguration/constructorbinding/nonnull/AcmeProperties.java[tag=*] ---- diff --git a/spring-boot-project/spring-boot-docs/src/main/java/org/springframework/boot/docs/springbootfeatures/externalizedconfiguration/constructorbinding/AcmeProperties.java b/spring-boot-project/spring-boot-docs/src/main/java/org/springframework/boot/docs/springbootfeatures/externalizedconfiguration/constructorbinding/AcmeProperties.java new file mode 100644 index 000000000000..f5794c3653c7 --- /dev/null +++ b/spring-boot-project/spring-boot-docs/src/main/java/org/springframework/boot/docs/springbootfeatures/externalizedconfiguration/constructorbinding/AcmeProperties.java @@ -0,0 +1,84 @@ +/* + * Copyright 2012-2021 the original author or authors. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package org.springframework.boot.docs.springbootfeatures.externalizedconfiguration.constructorbinding; + +//tag::code[] +import java.net.InetAddress; +import java.util.List; + +import org.springframework.boot.context.properties.ConfigurationProperties; +import org.springframework.boot.context.properties.ConstructorBinding; +import org.springframework.boot.context.properties.bind.DefaultValue; + +@ConstructorBinding +@ConfigurationProperties("acme") +public class AcmeProperties { + + private final boolean enabled; + + private final InetAddress remoteAddress; + + private final Security security; + + public AcmeProperties(boolean enabled, InetAddress remoteAddress, Security security) { + this.enabled = enabled; + this.remoteAddress = remoteAddress; + this.security = security; + } + + public boolean isEnabled() { + return this.enabled; + } + + public InetAddress getRemoteAddress() { + return this.remoteAddress; + } + + public Security getSecurity() { + return this.security; + } + + public static class Security { + + private final String username; + + private final String password; + + private final List roles; + + public Security(String username, String password, @DefaultValue("USER") List roles) { + this.username = username; + this.password = password; + this.roles = roles; + } + + public String getUsername() { + return this.username; + } + + public String getPassword() { + return this.password; + } + + public List getRoles() { + return this.roles; + } + + } + +} +// end::code[] diff --git a/spring-boot-project/spring-boot-docs/src/main/java/org/springframework/boot/docs/springbootfeatures/externalizedconfiguration/constructorbinding/nonnull/AcmeProperties.java b/spring-boot-project/spring-boot-docs/src/main/java/org/springframework/boot/docs/springbootfeatures/externalizedconfiguration/constructorbinding/nonnull/AcmeProperties.java new file mode 100644 index 000000000000..19aaf5ff87e1 --- /dev/null +++ b/spring-boot-project/spring-boot-docs/src/main/java/org/springframework/boot/docs/springbootfeatures/externalizedconfiguration/constructorbinding/nonnull/AcmeProperties.java @@ -0,0 +1,84 @@ +/* + * Copyright 2012-2021 the original author or authors. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package org.springframework.boot.docs.springbootfeatures.externalizedconfiguration.constructorbinding.nonnull; + +import java.net.InetAddress; +import java.util.List; + +import org.springframework.boot.context.properties.ConfigurationProperties; +import org.springframework.boot.context.properties.ConstructorBinding; +import org.springframework.boot.context.properties.bind.DefaultValue; + +@ConstructorBinding +@ConfigurationProperties("acme") +public class AcmeProperties { + + private final boolean enabled; + + private final InetAddress remoteAddress; + + private final Security security; + + // tag::code[] + public AcmeProperties(boolean enabled, InetAddress remoteAddress, @DefaultValue Security security) { + this.enabled = enabled; + this.remoteAddress = remoteAddress; + this.security = security; + } + // end::code[] + + public boolean isEnabled() { + return this.enabled; + } + + public InetAddress getRemoteAddress() { + return this.remoteAddress; + } + + public Security getSecurity() { + return this.security; + } + + public static class Security { + + private final String username; + + private final String password; + + private final List roles; + + public Security(String username, String password, @DefaultValue("USER") List roles) { + this.username = username; + this.password = password; + this.roles = roles; + } + + public String getUsername() { + return this.username; + } + + public String getPassword() { + return this.password; + } + + public List getRoles() { + return this.roles; + } + + } + +} diff --git a/spring-boot-project/spring-boot-docs/src/main/java/org/springframework/boot/docs/springbootfeatures/externalizedconfiguration/javabeanbinding/AcmeProperties.java b/spring-boot-project/spring-boot-docs/src/main/java/org/springframework/boot/docs/springbootfeatures/externalizedconfiguration/javabeanbinding/AcmeProperties.java new file mode 100644 index 000000000000..a994f5de38ca --- /dev/null +++ b/spring-boot-project/spring-boot-docs/src/main/java/org/springframework/boot/docs/springbootfeatures/externalizedconfiguration/javabeanbinding/AcmeProperties.java @@ -0,0 +1,91 @@ +/* + * Copyright 2012-2021 the original author or authors. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package org.springframework.boot.docs.springbootfeatures.externalizedconfiguration.javabeanbinding; + +//tag::code[] +import java.net.InetAddress; +import java.util.ArrayList; +import java.util.Collections; +import java.util.List; + +import org.springframework.boot.context.properties.ConfigurationProperties; + +@ConfigurationProperties("acme") +public class AcmeProperties { + + private boolean enabled; + + private InetAddress remoteAddress; + + private final Security security = new Security(); + + public boolean isEnabled() { + return this.enabled; + } + + public void setEnabled(boolean enabled) { + this.enabled = enabled; + } + + public InetAddress getRemoteAddress() { + return this.remoteAddress; + } + + public void setRemoteAddress(InetAddress remoteAddress) { + this.remoteAddress = remoteAddress; + } + + public Security getSecurity() { + return this.security; + } + + public static class Security { + + private String username; + + private String password; + + private List roles = new ArrayList<>(Collections.singleton("USER")); + + public String getUsername() { + return this.username; + } + + public void setUsername(String username) { + this.username = username; + } + + public String getPassword() { + return this.password; + } + + public void setPassword(String password) { + this.password = password; + } + + public List getRoles() { + return this.roles; + } + + public void setRoles(List roles) { + this.roles = roles; + } + + } + +} +// end::code[] diff --git a/spring-boot-project/spring-boot-docs/src/main/java/org/springframework/boot/docs/springbootfeatures/externalizedconfiguration/valueinjection/MyBean.java b/spring-boot-project/spring-boot-docs/src/main/java/org/springframework/boot/docs/springbootfeatures/externalizedconfiguration/valueinjection/MyBean.java new file mode 100644 index 000000000000..f2a388ca71e8 --- /dev/null +++ b/spring-boot-project/spring-boot-docs/src/main/java/org/springframework/boot/docs/springbootfeatures/externalizedconfiguration/valueinjection/MyBean.java @@ -0,0 +1,32 @@ +/* + * Copyright 2012-2021 the original author or authors. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package org.springframework.boot.docs.springbootfeatures.externalizedconfiguration.valueinjection; + +// tag::code[] +import org.springframework.beans.factory.annotation.Value; +import org.springframework.stereotype.Component; + +@Component +public class MyBean { + + @Value("${name}") + private String name; + + // ... + +} +// end::code[] diff --git a/spring-boot-project/spring-boot-docs/src/main/java/org/springframework/boot/docs/springbootfeatures/springapplication/ApplicationArgumentsExample.java b/spring-boot-project/spring-boot-docs/src/main/java/org/springframework/boot/docs/springbootfeatures/springapplication/ApplicationArgumentsExample.java new file mode 100644 index 000000000000..55d895f82623 --- /dev/null +++ b/spring-boot-project/spring-boot-docs/src/main/java/org/springframework/boot/docs/springbootfeatures/springapplication/ApplicationArgumentsExample.java @@ -0,0 +1,38 @@ +/* + * Copyright 2012-2021 the original author or authors. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package org.springframework.boot.docs.springbootfeatures.springapplication; + +//tag::code[] +import java.util.List; + +import org.springframework.boot.ApplicationArguments; +import org.springframework.stereotype.Component; + +@Component +public class ApplicationArgumentsExample { + + public ApplicationArgumentsExample(ApplicationArguments args) { + boolean debug = args.containsOption("debug"); + List files = args.getNonOptionArgs(); + if (debug) { + System.out.println(files); + } + // if run with "--debug logfile.txt" prints ["logfile.txt"] + } + +} +// end::code[] diff --git a/spring-boot-project/spring-boot-docs/src/main/java/org/springframework/boot/docs/springbootfeatures/springapplication/CommandLineRunnerExample.java b/spring-boot-project/spring-boot-docs/src/main/java/org/springframework/boot/docs/springbootfeatures/springapplication/CommandLineRunnerExample.java new file mode 100644 index 000000000000..e082045d67d2 --- /dev/null +++ b/spring-boot-project/spring-boot-docs/src/main/java/org/springframework/boot/docs/springbootfeatures/springapplication/CommandLineRunnerExample.java @@ -0,0 +1,32 @@ +/* + * Copyright 2012-2021 the original author or authors. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package org.springframework.boot.docs.springbootfeatures.springapplication; + +//tag::code[] +import org.springframework.boot.CommandLineRunner; +import org.springframework.stereotype.Component; + +@Component +public class CommandLineRunnerExample implements CommandLineRunner { + + @Override + public void run(String... args) { + // Do something... + } + +} +// end::code[] diff --git a/spring-boot-project/spring-boot-docs/src/main/java/org/springframework/boot/docs/springbootfeatures/springapplication/availability/LocalCacheVerifier.java b/spring-boot-project/spring-boot-docs/src/main/java/org/springframework/boot/docs/springbootfeatures/springapplication/availability/LocalCacheVerifier.java new file mode 100644 index 000000000000..1fd7fbb4064d --- /dev/null +++ b/spring-boot-project/spring-boot-docs/src/main/java/org/springframework/boot/docs/springbootfeatures/springapplication/availability/LocalCacheVerifier.java @@ -0,0 +1,48 @@ +/* + * Copyright 2012-2021 the original author or authors. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package org.springframework.boot.docs.springbootfeatures.springapplication.availability; + +//tag::code[] +import org.springframework.boot.availability.AvailabilityChangeEvent; +import org.springframework.boot.availability.LivenessState; +import org.springframework.context.ApplicationEventPublisher; +import org.springframework.stereotype.Component; + +@Component +public class LocalCacheVerifier { + + private final ApplicationEventPublisher eventPublisher; + + public LocalCacheVerifier(ApplicationEventPublisher eventPublisher) { + this.eventPublisher = eventPublisher; + } + + public void checkLocalCache() { + try { + // ... + } + catch (CacheCompletelyBrokenException ex) { + AvailabilityChangeEvent.publish(this.eventPublisher, ex, LivenessState.BROKEN); + } + } + +} +// end::code[] + +class CacheCompletelyBrokenException extends RuntimeException { + +} diff --git a/spring-boot-project/spring-boot-docs/src/main/java/org/springframework/boot/docs/springbootfeatures/springapplication/availability/ReadinessStateExporter.java b/spring-boot-project/spring-boot-docs/src/main/java/org/springframework/boot/docs/springbootfeatures/springapplication/availability/ReadinessStateExporter.java new file mode 100644 index 000000000000..4b82ecf8d31d --- /dev/null +++ b/spring-boot-project/spring-boot-docs/src/main/java/org/springframework/boot/docs/springbootfeatures/springapplication/availability/ReadinessStateExporter.java @@ -0,0 +1,41 @@ +/* + * Copyright 2012-2021 the original author or authors. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package org.springframework.boot.docs.springbootfeatures.springapplication.availability; + +// tag::code[] +import org.springframework.boot.availability.AvailabilityChangeEvent; +import org.springframework.boot.availability.ReadinessState; +import org.springframework.context.event.EventListener; +import org.springframework.stereotype.Component; + +@Component +public class ReadinessStateExporter { + + @EventListener + public void onStateChange(AvailabilityChangeEvent event) { + switch (event.getState()) { + case ACCEPTING_TRAFFIC: + // create file /tmp/healthy + break; + case REFUSING_TRAFFIC: + // remove file /tmp/healthy + break; + } + } + +} +// end::code[] diff --git a/spring-boot-project/spring-boot-docs/src/main/java/org/springframework/boot/docs/springbootfeatures/springapplication/main/custom/MyApplication.java b/spring-boot-project/spring-boot-docs/src/main/java/org/springframework/boot/docs/springbootfeatures/springapplication/main/custom/MyApplication.java new file mode 100644 index 000000000000..40f8f32e3f9f --- /dev/null +++ b/spring-boot-project/spring-boot-docs/src/main/java/org/springframework/boot/docs/springbootfeatures/springapplication/main/custom/MyApplication.java @@ -0,0 +1,34 @@ +/* + * Copyright 2012-2021 the original author or authors. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package org.springframework.boot.docs.springbootfeatures.springapplication.main.custom; + +import org.springframework.boot.Banner; +import org.springframework.boot.SpringApplication; +import org.springframework.boot.autoconfigure.SpringBootApplication; + +@SpringBootApplication +public class MyApplication { + + // tag::code[] + public static void main(String[] args) { + SpringApplication application = new SpringApplication(MyApplication.class); + application.setBannerMode(Banner.Mode.OFF); + application.run(args); + } + // end::code[] + +} diff --git a/spring-boot-project/spring-boot-docs/src/main/java/org/springframework/boot/docs/springbootfeatures/springapplication/main/run/MyApplication.java b/spring-boot-project/spring-boot-docs/src/main/java/org/springframework/boot/docs/springbootfeatures/springapplication/main/run/MyApplication.java new file mode 100644 index 000000000000..07d9b0ceffed --- /dev/null +++ b/spring-boot-project/spring-boot-docs/src/main/java/org/springframework/boot/docs/springbootfeatures/springapplication/main/run/MyApplication.java @@ -0,0 +1,31 @@ +/* + * Copyright 2012-2021 the original author or authors. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package org.springframework.boot.docs.springbootfeatures.springapplication.main.run; + +import org.springframework.boot.SpringApplication; +import org.springframework.boot.autoconfigure.SpringBootApplication; + +@SpringBootApplication +public class MyApplication { + + // tag::code[] + public static void main(String[] args) { + SpringApplication.run(MyApplication.class, args); + } + // end::code[] + +} diff --git a/spring-boot-project/spring-boot-docs/src/main/java/org/springframework/boot/docs/springbootfeatures/springapplication/startup/MyApplication.java b/spring-boot-project/spring-boot-docs/src/main/java/org/springframework/boot/docs/springbootfeatures/springapplication/startup/MyApplication.java new file mode 100644 index 000000000000..5df88e11ad95 --- /dev/null +++ b/spring-boot-project/spring-boot-docs/src/main/java/org/springframework/boot/docs/springbootfeatures/springapplication/startup/MyApplication.java @@ -0,0 +1,34 @@ +/* + * Copyright 2012-2021 the original author or authors. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package org.springframework.boot.docs.springbootfeatures.springapplication.startup; + +import org.springframework.boot.SpringApplication; +import org.springframework.boot.autoconfigure.SpringBootApplication; +import org.springframework.boot.context.metrics.buffering.BufferingApplicationStartup; + +@SpringBootApplication +public class MyApplication { + + // tag::code[] + public static void main(String[] args) { + SpringApplication application = new SpringApplication(MyApplication.class); + application.setApplicationStartup(new BufferingApplicationStartup(2048)); + application.run(args); + } + // end::code[] + +} From d30251092b3f4805586f67e5cf2084ee80d890df Mon Sep 17 00:00:00 2001 From: Andy Wilkinson Date: Thu, 4 Feb 2021 10:16:48 +0000 Subject: [PATCH 10/13] Test the Gradle Plugin against 7.0-milestone-1 Closes gh-25103 --- .../gradle/junit/GradleCompatibility.java | 4 +++- .../junit/GradleCompatibilityExtension.java | 24 +++++++++++++------ .../MavenPluginActionIntegrationTests.java | 4 ++-- .../tasks/bundling/MavenIntegrationTests.java | 4 ++-- 4 files changed, 24 insertions(+), 12 deletions(-) diff --git a/spring-boot-project/spring-boot-tools/spring-boot-gradle-plugin/src/test/java/org/springframework/boot/gradle/junit/GradleCompatibility.java b/spring-boot-project/spring-boot-tools/spring-boot-gradle-plugin/src/test/java/org/springframework/boot/gradle/junit/GradleCompatibility.java index 73fe2698f06b..9617f0d94de6 100644 --- a/spring-boot-project/spring-boot-tools/spring-boot-gradle-plugin/src/test/java/org/springframework/boot/gradle/junit/GradleCompatibility.java +++ b/spring-boot-project/spring-boot-tools/spring-boot-gradle-plugin/src/test/java/org/springframework/boot/gradle/junit/GradleCompatibility.java @@ -1,5 +1,5 @@ /* - * Copyright 2012-2020 the original author or authors. + * Copyright 2012-2021 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -48,4 +48,6 @@ */ boolean configurationCache() default false; + String versionsLessThan() default ""; + } diff --git a/spring-boot-project/spring-boot-tools/spring-boot-gradle-plugin/src/test/java/org/springframework/boot/gradle/junit/GradleCompatibilityExtension.java b/spring-boot-project/spring-boot-tools/spring-boot-gradle-plugin/src/test/java/org/springframework/boot/gradle/junit/GradleCompatibilityExtension.java index 52238d14ab31..025b42690563 100644 --- a/spring-boot-project/spring-boot-tools/spring-boot-gradle-plugin/src/test/java/org/springframework/boot/gradle/junit/GradleCompatibilityExtension.java +++ b/spring-boot-project/spring-boot-tools/spring-boot-gradle-plugin/src/test/java/org/springframework/boot/gradle/junit/GradleCompatibilityExtension.java @@ -32,6 +32,7 @@ import org.springframework.boot.gradle.testkit.GradleBuild; import org.springframework.boot.gradle.testkit.GradleBuildExtension; +import org.springframework.util.StringUtils; /** * {@link Extension} that runs {@link TestTemplate templated tests} against multiple @@ -48,24 +49,33 @@ final class GradleCompatibilityExtension implements TestTemplateInvocationContex JavaVersion javaVersion = JavaVersion.current(); if (javaVersion.isCompatibleWith(JavaVersion.VERSION_14) || javaVersion.isCompatibleWith(JavaVersion.VERSION_13)) { - GRADLE_VERSIONS = Arrays.asList("6.3", "6.4.1", "6.5.1", "6.6.1", "6.7.1", "current"); + GRADLE_VERSIONS = Arrays.asList("6.3", "6.4.1", "6.5.1", "6.6.1", "6.7.1", "current", "7.0-milestone-1"); } else { - GRADLE_VERSIONS = Arrays.asList("5.6.4", "6.3", "6.4.1", "6.5.1", "6.6.1", "6.7.1", "current"); + GRADLE_VERSIONS = Arrays.asList("5.6.4", "6.3", "6.4.1", "6.5.1", "6.6.1", "6.7.1", "current", + "7.0-milestone-1"); } } @Override public Stream provideTestTemplateInvocationContexts(ExtensionContext context) { - return GRADLE_VERSIONS.stream().flatMap((version) -> { + Stream gradleVersions = GRADLE_VERSIONS.stream().map((version) -> { if (version.equals("current")) { - version = GradleVersion.current().getVersion(); + return GradleVersion.current().getVersion(); } + return version; + }); + GradleCompatibility gradleCompatibility = AnnotationUtils + .findAnnotation(context.getRequiredTestClass(), GradleCompatibility.class).get(); + if (StringUtils.hasText(gradleCompatibility.versionsLessThan())) { + GradleVersion upperExclusive = GradleVersion.version(gradleCompatibility.versionsLessThan()); + gradleVersions = gradleVersions + .filter((version) -> GradleVersion.version(version).compareTo(upperExclusive) < 0); + } + return gradleVersions.flatMap((version) -> { List invocationContexts = new ArrayList<>(); invocationContexts.add(new GradleVersionTestTemplateInvocationContext(version, false)); - boolean configurationCache = AnnotationUtils - .findAnnotation(context.getRequiredTestClass(), GradleCompatibility.class).get() - .configurationCache(); + boolean configurationCache = gradleCompatibility.configurationCache(); if (configurationCache && GradleVersion.version(version).compareTo(GradleVersion.version("6.7")) >= 0) { invocationContexts.add(new GradleVersionTestTemplateInvocationContext(version, true)); } diff --git a/spring-boot-project/spring-boot-tools/spring-boot-gradle-plugin/src/test/java/org/springframework/boot/gradle/plugin/MavenPluginActionIntegrationTests.java b/spring-boot-project/spring-boot-tools/spring-boot-gradle-plugin/src/test/java/org/springframework/boot/gradle/plugin/MavenPluginActionIntegrationTests.java index b6a55b8a91d4..1575799b5a61 100644 --- a/spring-boot-project/spring-boot-tools/spring-boot-gradle-plugin/src/test/java/org/springframework/boot/gradle/plugin/MavenPluginActionIntegrationTests.java +++ b/spring-boot-project/spring-boot-tools/spring-boot-gradle-plugin/src/test/java/org/springframework/boot/gradle/plugin/MavenPluginActionIntegrationTests.java @@ -1,5 +1,5 @@ /* - * Copyright 2012-2020 the original author or authors. + * Copyright 2012-2021 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -28,7 +28,7 @@ * * @author Andy Wilkinson */ -@GradleCompatibility +@GradleCompatibility(versionsLessThan = "7.0-milestone-1") class MavenPluginActionIntegrationTests { GradleBuild gradleBuild; diff --git a/spring-boot-project/spring-boot-tools/spring-boot-gradle-plugin/src/test/java/org/springframework/boot/gradle/tasks/bundling/MavenIntegrationTests.java b/spring-boot-project/spring-boot-tools/spring-boot-gradle-plugin/src/test/java/org/springframework/boot/gradle/tasks/bundling/MavenIntegrationTests.java index 46a9f07b49fc..7f5c9a0dccb1 100644 --- a/spring-boot-project/spring-boot-tools/spring-boot-gradle-plugin/src/test/java/org/springframework/boot/gradle/tasks/bundling/MavenIntegrationTests.java +++ b/spring-boot-project/spring-boot-tools/spring-boot-gradle-plugin/src/test/java/org/springframework/boot/gradle/tasks/bundling/MavenIntegrationTests.java @@ -1,5 +1,5 @@ /* - * Copyright 2012-2020 the original author or authors. + * Copyright 2012-2021 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -34,7 +34,7 @@ * * @author Andy Wilkinson */ -@GradleCompatibility +@GradleCompatibility(versionsLessThan = "7.0-milestone-1") class MavenIntegrationTests { GradleBuild gradleBuild; From 297e3079d003a40b78b081082b6f1251481a229c Mon Sep 17 00:00:00 2001 From: Andy Wilkinson Date: Thu, 4 Feb 2021 10:59:00 +0000 Subject: [PATCH 11/13] Fix handling of UriTemplateRequestEntity in TestRestTemplate A change [1] in Spring Framework 5.3 means that getUrl() on a RequestEntity will throw an UnsupportedOperationException if the entity was created using a template. This commit updates TestRestTemplate to check for instances of UriTemplateRequestEntity and to resolve the URI using the entity's UriTemplateHandler instead of calling getUrl() directly. Fixes gh-25097 [1] https://github.com/spring-projects/spring-framework/commit/a0f4d81db76cb100b8f0da3a3cc8a945a012a2c0 --- .../test/web/client/TestRestTemplate.java | 22 +++++++++++-- .../web/client/TestRestTemplateTests.java | 32 ++++++++++++++++++- 2 files changed, 51 insertions(+), 3 deletions(-) diff --git a/spring-boot-project/spring-boot-test/src/main/java/org/springframework/boot/test/web/client/TestRestTemplate.java b/spring-boot-project/spring-boot-test/src/main/java/org/springframework/boot/test/web/client/TestRestTemplate.java index 435e22a46a94..18ba59787bce 100644 --- a/spring-boot-project/spring-boot-test/src/main/java/org/springframework/boot/test/web/client/TestRestTemplate.java +++ b/spring-boot-project/spring-boot-test/src/main/java/org/springframework/boot/test/web/client/TestRestTemplate.java @@ -1,5 +1,5 @@ /* - * Copyright 2012-2020 the original author or authors. + * Copyright 2012-2021 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -41,6 +41,7 @@ import org.springframework.http.HttpHeaders; import org.springframework.http.HttpMethod; import org.springframework.http.RequestEntity; +import org.springframework.http.RequestEntity.UriTemplateRequestEntity; import org.springframework.http.ResponseEntity; import org.springframework.http.client.ClientHttpRequestFactory; import org.springframework.http.client.ClientHttpResponse; @@ -965,7 +966,7 @@ public TestRestTemplate withBasicAuth(String username, String password) { @SuppressWarnings({ "rawtypes", "unchecked" }) private RequestEntity createRequestEntityWithRootAppliedUri(RequestEntity requestEntity) { return new RequestEntity(requestEntity.getBody(), requestEntity.getHeaders(), requestEntity.getMethod(), - applyRootUriIfNecessary(requestEntity.getUrl()), requestEntity.getType()); + applyRootUriIfNecessary(resolveUri(requestEntity)), requestEntity.getType()); } private URI applyRootUriIfNecessary(URI uri) { @@ -976,6 +977,23 @@ private URI applyRootUriIfNecessary(URI uri) { return uri; } + private URI resolveUri(RequestEntity entity) { + if (entity instanceof UriTemplateRequestEntity) { + UriTemplateRequestEntity templatedUriEntity = (UriTemplateRequestEntity) entity; + if (templatedUriEntity.getVars() != null) { + return this.restTemplate.getUriTemplateHandler().expand(templatedUriEntity.getUriTemplate(), + templatedUriEntity.getVars()); + } + else if (templatedUriEntity.getVarsMap() != null) { + return this.restTemplate.getUriTemplateHandler().expand(templatedUriEntity.getUriTemplate(), + templatedUriEntity.getVarsMap()); + } + throw new IllegalStateException( + "No variables specified for URI template: " + templatedUriEntity.getUriTemplate()); + } + return entity.getUrl(); + } + /** * Options used to customize the Apache HTTP Client. */ diff --git a/spring-boot-project/spring-boot-test/src/test/java/org/springframework/boot/test/web/client/TestRestTemplateTests.java b/spring-boot-project/spring-boot-test/src/test/java/org/springframework/boot/test/web/client/TestRestTemplateTests.java index 341e9fef59ba..fe945952548e 100644 --- a/spring-boot-project/spring-boot-test/src/test/java/org/springframework/boot/test/web/client/TestRestTemplateTests.java +++ b/spring-boot-project/spring-boot-test/src/test/java/org/springframework/boot/test/web/client/TestRestTemplateTests.java @@ -1,5 +1,5 @@ /* - * Copyright 2012-2019 the original author or authors. + * Copyright 2012-2021 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -233,6 +233,36 @@ void withBasicAuthShouldUseNoOpErrorHandler() throws Exception { Class.forName("org.springframework.boot.test.web.client.TestRestTemplate$NoOpResponseErrorHandler")); } + @Test + void exchangeWithRelativeTemplatedUrlRequestEntity() throws Exception { + RequestEntity entity = RequestEntity.get("/a/b/c.{ext}", "txt").build(); + TestRestTemplate template = new TestRestTemplate(); + ClientHttpRequestFactory requestFactory = mock(ClientHttpRequestFactory.class); + MockClientHttpRequest request = new MockClientHttpRequest(); + request.setResponse(new MockClientHttpResponse(new byte[0], HttpStatus.OK)); + URI absoluteUri = URI.create("http://localhost:8080/a/b/c.txt"); + given(requestFactory.createRequest(eq(absoluteUri), eq(HttpMethod.GET))).willReturn(request); + template.getRestTemplate().setRequestFactory(requestFactory); + LocalHostUriTemplateHandler uriTemplateHandler = new LocalHostUriTemplateHandler(new MockEnvironment()); + template.setUriTemplateHandler(uriTemplateHandler); + template.exchange(entity, String.class); + verify(requestFactory).createRequest(eq(absoluteUri), eq(HttpMethod.GET)); + } + + @Test + void exchangeWithAbsoluteTemplatedUrlRequestEntity() throws Exception { + RequestEntity entity = RequestEntity.get("https://api.example.com/a/b/c.{ext}", "txt").build(); + TestRestTemplate template = new TestRestTemplate(); + ClientHttpRequestFactory requestFactory = mock(ClientHttpRequestFactory.class); + MockClientHttpRequest request = new MockClientHttpRequest(); + request.setResponse(new MockClientHttpResponse(new byte[0], HttpStatus.OK)); + URI absoluteUri = URI.create("https://api.example.com/a/b/c.txt"); + given(requestFactory.createRequest(eq(absoluteUri), eq(HttpMethod.GET))).willReturn(request); + template.getRestTemplate().setRequestFactory(requestFactory); + template.exchange(entity, String.class); + verify(requestFactory).createRequest(eq(absoluteUri), eq(HttpMethod.GET)); + } + @Test void deleteHandlesRelativeUris() throws IOException { verifyRelativeUriHandling(TestRestTemplate::delete); From 23ebf017c032038d2c63ebc996d40944b6f9f9a6 Mon Sep 17 00:00:00 2001 From: Phillip Webb Date: Thu, 4 Feb 2021 15:55:35 -0800 Subject: [PATCH 12/13] Extract code samples from docs See gh-6313 --- .../spring-boot-docs/build.gradle | 1 + .../docs/asciidoc/spring-boot-features.adoc | 372 +++--------------- .../ThirdPartyConfiguration.java | 38 ++ .../enable/MyApplication.java | 28 ++ .../enable/MyConfiguration.java | 32 ++ .../merge/list/AcmeProperties.java | 39 ++ .../merge/map/AcmeProperties.java | 39 ++ .../relaxed/OwnerProperties.java | 36 ++ .../use/MyService.java | 58 +++ .../validate/AcmeProperties.java | 43 ++ .../validate/nested/AcmeProperties.java | 67 ++++ .../profiles/ProductionConfiguration.java | 30 ++ .../HttpMessageConvertersConfiguration.java | 67 ++++ .../webapplications/json/MyJsonComponent.java | 78 ++++ .../json/object/MyJsonComponent.java | 76 ++++ .../servlet/CorsConfiguration.java | 41 ++ .../servlet/ErrorPageConfiguration.java | 40 ++ .../servlet/MyControllerAdvice.java | 62 +++ .../servlet/MyErrorViewResolver.java | 41 ++ .../servlet/MyRestController.java | 80 ++++ .../servlet/ServletFilterConfiguration.java | 55 +++ .../webflux/CodecConfiguration.java | 38 ++ .../CustomErrorWebExceptionHandler.java | 59 +++ .../webflux/MyRestController.java | 83 ++++ .../webflux/fn/RoutingConfiguration.java | 48 +++ .../webflux/fn/UserHandler.java | 45 +++ 26 files changed, 1279 insertions(+), 317 deletions(-) create mode 100644 spring-boot-project/spring-boot-docs/src/main/java/org/springframework/boot/docs/springbootfeatures/externalizedconfiguration/ThirdPartyConfiguration.java create mode 100644 spring-boot-project/spring-boot-docs/src/main/java/org/springframework/boot/docs/springbootfeatures/externalizedconfiguration/enable/MyApplication.java create mode 100644 spring-boot-project/spring-boot-docs/src/main/java/org/springframework/boot/docs/springbootfeatures/externalizedconfiguration/enable/MyConfiguration.java create mode 100644 spring-boot-project/spring-boot-docs/src/main/java/org/springframework/boot/docs/springbootfeatures/externalizedconfiguration/merge/list/AcmeProperties.java create mode 100644 spring-boot-project/spring-boot-docs/src/main/java/org/springframework/boot/docs/springbootfeatures/externalizedconfiguration/merge/map/AcmeProperties.java create mode 100644 spring-boot-project/spring-boot-docs/src/main/java/org/springframework/boot/docs/springbootfeatures/externalizedconfiguration/relaxed/OwnerProperties.java create mode 100644 spring-boot-project/spring-boot-docs/src/main/java/org/springframework/boot/docs/springbootfeatures/externalizedconfiguration/use/MyService.java create mode 100644 spring-boot-project/spring-boot-docs/src/main/java/org/springframework/boot/docs/springbootfeatures/externalizedconfiguration/validate/AcmeProperties.java create mode 100644 spring-boot-project/spring-boot-docs/src/main/java/org/springframework/boot/docs/springbootfeatures/externalizedconfiguration/validate/nested/AcmeProperties.java create mode 100644 spring-boot-project/spring-boot-docs/src/main/java/org/springframework/boot/docs/springbootfeatures/profiles/ProductionConfiguration.java create mode 100644 spring-boot-project/spring-boot-docs/src/main/java/org/springframework/boot/docs/springbootfeatures/webapplications/HttpMessageConvertersConfiguration.java create mode 100644 spring-boot-project/spring-boot-docs/src/main/java/org/springframework/boot/docs/springbootfeatures/webapplications/json/MyJsonComponent.java create mode 100644 spring-boot-project/spring-boot-docs/src/main/java/org/springframework/boot/docs/springbootfeatures/webapplications/json/object/MyJsonComponent.java create mode 100644 spring-boot-project/spring-boot-docs/src/main/java/org/springframework/boot/docs/springbootfeatures/webapplications/servlet/CorsConfiguration.java create mode 100644 spring-boot-project/spring-boot-docs/src/main/java/org/springframework/boot/docs/springbootfeatures/webapplications/servlet/ErrorPageConfiguration.java create mode 100644 spring-boot-project/spring-boot-docs/src/main/java/org/springframework/boot/docs/springbootfeatures/webapplications/servlet/MyControllerAdvice.java create mode 100644 spring-boot-project/spring-boot-docs/src/main/java/org/springframework/boot/docs/springbootfeatures/webapplications/servlet/MyErrorViewResolver.java create mode 100644 spring-boot-project/spring-boot-docs/src/main/java/org/springframework/boot/docs/springbootfeatures/webapplications/servlet/MyRestController.java create mode 100644 spring-boot-project/spring-boot-docs/src/main/java/org/springframework/boot/docs/springbootfeatures/webapplications/servlet/ServletFilterConfiguration.java create mode 100644 spring-boot-project/spring-boot-docs/src/main/java/org/springframework/boot/docs/springbootfeatures/webapplications/webflux/CodecConfiguration.java create mode 100644 spring-boot-project/spring-boot-docs/src/main/java/org/springframework/boot/docs/springbootfeatures/webapplications/webflux/CustomErrorWebExceptionHandler.java create mode 100644 spring-boot-project/spring-boot-docs/src/main/java/org/springframework/boot/docs/springbootfeatures/webapplications/webflux/MyRestController.java create mode 100644 spring-boot-project/spring-boot-docs/src/main/java/org/springframework/boot/docs/springbootfeatures/webapplications/webflux/fn/RoutingConfiguration.java create mode 100644 spring-boot-project/spring-boot-docs/src/main/java/org/springframework/boot/docs/springbootfeatures/webapplications/webflux/fn/UserHandler.java diff --git a/spring-boot-project/spring-boot-docs/build.gradle b/spring-boot-project/spring-boot-docs/build.gradle index 2128ada0636a..fa4dcb6ec90c 100644 --- a/spring-boot-project/spring-boot-docs/build.gradle +++ b/spring-boot-project/spring-boot-docs/build.gradle @@ -86,6 +86,7 @@ dependencies { implementation("org.slf4j:jul-to-slf4j") implementation("org.springframework:spring-test") implementation("org.springframework:spring-web") + implementation("org.springframework:spring-webmvc") implementation("org.springframework:spring-webflux") implementation("org.springframework.data:spring-data-couchbase") implementation("org.springframework.data:spring-data-neo4j") diff --git a/spring-boot-project/spring-boot-docs/src/docs/asciidoc/spring-boot-features.adoc b/spring-boot-project/spring-boot-docs/src/docs/asciidoc/spring-boot-features.adoc index 6123756b13b0..b3c6eefe947a 100644 --- a/spring-boot-project/spring-boot-docs/src/docs/asciidoc/spring-boot-features.adoc +++ b/spring-boot-project/spring-boot-docs/src/docs/asciidoc/spring-boot-features.adoc @@ -1118,12 +1118,9 @@ Sometimes, classes annotated with `@ConfigurationProperties` might not be suitab In these cases, specify the list of types to process using the `@EnableConfigurationProperties` annotation. This can be done on any `@Configuration` class, as shown in the following example: -[source,java,pending-extract=true,indent=0] +[source,java,indent=0] ---- - @Configuration(proxyBeanMethods = false) - @EnableConfigurationProperties(AcmeProperties.class) - public class MyConfiguration { - } +include::{include-springbootfeatures}/externalizedconfiguration/enable/MyConfiguration.java[tag=*] ---- To use configuration property scanning, add the `@ConfigurationPropertiesScan` annotation to your application. @@ -1131,12 +1128,9 @@ Typically, it is added to the main application class that is annotated with `@Sp By default, scanning will occur from the package of the class that declares the annotation. If you want to define specific packages to scan, you can do so as shown in the following example: -[source,java,pending-extract=true,indent=0] +[source,java,indent=0] ---- - @SpringBootApplication - @ConfigurationPropertiesScan({ "com.example.app", "org.acme.another" }) - public class MyApplication { - } +include::{include-springbootfeatures}/externalizedconfiguration/enable/MyApplication.java[tag=*] ---- [NOTE] @@ -1170,27 +1164,9 @@ This style of configuration works particularly well with the `SpringApplication` To work with `@ConfigurationProperties` beans, you can inject them in the same way as any other bean, as shown in the following example: -[source,java,pending-extract=true,indent=0] +[source,java,indent=0] ---- - @Service - public class MyService { - - private final AcmeProperties properties; - - @Autowired - public MyService(AcmeProperties properties) { - this.properties = properties; - } - - //... - - @PostConstruct - public void openConnection() { - Server server = new Server(this.properties.getRemoteAddress()); - // ... - } - - } +include::{include-springbootfeatures}/externalizedconfiguration/use/MyService.java[tag=*] ---- TIP: Using `@ConfigurationProperties` also lets you generate metadata files that can be used by IDEs to offer auto-completion for your own keys. @@ -1205,13 +1181,9 @@ Doing so can be particularly useful when you want to bind properties to third-pa To configure a bean from the `Environment` properties, add `@ConfigurationProperties` to its bean registration, as shown in the following example: -[source,java,pending-extract=true,indent=0] +[source,java,indent=0] ---- - @ConfigurationProperties(prefix = "another") - @Bean - public AnotherComponent anotherComponent() { - ... - } +include::{include-springbootfeatures}/externalizedconfiguration/ThirdPartyConfiguration.java[tag=*] ---- Any JavaBean property defined with the `another` prefix is mapped onto that `AnotherComponent` bean in manner similar to the preceding `AcmeProperties` example. @@ -1225,22 +1197,9 @@ Common examples where this is useful include dash-separated environment properti As an example, consider the following `@ConfigurationProperties` class: -[source,java,pending-extract=true,indent=0] +[source,java,indent=0] ---- - @ConfigurationProperties(prefix="acme.my-project.person") - public class OwnerProperties { - - private String firstName; - - public String getFirstName() { - return this.firstName; - } - - public void setFirstName(String firstName) { - this.firstName = firstName; - } - - } +include::{include-springbootfeatures}/externalizedconfiguration/relaxed/OwnerProperties.java[tag=*] ---- With the preceding code, the following properties names can all be used: @@ -1357,18 +1316,9 @@ When lists are configured in more than one place, overriding works by replacing For example, assume a `MyPojo` object with `name` and `description` attributes that are `null` by default. The following example exposes a list of `MyPojo` objects from `AcmeProperties`: -[source,java,pending-extract=true,indent=0] +[source,java,indent=0] ---- - @ConfigurationProperties("acme") - public class AcmeProperties { - - private final List list = new ArrayList<>(); - - public List getList() { - return this.list; - } - - } +include::{include-springbootfeatures}/externalizedconfiguration/merge/list/AcmeProperties.java[tag=*] ---- Consider the following configuration: @@ -1421,18 +1371,9 @@ For `Map` properties, you can bind with property values drawn from multiple sour However, for the same property in multiple sources, the one with the highest priority is used. The following example exposes a `Map` from `AcmeProperties`: -[source,java,pending-extract=true,indent=0] +[source,java,indent=0] ---- - @ConfigurationProperties("acme") - public class AcmeProperties { - - private final Map map = new HashMap<>(); - - public Map getMap() { - return this.map; - } - - } +include::{include-springbootfeatures}/externalizedconfiguration/merge/map/AcmeProperties.java[tag=*] ---- Consider the following configuration: @@ -1588,18 +1529,9 @@ Spring Boot attempts to validate `@ConfigurationProperties` classes whenever the You can use JSR-303 `javax.validation` constraint annotations directly on your configuration class. To do so, ensure that a compliant JSR-303 implementation is on your classpath and then add constraint annotations to your fields, as shown in the following example: -[source,java,pending-extract=true,indent=0] +[source,java,indent=0] ---- - @ConfigurationProperties(prefix="acme") - @Validated - public class AcmeProperties { - - @NotNull - private InetAddress remoteAddress; - - // ... getters and setters - - } +include::{include-springbootfeatures}/externalizedconfiguration/validate/AcmeProperties.java[tag=*] ---- TIP: You can also trigger validation by annotating the `@Bean` method that creates the configuration properties with `@Validated`. @@ -1607,30 +1539,9 @@ TIP: You can also trigger validation by annotating the `@Bean` method that creat To ensure that validation is always triggered for nested properties, even when no properties are found, the associated field must be annotated with `@Valid`. The following example builds on the preceding `AcmeProperties` example: -[source,java,pending-extract=true,indent=0] +[source,java,indent=0] ---- - @ConfigurationProperties(prefix="acme") - @Validated - public class AcmeProperties { - - @NotNull - private InetAddress remoteAddress; - - @Valid - private final Security security = new Security(); - - // ... getters and setters - - public static class Security { - - @NotEmpty - public String username; - - // ... getters and setters - - } - - } +include::{include-springbootfeatures}/externalizedconfiguration/validate/nested/AcmeProperties.java[tag=*] ---- You can also add a custom Spring `Validator` by creating a bean definition called `configurationPropertiesValidator`. @@ -1685,15 +1596,9 @@ If the value of a property from an application property file is a `SpEL` express Spring Profiles provide a way to segregate parts of your application configuration and make it be available only in certain environments. Any `@Component`, `@Configuration` or `@ConfigurationProperties` can be marked with `@Profile` to limit when it is loaded, as shown in the following example: -[source,java,pending-extract=true,indent=0] +[source,java,indent=0] ---- - @Configuration(proxyBeanMethods = false) - @Profile("production") - public class ProductionConfiguration { - - // ... - - } +include::{include-springbootfeatures}/profiles/ProductionConfiguration.java[tag=*] ---- NOTE: If `@ConfigurationProperties` beans are registered via `@EnableConfigurationProperties` instead of automatic scanning, the `@Profile` annotation needs to be specified on the `@Configuration` class that has the `@EnableConfigurationProperties` annotation. @@ -2326,28 +2231,9 @@ Methods in your controller are mapped to HTTP by using `@RequestMapping` annotat The following code shows a typical `@RestController` that serves JSON data: -[source,java,pending-extract=true,indent=0] +[source,java,indent=0] ---- - @RestController - @RequestMapping(value="/users") - public class MyRestController { - - @RequestMapping(value="/{user}", method=RequestMethod.GET) - public User getUser(@PathVariable Long user) { - // ... - } - - @RequestMapping(value="/{user}/customers", method=RequestMethod.GET) - List getUserCustomers(@PathVariable Long user) { - // ... - } - - @RequestMapping(value="/{user}", method=RequestMethod.DELETE) - public User deleteUser(@PathVariable Long user) { - // ... - } - - } +include::{include-springbootfeatures}/webapplications/servlet/MyRestController.java[tag=*] ---- Spring MVC is part of the core Spring Framework, and detailed information is available in the {spring-framework-docs}/web.html#mvc[reference documentation]. @@ -2395,23 +2281,9 @@ By default, strings are encoded in `UTF-8`. If you need to add or customize converters, you can use Spring Boot's `HttpMessageConverters` class, as shown in the following listing: -[source,java,pending-extract=true,indent=0] +[source,java,indent=0] ---- - import org.springframework.boot.autoconfigure.http.HttpMessageConverters; - import org.springframework.context.annotation.*; - import org.springframework.http.converter.*; - - @Configuration(proxyBeanMethods = false) - public class MyConfiguration { - - @Bean - public HttpMessageConverters customConverters() { - HttpMessageConverter additional = ... - HttpMessageConverter another = ... - return new HttpMessageConverters(additional, another); - } - - } +include::{include-springbootfeatures}/webapplications/HttpMessageConvertersConfiguration.java[tag=*] ---- Any `HttpMessageConverter` bean that is present in the context is added to the list of converters. @@ -2427,25 +2299,9 @@ Custom serializers are usually https://github.com/FasterXML/jackson-docs/wiki/Ja You can use the `@JsonComponent` annotation directly on `JsonSerializer`, `JsonDeserializer` or `KeyDeserializer` implementations. You can also use it on classes that contain serializers/deserializers as inner classes, as shown in the following example: -[source,java,pending-extract=true,indent=0] +[source,java,indent=0] ---- - 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 { - // ... - } - - } +include::{include-springbootfeatures}/webapplications/json/MyJsonComponent.java[tag=*] ---- All `@JsonComponent` beans in the `ApplicationContext` are automatically registered with Jackson. @@ -2454,6 +2310,13 @@ Because `@JsonComponent` is meta-annotated with `@Component`, the usual componen Spring Boot also provides {spring-boot-module-code}/jackson/JsonObjectSerializer.java[`JsonObjectSerializer`] and {spring-boot-module-code}/jackson/JsonObjectDeserializer.java[`JsonObjectDeserializer`] base classes that provide useful alternatives to the standard Jackson versions when serializing objects. See {spring-boot-module-api}/jackson/JsonObjectSerializer.html[`JsonObjectSerializer`] and {spring-boot-module-api}/jackson/JsonObjectDeserializer.html[`JsonObjectDeserializer`] in the Javadoc for details. +The example above can be rewritten to use `JsonObjectSerializer`/`JsonObjectDeserializer` as follows: + +[source,java,indent=0] +---- +include::{include-springbootfeatures}/webapplications/json/object/MyJsonComponent.java[tag=*] +---- + [[boot-features-spring-message-codes]] @@ -2692,27 +2555,9 @@ To do so, extend `BasicErrorController`, add a public method with a `@RequestMap You can also define a class annotated with `@ControllerAdvice` to customize the JSON document to return for a particular controller and/or exception type, as shown in the following example: -[source,java,pending-extract=true,indent=0,subs="verbatim,quotes,attributes"] +[source,java,indent=0,subs="verbatim,quotes,attributes"] ---- - @ControllerAdvice(basePackageClasses = AcmeController.class) - public class AcmeControllerAdvice extends ResponseEntityExceptionHandler { - - @ExceptionHandler(YourException.class) - @ResponseBody - ResponseEntity handleControllerException(HttpServletRequest request, Throwable ex) { - HttpStatus status = getStatus(request); - return new ResponseEntity<>(new CustomErrorType(status.value(), ex.getMessage()), status); - } - - private HttpStatus getStatus(HttpServletRequest request) { - Integer statusCode = (Integer) request.getAttribute("javax.servlet.error.status_code"); - if (statusCode == null) { - return HttpStatus.INTERNAL_SERVER_ERROR; - } - return HttpStatus.valueOf(statusCode); - } - - } +include::{include-springbootfeatures}/webapplications/servlet/MyControllerAdvice.java[tag=*] ---- In the preceding example, if `YourException` is thrown by a controller defined in the same package as `AcmeController`, a JSON representation of the `CustomErrorType` POJO is used instead of the `ErrorAttributes` representation. @@ -2757,21 +2602,11 @@ To map all `5xx` errors by using a FreeMarker template, your directory structure For more complex mappings, you can also add beans that implement the `ErrorViewResolver` interface, as shown in the following example: -[source,java,pending-extract=true,indent=0,subs="verbatim,quotes,attributes"] +[source,java,indent=0,subs="verbatim,quotes,attributes"] ---- - public class MyErrorViewResolver implements ErrorViewResolver { - - @Override - public ModelAndView resolveErrorView(HttpServletRequest request, - HttpStatus status, Map model) { - // Use the request or status to optionally return a ModelAndView - return ... - } - - } +include::{include-springbootfeatures}/webapplications/servlet/MyErrorViewResolver.java[tag=*] ---- - You can also use regular Spring MVC features such as {spring-framework-docs}/web.html#mvc-exceptionhandlers[`@ExceptionHandler` methods] and {spring-framework-docs}/web.html#mvc-ann-controller-advice[`@ControllerAdvice`]. The `ErrorController` then picks up any unhandled exceptions. @@ -2782,37 +2617,16 @@ The `ErrorController` then picks up any unhandled exceptions. For applications that do not use Spring MVC, you can use the `ErrorPageRegistrar` interface to directly register `ErrorPages`. This abstraction works directly with the underlying embedded servlet container and works even if you do not have a Spring MVC `DispatcherServlet`. -[source,java,pending-extract=true,indent=0,subs="verbatim,quotes,attributes"] +[source,java,indent=0,subs="verbatim,quotes,attributes"] ---- - @Bean - public ErrorPageRegistrar errorPageRegistrar(){ - return new MyErrorPageRegistrar(); - } - - // ... - - private static class MyErrorPageRegistrar implements ErrorPageRegistrar { - - @Override - public void registerErrorPages(ErrorPageRegistry registry) { - registry.addErrorPages(new ErrorPage(HttpStatus.BAD_REQUEST, "/400")); - } - - } +include::{include-springbootfeatures}/webapplications/servlet/ErrorPageConfiguration.java[tag=*] ---- NOTE: If you register an `ErrorPage` with a path that ends up being handled by a `Filter` (as is common with some non-Spring web frameworks, like Jersey and Wicket), then the `Filter` has to be explicitly registered as an `ERROR` dispatcher, as shown in the following example: -[source,java,pending-extract=true,indent=0,subs="verbatim,quotes,attributes"] +[source,java,indent=0,subs="verbatim,quotes,attributes"] ---- - @Bean - public FilterRegistrationBean myFilter() { - FilterRegistrationBean registration = new FilterRegistrationBean(); - registration.setFilter(new MyFilter()); - ... - registration.setDispatcherTypes(EnumSet.allOf(DispatcherType.class)); - return registration; - } +include::{include-springbootfeatures}/webapplications/servlet/ServletFilterConfiguration.java[tag=*] ---- Note that the default `FilterRegistrationBean` does not include the `ERROR` dispatcher type. @@ -2854,21 +2668,9 @@ As of version 4.2, Spring MVC {spring-framework-docs}/web.html#mvc-cors[supports Using {spring-framework-docs}/web.html#mvc-cors-controller[controller method CORS configuration] with {spring-framework-api}/web/bind/annotation/CrossOrigin.html[`@CrossOrigin`] annotations in your Spring Boot application does not require any specific configuration. {spring-framework-docs}/web.html#mvc-cors-global[Global CORS configuration] can be defined by registering a `WebMvcConfigurer` bean with a customized `addCorsMappings(CorsRegistry)` method, as shown in the following example: -[source,java,pending-extract=true,indent=0] +[source,java,indent=0] ---- - @Configuration(proxyBeanMethods = false) - public class MyConfiguration { - - @Bean - public WebMvcConfigurer corsConfigurer() { - return new WebMvcConfigurer() { - @Override - public void addCorsMappings(CorsRegistry registry) { - registry.addMapping("/api/**"); - } - }; - } - } +include::{include-springbootfeatures}/webapplications/servlet/CorsConfiguration.java[tag=*] ---- @@ -2881,61 +2683,21 @@ Unlike Spring MVC, it does not require the Servlet API, is fully asynchronous an 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: -[source,java,pending-extract=true,indent=0] +[source,java,indent=0] ---- - @RestController - @RequestMapping("/users") - public class MyRestController { - - @GetMapping("/{user}") - public Mono getUser(@PathVariable Long user) { - // ... - } - - @GetMapping("/{user}/customers") - public Flux getUserCustomers(@PathVariable Long user) { - // ... - } - - @DeleteMapping("/{user}") - public Mono deleteUser(@PathVariable Long user) { - // ... - } - - } +include::{include-springbootfeatures}/webapplications/webflux/MyRestController.java[tag=*] ---- "`WebFlux.fn`", the functional variant, separates the routing configuration from the actual handling of the requests, as shown in the following example: -[source,java,pending-extract=true,indent=0] +[source,java,indent=0] +---- +include::{include-springbootfeatures}/webapplications/webflux/fn/RoutingConfiguration.java[tag=*] ---- - @Configuration(proxyBeanMethods = false) - public class RoutingConfiguration { - - @Bean - public RouterFunction monoRouterFunction(UserHandler userHandler) { - return route(GET("/{user}").and(accept(APPLICATION_JSON)), userHandler::getUser) - .andRoute(GET("/{user}/customers").and(accept(APPLICATION_JSON)), userHandler::getUserCustomers) - .andRoute(DELETE("/{user}").and(accept(APPLICATION_JSON)), userHandler::deleteUser); - } - - } - - @Component - public class UserHandler { - - public Mono getUser(ServerRequest request) { - // ... - } - - public Mono getUserCustomers(ServerRequest request) { - // ... - } - public Mono deleteUser(ServerRequest request) { - // ... - } - } +[source,java,indent=0] +---- +include::{include-springbootfeatures}/webapplications/webflux/fn/UserHandler.java[tag=*] ---- WebFlux is part of the Spring Framework and detailed information is available in its {spring-framework-docs}/web-reactive.html#webflux-fn[reference documentation]. @@ -2977,21 +2739,9 @@ For example, `+spring.jackson.*+` configuration keys are applied to the Jackson If you need to add or customize codecs, you can create a custom `CodecCustomizer` component, as shown in the following example: -[source,java,pending-extract=true,indent=0] +[source,java,indent=0] ---- - import org.springframework.boot.web.codec.CodecCustomizer; - - @Configuration(proxyBeanMethods = false) - public class MyConfiguration { - - @Bean - public CodecCustomizer myCodecCustomizer() { - return codecConfigurer -> { - // ... - }; - } - - } +include::{include-springbootfeatures}/webapplications/webflux/CodecConfiguration.java[tag=*] ---- You can also leverage <>. @@ -3062,21 +2812,9 @@ 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: -[source,java,pending-extract=true,indent=0,subs="verbatim,quotes,attributes"] +[source,java,indent=0,subs="verbatim,quotes,attributes"] ---- - public class CustomErrorWebExceptionHandler extends AbstractErrorWebExceptionHandler { - - // Define constructor here - - @Override - protected RouterFunction getRoutingFunction(ErrorAttributes errorAttributes) { - - return RouterFunctions - .route(aPredicate, aHandler) - .andRoute(anotherPredicate, anotherHandler); - } - - } +include::{include-springbootfeatures}/webapplications/webflux/CustomErrorWebExceptionHandler.java[tag=*] ---- For a more complete picture, you can also subclass `DefaultErrorWebExceptionHandler` directly and override specific methods. diff --git a/spring-boot-project/spring-boot-docs/src/main/java/org/springframework/boot/docs/springbootfeatures/externalizedconfiguration/ThirdPartyConfiguration.java b/spring-boot-project/spring-boot-docs/src/main/java/org/springframework/boot/docs/springbootfeatures/externalizedconfiguration/ThirdPartyConfiguration.java new file mode 100644 index 000000000000..ee9d4ee8a18d --- /dev/null +++ b/spring-boot-project/spring-boot-docs/src/main/java/org/springframework/boot/docs/springbootfeatures/externalizedconfiguration/ThirdPartyConfiguration.java @@ -0,0 +1,38 @@ +/* + * Copyright 2012-2021 the original author or authors. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package org.springframework.boot.docs.springbootfeatures.externalizedconfiguration; + +//tag::code[] +import org.springframework.boot.context.properties.ConfigurationProperties; +import org.springframework.context.annotation.Bean; +import org.springframework.context.annotation.Configuration; + +@Configuration(proxyBeanMethods = false) +public class ThirdPartyConfiguration { + + @Bean + @ConfigurationProperties(prefix = "another") + public AnotherComponent anotherComponent() { + return new AnotherComponent(); + } + +} +// end::code[] + +class AnotherComponent { + +} diff --git a/spring-boot-project/spring-boot-docs/src/main/java/org/springframework/boot/docs/springbootfeatures/externalizedconfiguration/enable/MyApplication.java b/spring-boot-project/spring-boot-docs/src/main/java/org/springframework/boot/docs/springbootfeatures/externalizedconfiguration/enable/MyApplication.java new file mode 100644 index 000000000000..9e41e9e65b8b --- /dev/null +++ b/spring-boot-project/spring-boot-docs/src/main/java/org/springframework/boot/docs/springbootfeatures/externalizedconfiguration/enable/MyApplication.java @@ -0,0 +1,28 @@ +/* + * Copyright 2012-2021 the original author or authors. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package org.springframework.boot.docs.springbootfeatures.externalizedconfiguration.enable; + +//tag::code[] +import org.springframework.boot.autoconfigure.SpringBootApplication; +import org.springframework.boot.context.properties.ConfigurationPropertiesScan; + +@SpringBootApplication +@ConfigurationPropertiesScan({ "com.example.app", "org.acme.another" }) +public class MyApplication { + +} +// end::code[] diff --git a/spring-boot-project/spring-boot-docs/src/main/java/org/springframework/boot/docs/springbootfeatures/externalizedconfiguration/enable/MyConfiguration.java b/spring-boot-project/spring-boot-docs/src/main/java/org/springframework/boot/docs/springbootfeatures/externalizedconfiguration/enable/MyConfiguration.java new file mode 100644 index 000000000000..41d624a8d90f --- /dev/null +++ b/spring-boot-project/spring-boot-docs/src/main/java/org/springframework/boot/docs/springbootfeatures/externalizedconfiguration/enable/MyConfiguration.java @@ -0,0 +1,32 @@ +/* + * Copyright 2012-2021 the original author or authors. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package org.springframework.boot.docs.springbootfeatures.externalizedconfiguration.enable; + +//tag::code[] +import org.springframework.boot.context.properties.EnableConfigurationProperties; +import org.springframework.context.annotation.Configuration; + +@Configuration(proxyBeanMethods = false) +@EnableConfigurationProperties(AcmeProperties.class) +public class MyConfiguration { + +} +// end::code[] + +class AcmeProperties { + +} diff --git a/spring-boot-project/spring-boot-docs/src/main/java/org/springframework/boot/docs/springbootfeatures/externalizedconfiguration/merge/list/AcmeProperties.java b/spring-boot-project/spring-boot-docs/src/main/java/org/springframework/boot/docs/springbootfeatures/externalizedconfiguration/merge/list/AcmeProperties.java new file mode 100644 index 000000000000..7419f33d00bc --- /dev/null +++ b/spring-boot-project/spring-boot-docs/src/main/java/org/springframework/boot/docs/springbootfeatures/externalizedconfiguration/merge/list/AcmeProperties.java @@ -0,0 +1,39 @@ +/* + * Copyright 2012-2021 the original author or authors. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package org.springframework.boot.docs.springbootfeatures.externalizedconfiguration.merge.list; + +//tag::code[] +import java.util.ArrayList; +import java.util.List; + +import org.springframework.boot.context.properties.ConfigurationProperties; + +@ConfigurationProperties("acme") +public class AcmeProperties { + + private final List list = new ArrayList<>(); + + public List getList() { + return this.list; + } + +} +// end::code[] + +class MyPojo { + +} diff --git a/spring-boot-project/spring-boot-docs/src/main/java/org/springframework/boot/docs/springbootfeatures/externalizedconfiguration/merge/map/AcmeProperties.java b/spring-boot-project/spring-boot-docs/src/main/java/org/springframework/boot/docs/springbootfeatures/externalizedconfiguration/merge/map/AcmeProperties.java new file mode 100644 index 000000000000..250d1c44dca2 --- /dev/null +++ b/spring-boot-project/spring-boot-docs/src/main/java/org/springframework/boot/docs/springbootfeatures/externalizedconfiguration/merge/map/AcmeProperties.java @@ -0,0 +1,39 @@ +/* + * Copyright 2012-2021 the original author or authors. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package org.springframework.boot.docs.springbootfeatures.externalizedconfiguration.merge.map; + +//tag::code[] +import java.util.LinkedHashMap; +import java.util.Map; + +import org.springframework.boot.context.properties.ConfigurationProperties; + +@ConfigurationProperties("acme") +public class AcmeProperties { + + private final Map map = new LinkedHashMap<>(); + + public Map getMap() { + return this.map; + } + +} +// end::code[] + +class MyPojo { + +} diff --git a/spring-boot-project/spring-boot-docs/src/main/java/org/springframework/boot/docs/springbootfeatures/externalizedconfiguration/relaxed/OwnerProperties.java b/spring-boot-project/spring-boot-docs/src/main/java/org/springframework/boot/docs/springbootfeatures/externalizedconfiguration/relaxed/OwnerProperties.java new file mode 100644 index 000000000000..0ebc6f17d813 --- /dev/null +++ b/spring-boot-project/spring-boot-docs/src/main/java/org/springframework/boot/docs/springbootfeatures/externalizedconfiguration/relaxed/OwnerProperties.java @@ -0,0 +1,36 @@ +/* + * Copyright 2012-2021 the original author or authors. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package org.springframework.boot.docs.springbootfeatures.externalizedconfiguration.relaxed; + +//tag::code[] +import org.springframework.boot.context.properties.ConfigurationProperties; + +@ConfigurationProperties(prefix = "acme.my-project.person") +public class OwnerProperties { + + private String firstName; + + public String getFirstName() { + return this.firstName; + } + + public void setFirstName(String firstName) { + this.firstName = firstName; + } + +} +// end::code[] diff --git a/spring-boot-project/spring-boot-docs/src/main/java/org/springframework/boot/docs/springbootfeatures/externalizedconfiguration/use/MyService.java b/spring-boot-project/spring-boot-docs/src/main/java/org/springframework/boot/docs/springbootfeatures/externalizedconfiguration/use/MyService.java new file mode 100644 index 000000000000..d6d74c52acca --- /dev/null +++ b/spring-boot-project/spring-boot-docs/src/main/java/org/springframework/boot/docs/springbootfeatures/externalizedconfiguration/use/MyService.java @@ -0,0 +1,58 @@ +/* + * Copyright 2012-2021 the original author or authors. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package org.springframework.boot.docs.springbootfeatures.externalizedconfiguration.use; + +//tag::code[] +import org.springframework.stereotype.Service; + +@Service +public class MyService { + + private final AcmeProperties properties; + + public MyService(AcmeProperties properties) { + this.properties = properties; + } + + public void openConnection() { + Server server = new Server(this.properties.getRemoteAddress()); + server.start(); + // ... + } + + // ... + +} +// end::code[] + +class AcmeProperties { + + Object getRemoteAddress() { + return null; + } + +} + +class Server { + + Server(Object remoteAddress) { + } + + void start() { + } + +} diff --git a/spring-boot-project/spring-boot-docs/src/main/java/org/springframework/boot/docs/springbootfeatures/externalizedconfiguration/validate/AcmeProperties.java b/spring-boot-project/spring-boot-docs/src/main/java/org/springframework/boot/docs/springbootfeatures/externalizedconfiguration/validate/AcmeProperties.java new file mode 100644 index 000000000000..da5b5133a4cd --- /dev/null +++ b/spring-boot-project/spring-boot-docs/src/main/java/org/springframework/boot/docs/springbootfeatures/externalizedconfiguration/validate/AcmeProperties.java @@ -0,0 +1,43 @@ +/* + * Copyright 2012-2021 the original author or authors. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package org.springframework.boot.docs.springbootfeatures.externalizedconfiguration.validate; + +//tag::code[] +import java.net.InetAddress; + +import javax.validation.constraints.NotNull; + +import org.springframework.boot.context.properties.ConfigurationProperties; +import org.springframework.validation.annotation.Validated; + +@ConfigurationProperties(prefix = "acme") +@Validated +public class AcmeProperties { + + @NotNull + private InetAddress remoteAddress; + + public InetAddress getRemoteAddress() { + return this.remoteAddress; + } + + public void setRemoteAddress(InetAddress remoteAddress) { + this.remoteAddress = remoteAddress; + } + +} +// end::code[] diff --git a/spring-boot-project/spring-boot-docs/src/main/java/org/springframework/boot/docs/springbootfeatures/externalizedconfiguration/validate/nested/AcmeProperties.java b/spring-boot-project/spring-boot-docs/src/main/java/org/springframework/boot/docs/springbootfeatures/externalizedconfiguration/validate/nested/AcmeProperties.java new file mode 100644 index 000000000000..4e71fec39adc --- /dev/null +++ b/spring-boot-project/spring-boot-docs/src/main/java/org/springframework/boot/docs/springbootfeatures/externalizedconfiguration/validate/nested/AcmeProperties.java @@ -0,0 +1,67 @@ +/* + * Copyright 2012-2021 the original author or authors. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package org.springframework.boot.docs.springbootfeatures.externalizedconfiguration.validate.nested; + +//tag::code[] +import java.net.InetAddress; + +import javax.validation.Valid; +import javax.validation.constraints.NotEmpty; +import javax.validation.constraints.NotNull; + +import org.springframework.boot.context.properties.ConfigurationProperties; +import org.springframework.validation.annotation.Validated; + +@ConfigurationProperties(prefix = "acme") +@Validated +public class AcmeProperties { + + @NotNull + private InetAddress remoteAddress; + + @Valid + private final Security security = new Security(); + + public InetAddress getRemoteAddress() { + return this.remoteAddress; + } + + public void setRemoteAddress(InetAddress remoteAddress) { + this.remoteAddress = remoteAddress; + } + + public Security getSecurity() { + return this.security; + } + + public static class Security { + + @NotEmpty + private String username; + + public String getUsername() { + return this.username; + } + + public void setUsername(String username) { + this.username = username; + } + + } + +} +// end::code[] diff --git a/spring-boot-project/spring-boot-docs/src/main/java/org/springframework/boot/docs/springbootfeatures/profiles/ProductionConfiguration.java b/spring-boot-project/spring-boot-docs/src/main/java/org/springframework/boot/docs/springbootfeatures/profiles/ProductionConfiguration.java new file mode 100644 index 000000000000..4317d6faf4ef --- /dev/null +++ b/spring-boot-project/spring-boot-docs/src/main/java/org/springframework/boot/docs/springbootfeatures/profiles/ProductionConfiguration.java @@ -0,0 +1,30 @@ +/* + * Copyright 2012-2021 the original author or authors. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package org.springframework.boot.docs.springbootfeatures.profiles; + +//tag::code[] +import org.springframework.context.annotation.Configuration; +import org.springframework.context.annotation.Profile; + +@Configuration(proxyBeanMethods = false) +@Profile("production") +public class ProductionConfiguration { + + // ... + +} +// end::code[] diff --git a/spring-boot-project/spring-boot-docs/src/main/java/org/springframework/boot/docs/springbootfeatures/webapplications/HttpMessageConvertersConfiguration.java b/spring-boot-project/spring-boot-docs/src/main/java/org/springframework/boot/docs/springbootfeatures/webapplications/HttpMessageConvertersConfiguration.java new file mode 100644 index 000000000000..84aae404e655 --- /dev/null +++ b/spring-boot-project/spring-boot-docs/src/main/java/org/springframework/boot/docs/springbootfeatures/webapplications/HttpMessageConvertersConfiguration.java @@ -0,0 +1,67 @@ +/* + * Copyright 2012-2021 the original author or authors. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package org.springframework.boot.docs.springbootfeatures.webapplications; + +//tag::code[] +import java.io.IOException; + +import org.springframework.boot.autoconfigure.http.HttpMessageConverters; +import org.springframework.context.annotation.Bean; +import org.springframework.context.annotation.Configuration; +import org.springframework.http.HttpInputMessage; +import org.springframework.http.HttpOutputMessage; +import org.springframework.http.converter.AbstractHttpMessageConverter; +import org.springframework.http.converter.HttpMessageConverter; +import org.springframework.http.converter.HttpMessageNotReadableException; +import org.springframework.http.converter.HttpMessageNotWritableException; + +@Configuration(proxyBeanMethods = false) +public class HttpMessageConvertersConfiguration { + + @Bean + public HttpMessageConverters customConverters() { + HttpMessageConverter additional = new AdditionalHttpMessageConverter(); + HttpMessageConverter another = new AnotherHttpMessageConverter(); + return new HttpMessageConverters(additional, another); + } + +} +// end::code[] + +class AdditionalHttpMessageConverter extends AbstractHttpMessageConverter { + + @Override + protected boolean supports(Class clazz) { + return false; + } + + @Override + protected Object readInternal(Class clazz, HttpInputMessage inputMessage) + throws IOException, HttpMessageNotReadableException { + return null; + } + + @Override + protected void writeInternal(Object t, HttpOutputMessage outputMessage) + throws IOException, HttpMessageNotWritableException { + } + +} + +class AnotherHttpMessageConverter extends AdditionalHttpMessageConverter { + +} diff --git a/spring-boot-project/spring-boot-docs/src/main/java/org/springframework/boot/docs/springbootfeatures/webapplications/json/MyJsonComponent.java b/spring-boot-project/spring-boot-docs/src/main/java/org/springframework/boot/docs/springbootfeatures/webapplications/json/MyJsonComponent.java new file mode 100644 index 000000000000..e610051f1963 --- /dev/null +++ b/spring-boot-project/spring-boot-docs/src/main/java/org/springframework/boot/docs/springbootfeatures/webapplications/json/MyJsonComponent.java @@ -0,0 +1,78 @@ +/* + * Copyright 2012-2021 the original author or authors. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package org.springframework.boot.docs.springbootfeatures.webapplications.json; + +//tag::code[] +import java.io.IOException; + +import com.fasterxml.jackson.core.JsonGenerator; +import com.fasterxml.jackson.core.JsonParser; +import com.fasterxml.jackson.core.JsonProcessingException; +import com.fasterxml.jackson.core.ObjectCodec; +import com.fasterxml.jackson.databind.DeserializationContext; +import com.fasterxml.jackson.databind.JsonDeserializer; +import com.fasterxml.jackson.databind.JsonNode; +import com.fasterxml.jackson.databind.JsonSerializer; +import com.fasterxml.jackson.databind.SerializerProvider; + +import org.springframework.boot.jackson.JsonComponent; + +@JsonComponent +public class MyJsonComponent { + + public static class Serializer extends JsonSerializer { + + @Override + public void serialize(MyObject value, JsonGenerator jgen, SerializerProvider serializers) throws IOException { + jgen.writeStringField("name", value.getName()); + jgen.writeNumberField("age", value.getAge()); + } + + } + + public static class Deserializer extends JsonDeserializer { + + @Override + public MyObject deserialize(JsonParser jsonParser, DeserializationContext ctxt) + throws IOException, JsonProcessingException { + ObjectCodec codec = jsonParser.getCodec(); + JsonNode tree = codec.readTree(jsonParser); + String name = tree.get("name").textValue(); + int age = tree.get("age").intValue(); + return new MyObject(name, age); + } + + } + +} +// end::code[] + +class MyObject { + + MyObject(String name, int age) { + } + + String getName() { + return null; + } + + Integer getAge() { + return null; + + } + +} diff --git a/spring-boot-project/spring-boot-docs/src/main/java/org/springframework/boot/docs/springbootfeatures/webapplications/json/object/MyJsonComponent.java b/spring-boot-project/spring-boot-docs/src/main/java/org/springframework/boot/docs/springbootfeatures/webapplications/json/object/MyJsonComponent.java new file mode 100644 index 000000000000..cd2a062f9b9e --- /dev/null +++ b/spring-boot-project/spring-boot-docs/src/main/java/org/springframework/boot/docs/springbootfeatures/webapplications/json/object/MyJsonComponent.java @@ -0,0 +1,76 @@ +/* + * Copyright 2012-2021 the original author or authors. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package org.springframework.boot.docs.springbootfeatures.webapplications.json.object; + +//tag::code[] +import java.io.IOException; + +import com.fasterxml.jackson.core.JsonGenerator; +import com.fasterxml.jackson.core.JsonParser; +import com.fasterxml.jackson.core.ObjectCodec; +import com.fasterxml.jackson.databind.DeserializationContext; +import com.fasterxml.jackson.databind.JsonNode; +import com.fasterxml.jackson.databind.SerializerProvider; + +import org.springframework.boot.jackson.JsonComponent; +import org.springframework.boot.jackson.JsonObjectDeserializer; +import org.springframework.boot.jackson.JsonObjectSerializer; + +@JsonComponent +public class MyJsonComponent { + + public static class Serializer extends JsonObjectSerializer { + + @Override + protected void serializeObject(MyObject value, JsonGenerator jgen, SerializerProvider provider) + throws IOException { + jgen.writeStringField("name", value.getName()); + jgen.writeNumberField("age", value.getAge()); + } + + } + + public static class Deserializer extends JsonObjectDeserializer { + + @Override + protected MyObject deserializeObject(JsonParser jsonParser, DeserializationContext context, ObjectCodec codec, + JsonNode tree) throws IOException { + String name = nullSafeValue(tree.get("name"), String.class); + int age = nullSafeValue(tree.get("age"), Integer.class); + return new MyObject(name, age); + } + + } + +} +// end::code[] + +class MyObject { + + MyObject(String name, int age) { + } + + String getName() { + return null; + } + + Integer getAge() { + return null; + + } + +} diff --git a/spring-boot-project/spring-boot-docs/src/main/java/org/springframework/boot/docs/springbootfeatures/webapplications/servlet/CorsConfiguration.java b/spring-boot-project/spring-boot-docs/src/main/java/org/springframework/boot/docs/springbootfeatures/webapplications/servlet/CorsConfiguration.java new file mode 100644 index 000000000000..6b253b255ef0 --- /dev/null +++ b/spring-boot-project/spring-boot-docs/src/main/java/org/springframework/boot/docs/springbootfeatures/webapplications/servlet/CorsConfiguration.java @@ -0,0 +1,41 @@ +/* + * Copyright 2012-2021 the original author or authors. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package org.springframework.boot.docs.springbootfeatures.webapplications.servlet; + +//tag::code[] +import org.springframework.context.annotation.Bean; +import org.springframework.context.annotation.Configuration; +import org.springframework.web.servlet.config.annotation.CorsRegistry; +import org.springframework.web.servlet.config.annotation.WebMvcConfigurer; + +@Configuration(proxyBeanMethods = false) +public class CorsConfiguration { + + @Bean + public WebMvcConfigurer corsConfigurer() { + return new WebMvcConfigurer() { + + @Override + public void addCorsMappings(CorsRegistry registry) { + registry.addMapping("/api/**"); + } + + }; + } + +} +// end::code[] diff --git a/spring-boot-project/spring-boot-docs/src/main/java/org/springframework/boot/docs/springbootfeatures/webapplications/servlet/ErrorPageConfiguration.java b/spring-boot-project/spring-boot-docs/src/main/java/org/springframework/boot/docs/springbootfeatures/webapplications/servlet/ErrorPageConfiguration.java new file mode 100644 index 000000000000..6792a8fb86b6 --- /dev/null +++ b/spring-boot-project/spring-boot-docs/src/main/java/org/springframework/boot/docs/springbootfeatures/webapplications/servlet/ErrorPageConfiguration.java @@ -0,0 +1,40 @@ +/* + * Copyright 2012-2021 the original author or authors. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package org.springframework.boot.docs.springbootfeatures.webapplications.servlet; + +//tag::code[] +import org.springframework.boot.web.server.ErrorPage; +import org.springframework.boot.web.server.ErrorPageRegistrar; +import org.springframework.boot.web.server.ErrorPageRegistry; +import org.springframework.context.annotation.Bean; +import org.springframework.context.annotation.Configuration; +import org.springframework.http.HttpStatus; + +@Configuration +public class ErrorPageConfiguration { + + @Bean + public ErrorPageRegistrar errorPageRegistrar() { + return this::registerErrorPages; + } + + private void registerErrorPages(ErrorPageRegistry registry) { + registry.addErrorPages(new ErrorPage(HttpStatus.BAD_REQUEST, "/400")); + } + +} +// end::code[] diff --git a/spring-boot-project/spring-boot-docs/src/main/java/org/springframework/boot/docs/springbootfeatures/webapplications/servlet/MyControllerAdvice.java b/spring-boot-project/spring-boot-docs/src/main/java/org/springframework/boot/docs/springbootfeatures/webapplications/servlet/MyControllerAdvice.java new file mode 100644 index 000000000000..02e3ce2c7055 --- /dev/null +++ b/spring-boot-project/spring-boot-docs/src/main/java/org/springframework/boot/docs/springbootfeatures/webapplications/servlet/MyControllerAdvice.java @@ -0,0 +1,62 @@ +/* + * Copyright 2012-2021 the original author or authors. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package org.springframework.boot.docs.springbootfeatures.webapplications.servlet; + +//tag::code[] +import javax.servlet.RequestDispatcher; +import javax.servlet.http.HttpServletRequest; + +import org.springframework.http.HttpStatus; +import org.springframework.http.ResponseEntity; +import org.springframework.web.bind.annotation.ControllerAdvice; +import org.springframework.web.bind.annotation.ExceptionHandler; +import org.springframework.web.bind.annotation.ResponseBody; +import org.springframework.web.servlet.mvc.method.annotation.ResponseEntityExceptionHandler; + +@ControllerAdvice(basePackageClasses = AcmeController.class) +public class MyControllerAdvice extends ResponseEntityExceptionHandler { + + @ResponseBody + @ExceptionHandler(MyException.class) + ResponseEntity handleControllerException(HttpServletRequest request, Throwable ex) { + HttpStatus status = getStatus(request); + return new ResponseEntity<>(new MyErrorBody(status.value(), ex.getMessage()), status); + } + + private HttpStatus getStatus(HttpServletRequest request) { + Integer code = (Integer) request.getAttribute(RequestDispatcher.ERROR_STATUS_CODE); + HttpStatus status = HttpStatus.resolve(code); + return (status != null) ? status : HttpStatus.INTERNAL_SERVER_ERROR; + } + +} +// end::code[] + +class AcmeController { + +} + +class MyException extends RuntimeException { + +} + +class MyErrorBody { + + MyErrorBody(int value, String message) { + } + +} diff --git a/spring-boot-project/spring-boot-docs/src/main/java/org/springframework/boot/docs/springbootfeatures/webapplications/servlet/MyErrorViewResolver.java b/spring-boot-project/spring-boot-docs/src/main/java/org/springframework/boot/docs/springbootfeatures/webapplications/servlet/MyErrorViewResolver.java new file mode 100644 index 000000000000..cfe32cf3b273 --- /dev/null +++ b/spring-boot-project/spring-boot-docs/src/main/java/org/springframework/boot/docs/springbootfeatures/webapplications/servlet/MyErrorViewResolver.java @@ -0,0 +1,41 @@ +/* + * Copyright 2012-2020 the original author or authors. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package org.springframework.boot.docs.springbootfeatures.webapplications.servlet; + +//tag::code[] +import java.util.Map; + +import javax.servlet.http.HttpServletRequest; + +import org.springframework.boot.autoconfigure.web.servlet.error.ErrorViewResolver; +import org.springframework.http.HttpStatus; +import org.springframework.web.servlet.ModelAndView; + +public class MyErrorViewResolver implements ErrorViewResolver { + + @Override + public ModelAndView resolveErrorView(HttpServletRequest request, HttpStatus status, Map model) { + // Use the request or status to optionally return a ModelAndView + if (status == HttpStatus.INSUFFICIENT_STORAGE) { + // We could add custom model values here + new ModelAndView("myview"); + } + return null; + } + +} +// end::code[] diff --git a/spring-boot-project/spring-boot-docs/src/main/java/org/springframework/boot/docs/springbootfeatures/webapplications/servlet/MyRestController.java b/spring-boot-project/spring-boot-docs/src/main/java/org/springframework/boot/docs/springbootfeatures/webapplications/servlet/MyRestController.java new file mode 100644 index 000000000000..5983f3a69f02 --- /dev/null +++ b/spring-boot-project/spring-boot-docs/src/main/java/org/springframework/boot/docs/springbootfeatures/webapplications/servlet/MyRestController.java @@ -0,0 +1,80 @@ +/* + * Copyright 2012-2021 the original author or authors. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package org.springframework.boot.docs.springbootfeatures.webapplications.servlet; + +//tag::code[] +import java.util.List; + +import org.springframework.data.repository.CrudRepository; +import org.springframework.web.bind.annotation.DeleteMapping; +import org.springframework.web.bind.annotation.GetMapping; +import org.springframework.web.bind.annotation.PathVariable; +import org.springframework.web.bind.annotation.RequestMapping; +import org.springframework.web.bind.annotation.RestController; + +@RestController +@RequestMapping("/users") +public class MyRestController { + + private final UserRepository userRepository; + + private final CustomerRepository customerRepository; + + public MyRestController(UserRepository userRepository, CustomerRepository customerRepository) { + this.userRepository = userRepository; + this.customerRepository = customerRepository; + } + + @GetMapping("/{user}") + public User getUser(@PathVariable Long userId) { + return this.userRepository.findById(userId).get(); + } + + @GetMapping("/{user}/customers") + List getUserCustomers(@PathVariable Long userId) { + return this.userRepository.findById(userId).map(this.customerRepository::findByUser).get(); + } + + @DeleteMapping("/{user}") + public void deleteUser(@PathVariable Long userId) { + this.userRepository.deleteById(userId); + } + +} +// end::code[] + +interface UserRepository extends CrudRepository { + +} + +interface CustomerRepository extends CrudRepository { + + List findByUser(User user); + +} + +class User { + + List getCustomers() { + return null; + } + +} + +class Customer { + +} diff --git a/spring-boot-project/spring-boot-docs/src/main/java/org/springframework/boot/docs/springbootfeatures/webapplications/servlet/ServletFilterConfiguration.java b/spring-boot-project/spring-boot-docs/src/main/java/org/springframework/boot/docs/springbootfeatures/webapplications/servlet/ServletFilterConfiguration.java new file mode 100644 index 000000000000..9038e56af58e --- /dev/null +++ b/spring-boot-project/spring-boot-docs/src/main/java/org/springframework/boot/docs/springbootfeatures/webapplications/servlet/ServletFilterConfiguration.java @@ -0,0 +1,55 @@ +/* + * Copyright 2012-2021 the original author or authors. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package org.springframework.boot.docs.springbootfeatures.webapplications.servlet; + +//tag::code[] +import java.io.IOException; +import java.util.EnumSet; + +import javax.servlet.DispatcherType; +import javax.servlet.FilterChain; +import javax.servlet.ServletException; +import javax.servlet.ServletRequest; +import javax.servlet.ServletResponse; + +import org.springframework.boot.web.servlet.FilterRegistrationBean; +import org.springframework.context.annotation.Bean; +import org.springframework.context.annotation.Configuration; +import org.springframework.web.filter.GenericFilterBean; + +@Configuration +public class ServletFilterConfiguration { + + @Bean + public FilterRegistrationBean myFilter() { + FilterRegistrationBean registration = new FilterRegistrationBean<>(new MyFilter()); + // ... + registration.setDispatcherTypes(EnumSet.allOf(DispatcherType.class)); + return registration; + } + +} +// end::code[] + +class MyFilter extends GenericFilterBean { + + @Override + public void doFilter(ServletRequest request, ServletResponse response, FilterChain chain) + throws IOException, ServletException { + } + +} diff --git a/spring-boot-project/spring-boot-docs/src/main/java/org/springframework/boot/docs/springbootfeatures/webapplications/webflux/CodecConfiguration.java b/spring-boot-project/spring-boot-docs/src/main/java/org/springframework/boot/docs/springbootfeatures/webapplications/webflux/CodecConfiguration.java new file mode 100644 index 000000000000..01e2af66172c --- /dev/null +++ b/spring-boot-project/spring-boot-docs/src/main/java/org/springframework/boot/docs/springbootfeatures/webapplications/webflux/CodecConfiguration.java @@ -0,0 +1,38 @@ +/* + * Copyright 2012-2021 the original author or authors. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package org.springframework.boot.docs.springbootfeatures.webapplications.webflux; + +//tag::code[] +import org.springframework.boot.web.codec.CodecCustomizer; +import org.springframework.context.annotation.Bean; +import org.springframework.context.annotation.Configuration; +import org.springframework.http.codec.ServerSentEventHttpMessageReader; + +@Configuration(proxyBeanMethods = false) +public class CodecConfiguration { + + @Bean + public CodecCustomizer myCodecCustomizer() { + return (configurer) -> { + configurer.registerDefaults(false); + configurer.customCodecs().register(new ServerSentEventHttpMessageReader()); + // ... + }; + } + +} +// end::code[] diff --git a/spring-boot-project/spring-boot-docs/src/main/java/org/springframework/boot/docs/springbootfeatures/webapplications/webflux/CustomErrorWebExceptionHandler.java b/spring-boot-project/spring-boot-docs/src/main/java/org/springframework/boot/docs/springbootfeatures/webapplications/webflux/CustomErrorWebExceptionHandler.java new file mode 100644 index 000000000000..525b79acb2cf --- /dev/null +++ b/spring-boot-project/spring-boot-docs/src/main/java/org/springframework/boot/docs/springbootfeatures/webapplications/webflux/CustomErrorWebExceptionHandler.java @@ -0,0 +1,59 @@ +/* + * Copyright 2012-2021 the original author or authors. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package org.springframework.boot.docs.springbootfeatures.webapplications.webflux; + +//tag::code[] +import reactor.core.publisher.Mono; + +import org.springframework.boot.autoconfigure.web.WebProperties.Resources; +import org.springframework.boot.autoconfigure.web.reactive.error.AbstractErrorWebExceptionHandler; +import org.springframework.boot.web.reactive.error.ErrorAttributes; +import org.springframework.context.ApplicationContext; +import org.springframework.http.HttpStatus; +import org.springframework.http.MediaType; +import org.springframework.stereotype.Component; +import org.springframework.web.reactive.function.server.RouterFunction; +import org.springframework.web.reactive.function.server.RouterFunctions; +import org.springframework.web.reactive.function.server.ServerRequest; +import org.springframework.web.reactive.function.server.ServerResponse; +import org.springframework.web.reactive.function.server.ServerResponse.BodyBuilder; + +@Component +public class CustomErrorWebExceptionHandler extends AbstractErrorWebExceptionHandler { + + public CustomErrorWebExceptionHandler(ErrorAttributes errorAttributes, Resources resources, + ApplicationContext applicationContext) { + super(errorAttributes, resources, applicationContext); + } + + @Override + protected RouterFunction getRoutingFunction(ErrorAttributes errorAttributes) { + return RouterFunctions.route(this::acceptsXml, this::handleErrorAsXml); + } + + private boolean acceptsXml(ServerRequest request) { + return request.headers().accept().contains(MediaType.APPLICATION_XML); + } + + public Mono handleErrorAsXml(ServerRequest request) { + BodyBuilder builder = ServerResponse.status(HttpStatus.INTERNAL_SERVER_ERROR); + // ... additional builder calls + return builder.build(); + } + +} +// end::code[] diff --git a/spring-boot-project/spring-boot-docs/src/main/java/org/springframework/boot/docs/springbootfeatures/webapplications/webflux/MyRestController.java b/spring-boot-project/spring-boot-docs/src/main/java/org/springframework/boot/docs/springbootfeatures/webapplications/webflux/MyRestController.java new file mode 100644 index 000000000000..d4b6d528ebfd --- /dev/null +++ b/spring-boot-project/spring-boot-docs/src/main/java/org/springframework/boot/docs/springbootfeatures/webapplications/webflux/MyRestController.java @@ -0,0 +1,83 @@ +/* + * Copyright 2012-2021 the original author or authors. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package org.springframework.boot.docs.springbootfeatures.webapplications.webflux; + +//tag::code[] +import java.util.List; + +import reactor.core.publisher.Flux; +import reactor.core.publisher.Mono; + +import org.springframework.data.repository.reactive.ReactiveCrudRepository; +import org.springframework.web.bind.annotation.DeleteMapping; +import org.springframework.web.bind.annotation.GetMapping; +import org.springframework.web.bind.annotation.PathVariable; +import org.springframework.web.bind.annotation.RequestMapping; +import org.springframework.web.bind.annotation.RestController; + +@RestController +@RequestMapping("/users") +public class MyRestController { + + private final UserRepository userRepository; + + private final CustomerRepository customerRepository; + + public MyRestController(UserRepository userRepository, CustomerRepository customerRepository) { + this.userRepository = userRepository; + this.customerRepository = customerRepository; + } + + @GetMapping("/{user}") + public Mono getUser(@PathVariable Long userId) { + return this.userRepository.findById(userId); + } + + @GetMapping("/{user}/customers") + Flux getUserCustomers(@PathVariable Long userId) { + return this.userRepository.findById(userId).flatMapMany(this.customerRepository::findByUser); + } + + @DeleteMapping("/{user}") + public void deleteUser(@PathVariable Long userId) { + this.userRepository.deleteById(userId); + } + +} +// end::code[] + +interface UserRepository extends ReactiveCrudRepository { + +} + +interface CustomerRepository extends ReactiveCrudRepository { + + Flux findByUser(User user); + +} + +class User { + + List getCustomers() { + return null; + } + +} + +class Customer { + +} diff --git a/spring-boot-project/spring-boot-docs/src/main/java/org/springframework/boot/docs/springbootfeatures/webapplications/webflux/fn/RoutingConfiguration.java b/spring-boot-project/spring-boot-docs/src/main/java/org/springframework/boot/docs/springbootfeatures/webapplications/webflux/fn/RoutingConfiguration.java new file mode 100644 index 000000000000..089ee7ac3758 --- /dev/null +++ b/spring-boot-project/spring-boot-docs/src/main/java/org/springframework/boot/docs/springbootfeatures/webapplications/webflux/fn/RoutingConfiguration.java @@ -0,0 +1,48 @@ +/* + * Copyright 2012-2021 the original author or authors. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package org.springframework.boot.docs.springbootfeatures.webapplications.webflux.fn; + +//tag::code[] +import org.springframework.context.annotation.Bean; +import org.springframework.context.annotation.Configuration; +import org.springframework.http.MediaType; +import org.springframework.web.reactive.function.server.RequestPredicate; +import org.springframework.web.reactive.function.server.RouterFunction; +import org.springframework.web.reactive.function.server.ServerResponse; + +import static org.springframework.web.reactive.function.server.RequestPredicates.DELETE; +import static org.springframework.web.reactive.function.server.RequestPredicates.GET; +import static org.springframework.web.reactive.function.server.RequestPredicates.accept; +import static org.springframework.web.reactive.function.server.RouterFunctions.route; + +@Configuration(proxyBeanMethods = false) +public class RoutingConfiguration { + + private static final RequestPredicate ACCEPT_JSON = accept(MediaType.APPLICATION_JSON); + + @Bean + public RouterFunction monoRouterFunction(UserHandler userHandler) { + // @formatter:off + return route( + GET("/{user}").and(ACCEPT_JSON), userHandler::getUser).andRoute( + GET("/{user}/customers").and(ACCEPT_JSON), userHandler::getUserCustomers).andRoute( + DELETE("/{user}").and(ACCEPT_JSON), userHandler::deleteUser); + // @formatter:on + } + +} +// end::code[] diff --git a/spring-boot-project/spring-boot-docs/src/main/java/org/springframework/boot/docs/springbootfeatures/webapplications/webflux/fn/UserHandler.java b/spring-boot-project/spring-boot-docs/src/main/java/org/springframework/boot/docs/springbootfeatures/webapplications/webflux/fn/UserHandler.java new file mode 100644 index 000000000000..8ddd5ef6a7ef --- /dev/null +++ b/spring-boot-project/spring-boot-docs/src/main/java/org/springframework/boot/docs/springbootfeatures/webapplications/webflux/fn/UserHandler.java @@ -0,0 +1,45 @@ +/* + * Copyright 2012-2021 the original author or authors. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package org.springframework.boot.docs.springbootfeatures.webapplications.webflux.fn; + +//tag::code[] +import reactor.core.publisher.Mono; + +import org.springframework.stereotype.Component; +import org.springframework.web.reactive.function.server.ServerRequest; +import org.springframework.web.reactive.function.server.ServerResponse; + +@Component +public class UserHandler { + + public Mono getUser(ServerRequest request) { + // ... + return ServerResponse.ok().build(); + } + + public Mono getUserCustomers(ServerRequest request) { + // ... + return ServerResponse.ok().build(); + } + + public Mono deleteUser(ServerRequest request) { + // ... + return ServerResponse.ok().build(); + } + +} +// end::code[] From d12bb6f915a71f1c925fbb1b6f6d9fb7b53ffab1 Mon Sep 17 00:00:00 2001 From: Andy Wilkinson Date: Fri, 5 Feb 2021 13:34:00 +0000 Subject: [PATCH 13/13] Upgrade to Gradle 6.8.2 Closes gh-25117 --- gradle/wrapper/gradle-wrapper.properties | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/gradle/wrapper/gradle-wrapper.properties b/gradle/wrapper/gradle-wrapper.properties index 28ff446a2157..2a563242c113 100644 --- a/gradle/wrapper/gradle-wrapper.properties +++ b/gradle/wrapper/gradle-wrapper.properties @@ -1,5 +1,5 @@ distributionBase=GRADLE_USER_HOME distributionPath=wrapper/dists -distributionUrl=https\://services.gradle.org/distributions/gradle-6.8.1-bin.zip +distributionUrl=https\://services.gradle.org/distributions/gradle-6.8.2-bin.zip zipStoreBase=GRADLE_USER_HOME zipStorePath=wrapper/dists