Commit ae1be76c authored by Phillip Webb's avatar Phillip Webb

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
parent 073f8c4b
......@@ -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, <<configuration-metadata-additional-metadata,manual metadata>> 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 {
......
......@@ -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);
......
......@@ -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 {
......
......@@ -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.*;
......
......@@ -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<MeterRegistry> 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<GraphiteMeterRegistry> 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")
......
......@@ -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"])
......
......@@ -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 <<using-boot-structuring-your-code,the best practices>>)
* `@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");
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment