Skip to content

Commit 91ccc23

Browse files
committed
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
1 parent db781a0 commit 91ccc23

File tree

129 files changed

+1540
-283
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

129 files changed

+1540
-283
lines changed

spring-boot-project/spring-boot-docs/src/docs/asciidoc/attributes.adoc

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -20,8 +20,10 @@
2020
:github-issues: https://github.com/{github-repo}/issues/
2121
:github-wiki: https://github.com/{github-repo}/wiki
2222

23-
:code-examples: ../main/java/org/springframework/boot/docs
24-
:test-examples: ../test/java/org/springframework/boot/docs
23+
:include: ../main/java/org/springframework/boot/docs
24+
:include-springbootfeatures: {include}/springbootfeatures
25+
:include-productionreadyfeatures: {include}/productionreadyfeatures
26+
:include-howto: {include}/howto
2527

2628
:spring-boot-code: https://github.com/{github-repo}/tree/{github-tag}
2729
:spring-boot-api: https://docs.spring.io/spring-boot/docs/{spring-boot-version}/api
@@ -94,9 +96,6 @@
9496
:spring-session: https://spring.io/projects/spring-session
9597
:spring-webservices-docs: https://docs.spring.io/spring-ws/docs/{spring-webservices-version}/reference/
9698

97-
98-
99-
10099
:ant-docs: https://ant.apache.org/manual
101100
:dependency-management-plugin-code: https://github.com/spring-gradle-plugins/dependency-management-plugin
102101
:gradle-docs: https://docs.gradle.org/current/userguide

spring-boot-project/spring-boot-docs/src/docs/asciidoc/howto.adoc

Lines changed: 17 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -95,7 +95,7 @@ For instance, the following example loads a YAML configuration file from the cla
9595

9696
[source,java,indent=0]
9797
----
98-
include::{code-examples}/context/EnvironmentPostProcessorExample.java[tag=example]
98+
include::{include-howto}/springbootapplication/EnvironmentPostProcessorExample.java[tag=*]
9999
----
100100

101101
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
931931

932932
[source,java,indent=0,subs="verbatim,quotes,attributes"]
933933
----
934-
include::{code-examples}/context/embedded/TomcatMultipleConnectorsExample.java[tag=configuration]
934+
include::{include-howto}/embeddedwebservers/TomcatMultipleConnectorsExample.java[tag=*]
935935
----
936936

937937

@@ -951,7 +951,7 @@ To switch to the `LegacyCookieProcessor`, use an `WebServerFactoryCustomizer` be
951951

952952
[source,java,indent=0]
953953
----
954-
include::{code-examples}/context/embedded/TomcatLegacyCookieProcessorExample.java[tag=customizer]
954+
include::{include-howto}/embeddedwebservers/TomcatLegacyCookieProcessorExample.java[tag=*]
955955
----
956956

957957

@@ -978,7 +978,7 @@ Add an `UndertowBuilderCustomizer` to the `UndertowServletWebServerFactory` and
978978

979979
[source,java,indent=0,subs="verbatim,quotes,attributes"]
980980
----
981-
include::{code-examples}/context/embedded/UndertowMultipleListenersExample.java[tag=configuration]
981+
include::{include-howto}/embeddedwebservers/UndertowMultipleListenersExample.java[tag=*]
982982
----
983983

984984

@@ -1283,7 +1283,7 @@ The `jersey.config.server.response.setStatusOverSendError` property must be set
12831283

12841284
[source,java,indent=0]
12851285
----
1286-
include::{code-examples}/jersey/JerseySetStatusOverSendErrorExample.java[tag=resource-config]
1286+
include::{include-howto}/jersey/JerseySetStatusOverSendErrorExample.java[tag=*]
12871287
----
12881288

12891289

@@ -1326,7 +1326,7 @@ The following example configures `HttpComponentsClientRequestFactory` with an `H
13261326

13271327
[source,java,indent=0]
13281328
----
1329-
include::{code-examples}/web/client/RestTemplateProxyCustomizationExample.java[tag=customizer]
1329+
include::{include-springbootfeatures}/resttemplate/RestTemplateProxyCustomizationExample.java[tag=*]
13301330
----
13311331

13321332
[[howto-webclient-reactor-netty-customization]]
@@ -1337,7 +1337,7 @@ The following example configures a 60 second connect timeout and adds a `ReadTim
13371337

13381338
[source,java,indent=0]
13391339
----
1340-
include::{code-examples}/web/reactive/function/client/ReactorNettyClientCustomizationExample.java[tag=custom-http-connector]
1340+
include::{include-howto}/httpclients/ReactorNettyClientCustomizationExample.java[tag=*]
13411341
----
13421342

13431343
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
15821582

15831583
[source,java,indent=0,subs="verbatim,quotes,attributes"]
15841584
----
1585-
include::{code-examples}/jdbc/BasicDataSourceExample.java[tag=configuration]
1585+
include::{include-howto}/dataaccess/BasicDataSourceExample.java[tag=*]
15861586
----
15871587

15881588
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
16231623

16241624
[source,java,indent=0,subs="verbatim,quotes,attributes"]
16251625
----
1626-
include::{code-examples}/jdbc/SimpleDataSourceExample.java[tag=configuration]
1626+
include::{include-howto}/dataaccess/SimpleDataSourceExample.java[tag=*]
16271627
----
16281628

16291629
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
16331633

16341634
[source,java,indent=0,subs="verbatim,quotes,attributes"]
16351635
----
1636-
include::{code-examples}/jdbc/ConfigurableDataSourceExample.java[tag=configuration]
1636+
include::{include-howto}/dataaccess/ConfigurableDataSourceExample.java[tag=*]
16371637
----
16381638

16391639
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
16701670

16711671
[source,java,indent=0,subs="verbatim,quotes,attributes"]
16721672
----
1673-
include::{code-examples}/jdbc/SimpleTwoDataSourcesExample.java[tag=configuration]
1673+
include::{include-howto}/dataaccess/SimpleTwoDataSourcesExample.java[tag=*]
16741674
----
16751675

16761676
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
17001700

17011701
[source,java,indent=0,subs="verbatim,quotes,attributes"]
17021702
----
1703-
include::{code-examples}/jdbc/CompleteTwoDataSourcesExample.java[tag=configuration]
1703+
include::{include-howto}/dataaccess/CompleteTwoDataSourcesExample.java[tag=*]
17041704
----
17051705

17061706
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
17941794

17951795
[source,java,indent=0]
17961796
----
1797-
include::{code-examples}/jpa/CaseSensitiveSpringPhysicalNamingStrategyExample.java[tag=naming-strategy]
1797+
include::{include-howto}/dataaccess/CaseSensitiveSpringPhysicalNamingStrategyExample.java[tag=*]
17981798
----
17991799

18001800
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
18281828

18291829
[source,java,indent=0]
18301830
----
1831-
include::{code-examples}/jpa/HibernateSecondLevelCacheExample.java[tag=configuration]
1831+
include::{include-howto}/dataaccess/HibernateSecondLevelCacheExample.java[tag=*]
18321832
----
18331833

18341834
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
19691969

19701970
[source,java,indent=0]
19711971
----
1972-
include::{code-examples}/elasticsearch/HibernateSearchElasticsearchExample.java[tag=configuration]
1972+
include::{include-howto}/dataaccess/HibernateSearchElasticsearchExample.java[tag=*]
19731973
----
19741974

19751975

@@ -2066,7 +2066,7 @@ You can initialize the database on startup using SQL scripts as shown in the fol
20662066

20672067
[source,java,indent=0]
20682068
----
2069-
include::{code-examples}/r2dbc/R2dbcDatabaseInitializationExample.java[tag=configuration]
2069+
include::{include-howto}/dataaccess/R2dbcDatabaseInitializationExample.java[tag=*]
20702070
----
20712071

20722072
Alternatively, you can configure either <<howto-execute-flyway-database-migrations-on-startup,Flyway>> or <<howto-execute-liquibase-database-migrations-on-startup,Liquibase>> 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:
23512351

23522352
[source,java,indent=0,subs="verbatim,quotes,attributes"]
23532353
----
2354-
include::{code-examples}/actuate/metrics/MetricsHealthMicrometerExportExample.java[tag=configuration]
2354+
include::{include-howto}/actuator/MetricsHealthMicrometerExportExample.java[tag=*]
23552355
----
23562356

23572357

spring-boot-project/spring-boot-docs/src/docs/asciidoc/production-ready-features.adoc

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -463,7 +463,7 @@ The following example exposes a read operation that returns a custom object:
463463

464464
[source,java,indent=0]
465465
----
466-
include::{code-examples}/actuate/endpoint/CustomEndpointExample.java[tag=read]
466+
include::{include-productionreadyfeatures}/endpoints/CustomEndpointExample.java[tag=read]
467467
----
468468

469469
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
500500

501501
[source,java,indent=0]
502502
----
503-
include::{code-examples}/actuate/endpoint/CustomEndpointExample.java[tag=write]
503+
include::{include-productionreadyfeatures}/endpoints/CustomEndpointExample.java[tag=write]
504504
----
505505

506506
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
23792379
23802380
[source,java,indent=0]
23812381
----
2382-
include::{code-examples}/actuate/metrics/MetricsMeterRegistryInjectionExample.java[tag=component]
2382+
include::{include-productionreadyfeatures}/metrics/MetricsMeterRegistryInjectionExample.java[tag=*]
23832383
----
23842384
23852385
If your metrics depend on other beans, it is recommended that you use a `MeterBinder` to register them, as shown in the following example:
23862386
23872387
[source,java,indent=0]
23882388
----
2389-
include::{code-examples}/actuate/metrics/SampleMeterBinderConfiguration.java[tag=example]
2389+
include::{include-productionreadyfeatures}/metrics/SampleMeterBinderConfiguration.java[tag=*]
23902390
----
23912391
23922392
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
24042404
24052405
[source,java,indent=0]
24062406
----
2407-
include::{code-examples}/actuate/metrics/MetricsFilterBeanExample.java[tag=configuration]
2407+
include::{include-productionreadyfeatures}/metrics/MetricsFilterBeanExample.java[tag=*]
24082408
----
24092409
24102410
@@ -2622,7 +2622,7 @@ For Tomcat, the following configuration can be added:
26222622
26232623
[source,java,indent=0]
26242624
----
2625-
include::{code-examples}/cloudfoundry/CloudFoundryCustomContextPathExample.java[tag=configuration]
2625+
include::{include-productionreadyfeatures}/cloudfoundry/CloudFoundryCustomContextPathExample.java[tag=*]
26262626
----
26272627
26282628

0 commit comments

Comments
 (0)