parent
9aad29da0c
commit
b5583a4620
|
|
@ -52,5 +52,5 @@ For Tomcat, the following configuration can be added:
|
|||
|
||||
[source,java,indent=0]
|
||||
----
|
||||
include::{docs-java}/actuator/cloudfoundry/customcontextpath/CloudFoundryCustomContextPathConfiguration.java[]
|
||||
include::{docs-java}/actuator/cloudfoundry/customcontextpath/MyCloudFoundryConfiguration.java[]
|
||||
----
|
||||
|
|
|
|||
|
|
@ -426,7 +426,7 @@ The following example exposes a read operation that returns a custom object:
|
|||
|
||||
[source,java,indent=0]
|
||||
----
|
||||
include::{docs-java}/actuator/endpoints/implementingcustom/CustomEndpoint.java[tag=read]
|
||||
include::{docs-java}/actuator/endpoints/implementingcustom/MyEndpoint.java[tag=read]
|
||||
----
|
||||
|
||||
You can also write technology-specific endpoints by using `@JmxEndpoint` or `@WebEndpoint`.
|
||||
|
|
@ -463,7 +463,7 @@ This can be used to invoke a write operation that takes `String name` and `int c
|
|||
|
||||
[source,java,indent=0]
|
||||
----
|
||||
include::{docs-java}/actuator/endpoints/implementingcustom/CustomEndpoint.java[tag=write]
|
||||
include::{docs-java}/actuator/endpoints/implementingcustom/MyEndpoint.java[tag=write]
|
||||
----
|
||||
|
||||
TIP: Because endpoints are technology agnostic, only simple types can be specified in the method signature.
|
||||
|
|
|
|||
|
|
@ -886,7 +886,7 @@ To replace the default metric tags, define a `MongoCommandTagsProvider` bean, as
|
|||
|
||||
[source,java,indent=0]
|
||||
----
|
||||
include::{docs-java}/actuator/metrics/supported/mongodb/command/SampleCommandTagsProviderConfiguration.java[]
|
||||
include::{docs-java}/actuator/metrics/supported/mongodb/command/MyCommandTagsProviderConfiguration.java[]
|
||||
----
|
||||
|
||||
To disable the auto-configured command metrics, set the following property:
|
||||
|
|
@ -927,7 +927,7 @@ To replace the default metric tags, define a `MongoConnectionPoolTagsProvider` b
|
|||
|
||||
[source,java,indent=0]
|
||||
----
|
||||
include::{docs-java}/actuator/metrics/supported/mongodb/connectionpool/SampleConnectionPoolTagsProviderConfiguration.java[]
|
||||
include::{docs-java}/actuator/metrics/supported/mongodb/connectionpool/MyConnectionPoolTagsProviderConfiguration.java[]
|
||||
----
|
||||
|
||||
To disable the auto-configured connection pool metrics, set the following property:
|
||||
|
|
@ -980,14 +980,14 @@ To register custom metrics, inject `MeterRegistry` into your component, as shown
|
|||
|
||||
[source,java,indent=0]
|
||||
----
|
||||
include::{docs-java}/actuator/metrics/registeringcustom/MetricsMeterRegistryInjection.java[]
|
||||
include::{docs-java}/actuator/metrics/registeringcustom/MyBean.java[]
|
||||
----
|
||||
|
||||
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::{docs-java}/actuator/metrics/registeringcustom/SampleMeterBinderConfiguration.java[]
|
||||
include::{docs-java}/actuator/metrics/registeringcustom/MyMeterBinderConfiguration.java[]
|
||||
----
|
||||
|
||||
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.
|
||||
|
|
@ -1005,7 +1005,7 @@ For example, if you want to rename the `mytag.region` tag to `mytag.area` for al
|
|||
|
||||
[source,java,indent=0]
|
||||
----
|
||||
include::{docs-java}/actuator/metrics/customizing/MetricsFilterConfiguration.java[]
|
||||
include::{docs-java}/actuator/metrics/customizing/MyMetricsFilterConfiguration.java[]
|
||||
----
|
||||
|
||||
NOTE: By default, all `MeterFilter` beans will be automatically bound to the Spring-managed `MeterRegistry`.
|
||||
|
|
|
|||
|
|
@ -71,11 +71,11 @@ Consider the following example:
|
|||
|
||||
[source,java,indent=0,subs="verbatim,attributes"]
|
||||
----
|
||||
include::{docs-java}/configurationmetadata/annotationprocessor/automaticmetadatageneration/ServerProperties.java[]
|
||||
include::{docs-java}/configurationmetadata/annotationprocessor/automaticmetadatageneration/MyServerProperties.java[]
|
||||
----
|
||||
|
||||
This exposes three properties where `server.name` has no default and `server.ip` and `server.port` defaults to `"127.0.0.1"` and `9797` respectively.
|
||||
The Javadoc on fields is used to populate the `description` attribute. For instance, the description of `server.ip` is "IP address to listen to.".
|
||||
This exposes three properties where `my.server.name` has no default and `my.server.ip` and `my.server.port` defaults to `"127.0.0.1"` and `9797` respectively.
|
||||
The Javadoc on fields is used to populate the `description` attribute. For instance, the description of `my.server.ip` is "IP address to listen to.".
|
||||
|
||||
NOTE: You should only use plain text with `@ConfigurationProperties` field Javadoc, since they are not processed before being added to the JSON.
|
||||
|
||||
|
|
@ -88,7 +88,7 @@ Consider the following example:
|
|||
|
||||
[source,java,indent=0,subs="verbatim,quotes,attributes"]
|
||||
----
|
||||
include::{docs-java}/configurationmetadata/annotationprocessor/automaticmetadatageneration/MessagingProperties.java[]
|
||||
include::{docs-java}/configurationmetadata/annotationprocessor/automaticmetadatageneration/MyMessagingProperties.java[]
|
||||
----
|
||||
|
||||
In order to document default values for properties in the class above, you could add the following content to <<configuration-metadata#configuration-metadata.annotation-processor.adding-additional-metadata,the manual metadata of the module>>:
|
||||
|
|
@ -97,11 +97,11 @@ In order to document default values for properties in the class above, you could
|
|||
----
|
||||
{"properties": [
|
||||
{
|
||||
"name": "acme.messaging.addresses",
|
||||
"name": "my.messaging.addresses",
|
||||
"defaultValue": ["a", "b"]
|
||||
},
|
||||
{
|
||||
"name": "acme.messaging.container-type",
|
||||
"name": "my.messaging.container-type",
|
||||
"defaultValue": "simple"
|
||||
}
|
||||
]}
|
||||
|
|
@ -119,10 +119,10 @@ Consider the updated example:
|
|||
|
||||
[source,java,indent=0,subs="verbatim,quotes,attributes"]
|
||||
----
|
||||
include::{docs-java}/configurationmetadata/annotationprocessor/automaticmetadatageneration/nestedproperties/ServerProperties.java[]
|
||||
include::{docs-java}/configurationmetadata/annotationprocessor/automaticmetadatageneration/nestedproperties/MyServerProperties.java[]
|
||||
----
|
||||
|
||||
The preceding example produces metadata information for `server.name`, `server.host.ip`, and `server.host.port` properties.
|
||||
The preceding example produces metadata information for `my.server.name`, `my.server.host.ip`, and `my.server.host.port` properties.
|
||||
You can use the `@NestedConfigurationProperty` annotation on a field to indicate that a regular (non-inner) class should be treated as if it were nested.
|
||||
|
||||
TIP: This has no effect on collections and maps, as those types are automatically identified, and a single metadata property is generated for each of them.
|
||||
|
|
|
|||
|
|
@ -142,7 +142,7 @@ The JSON object contained in the `properties` array can contain the attributes d
|
|||
|
||||
| `type`
|
||||
| String
|
||||
| The full signature of the data type of the property (for example, `java.lang.String`) but also a full generic type (such as `java.util.Map<java.lang.String,acme.MyEnum>`).
|
||||
| The full signature of the data type of the property (for example, `java.lang.String`) but also a full generic type (such as `java.util.Map<java.lang.String,com.example.MyEnum>`).
|
||||
You can use this attribute to guide the user as to the types of values that they can enter.
|
||||
For consistency, the type of a primitive is specified by using its wrapper counterpart (for example, `boolean` becomes `java.lang.Boolean`).
|
||||
Note that this class may be a complex type that gets converted from a `String` as values are bound.
|
||||
|
|
@ -204,12 +204,12 @@ This is still supported in a deprecated fashion and should no longer be used.
|
|||
If no reason and replacement are available, an empty `deprecation` object should be set.
|
||||
|
||||
Deprecation can also be specified declaratively in code by adding the `@DeprecatedConfigurationProperty` annotation to the getter exposing the deprecated property.
|
||||
For instance, assume that the `app.acme.target` property was confusing and was renamed to `app.acme.name`.
|
||||
For instance, assume that the `my.app.target` property was confusing and was renamed to `my.app.name`.
|
||||
The following example shows how to handle that situation:
|
||||
|
||||
[source,java,indent=0]
|
||||
----
|
||||
include::{docs-java}/configurationmetadata/format/group/AcmeProperties.java[]
|
||||
include::{docs-java}/configurationmetadata/format/group/MyProperties.java[]
|
||||
----
|
||||
|
||||
NOTE: There is no way to set a `level`.
|
||||
|
|
|
|||
|
|
@ -16,11 +16,11 @@ Each value may have a description as well.
|
|||
If your property is of type `Map`, you can provide hints for both the keys and the values (but not for the map itself).
|
||||
The special `.keys` and `.values` suffixes must refer to the keys and the values, respectively.
|
||||
|
||||
Assume a `sample.contexts` maps magic `String` values to an integer, as shown in the following example:
|
||||
Assume a `my.contexts` maps magic `String` values to an integer, as shown in the following example:
|
||||
|
||||
[source,java,indent=0]
|
||||
----
|
||||
include::{docs-java}/configurationmetadata/manualhints/valuehint/SampleProperties.java[]
|
||||
include::{docs-java}/configurationmetadata/manualhints/valuehint/MyProperties.java[]
|
||||
----
|
||||
|
||||
The magic values are (in this example) are `sample1` and `sample2`.
|
||||
|
|
@ -30,7 +30,7 @@ In order to offer additional content assistance for the keys, you could add the
|
|||
----
|
||||
{"hints": [
|
||||
{
|
||||
"name": "sample.contexts.keys",
|
||||
"name": "my.contexts.keys",
|
||||
"values": [
|
||||
{
|
||||
"value": "sample1"
|
||||
|
|
|
|||
|
|
@ -11,7 +11,7 @@ In a nutshell, to add caching to an operation of your service add the relevant a
|
|||
|
||||
[source,java,indent=0]
|
||||
----
|
||||
include::{docs-java}/features/caching/MathService.java[]
|
||||
include::{docs-java}/features/caching/MyMathService.java[]
|
||||
----
|
||||
|
||||
This example demonstrates the use of caching on a potentially costly operation.
|
||||
|
|
@ -61,7 +61,7 @@ The following example sets a flag to say that `null` values should be passed dow
|
|||
|
||||
[source,java,indent=0]
|
||||
----
|
||||
include::{docs-java}/features/caching/provider/CacheManagerCustomizerConfiguration.java[]
|
||||
include::{docs-java}/features/caching/provider/MyCacheManagerConfiguration.java[]
|
||||
----
|
||||
|
||||
NOTE: In the preceding example, an auto-configured `ConcurrentMapCacheManager` is expected.
|
||||
|
|
@ -92,8 +92,8 @@ Even if the JSR-107 standard does not enforce a standardized way to define the l
|
|||
spring:
|
||||
cache:
|
||||
jcache:
|
||||
provider: "com.acme.MyCachingProvider"
|
||||
config: "classpath:acme.xml"
|
||||
provider: "com.example.MyCachingProvider"
|
||||
config: "classpath:example.xml"
|
||||
----
|
||||
|
||||
NOTE: When a cache library offers both a native implementation and JSR-107 support, Spring Boot prefers the JSR-107 support, so that the same features are available if you switch to a different JSR-107 implementation.
|
||||
|
|
@ -177,7 +177,7 @@ The following example shows a customizer that configures a specific entry expira
|
|||
|
||||
[source,java,indent=0]
|
||||
----
|
||||
include::{docs-java}/features/caching/provider/couchbase/CouchbaseCacheManagerConfiguration.java[]
|
||||
include::{docs-java}/features/caching/provider/couchbase/MyCouchbaseCacheManagerConfiguration.java[]
|
||||
----
|
||||
|
||||
|
||||
|
|
@ -208,7 +208,7 @@ The following example shows a customizer that configures a specific time to live
|
|||
|
||||
[source,java,indent=0]
|
||||
----
|
||||
include::{docs-java}/features/caching/provider/redis/RedisCacheManagerConfiguration.java[]
|
||||
include::{docs-java}/features/caching/provider/redis/MyRedisCacheManagerConfiguration.java[]
|
||||
----
|
||||
|
||||
|
||||
|
|
|
|||
|
|
@ -152,11 +152,11 @@ Concretely, each test should create a well defined `ApplicationContext` that rep
|
|||
`ApplicationContextRunner` provides a great way to achieve that.
|
||||
|
||||
`ApplicationContextRunner` is usually defined as a field of the test class to gather the base, common configuration.
|
||||
The following example makes sure that `UserServiceAutoConfiguration` is always invoked:
|
||||
The following example makes sure that `MyServiceAutoConfiguration` is always invoked:
|
||||
|
||||
[source,java,indent=0]
|
||||
----
|
||||
include::{docs-java}/features/developingautoconfiguration/testing/UserServiceAutoConfigurationTests.java[tag=runner]
|
||||
include::{docs-java}/features/developingautoconfiguration/testing/MyServiceAutoConfigurationTests.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.
|
||||
|
|
@ -167,14 +167,14 @@ Invoking `run` provides a callback context that can be used with `AssertJ`.
|
|||
|
||||
[source,java,indent=0]
|
||||
----
|
||||
include::{docs-java}/features/developingautoconfiguration/testing/UserServiceAutoConfigurationTests.java[tag=test-user-config]
|
||||
include::{docs-java}/features/developingautoconfiguration/testing/MyServiceAutoConfigurationTests.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::{docs-java}/features/developingautoconfiguration/testing/UserServiceAutoConfigurationTests.java[tag=test-env]
|
||||
include::{docs-java}/features/developingautoconfiguration/testing/MyServiceAutoConfigurationTests.java[tag=test-env]
|
||||
----
|
||||
|
||||
The runner can also be used to display the `ConditionEvaluationReport`.
|
||||
|
|
@ -183,7 +183,7 @@ The following example shows how to use the `ConditionEvaluationReportLoggingList
|
|||
|
||||
[source,java,indent=0]
|
||||
----
|
||||
include::{docs-java}/features/developingautoconfiguration/testing/ConditionEvaluationReportTests.java[]
|
||||
include::{docs-java}/features/developingautoconfiguration/testing/MyConditionEvaluationReportingTests.java[]
|
||||
----
|
||||
|
||||
|
||||
|
|
@ -198,11 +198,11 @@ If you need to test an auto-configuration that only operates in a Servlet or Rea
|
|||
==== Overriding the Classpath
|
||||
It is also possible to test what happens when a particular class and/or package is not present at runtime.
|
||||
Spring Boot ships with a `FilteredClassLoader` that can easily be used by the runner.
|
||||
In the following example, we assert that if `UserService` is not present, the auto-configuration is properly disabled:
|
||||
In the following example, we assert that if `MyService` is not present, the auto-configuration is properly disabled:
|
||||
|
||||
[source,java,indent=0]
|
||||
----
|
||||
include::{docs-java}/features/developingautoconfiguration/testing/UserServiceAutoConfigurationTests.java[tag=test-classloader]
|
||||
include::{docs-java}/features/developingautoconfiguration/testing/MyServiceAutoConfigurationTests.java[tag=test-classloader]
|
||||
----
|
||||
|
||||
|
||||
|
|
|
|||
|
|
@ -69,7 +69,7 @@ If you need to add or customize converters, you can use Spring Boot's `HttpMessa
|
|||
|
||||
[source,java,indent=0]
|
||||
----
|
||||
include::{docs-java}/features/developingwebapplications/springmvc/messageconverters/HttpMessageConvertersConfiguration.java[]
|
||||
include::{docs-java}/features/developingwebapplications/springmvc/messageconverters/MyHttpMessageConvertersConfiguration.java[]
|
||||
----
|
||||
|
||||
Any `HttpMessageConverter` bean that is present in the context is added to the list of converters.
|
||||
|
|
@ -352,7 +352,7 @@ You can also define a class annotated with `@ControllerAdvice` to customize the
|
|||
include::{docs-java}/features/developingwebapplications/springmvc/errorhandling/MyControllerAdvice.java[]
|
||||
----
|
||||
|
||||
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.
|
||||
In the preceding example, if `YourException` is thrown by a controller defined in the same package as `SomeController`, a JSON representation of the `CustomErrorType` POJO is used instead of the `ErrorAttributes` representation.
|
||||
|
||||
In some cases, errors handled at the controller level are not recorded by the <<actuator#actuator.metrics.supported.spring-mvc, metrics infrastructure>>.
|
||||
Applications can ensure that such exceptions are recorded with the request metrics by setting the handled exception as a request attribute:
|
||||
|
|
@ -419,14 +419,14 @@ This abstraction works directly with the underlying embedded servlet container a
|
|||
|
||||
[source,java,indent=0,subs="verbatim,quotes,attributes"]
|
||||
----
|
||||
include::{docs-java}/features/developingwebapplications/springmvc/errorhandling/errorpageswithoutspringmvc/ErrorPageConfiguration.java[]
|
||||
include::{docs-java}/features/developingwebapplications/springmvc/errorhandling/errorpageswithoutspringmvc/MyErrorPagesConfiguration.java[]
|
||||
----
|
||||
|
||||
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"]
|
||||
----
|
||||
include::{docs-java}/features/developingwebapplications/springmvc/errorhandling/errorpageswithoutspringmvc/ServletFilterConfiguration.java[]
|
||||
include::{docs-java}/features/developingwebapplications/springmvc/errorhandling/errorpageswithoutspringmvc/MyFilterConfiguration.java[]
|
||||
----
|
||||
|
||||
Note that the default `FilterRegistrationBean` does not include the `ERROR` dispatcher type.
|
||||
|
|
@ -469,7 +469,7 @@ Using {spring-framework-docs}/web.html#mvc-cors-controller[controller method COR
|
|||
|
||||
[source,java,indent=0]
|
||||
----
|
||||
include::{docs-java}/features/developingwebapplications/springmvc/cors/CorsConfiguration.java[]
|
||||
include::{docs-java}/features/developingwebapplications/springmvc/cors/MyCorsConfiguration.java[]
|
||||
----
|
||||
|
||||
|
||||
|
|
@ -491,12 +491,12 @@ include::{docs-java}/features/developingwebapplications/springwebflux/MyRestCont
|
|||
|
||||
[source,java,indent=0]
|
||||
----
|
||||
include::{docs-java}/features/developingwebapplications/springwebflux/RoutingConfiguration.java[]
|
||||
include::{docs-java}/features/developingwebapplications/springwebflux/MyRoutingConfiguration.java[]
|
||||
----
|
||||
|
||||
[source,java,indent=0]
|
||||
----
|
||||
include::{docs-java}/features/developingwebapplications/springwebflux/UserHandler.java[]
|
||||
include::{docs-java}/features/developingwebapplications/springwebflux/MyUserHandler.java[]
|
||||
----
|
||||
|
||||
WebFlux is part of the Spring Framework and detailed information is available in its {spring-framework-docs}/web-reactive.html#webflux-fn[reference documentation].
|
||||
|
|
@ -540,7 +540,7 @@ If you need to add or customize codecs, you can create a custom `CodecCustomizer
|
|||
|
||||
[source,java,indent=0]
|
||||
----
|
||||
include::{docs-java}/features/developingwebapplications/springwebflux/httpcodecs/CodecConfiguration.java[]
|
||||
include::{docs-java}/features/developingwebapplications/springwebflux/httpcodecs/MyCodecsConfiguration.java[]
|
||||
----
|
||||
|
||||
You can also leverage <<features#features.developing-web-applications.spring-mvc.json,Boot's custom JSON serializers and deserializers>>.
|
||||
|
|
@ -610,11 +610,11 @@ The first step to customizing this feature often involves using the existing mec
|
|||
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:
|
||||
Because a `ErrorWebExceptionHandler` 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"]
|
||||
----
|
||||
include::{docs-java}/features/developingwebapplications/springwebflux/errorhandling/CustomErrorWebExceptionHandler.java[]
|
||||
include::{docs-java}/features/developingwebapplications/springwebflux/errorhandling/MyErrorWebExceptionHandler.java[]
|
||||
----
|
||||
|
||||
For a more complete picture, you can also subclass `DefaultErrorWebExceptionHandler` directly and override specific methods.
|
||||
|
|
@ -624,7 +624,7 @@ Applications can ensure that such exceptions are recorded with the request metri
|
|||
|
||||
[source,java,indent=0,subs="verbatim,quotes,attributes"]
|
||||
----
|
||||
include::{docs-java}/features/developingwebapplications/springwebflux/errorhandling/ExceptionHandlingController.java[]
|
||||
include::{docs-java}/features/developingwebapplications/springwebflux/errorhandling/MyExceptionHandlingController.java[]
|
||||
----
|
||||
|
||||
|
||||
|
|
@ -702,7 +702,7 @@ To get started with Jersey, include the `spring-boot-starter-jersey` as a depend
|
|||
|
||||
[source,java,indent=0,subs="verbatim,quotes,attributes"]
|
||||
----
|
||||
include::{docs-java}/features/developingwebapplications/jersey/JerseyConfig.java[]
|
||||
include::{docs-java}/features/developingwebapplications/jersey/MyJerseyConfig.java[]
|
||||
----
|
||||
|
||||
WARNING: Jersey's support for scanning executable archives is rather limited.
|
||||
|
|
@ -715,7 +715,7 @@ All the registered endpoints should be `@Components` with HTTP resource annotati
|
|||
|
||||
[source,java,indent=0,subs="verbatim,quotes,attributes"]
|
||||
----
|
||||
include::{docs-java}/features/developingwebapplications/jersey/Endpoint.java[]
|
||||
include::{docs-java}/features/developingwebapplications/jersey/MyEndpoint.java[]
|
||||
----
|
||||
|
||||
Since the `Endpoint` is a Spring `@Component`, its lifecycle is managed by Spring and you can use the `@Autowired` annotation to inject dependencies and use the `@Value` annotation to inject external configuration.
|
||||
|
|
@ -829,7 +829,7 @@ The following example shows programmatically setting the port:
|
|||
|
||||
[source,java,indent=0]
|
||||
----
|
||||
include::{docs-java}/features/developingwebapplications/embeddedcontainer/customizing/programmatic/CustomizationBean.java[]
|
||||
include::{docs-java}/features/developingwebapplications/embeddedcontainer/customizing/programmatic/MyWebServerFactoryCustomizer.java[]
|
||||
----
|
||||
|
||||
`TomcatServletWebServerFactory`, `JettyServletWebServerFactory` and `UndertowServletWebServerFactory` are dedicated variants of `ConfigurableServletWebServerFactory` that have additional customization setter methods for Tomcat, Jetty and Undertow respectively.
|
||||
|
|
@ -837,7 +837,7 @@ The following example shows how to customize `TomcatServletWebServerFactory` tha
|
|||
|
||||
[source,java,indent=0,subs="verbatim,quotes,attributes"]
|
||||
----
|
||||
include::{docs-java}/features/developingwebapplications/embeddedcontainer/customizing/programmatic/TomcatServerCustomizer.java[]
|
||||
include::{docs-java}/features/developingwebapplications/embeddedcontainer/customizing/programmatic/MyTomcatWebServerFactoryCustomizer.java[]
|
||||
----
|
||||
|
||||
|
||||
|
|
|
|||
|
|
@ -73,23 +73,23 @@ For example, the `SPRING_APPLICATION_JSON` property can be supplied on the comma
|
|||
|
||||
[indent=0]
|
||||
----
|
||||
$ SPRING_APPLICATION_JSON='{"acme":{"name":"test"}}' java -jar myapp.jar
|
||||
$ SPRING_APPLICATION_JSON='{"my":{"name":"test"}}' java -jar myapp.jar
|
||||
----
|
||||
|
||||
In the preceding example, you end up with `acme.name=test` in the Spring `Environment`.
|
||||
In the preceding example, you end up with `my.name=test` in the Spring `Environment`.
|
||||
|
||||
The same JSON can also be provided as a system property:
|
||||
|
||||
[indent=0]
|
||||
----
|
||||
$ java -Dspring.application.json='{"acme":{"name":"test"}}' -jar myapp.jar
|
||||
$ java -Dspring.application.json='{"my":{"name":"test"}}' -jar myapp.jar
|
||||
----
|
||||
|
||||
Or you could supply the JSON by using a command line argument:
|
||||
|
||||
[indent=0]
|
||||
----
|
||||
$ java -jar myapp.jar --spring.application.json='{"acme":{"name":"test"}}'
|
||||
$ java -jar myapp.jar --spring.application.json='{"my":{"name":"test"}}'
|
||||
----
|
||||
|
||||
If you are deploying to a classic Application Server, you could also use a JNDI variable named `java:comp/env/spring.application.json`.
|
||||
|
|
@ -616,17 +616,17 @@ It is possible to bind a bean declaring standard JavaBean properties as shown in
|
|||
|
||||
[source,java,indent=0]
|
||||
----
|
||||
include::{docs-java}/features/externalconfig/typesafeconfigurationproperties/javabeanbinding/AcmeProperties.java[]
|
||||
include::{docs-java}/features/externalconfig/typesafeconfigurationproperties/javabeanbinding/MyProperties.java[]
|
||||
----
|
||||
|
||||
The preceding POJO defines the following properties:
|
||||
|
||||
* `acme.enabled`, with a value of `false` by default.
|
||||
* `acme.remote-address`, with a type that can be coerced from `String`.
|
||||
* `acme.security.username`, with a nested "security" object whose name is determined by the name of the property.
|
||||
* `my.service.enabled`, with a value of `false` by default.
|
||||
* `my.service.remote-address`, with a type that can be coerced from `String`.
|
||||
* `my.service.security.username`, with a nested "security" object whose name is determined by the name of the property.
|
||||
In particular, the return type is not used at all there and could have been `SecurityProperties`.
|
||||
* `acme.security.password`.
|
||||
* `acme.security.roles`, with a collection of `String` that defaults to `USER`.
|
||||
* `my.service.security.password`.
|
||||
* `my.service.security.roles`, with a collection of `String` that defaults to `USER`.
|
||||
|
||||
NOTE: The properties that map to `@ConfigurationProperties` classes available in Spring Boot, which are configured via properties files, YAML files, environment variables etc., are public API but the accessors (getters/setters) of the class itself are not meant to be used directly.
|
||||
|
||||
|
|
@ -657,7 +657,7 @@ The example in the previous section can be rewritten in an immutable fashion as
|
|||
|
||||
[source,java,indent=0]
|
||||
----
|
||||
include::{docs-java}/features/externalconfig/typesafeconfigurationproperties/constructorbinding/AcmeProperties.java[]
|
||||
include::{docs-java}/features/externalconfig/typesafeconfigurationproperties/constructorbinding/MyProperties.java[]
|
||||
----
|
||||
|
||||
In this setup, the `@ConstructorBinding` annotation is used to indicate that constructor binding should be used.
|
||||
|
|
@ -666,12 +666,12 @@ This means that the binder will expect to find a constructor with the parameters
|
|||
Nested members of a `@ConstructorBinding` class (such as `Security` in the example above) will also be bound via their constructor.
|
||||
|
||||
Default values can be specified using `@DefaultValue` and the same conversion service will be applied to coerce the `String` value to the target type of a missing property.
|
||||
By default, if no properties are bound to `Security`, the `AcmeProperties` instance will contain a `null` value for `security`.
|
||||
By default, if no properties are bound to `Security`, the `MyProperties` 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,indent=0]
|
||||
----
|
||||
include::{docs-java}/features/externalconfig/typesafeconfigurationproperties/constructorbinding/nonnull/AcmeProperties.java[]
|
||||
include::{docs-java}/features/externalconfig/typesafeconfigurationproperties/constructorbinding/nonnull/MyProperties.java[]
|
||||
----
|
||||
|
||||
|
||||
|
|
@ -715,7 +715,7 @@ include::{docs-java}/features/externalconfig/typesafeconfigurationproperties/ena
|
|||
When the `@ConfigurationProperties` bean is registered using configuration property scanning or via `@EnableConfigurationProperties`, the bean has a conventional name: `<prefix>-<fqn>`, where `<prefix>` is the environment key prefix specified in the `@ConfigurationProperties` annotation and `<fqn>` is the fully qualified name of the bean.
|
||||
If the annotation does not provide any prefix, only the fully qualified name of the bean is used.
|
||||
|
||||
The bean name in the example above is `acme-com.example.AcmeProperties`.
|
||||
The bean name in the example above is `com.example.app-com.example.app.SomeProperties`.
|
||||
====
|
||||
|
||||
We recommend that `@ConfigurationProperties` only deal with the environment and, in particular, does not inject other beans from the context.
|
||||
|
|
@ -730,13 +730,14 @@ This style of configuration works particularly well with the `SpringApplication`
|
|||
|
||||
[source,yaml,indent=0]
|
||||
----
|
||||
acme:
|
||||
remote-address: 192.168.1.1
|
||||
security:
|
||||
username: admin
|
||||
roles:
|
||||
- USER
|
||||
- ADMIN
|
||||
my:
|
||||
service:
|
||||
remote-address: 192.168.1.1
|
||||
security:
|
||||
username: admin
|
||||
roles:
|
||||
- USER
|
||||
- ADMIN
|
||||
----
|
||||
|
||||
To work with `@ConfigurationProperties` beans, you can inject them in the same way as any other bean, as shown in the following example:
|
||||
|
|
@ -763,7 +764,7 @@ To configure a bean from the `Environment` properties, add `@ConfigurationProper
|
|||
include::{docs-java}/features/externalconfig/typesafeconfigurationproperties/thirdpartyconfiguration/ThirdPartyConfiguration.java[]
|
||||
----
|
||||
|
||||
Any JavaBean property defined with the `another` prefix is mapped onto that `AnotherComponent` bean in manner similar to the preceding `AcmeProperties` example.
|
||||
Any JavaBean property defined with the `another` prefix is mapped onto that `AnotherComponent` bean in manner similar to the preceding `SomeProperties` example.
|
||||
|
||||
|
||||
|
||||
|
|
@ -776,7 +777,7 @@ As an example, consider the following `@ConfigurationProperties` class:
|
|||
|
||||
[source,java,indent=0]
|
||||
----
|
||||
include::{docs-java}/features/externalconfig/typesafeconfigurationproperties/relaxedbinding/OwnerProperties.java[]
|
||||
include::{docs-java}/features/externalconfig/typesafeconfigurationproperties/relaxedbinding/MyPersonProperties.java[]
|
||||
----
|
||||
|
||||
With the preceding code, the following properties names can all be used:
|
||||
|
|
@ -786,20 +787,20 @@ With the preceding code, the following properties names can all be used:
|
|||
|===
|
||||
| Property | Note
|
||||
|
||||
| `acme.my-project.person.first-name`
|
||||
| `my.main-project.person.first-name`
|
||||
| Kebab case, which is recommended for use in `.properties` and `.yml` files.
|
||||
|
||||
| `acme.myProject.person.firstName`
|
||||
| `my.main-project.person.firstName`
|
||||
| Standard camel case syntax.
|
||||
|
||||
| `acme.my_project.person.first_name`
|
||||
| `my.main-project.person.first_name`
|
||||
| Underscore notation, which is an alternative format for use in `.properties` and `.yml` files.
|
||||
|
||||
| `ACME_MYPROJECT_PERSON_FIRSTNAME`
|
||||
| `MY_MAINPROJECT_PERSON_FIRSTNAME`
|
||||
| Upper case format, which is recommended when using system environment variables.
|
||||
|===
|
||||
|
||||
NOTE: The `prefix` value for the annotation _must_ be in kebab case (lowercase and separated by `-`, such as `acme.my-project.person`).
|
||||
NOTE: The `prefix` value for the annotation _must_ be in kebab case (lowercase and separated by `-`, such as `my.main-project.person`).
|
||||
|
||||
.relaxed binding rules per property source
|
||||
[cols="2,4,4"]
|
||||
|
|
@ -823,7 +824,7 @@ NOTE: The `prefix` value for the annotation _must_ be in kebab case (lowercase a
|
|||
| Standard list syntax using `[ ]` or comma-separated values
|
||||
|===
|
||||
|
||||
TIP: We recommend that, when possible, properties are stored in lower-case kebab format, such as `my.property-name=acme`.
|
||||
TIP: We recommend that, when possible, properties are stored in lower-case kebab format, such as `my.person.first-name=Rod`.
|
||||
|
||||
|
||||
|
||||
|
|
@ -838,15 +839,15 @@ For example, consider binding the following properties to a `Map<String,String>`
|
|||
[source,properties,indent=0,role="primary"]
|
||||
.Properties
|
||||
----
|
||||
acme.map.[/key1]=value1
|
||||
acme.map.[/key2]=value2
|
||||
acme.map./key3=value3
|
||||
my.map.[/key1]=value1
|
||||
my.map.[/key2]=value2
|
||||
my.map./key3=value3
|
||||
----
|
||||
|
||||
[source,yaml,indent=0,role="secondary"]
|
||||
.Yaml
|
||||
----
|
||||
acme:
|
||||
my:
|
||||
map:
|
||||
"[/key1]": "value1"
|
||||
"[/key2]": "value2"
|
||||
|
|
@ -882,7 +883,7 @@ For example, the configuration property `spring.main.log-startup-info` would be
|
|||
Environment variables can also be used when binding to object lists.
|
||||
To bind to a `List`, the element number should be surrounded with underscores in the variable name.
|
||||
|
||||
For example, the configuration property `my.acme[0].other` would use an environment variable named `MY_ACME_0_OTHER`.
|
||||
For example, the configuration property `my.service[0].other` would use an environment variable named `MY_SERVICE_0_OTHER`.
|
||||
|
||||
|
||||
|
||||
|
|
@ -891,18 +892,18 @@ For example, the configuration property `my.acme[0].other` would use an environm
|
|||
When lists are configured in more than one place, overriding works by replacing the entire list.
|
||||
|
||||
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`:
|
||||
The following example exposes a list of `MyPojo` objects from `MyProperties`:
|
||||
|
||||
[source,java,indent=0]
|
||||
----
|
||||
include::{docs-java}/features/externalconfig/typesafeconfigurationproperties/mergingcomplextypes/list/AcmeProperties.java[tag=*]
|
||||
include::{docs-java}/features/externalconfig/typesafeconfigurationproperties/mergingcomplextypes/list/MyProperties.java[]
|
||||
----
|
||||
|
||||
Consider the following configuration:
|
||||
|
||||
[source,yaml,indent=0,configblocks]
|
||||
----
|
||||
acme:
|
||||
my:
|
||||
list:
|
||||
- name: "my name"
|
||||
description: "my description"
|
||||
|
|
@ -911,12 +912,12 @@ Consider the following configuration:
|
|||
config:
|
||||
activate:
|
||||
on-profile: "dev"
|
||||
acme:
|
||||
my:
|
||||
list:
|
||||
- name: "my another name"
|
||||
----
|
||||
|
||||
If the `dev` profile is not active, `AcmeProperties.list` contains one `MyPojo` entry, as previously defined.
|
||||
If the `dev` profile is not active, `MyProperties.list` contains one `MyPojo` entry, as previously defined.
|
||||
If the `dev` profile is enabled, however, the `list` _still_ contains only one entry (with a name of `my another name` and a description of `null`).
|
||||
This configuration _does not_ add a second `MyPojo` instance to the list, and it does not merge the items.
|
||||
|
||||
|
|
@ -925,7 +926,7 @@ Consider the following example:
|
|||
|
||||
[source,yaml,indent=0,configblocks]
|
||||
----
|
||||
acme:
|
||||
my:
|
||||
list:
|
||||
- name: "my name"
|
||||
description: "my description"
|
||||
|
|
@ -936,28 +937,28 @@ Consider the following example:
|
|||
config:
|
||||
activate:
|
||||
on-profile: "dev"
|
||||
acme:
|
||||
my:
|
||||
list:
|
||||
- name: "my another name"
|
||||
----
|
||||
|
||||
In the preceding example, if the `dev` profile is active, `AcmeProperties.list` contains _one_ `MyPojo` entry (with a name of `my another name` and a description of `null`).
|
||||
In the preceding example, if the `dev` profile is active, `MyProperties.list` contains _one_ `MyPojo` entry (with a name of `my another name` and a description of `null`).
|
||||
For YAML, both comma-separated lists and YAML lists can be used for completely overriding the contents of the list.
|
||||
|
||||
For `Map` properties, you can bind with property values drawn from multiple sources.
|
||||
However, for the same property in multiple sources, the one with the highest priority is used.
|
||||
The following example exposes a `Map<String, MyPojo>` from `AcmeProperties`:
|
||||
The following example exposes a `Map<String, MyPojo>` from `MyProperties`:
|
||||
|
||||
[source,java,indent=0]
|
||||
----
|
||||
include::{docs-java}/features/externalconfig/typesafeconfigurationproperties/mergingcomplextypes/map/AcmeProperties.java[tag=*]
|
||||
include::{docs-java}/features/externalconfig/typesafeconfigurationproperties/mergingcomplextypes/map/MyProperties.java[]
|
||||
----
|
||||
|
||||
Consider the following configuration:
|
||||
|
||||
[source,yaml,indent=0,configblocks]
|
||||
----
|
||||
acme:
|
||||
my:
|
||||
map:
|
||||
key1:
|
||||
name: "my name 1"
|
||||
|
|
@ -967,7 +968,7 @@ Consider the following configuration:
|
|||
config:
|
||||
activate:
|
||||
on-profile: "dev"
|
||||
acme:
|
||||
my:
|
||||
map:
|
||||
key1:
|
||||
name: "dev name 1"
|
||||
|
|
@ -976,7 +977,7 @@ Consider the following configuration:
|
|||
description: "dev description 2"
|
||||
----
|
||||
|
||||
If the `dev` profile is not active, `AcmeProperties.map` contains one entry with key `key1` (with a name of `my name 1` and a description of `my description 1`).
|
||||
If the `dev` profile is not active, `MyProperties.map` contains one entry with key `key1` (with a name of `my name 1` and a description of `my description 1`).
|
||||
If the `dev` profile is enabled, however, `map` contains two entries with keys `key1` (with a name of `dev name 1` and a description of `my description 1`) and `key2` (with a name of `dev name 2` and a description of `dev description 2`).
|
||||
|
||||
NOTE: The preceding merging rules apply to properties from all property sources, and not just files.
|
||||
|
|
@ -1007,7 +1008,7 @@ Consider the following example:
|
|||
|
||||
[source,java,indent=0]
|
||||
----
|
||||
include::{docs-java}/features/externalconfig/typesafeconfigurationproperties/conversion/durations/javabeanbinding/AppSystemProperties.java[]
|
||||
include::{docs-java}/features/externalconfig/typesafeconfigurationproperties/conversion/durations/javabeanbinding/MyProperties.java[]
|
||||
----
|
||||
|
||||
To specify a session timeout of 30 seconds, `30`, `PT30S` and `30s` are all equivalent.
|
||||
|
|
@ -1030,7 +1031,7 @@ If you prefer to use constructor binding, the same properties can be exposed, as
|
|||
|
||||
[source,java,indent=0]
|
||||
----
|
||||
include::{docs-java}/features/externalconfig/typesafeconfigurationproperties/conversion/durations/constructorbinding/AppSystemProperties.java[]
|
||||
include::{docs-java}/features/externalconfig/typesafeconfigurationproperties/conversion/durations/constructorbinding/MyProperties.java[]
|
||||
----
|
||||
|
||||
|
||||
|
|
@ -1071,7 +1072,7 @@ Consider the following example:
|
|||
|
||||
[source,java,indent=0]
|
||||
----
|
||||
include::{docs-java}/features/externalconfig/typesafeconfigurationproperties/conversion/datasizes/javabeanbinding/AppIoProperties.java[]
|
||||
include::{docs-java}/features/externalconfig/typesafeconfigurationproperties/conversion/datasizes/javabeanbinding/MyProperties.java[]
|
||||
----
|
||||
|
||||
To specify a buffer size of 10 megabytes, `10` and `10MB` are equivalent.
|
||||
|
|
@ -1092,7 +1093,7 @@ If you prefer to use constructor binding, the same properties can be exposed, as
|
|||
|
||||
[source,java,indent=0]
|
||||
----
|
||||
include::{docs-java}/features/externalconfig/typesafeconfigurationproperties/conversion/datasizes/constructorbinding/AppIoProperties.java[]
|
||||
include::{docs-java}/features/externalconfig/typesafeconfigurationproperties/conversion/datasizes/constructorbinding/MyProperties.java[]
|
||||
----
|
||||
|
||||
TIP: If you are upgrading a `Long` property, make sure to define the unit (using `@DataSizeUnit`) if it isn't bytes.
|
||||
|
|
@ -1108,17 +1109,17 @@ To do so, ensure that a compliant JSR-303 implementation is on your classpath an
|
|||
|
||||
[source,java,indent=0]
|
||||
----
|
||||
include::{docs-java}/features/externalconfig/typesafeconfigurationproperties/validate/AcmeProperties.java[]
|
||||
include::{docs-java}/features/externalconfig/typesafeconfigurationproperties/validate/MyProperties.java[]
|
||||
----
|
||||
|
||||
TIP: You can also trigger validation by annotating the `@Bean` method that creates the configuration properties with `@Validated`.
|
||||
|
||||
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:
|
||||
The following example builds on the preceding `MyProperties` example:
|
||||
|
||||
[source,java,indent=0]
|
||||
----
|
||||
include::{docs-java}/features/externalconfig/typesafeconfigurationproperties/validate/nested/AcmeProperties.java[]
|
||||
include::{docs-java}/features/externalconfig/typesafeconfigurationproperties/validate/nested/MyProperties.java[]
|
||||
----
|
||||
|
||||
You can also add a custom Spring `Validator` by creating a bean definition called `configurationPropertiesValidator`.
|
||||
|
|
|
|||
|
|
@ -174,7 +174,7 @@ For instance, the following example exposes another factory that uses a specific
|
|||
|
||||
[source,java,indent=0]
|
||||
----
|
||||
include::{docs-java}/features/messaging/jms/receiving/custom/JmsConfiguration.java[]
|
||||
include::{docs-java}/features/messaging/jms/receiving/custom/MyJmsConfiguration.java[]
|
||||
----
|
||||
|
||||
Then you can use the factory in any `@JmsListener`-annotated method as follows:
|
||||
|
|
@ -290,7 +290,7 @@ For instance, the following configuration class exposes another factory that use
|
|||
|
||||
[source,java,indent=0]
|
||||
----
|
||||
include::{docs-java}/features/messaging/amqp/receiving/custom/RabbitConfiguration.java[]
|
||||
include::{docs-java}/features/messaging/amqp/receiving/custom/MyRabbitConfiguration.java[]
|
||||
----
|
||||
|
||||
Then you can use the factory in any `@RabbitListener`-annotated method, as follows:
|
||||
|
|
@ -387,7 +387,7 @@ To use the factory bean, wire `StreamsBuilder` into your `@Bean` as shown in the
|
|||
|
||||
[source,java,indent=0]
|
||||
----
|
||||
include::{docs-java}/features/messaging/kafka/streams/KafkaStreamsConfiguration.java[]
|
||||
include::{docs-java}/features/messaging/kafka/streams/MyKafkaStreamsConfiguration.java[]
|
||||
----
|
||||
|
||||
By default, the streams managed by the `StreamBuilder` object it creates are started automatically.
|
||||
|
|
@ -440,7 +440,7 @@ You can also configure the Spring Kafka `JsonDeserializer` as follows:
|
|||
value-deserializer: "org.springframework.kafka.support.serializer.JsonDeserializer"
|
||||
properties:
|
||||
"[spring.json.value.default.type]": "com.example.Invoice"
|
||||
"[spring.json.trusted.packages]": "com.example,org.acme"
|
||||
"[spring.json.trusted.packages]": "com.example.main,com.example.another"
|
||||
----
|
||||
|
||||
Similarly, you can disable the `JsonSerializer` default behavior of sending type information in headers:
|
||||
|
|
|
|||
|
|
@ -222,7 +222,7 @@ To enable transaction management, the following bean must be defined in your con
|
|||
|
||||
[source,java,indent=0]
|
||||
----
|
||||
include::{docs-java}/features/nosql/neo4j/repositories/Neo4jReactiveTransactionManagerConfiguration.java[]
|
||||
include::{docs-java}/features/nosql/neo4j/repositories/MyNeo4jConfiguration.java[]
|
||||
----
|
||||
====
|
||||
|
||||
|
|
@ -527,7 +527,7 @@ For instance, you can customize the converters to use, as follows:
|
|||
|
||||
[source,java,indent=0]
|
||||
----
|
||||
include::{docs-java}/features/nosql/couchbase/repositories/CouchbaseConversionsConfiguration.java[]
|
||||
include::{docs-java}/features/nosql/couchbase/repositories/MyCouchbaseConfiguration.java[]
|
||||
----
|
||||
|
||||
|
||||
|
|
|
|||
|
|
@ -52,5 +52,5 @@ Regular beans can also be injected in a similar manner, as shown in the followin
|
|||
|
||||
[source,java,indent=0]
|
||||
----
|
||||
include::{docs-java}/features/quartz/SampleJob.java[]
|
||||
include::{docs-java}/features/quartz/MySampleJob.java[]
|
||||
----
|
||||
|
|
|
|||
|
|
@ -31,7 +31,7 @@ The following example shows a customizer that configures the use of a proxy for
|
|||
|
||||
[source,java,indent=0]
|
||||
----
|
||||
include::{docs-java}/features/resttemplate/customization/RestTemplateProxyCustomizer.java[]
|
||||
include::{docs-java}/features/resttemplate/customization/MyRestTemplateCustomizer.java[]
|
||||
----
|
||||
|
||||
Finally, you can also create your own `RestTemplateBuilder` bean.
|
||||
|
|
@ -40,7 +40,7 @@ The following example exposes a `RestTemplateBuilder` with what Spring Boot woul
|
|||
|
||||
[source,java,indent=0]
|
||||
----
|
||||
include::{docs-java}/features/resttemplate/customization/RestTemplateBuilderConfiguration.java[]
|
||||
include::{docs-java}/features/resttemplate/customization/MyRestTemplateBuilderConfiguration.java[]
|
||||
----
|
||||
|
||||
The most extreme (and rarely used) option is to create your own `RestTemplateBuilder` bean without using a configurer.
|
||||
|
|
|
|||
|
|
@ -62,7 +62,7 @@ For example, you can customize your security configuration by adding something l
|
|||
|
||||
[source,java,indent=0]
|
||||
----
|
||||
include::{docs-java}/features/security/springwebflux/CustomWebFluxSecurityConfiguration.java[]
|
||||
include::{docs-java}/features/security/springwebflux/MyWebFluxSecurityConfiguration.java[]
|
||||
----
|
||||
|
||||
|
||||
|
|
@ -141,7 +141,7 @@ For example, for servlet applications, you can add your own `SecurityFilterChain
|
|||
|
||||
[source,java,indent=0]
|
||||
----
|
||||
include::{docs-java}/features/security/oauth2/client/OAuthClientConfiguration.java[]
|
||||
include::{docs-java}/features/security/oauth2/client/MyOAuthClientConfiguration.java[]
|
||||
----
|
||||
|
||||
TIP: Spring Boot auto-configures an `InMemoryOAuth2AuthorizedClientService` which is used by Spring Security for the management of client registrations.
|
||||
|
|
|
|||
|
|
@ -188,7 +188,7 @@ The `SpringApplicationBuilder` lets you chain together multiple method calls and
|
|||
|
||||
[source,java,indent=0]
|
||||
----
|
||||
include::{docs-java}/features/springapplication/fluentbuilderapi/SpringApplicationBuilderExample.java[tag=*]
|
||||
include::{docs-java}/features/springapplication/fluentbuilderapi/MyApplication.java[tag=*]
|
||||
----
|
||||
|
||||
NOTE: There are some restrictions when creating an `ApplicationContext` hierarchy.
|
||||
|
|
@ -242,14 +242,14 @@ For example, we can export the "Readiness" state of the application to a file so
|
|||
|
||||
[source,java,indent=0]
|
||||
----
|
||||
include::{docs-java}/features/springapplication/applicationavailability/managing/ReadinessStateExporter.java[]
|
||||
include::{docs-java}/features/springapplication/applicationavailability/managing/MyReadinessStateExporter.java[]
|
||||
----
|
||||
|
||||
We can also update the state of the application, when the application breaks and cannot recover:
|
||||
|
||||
[source,java,indent=0]
|
||||
----
|
||||
include::{docs-java}/features/springapplication/applicationavailability/managing/LocalCacheVerifier.java[]
|
||||
include::{docs-java}/features/springapplication/applicationavailability/managing/MyLocalCacheVerifier.java[]
|
||||
----
|
||||
|
||||
Spring Boot provides <<actuator#actuator.endpoints.kubernetes-probes,Kubernetes HTTP probes for "Liveness" and "Readiness" with Actuator Health Endpoints>>.
|
||||
|
|
@ -334,7 +334,7 @@ The `ApplicationArguments` interface provides access to both the raw `String[]`
|
|||
|
||||
[source,java,indent=0]
|
||||
----
|
||||
include::{docs-java}/features/springapplication/applicationarguments/ApplicationArgumentsExample.java[]
|
||||
include::{docs-java}/features/springapplication/applicationarguments/MyBean.java[]
|
||||
----
|
||||
|
||||
TIP: Spring Boot also registers a `CommandLinePropertySource` with the Spring `Environment`.
|
||||
|
|
@ -355,7 +355,7 @@ The following example shows a `CommandLineRunner` with a `run` method:
|
|||
|
||||
[source,java,indent=0]
|
||||
----
|
||||
include::{docs-java}/features/springapplication/commandlinerunner/CommandLineRunnerExample.java[]
|
||||
include::{docs-java}/features/springapplication/commandlinerunner/MyCommandLineRunner.java[]
|
||||
----
|
||||
|
||||
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.
|
||||
|
|
|
|||
|
|
@ -368,7 +368,7 @@ To use the `DSLContext`, you can inject it, as shown in the following example:
|
|||
|
||||
[source,java,indent=0]
|
||||
----
|
||||
include::{docs-java}/features/sql/jooq/dslcontext/JooqExample.java[tag=!method]
|
||||
include::{docs-java}/features/sql/jooq/dslcontext/MyBean.java[tag=!method]
|
||||
----
|
||||
|
||||
TIP: The jOOQ manual tends to use a variable named `create` to hold the `DSLContext`.
|
||||
|
|
@ -377,7 +377,7 @@ You can then use the `DSLContext` to construct your queries, as shown in the fol
|
|||
|
||||
[source,java,indent=0]
|
||||
----
|
||||
include::{docs-java}/features/sql/jooq/dslcontext/JooqExample.java[tag=method]
|
||||
include::{docs-java}/features/sql/jooq/dslcontext/MyBean.java[tag=method]
|
||||
----
|
||||
|
||||
|
||||
|
|
@ -430,14 +430,14 @@ The following example shows how to manually override the database port while the
|
|||
|
||||
[source,java,indent=0]
|
||||
----
|
||||
include::{docs-java}/features/sql/r2dbc/MyR2dbcPortConfiguration.java[]
|
||||
include::{docs-java}/features/sql/r2dbc/MyR2dbcConfiguration.java[]
|
||||
----
|
||||
|
||||
The following examples show how to set some PostgreSQL connection options:
|
||||
|
||||
[source,java,indent=0]
|
||||
----
|
||||
include::{docs-java}/features/sql/r2dbc/CustomizeR2dbcPostgresOptionsConfiguration.java[tag=*]
|
||||
include::{docs-java}/features/sql/r2dbc/MyPostgresR2dbcConfiguration.java[]
|
||||
----
|
||||
|
||||
When a `ConnectionFactory` bean is available, the regular JDBC `DataSource` auto-configuration backs off.
|
||||
|
|
@ -474,7 +474,7 @@ A `DatabaseClient` bean is auto-configured, and you can `@Autowire` it directly
|
|||
|
||||
[source,java,indent=0]
|
||||
----
|
||||
include::{docs-java}/features/sql/r2dbc/usingdatabaseclient/MyBean.java[tag=*]
|
||||
include::{docs-java}/features/sql/r2dbc/usingdatabaseclient/MyBean.java[]
|
||||
----
|
||||
|
||||
|
||||
|
|
@ -494,7 +494,7 @@ The following example shows a typical Spring Data repository interface definitio
|
|||
|
||||
[source,java,indent=0]
|
||||
----
|
||||
include::{docs-java}/features/sql/r2dbc/repositories/CityRepository.java[tag=*]
|
||||
include::{docs-java}/features/sql/r2dbc/repositories/CityRepository.java[]
|
||||
----
|
||||
|
||||
TIP: We have barely scratched the surface of Spring Data R2DBC. For complete details, see the {spring-data-r2dbc-docs}[Spring Data R2DBC reference documentation].
|
||||
|
|
|
|||
|
|
@ -165,7 +165,7 @@ have `@SpringBootTest` inject them using the `args` attribute.
|
|||
|
||||
[source,java,indent=0]
|
||||
----
|
||||
include::{docs-java}/features/testing/springbootapplications/usingapplicationarguments/ApplicationArgumentTests.java[]
|
||||
include::{docs-java}/features/testing/springbootapplications/usingapplicationarguments/MyApplicationArgumentTests.java[]
|
||||
----
|
||||
|
||||
|
||||
|
|
@ -177,7 +177,7 @@ If you have web endpoints that you want to test against this mock environment, y
|
|||
|
||||
[source,java,indent=0]
|
||||
----
|
||||
include::{docs-java}/features/testing/springbootapplications/withmockenvironment/MockMvcTests.java[]
|
||||
include::{docs-java}/features/testing/springbootapplications/withmockenvironment/MyMockMvcTests.java[]
|
||||
----
|
||||
|
||||
TIP: If you want to focus only on the web layer and not start a complete `ApplicationContext`, consider <<features#features.testing.spring-boot-applications.spring-mvc-tests,using `@WebMvcTest` instead>>.
|
||||
|
|
@ -186,7 +186,7 @@ Alternatively, you can configure a {spring-framework-docs}/testing.html#webtestc
|
|||
|
||||
[source,java,indent=0]
|
||||
----
|
||||
include::{docs-java}/features/testing/springbootapplications/withmockenvironment/MockWebTestClientTests.java[]
|
||||
include::{docs-java}/features/testing/springbootapplications/withmockenvironment/MyMockWebTestClientTests.java[]
|
||||
----
|
||||
|
||||
[TIP]
|
||||
|
|
@ -211,7 +211,7 @@ For convenience, tests that need to make REST calls to the started server can ad
|
|||
|
||||
[source,java,indent=0]
|
||||
----
|
||||
include::{docs-java}/features/testing/springbootapplications/withrunningserver/RandomPortWebTestClientTests.java[]
|
||||
include::{docs-java}/features/testing/springbootapplications/withrunningserver/MyRandomPortWebTestClientTests.java[]
|
||||
----
|
||||
|
||||
This setup requires `spring-webflux` on the classpath.
|
||||
|
|
@ -219,7 +219,7 @@ If you can't or won't add webflux, Spring Boot also provides a `TestRestTemplate
|
|||
|
||||
[source,java,indent=0]
|
||||
----
|
||||
include::{docs-java}/features/testing/springbootapplications/withrunningserver/RandomPortTestRestTemplateTests.java[]
|
||||
include::{docs-java}/features/testing/springbootapplications/withrunningserver/MyRandomPortTestRestTemplateTests.java[]
|
||||
----
|
||||
|
||||
|
||||
|
|
@ -238,7 +238,7 @@ If such test needs access to an `MBeanServer`, consider marking it dirty as well
|
|||
|
||||
[source,java,indent=0]
|
||||
----
|
||||
include::{docs-java}/features/testing/springbootapplications/jmx/SampleJmxTests.java[]
|
||||
include::{docs-java}/features/testing/springbootapplications/jmx/MyJmxTests.java[]
|
||||
----
|
||||
|
||||
|
||||
|
|
@ -357,7 +357,7 @@ For instance, the following example asserts that the actual number is a float va
|
|||
|
||||
[source,java,indent=0]
|
||||
----
|
||||
include::{docs-java}/features/testing/springbootapplications/jsontests/AssertJ.java[tag=*]
|
||||
include::{docs-java}/features/testing/springbootapplications/jsontests/MyJsonAssertJTests.java[tag=*]
|
||||
----
|
||||
|
||||
|
||||
|
|
@ -710,14 +710,14 @@ You can inject it by using `@Autowired` and use it in your tests as you normally
|
|||
|
||||
[source,java,indent=0]
|
||||
----
|
||||
include::{docs-java}/features/testing/springbootapplications/autoconfiguredspringrestdocs/withmockmvc/UserDocumentationTests.java[]
|
||||
include::{docs-java}/features/testing/springbootapplications/autoconfiguredspringrestdocs/withmockmvc/MyUserDocumentationTests.java[]
|
||||
----
|
||||
|
||||
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]
|
||||
----
|
||||
include::{docs-java}/features/testing/springbootapplications/autoconfiguredspringrestdocs/withmockmvc/CustomizationConfiguration.java[]
|
||||
include::{docs-java}/features/testing/springbootapplications/autoconfiguredspringrestdocs/withmockmvc/MyRestDocsConfiguration.java[]
|
||||
----
|
||||
|
||||
If you want to make use of Spring REST Docs support for a parameterized output directory, you can create a `RestDocumentationResultHandler` bean.
|
||||
|
|
@ -726,7 +726,7 @@ The following example shows a `RestDocumentationResultHandler` being defined:
|
|||
|
||||
[source,java,indent=0]
|
||||
----
|
||||
include::{docs-java}/features/testing/springbootapplications/autoconfiguredspringrestdocs/withmockmvc/ResultHandlerConfiguration.java[]
|
||||
include::{docs-java}/features/testing/springbootapplications/autoconfiguredspringrestdocs/withmockmvc/MyResultHandlerConfiguration.java[]
|
||||
----
|
||||
|
||||
|
||||
|
|
@ -738,14 +738,14 @@ You can inject it by using `@Autowired` and use it in your tests as you normally
|
|||
|
||||
[source,java,indent=0]
|
||||
----
|
||||
include::{docs-java}/features/testing/springbootapplications/autoconfiguredspringrestdocs/withwebtestclient/UsersDocumentationTests.java[]
|
||||
include::{docs-java}/features/testing/springbootapplications/autoconfiguredspringrestdocs/withwebtestclient/MyUsersDocumentationTests.java[]
|
||||
----
|
||||
|
||||
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::{docs-java}/features/testing/springbootapplications/autoconfiguredspringrestdocs/withwebtestclient/AdvancedRestDocsConfiguration.java[]
|
||||
include::{docs-java}/features/testing/springbootapplications/autoconfiguredspringrestdocs/withwebtestclient/MyRestDocsConfiguration.java[]
|
||||
----
|
||||
|
||||
|
||||
|
|
@ -757,14 +757,14 @@ You can inject it by using `@Autowired` and use it in your tests as you normally
|
|||
|
||||
[source,java,indent=0]
|
||||
----
|
||||
include::{docs-java}/features/testing/springbootapplications/autoconfiguredspringrestdocs/withrestassured/UserDocumentationTests.java[]
|
||||
include::{docs-java}/features/testing/springbootapplications/autoconfiguredspringrestdocs/withrestassured/MyUserDocumentationTests.java[]
|
||||
----
|
||||
|
||||
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::{docs-java}/features/testing/springbootapplications/autoconfiguredspringrestdocs/withrestassured/AdvancedRestDocsConfiguration.java[]
|
||||
include::{docs-java}/features/testing/springbootapplications/autoconfiguredspringrestdocs/withrestassured/MyRestDocsConfiguration.java[]
|
||||
----
|
||||
|
||||
|
||||
|
|
@ -794,7 +794,7 @@ Additional auto-configurations can be added on a test-by-test basis by creating
|
|||
|
||||
[source,java,indent=0]
|
||||
----
|
||||
include::{docs-java}/features/testing/springbootapplications/additionalautoconfigurationandslicing/ExampleJdbcTests.java[]
|
||||
include::{docs-java}/features/testing/springbootapplications/additionalautoconfigurationandslicing/MyJdbcTests.java[]
|
||||
----
|
||||
|
||||
NOTE: Make sure to not use the regular `@Import` annotation to import auto-configurations as they are handled in a specific way by Spring Boot.
|
||||
|
|
@ -821,7 +821,7 @@ You could define your `@SpringBootApplication` as follows:
|
|||
|
||||
[source,java,indent=0]
|
||||
----
|
||||
include::{docs-java}/features/testing/springbootapplications/userconfigurationandslicing/SampleApplication.java[]
|
||||
include::{docs-java}/features/testing/springbootapplications/userconfigurationandslicing/MyApplication.java[]
|
||||
----
|
||||
|
||||
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.
|
||||
|
|
@ -829,7 +829,7 @@ A recommended approach is to move that area-specific configuration to a separate
|
|||
|
||||
[source,java,indent=0]
|
||||
----
|
||||
include::{docs-java}/features/testing/springbootapplications/userconfigurationandslicing/BatchConfiguration.java[]
|
||||
include::{docs-java}/features/testing/springbootapplications/userconfigurationandslicing/MyBatchConfiguration.java[]
|
||||
----
|
||||
|
||||
NOTE: Depending on the complexity of your application, you may either have a single `@Configuration` class for your customizations or one class per domain area.
|
||||
|
|
@ -840,14 +840,14 @@ For example, for a `@WebMvcTest`, the following configuration will not include t
|
|||
|
||||
[source,java,indent=0]
|
||||
----
|
||||
include::{docs-java}/features/testing/springbootapplications/userconfigurationandslicing/WebConfiguration.java[]
|
||||
include::{docs-java}/features/testing/springbootapplications/userconfigurationandslicing/MyWebConfiguration.java[]
|
||||
----
|
||||
|
||||
The configuration below will, however, cause the custom `WebMvcConfigurer` to be loaded by the test slice.
|
||||
|
||||
[source,java,indent=0]
|
||||
----
|
||||
include::{docs-java}/features/testing/springbootapplications/userconfigurationandslicing/TestWebMvcConfigurer.java[]
|
||||
include::{docs-java}/features/testing/springbootapplications/userconfigurationandslicing/MyWebMvcConfigurer.java[]
|
||||
----
|
||||
|
||||
Another source of confusion is classpath scanning.
|
||||
|
|
@ -856,7 +856,7 @@ Your application may resemble the following code:
|
|||
|
||||
[source,java,indent=0]
|
||||
----
|
||||
include::{docs-java}/features/testing/springbootapplications/userconfigurationandslicing/scan/SampleApplication.java[]
|
||||
include::{docs-java}/features/testing/springbootapplications/userconfigurationandslicing/scan/MyApplication.java[]
|
||||
----
|
||||
|
||||
Doing so effectively overrides the default component scan directive with the side effect of scanning those two packages regardless of the slice that you chose.
|
||||
|
|
@ -920,7 +920,7 @@ To use add `@ExtendWith(OutputCaptureExtension.class)` and inject `CapturedOutpu
|
|||
|
||||
[source,java,indent=0]
|
||||
----
|
||||
include::{docs-java}/features/testing/utilities/outputcapture/OutputCaptureTests.java[]
|
||||
include::{docs-java}/features/testing/utilities/outputcapture/MyOutputCaptureTests.java[]
|
||||
----
|
||||
|
||||
|
||||
|
|
|
|||
|
|
@ -147,11 +147,11 @@ If you run `mvn dependency:tree` again, you see that there are now a number of a
|
|||
[[getting-started.first-application.code]]
|
||||
=== Writing the Code
|
||||
To finish our application, we need to create a single Java file.
|
||||
By default, Maven compiles sources from `src/main/java`, so you need to create that directory structure and then add a file named `src/main/java/Example.java` to contain the following code:
|
||||
By default, Maven compiles sources from `src/main/java`, so you need to create that directory structure and then add a file named `src/main/java/MyApplication.java` to contain the following code:
|
||||
|
||||
[source,java,indent=0]
|
||||
----
|
||||
include::{docs-java}/gettingstarted/firstapplication/code/Example.java[]
|
||||
include::{docs-java}/gettingstarted/firstapplication/code/MyApplication.java[]
|
||||
----
|
||||
|
||||
Although there is not much code here, quite a lot is going on.
|
||||
|
|
@ -222,7 +222,7 @@ You should see output similar to the following:
|
|||
....... . . .
|
||||
....... . . . (log output here)
|
||||
....... . . .
|
||||
........ Started Example in 2.222 seconds (JVM running for 6.514)
|
||||
........ Started MyApplication in 2.222 seconds (JVM running for 6.514)
|
||||
----
|
||||
|
||||
If you open a web browser to `http://localhost:8080`, you should see the following output:
|
||||
|
|
@ -322,7 +322,7 @@ To run that application, use the `java -jar` command, as follows:
|
|||
....... . . .
|
||||
....... . . . (log output here)
|
||||
....... . . .
|
||||
........ Started Example in 2.536 seconds (JVM running for 2.864)
|
||||
........ Started MyApplication in 2.536 seconds (JVM running for 2.864)
|
||||
----
|
||||
|
||||
As before, to exit the application, press `ctrl-c`.
|
||||
|
|
|
|||
|
|
@ -68,5 +68,5 @@ The following example shows one way to write such an exporter:
|
|||
|
||||
[source,java,indent=0,subs="verbatim,quotes,attributes"]
|
||||
----
|
||||
include::{docs-java}/howto/actuator/maphealthindicatorstometrics/MetricsHealthMicrometerExport.java[]
|
||||
include::{docs-java}/howto/actuator/maphealthindicatorstometrics/MyHealthMetricsExportConfiguration.java[]
|
||||
----
|
||||
|
|
|
|||
|
|
@ -15,7 +15,7 @@ The following example shows how to define a data source in a bean:
|
|||
|
||||
[source,java,indent=0,subs="verbatim,quotes,attributes"]
|
||||
----
|
||||
include::{docs-java}/howto/dataaccess/configurecustomdatasource/FancyDataSourceConfiguration.java[]
|
||||
include::{docs-java}/howto/dataaccess/configurecustomdatasource/custom/MyDataSourceConfiguration.java[]
|
||||
----
|
||||
|
||||
The following example shows how to define a data source by setting properties:
|
||||
|
|
@ -29,7 +29,7 @@ The following example shows how to define a data source by setting properties:
|
|||
pool-size: 30
|
||||
----
|
||||
|
||||
Assuming that your `FancyDataSource` has regular JavaBean properties for the URL, the username, and the pool size, these settings are bound automatically before the `DataSource` is made available to other components.
|
||||
Assuming that `SomeDataSource` has regular JavaBean properties for the URL, the username, and the pool size, these settings are bound automatically before the `DataSource` is made available to other components.
|
||||
|
||||
Spring Boot also provides a utility builder class, called `DataSourceBuilder`, that can be used to create one of the standard data sources (if it is on the classpath).
|
||||
The builder can detect the one to use based on what's available on the classpath.
|
||||
|
|
@ -39,7 +39,7 @@ The following example shows how to create a data source by using a `DataSourceBu
|
|||
|
||||
[source,java,indent=0,subs="verbatim,quotes,attributes"]
|
||||
----
|
||||
include::{docs-java}/howto/dataaccess/configurecustomdatasource/BasicDataSourceConfiguration.java[]
|
||||
include::{docs-java}/howto/dataaccess/configurecustomdatasource/builder/MyDataSourceConfiguration.java[]
|
||||
----
|
||||
|
||||
To run an app with that `DataSource`, all you need is the connection information.
|
||||
|
|
@ -80,7 +80,7 @@ The following example shows how create a `HikariDataSource` with `DataSourceBuil
|
|||
|
||||
[source,java,indent=0,subs="verbatim,quotes,attributes"]
|
||||
----
|
||||
include::{docs-java}/howto/dataaccess/configurecustomdatasource/SimpleDataSourceConfiguration.java[]
|
||||
include::{docs-java}/howto/dataaccess/configurecustomdatasource/simple/MyDataSourceConfiguration.java[]
|
||||
----
|
||||
|
||||
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.
|
||||
|
|
@ -90,7 +90,7 @@ To avoid that, you can redefine a custom `DataSourceProperties` on your custom n
|
|||
|
||||
[source,java,indent=0,subs="verbatim,quotes,attributes"]
|
||||
----
|
||||
include::{docs-java}/howto/dataaccess/configurecustomdatasource/ConfigurableDataSourceConfiguration.java[]
|
||||
include::{docs-java}/howto/dataaccess/configurecustomdatasource/configurable/MyDataSourceConfiguration.java[]
|
||||
----
|
||||
|
||||
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.
|
||||
|
|
@ -127,7 +127,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::{docs-java}/howto/dataaccess/configuretwodatasources/SimpleDataSourcesConfiguration.java[]
|
||||
include::{docs-java}/howto/dataaccess/configuretwodatasources/MyDataSourcesConfiguration.java[]
|
||||
----
|
||||
|
||||
TIP: `firstDataSourceProperties` has to be flagged as `@Primary` so that the database initializer feature uses your copy (if you use the initializer).
|
||||
|
|
@ -157,7 +157,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::{docs-java}/howto/dataaccess/configuretwodatasources/CompleteDataSourcesConfiguration.java[]
|
||||
include::{docs-java}/howto/dataaccess/configuretwodatasources/MyCompleteDataSourcesConfiguration.java[]
|
||||
----
|
||||
|
||||
The preceding example configures two data sources on custom namespaces with the same logic as Spring Boot would use in auto-configuration.
|
||||
|
|
@ -188,7 +188,7 @@ To get more control, you can use the `@EntityScan` annotation, as shown in the f
|
|||
|
||||
[source,java,indent=0,subs="verbatim,quotes,attributes"]
|
||||
----
|
||||
include::{docs-java}/howto/dataaccess/separateentitydefinitionsfromspringconfiguration/Application.java[]
|
||||
include::{docs-java}/howto/dataaccess/separateentitydefinitionsfromspringconfiguration/MyApplication.java[]
|
||||
----
|
||||
|
||||
|
||||
|
|
@ -275,7 +275,7 @@ Then, add a `HibernatePropertiesCustomizer` bean as shown in the following examp
|
|||
|
||||
[source,java,indent=0]
|
||||
----
|
||||
include::{docs-java}/howto/dataaccess/configurehibernatesecondlevelcaching/HibernateSecondLevelCacheConfiguration.java[]
|
||||
include::{docs-java}/howto/dataaccess/configurehibernatesecondlevelcaching/MyHibernateSecondLevelCacheConfiguration.java[]
|
||||
----
|
||||
|
||||
This customizer will configure Hibernate to use the same `CacheManager` as the one that the application uses.
|
||||
|
|
@ -308,7 +308,7 @@ You can also reuse `JpaProperties` to bind settings for each `EntityManagerFacto
|
|||
|
||||
[source,java,indent=0,subs="verbatim,quotes,attributes"]
|
||||
----
|
||||
include::{docs-java}/howto/dataaccess/usemultipleentitymanagers/CustomEntityManagerFactoryConfiguration.java[]
|
||||
include::{docs-java}/howto/dataaccess/usemultipleentitymanagers/MyEntityManagerFactoryConfiguration.java[]
|
||||
----
|
||||
|
||||
The example above creates an `EntityManagerFactory` using a `DataSource` bean named `firstDataSource`.
|
||||
|
|
|
|||
|
|
@ -164,7 +164,7 @@ If you would rather map to a different path, you can configure one as follows:
|
|||
spring:
|
||||
mvc:
|
||||
servlet:
|
||||
path: "/acme"
|
||||
path: "/mypath"
|
||||
----
|
||||
|
||||
If you have additional servlets you can declare a `@Bean` of type `Servlet` or `ServletRegistrationBean` for each and Spring Boot will register them transparently to the container.
|
||||
|
|
|
|||
|
|
@ -443,7 +443,7 @@ You can add an `org.apache.catalina.connector.Connector` to the `TomcatServletWe
|
|||
|
||||
[source,java,indent=0,subs="verbatim,quotes,attributes"]
|
||||
----
|
||||
include::{docs-java}/howto/webserver/enablemultipleconnectorsintomcat/TomcatMultipleConnectorsConfiguration.java[]
|
||||
include::{docs-java}/howto/webserver/enablemultipleconnectorsintomcat/MyTomcatConfiguration.java[]
|
||||
----
|
||||
|
||||
|
||||
|
|
@ -463,7 +463,7 @@ To switch to the `LegacyCookieProcessor`, use an `WebServerFactoryCustomizer` be
|
|||
|
||||
[source,java,indent=0]
|
||||
----
|
||||
include::{docs-java}/howto/webserver/usetomcatlegacycookieprocessor/LegacyCookieProcessorConfiguration.java[]
|
||||
include::{docs-java}/howto/webserver/usetomcatlegacycookieprocessor/MyLegacyCookieProcessorConfiguration.java[]
|
||||
----
|
||||
|
||||
|
||||
|
|
@ -490,7 +490,7 @@ Add an `UndertowBuilderCustomizer` to the `UndertowServletWebServerFactory` and
|
|||
|
||||
[source,java,indent=0,subs="verbatim,quotes,attributes"]
|
||||
----
|
||||
include::{docs-java}/howto/webserver/enablemultiplelistenersinundertow/UndertowMultipleListenersConfiguration.java[]
|
||||
include::{docs-java}/howto/webserver/enablemultiplelistenersinundertow/MyUndertowConfiguration.java[]
|
||||
----
|
||||
|
||||
|
||||
|
|
|
|||
|
|
@ -10,14 +10,14 @@ The following example shows a `@Service` Bean that uses constructor injection to
|
|||
|
||||
[source,java,indent=0]
|
||||
----
|
||||
include::{docs-java}/using/springbeansanddependencyinjection/singleconstructor/DatabaseAccountService.java[]
|
||||
include::{docs-java}/using/springbeansanddependencyinjection/singleconstructor/MyAccountService.java[]
|
||||
----
|
||||
|
||||
If a bean has more than one constructor, you'll need to mark the one you want Spring to use with `@Autowired`:
|
||||
|
||||
[source,java,indent=0]
|
||||
----
|
||||
include::{docs-java}/using/springbeansanddependencyinjection/multipleconstructors/DatabaseAccountService.java[]
|
||||
include::{docs-java}/using/springbeansanddependencyinjection/multipleconstructors/MyAccountService.java[]
|
||||
----
|
||||
|
||||
TIP: Notice how using constructor injection lets the `riskAssessor` field be marked as `final`, indicating that it cannot be subsequently changed.
|
||||
|
|
|
|||
|
|
@ -37,7 +37,7 @@ import org.springframework.context.annotation.Bean;
|
|||
import org.springframework.context.annotation.Configuration;
|
||||
|
||||
@Configuration(proxyBeanMethods = false)
|
||||
public class CloudFoundryCustomContextPathConfiguration {
|
||||
public class MyCloudFoundryConfiguration {
|
||||
|
||||
@Bean
|
||||
public TomcatServletWebServerFactory servletWebServerFactory() {
|
||||
|
|
@ -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.actuator.endpoints.implementingcustom;
|
||||
|
||||
class CustomData {
|
||||
|
||||
private final String name;
|
||||
|
||||
private final int counter;
|
||||
|
||||
CustomData(String name, int counter) {
|
||||
this.name = name;
|
||||
this.counter = counter;
|
||||
}
|
||||
|
||||
String getName() {
|
||||
return this.name;
|
||||
}
|
||||
|
||||
int getCounter() {
|
||||
return this.counter;
|
||||
}
|
||||
|
||||
}
|
||||
|
|
@ -21,41 +21,20 @@ import org.springframework.boot.actuate.endpoint.annotation.ReadOperation;
|
|||
import org.springframework.boot.actuate.endpoint.annotation.WriteOperation;
|
||||
|
||||
@Endpoint(id = "custom")
|
||||
public class CustomEndpoint {
|
||||
public class MyEndpoint {
|
||||
|
||||
// tag::read[]
|
||||
@ReadOperation
|
||||
public CustomData getCustomData() {
|
||||
public CustomData getData() {
|
||||
return new CustomData("test", 5);
|
||||
}
|
||||
// end::read[]
|
||||
|
||||
// tag::write[]
|
||||
@WriteOperation
|
||||
public void updateCustomData(String name, int counter) {
|
||||
public void updateData(String name, int counter) {
|
||||
// injects "test" and 42
|
||||
}
|
||||
// end::write[]
|
||||
|
||||
public static class CustomData {
|
||||
|
||||
private final String name;
|
||||
|
||||
private final int counter;
|
||||
|
||||
public CustomData(String name, int counter) {
|
||||
this.name = name;
|
||||
this.counter = counter;
|
||||
}
|
||||
|
||||
public String getName() {
|
||||
return this.name;
|
||||
}
|
||||
|
||||
public int getCounter() {
|
||||
return this.counter;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
|
@ -22,7 +22,7 @@ import org.springframework.context.annotation.Bean;
|
|||
import org.springframework.context.annotation.Configuration;
|
||||
|
||||
@Configuration(proxyBeanMethods = false)
|
||||
public class MetricsFilterConfiguration {
|
||||
public class MyMetricsFilterConfiguration {
|
||||
|
||||
@Bean
|
||||
public MeterFilter renameRegionTagMeterFilter() {
|
||||
|
|
@ -28,7 +28,7 @@ import org.springframework.context.annotation.Configuration;
|
|||
public class MyMeterRegistryConfiguration {
|
||||
|
||||
@Bean
|
||||
MeterRegistryCustomizer<GraphiteMeterRegistry> graphiteMetricsNamingConvention() {
|
||||
public MeterRegistryCustomizer<GraphiteMeterRegistry> graphiteMetricsNamingConvention() {
|
||||
return (registry) -> registry.config().namingConvention(this::name);
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -22,11 +22,11 @@ import io.micrometer.core.instrument.Tags;
|
|||
import org.springframework.stereotype.Component;
|
||||
|
||||
@Component
|
||||
public class MetricsMeterRegistryInjection {
|
||||
public class MyBean {
|
||||
|
||||
private final Dictionary dictionary;
|
||||
|
||||
MetricsMeterRegistryInjection(MeterRegistry registry) {
|
||||
public MyBean(MeterRegistry registry) {
|
||||
this.dictionary = Dictionary.load();
|
||||
registry.gauge("dictionary.size", Tags.empty(), this.dictionary.getWords().size());
|
||||
}
|
||||
|
|
@ -21,10 +21,10 @@ import io.micrometer.core.instrument.binder.MeterBinder;
|
|||
|
||||
import org.springframework.context.annotation.Bean;
|
||||
|
||||
public class SampleMeterBinderConfiguration {
|
||||
public class MyMeterBinderConfiguration {
|
||||
|
||||
@Bean
|
||||
MeterBinder queueSize(Queue queue) {
|
||||
public MeterBinder queueSize(Queue queue) {
|
||||
return (registry) -> Gauge.builder("queueSize", queue::size).register(registry);
|
||||
}
|
||||
|
||||
|
|
@ -22,10 +22,10 @@ import org.springframework.context.annotation.Bean;
|
|||
import org.springframework.context.annotation.Configuration;
|
||||
|
||||
@Configuration(proxyBeanMethods = false)
|
||||
public class SampleCommandTagsProviderConfiguration {
|
||||
public class MyCommandTagsProviderConfiguration {
|
||||
|
||||
@Bean
|
||||
MongoCommandTagsProvider customCommandTagsProvider() {
|
||||
public MongoCommandTagsProvider customCommandTagsProvider() {
|
||||
return new CustomCommandTagsProvider();
|
||||
}
|
||||
|
||||
|
|
@ -20,7 +20,7 @@ import com.mongodb.event.ConnectionPoolCreatedEvent;
|
|||
import io.micrometer.core.instrument.Tag;
|
||||
import io.micrometer.core.instrument.binder.mongodb.MongoConnectionPoolTagsProvider;
|
||||
|
||||
class CustomConnectionPoolTagsProvider implements MongoConnectionPoolTagsProvider {
|
||||
public class CustomConnectionPoolTagsProvider implements MongoConnectionPoolTagsProvider {
|
||||
|
||||
@Override
|
||||
public Iterable<Tag> connectionPoolTags(ConnectionPoolCreatedEvent event) {
|
||||
|
|
|
|||
|
|
@ -22,10 +22,10 @@ import org.springframework.context.annotation.Bean;
|
|||
import org.springframework.context.annotation.Configuration;
|
||||
|
||||
@Configuration(proxyBeanMethods = false)
|
||||
public class SampleConnectionPoolTagsProviderConfiguration {
|
||||
public class MyConnectionPoolTagsProviderConfiguration {
|
||||
|
||||
@Bean
|
||||
MongoConnectionPoolTagsProvider customConnectionPoolTagsProvider() {
|
||||
public MongoConnectionPoolTagsProvider customConnectionPoolTagsProvider() {
|
||||
return new CustomConnectionPoolTagsProvider();
|
||||
}
|
||||
|
||||
|
|
@ -22,8 +22,8 @@ import java.util.List;
|
|||
|
||||
import org.springframework.boot.context.properties.ConfigurationProperties;
|
||||
|
||||
@ConfigurationProperties(prefix = "acme.messaging")
|
||||
public class MessagingProperties {
|
||||
@ConfigurationProperties(prefix = "my.messaging")
|
||||
public class MyMessagingProperties {
|
||||
|
||||
private List<String> addresses = new ArrayList<>(Arrays.asList("a", "b"));
|
||||
|
||||
|
|
@ -18,8 +18,8 @@ package org.springframework.boot.docs.configurationmetadata.annotationprocessor.
|
|||
|
||||
import org.springframework.boot.context.properties.ConfigurationProperties;
|
||||
|
||||
@ConfigurationProperties(prefix = "server")
|
||||
public class ServerProperties {
|
||||
@ConfigurationProperties(prefix = "my.server")
|
||||
public class MyServerProperties {
|
||||
|
||||
/**
|
||||
* Name of the server.
|
||||
|
|
@ -18,8 +18,8 @@ package org.springframework.boot.docs.configurationmetadata.annotationprocessor.
|
|||
|
||||
import org.springframework.boot.context.properties.ConfigurationProperties;
|
||||
|
||||
@ConfigurationProperties(prefix = "server")
|
||||
public class ServerProperties {
|
||||
@ConfigurationProperties(prefix = "my.server")
|
||||
public class MyServerProperties {
|
||||
|
||||
private String name;
|
||||
|
||||
|
|
@ -19,8 +19,8 @@ package org.springframework.boot.docs.configurationmetadata.format.group;
|
|||
import org.springframework.boot.context.properties.ConfigurationProperties;
|
||||
import org.springframework.boot.context.properties.DeprecatedConfigurationProperty;
|
||||
|
||||
@ConfigurationProperties("app.acme")
|
||||
public class AcmeProperties {
|
||||
@ConfigurationProperties("my.app")
|
||||
public class MyProperties {
|
||||
|
||||
private String name;
|
||||
|
||||
|
|
@ -33,7 +33,7 @@ public class AcmeProperties {
|
|||
}
|
||||
|
||||
@Deprecated
|
||||
@DeprecatedConfigurationProperty(replacement = "app.acme.name")
|
||||
@DeprecatedConfigurationProperty(replacement = "my.app.name")
|
||||
public String getTarget() {
|
||||
return this.name;
|
||||
}
|
||||
|
|
@ -20,8 +20,8 @@ import java.util.Map;
|
|||
|
||||
import org.springframework.boot.context.properties.ConfigurationProperties;
|
||||
|
||||
@ConfigurationProperties("sample")
|
||||
public class SampleProperties {
|
||||
@ConfigurationProperties("my")
|
||||
public class MyProperties {
|
||||
|
||||
private Map<String, Integer> contexts;
|
||||
|
||||
|
|
@ -21,7 +21,7 @@ import org.springframework.core.env.Environment;
|
|||
import org.springframework.stereotype.Component;
|
||||
|
||||
@Component
|
||||
class MyBean implements EnvironmentAware {
|
||||
public class MyBean implements EnvironmentAware {
|
||||
|
||||
@SuppressWarnings("unused")
|
||||
private String instanceId;
|
||||
|
|
|
|||
|
|
@ -20,7 +20,7 @@ import org.springframework.cache.annotation.Cacheable;
|
|||
import org.springframework.stereotype.Component;
|
||||
|
||||
@Component
|
||||
public class MathService {
|
||||
public class MyMathService {
|
||||
|
||||
@Cacheable("piDecimals")
|
||||
public int computePiDecimal(int precision) {
|
||||
|
|
@ -21,8 +21,8 @@ import org.springframework.cache.concurrent.ConcurrentMapCacheManager;
|
|||
import org.springframework.context.annotation.Bean;
|
||||
import org.springframework.context.annotation.Configuration;
|
||||
|
||||
@Configuration
|
||||
public class CacheManagerCustomizerConfiguration {
|
||||
@Configuration(proxyBeanMethods = false)
|
||||
public class MyCacheManagerConfiguration {
|
||||
|
||||
@Bean
|
||||
public CacheManagerCustomizer<ConcurrentMapCacheManager> cacheManagerCustomizer() {
|
||||
|
|
@ -24,7 +24,7 @@ import org.springframework.context.annotation.Configuration;
|
|||
import org.springframework.data.couchbase.cache.CouchbaseCacheConfiguration;
|
||||
|
||||
@Configuration(proxyBeanMethods = false)
|
||||
public class CouchbaseCacheManagerConfiguration {
|
||||
public class MyCouchbaseCacheManagerConfiguration {
|
||||
|
||||
@Bean
|
||||
public CouchbaseCacheManagerBuilderCustomizer myCouchbaseCacheManagerBuilderCustomizer() {
|
||||
|
|
@ -24,7 +24,7 @@ import org.springframework.context.annotation.Configuration;
|
|||
import org.springframework.data.redis.cache.RedisCacheConfiguration;
|
||||
|
||||
@Configuration(proxyBeanMethods = false)
|
||||
public class RedisCacheManagerConfiguration {
|
||||
public class MyRedisCacheManagerConfiguration {
|
||||
|
||||
@Bean
|
||||
public RedisCacheManagerBuilderCustomizer myRedisCacheManagerBuilderCustomizer() {
|
||||
|
|
@ -22,15 +22,17 @@ import org.springframework.boot.autoconfigure.logging.ConditionEvaluationReportL
|
|||
import org.springframework.boot.logging.LogLevel;
|
||||
import org.springframework.boot.test.context.runner.ApplicationContextRunner;
|
||||
|
||||
public class ConditionEvaluationReportTests {
|
||||
public class MyConditionEvaluationReportingTests {
|
||||
|
||||
@Test
|
||||
void autoConfigTest() {
|
||||
ConditionEvaluationReportLoggingListener initializer = new ConditionEvaluationReportLoggingListener(
|
||||
LogLevel.INFO);
|
||||
new ApplicationContextRunner().withInitializer(initializer).run((context) -> {
|
||||
// Test something...
|
||||
});
|
||||
// @formatter:off
|
||||
new ApplicationContextRunner()
|
||||
.withInitializer(new ConditionEvaluationReportLoggingListener(LogLevel.INFO))
|
||||
.run((context) -> {
|
||||
// Test something...
|
||||
});
|
||||
// @formatter:on
|
||||
}
|
||||
|
||||
}
|
||||
|
|
@ -16,11 +16,11 @@
|
|||
|
||||
package org.springframework.boot.docs.features.developingautoconfiguration.testing;
|
||||
|
||||
public class UserService {
|
||||
public class MyService {
|
||||
|
||||
private final String name;
|
||||
|
||||
public UserService(String name) {
|
||||
public MyService(String name) {
|
||||
this.name = name;
|
||||
}
|
||||
|
||||
|
|
@ -20,19 +20,19 @@ 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.features.developingautoconfiguration.testing.UserServiceAutoConfiguration.UserProperties;
|
||||
import org.springframework.boot.docs.features.developingautoconfiguration.testing.MyServiceAutoConfiguration.UserProperties;
|
||||
import org.springframework.context.annotation.Bean;
|
||||
import org.springframework.context.annotation.Configuration;
|
||||
|
||||
@Configuration(proxyBeanMethods = false)
|
||||
@ConditionalOnClass(UserService.class)
|
||||
@ConditionalOnClass(MyService.class)
|
||||
@EnableConfigurationProperties(UserProperties.class)
|
||||
public class UserServiceAutoConfiguration {
|
||||
public class MyServiceAutoConfiguration {
|
||||
|
||||
@Bean
|
||||
@ConditionalOnMissingBean
|
||||
public UserService userService(UserProperties properties) {
|
||||
return new UserService(properties.getName());
|
||||
public MyService userService(UserProperties properties) {
|
||||
return new MyService(properties.getName());
|
||||
}
|
||||
|
||||
@ConfigurationProperties("user")
|
||||
|
|
@ -26,11 +26,11 @@ import org.springframework.context.annotation.Configuration;
|
|||
|
||||
import static org.assertj.core.api.Assertions.assertThat;
|
||||
|
||||
class UserServiceAutoConfigurationTests {
|
||||
class MyServiceAutoConfigurationTests {
|
||||
|
||||
// tag::runner[]
|
||||
private final ApplicationContextRunner contextRunner = new ApplicationContextRunner()
|
||||
.withConfiguration(AutoConfigurations.of(UserServiceAutoConfiguration.class));
|
||||
.withConfiguration(AutoConfigurations.of(MyServiceAutoConfiguration.class));
|
||||
|
||||
// end::runner[]
|
||||
|
||||
|
|
@ -38,8 +38,8 @@ class UserServiceAutoConfigurationTests {
|
|||
@Test
|
||||
void serviceNameCanBeConfigured() {
|
||||
this.contextRunner.withPropertyValues("user.name=test123").run((context) -> {
|
||||
assertThat(context).hasSingleBean(UserService.class);
|
||||
assertThat(context.getBean(UserService.class).getName()).isEqualTo("test123");
|
||||
assertThat(context).hasSingleBean(MyService.class);
|
||||
assertThat(context.getBean(MyService.class).getName()).isEqualTo("test123");
|
||||
});
|
||||
}
|
||||
// end::test-env[]
|
||||
|
|
@ -47,8 +47,8 @@ class UserServiceAutoConfigurationTests {
|
|||
// tag::test-classloader[]
|
||||
@Test
|
||||
void serviceIsIgnoredIfLibraryIsNotPresent() {
|
||||
this.contextRunner.withClassLoader(new FilteredClassLoader(UserService.class))
|
||||
.run((context) -> assertThat(context).doesNotHaveBean("userService"));
|
||||
this.contextRunner.withClassLoader(new FilteredClassLoader(MyService.class))
|
||||
.run((context) -> assertThat(context).doesNotHaveBean("myService"));
|
||||
}
|
||||
// end::test-classloader[]
|
||||
|
||||
|
|
@ -56,8 +56,8 @@ class UserServiceAutoConfigurationTests {
|
|||
@Test
|
||||
void defaultServiceBacksOff() {
|
||||
this.contextRunner.withUserConfiguration(UserConfiguration.class).run((context) -> {
|
||||
assertThat(context).hasSingleBean(UserService.class);
|
||||
assertThat(context).getBean("myUserService").isSameAs(context.getBean(UserService.class));
|
||||
assertThat(context).hasSingleBean(MyService.class);
|
||||
assertThat(context).getBean("myCustomService").isSameAs(context.getBean(MyService.class));
|
||||
});
|
||||
}
|
||||
|
||||
|
|
@ -65,8 +65,8 @@ class UserServiceAutoConfigurationTests {
|
|||
static class UserConfiguration {
|
||||
|
||||
@Bean
|
||||
UserService myUserService() {
|
||||
return new UserService("mine");
|
||||
MyService myCustomService() {
|
||||
return new MyService("mine");
|
||||
}
|
||||
|
||||
}
|
||||
|
|
@ -23,7 +23,7 @@ import org.springframework.boot.web.server.WebServerFactoryCustomizer;
|
|||
import org.springframework.stereotype.Component;
|
||||
|
||||
@Component
|
||||
public class TomcatServerCustomizer implements WebServerFactoryCustomizer<TomcatServletWebServerFactory> {
|
||||
public class MyTomcatWebServerFactoryCustomizer implements WebServerFactoryCustomizer<TomcatServletWebServerFactory> {
|
||||
|
||||
@Override
|
||||
public void customize(TomcatServletWebServerFactory server) {
|
||||
|
|
@ -21,7 +21,7 @@ import org.springframework.boot.web.servlet.server.ConfigurableServletWebServerF
|
|||
import org.springframework.stereotype.Component;
|
||||
|
||||
@Component
|
||||
public class CustomizationBean implements WebServerFactoryCustomizer<ConfigurableServletWebServerFactory> {
|
||||
public class MyWebServerFactoryCustomizer implements WebServerFactoryCustomizer<ConfigurableServletWebServerFactory> {
|
||||
|
||||
@Override
|
||||
public void customize(ConfigurableServletWebServerFactory server) {
|
||||
|
|
@ -23,7 +23,7 @@ import org.springframework.stereotype.Component;
|
|||
|
||||
@Component
|
||||
@Path("/hello")
|
||||
public class Endpoint {
|
||||
public class MyEndpoint {
|
||||
|
||||
@GET
|
||||
public String message() {
|
||||
|
|
@ -21,10 +21,10 @@ import org.glassfish.jersey.server.ResourceConfig;
|
|||
import org.springframework.stereotype.Component;
|
||||
|
||||
@Component
|
||||
public class JerseyConfig extends ResourceConfig {
|
||||
public class MyJerseyConfig extends ResourceConfig {
|
||||
|
||||
public JerseyConfig() {
|
||||
register(Endpoint.class);
|
||||
public MyJerseyConfig() {
|
||||
register(MyEndpoint.class);
|
||||
}
|
||||
|
||||
}
|
||||
|
|
@ -43,7 +43,7 @@ public class MyRestController {
|
|||
}
|
||||
|
||||
@GetMapping("/{user}/customers")
|
||||
List<Customer> getUserCustomers(@PathVariable Long userId) {
|
||||
public List<Customer> getUserCustomers(@PathVariable Long userId) {
|
||||
return this.userRepository.findById(userId).map(this.customerRepository::findByUser).get();
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -22,7 +22,7 @@ import org.springframework.web.servlet.config.annotation.CorsRegistry;
|
|||
import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;
|
||||
|
||||
@Configuration(proxyBeanMethods = false)
|
||||
public class CorsConfiguration {
|
||||
public class MyCorsConfiguration {
|
||||
|
||||
@Bean
|
||||
public WebMvcConfigurer corsConfigurer() {
|
||||
|
|
@ -26,12 +26,12 @@ 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)
|
||||
@ControllerAdvice(basePackageClasses = SomeController.class)
|
||||
public class MyControllerAdvice extends ResponseEntityExceptionHandler {
|
||||
|
||||
@ResponseBody
|
||||
@ExceptionHandler(MyException.class)
|
||||
ResponseEntity<?> handleControllerException(HttpServletRequest request, Throwable ex) {
|
||||
public ResponseEntity<?> handleControllerException(HttpServletRequest request, Throwable ex) {
|
||||
HttpStatus status = getStatus(request);
|
||||
return new ResponseEntity<>(new MyErrorBody(status.value(), ex.getMessage()), status);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -16,6 +16,6 @@
|
|||
|
||||
package org.springframework.boot.docs.features.developingwebapplications.springmvc.errorhandling;
|
||||
|
||||
class AcmeController {
|
||||
class SomeController {
|
||||
|
||||
}
|
||||
|
|
@ -23,8 +23,8 @@ import org.springframework.context.annotation.Bean;
|
|||
import org.springframework.context.annotation.Configuration;
|
||||
import org.springframework.http.HttpStatus;
|
||||
|
||||
@Configuration
|
||||
public class ErrorPageConfiguration {
|
||||
@Configuration(proxyBeanMethods = false)
|
||||
public class MyErrorPagesConfiguration {
|
||||
|
||||
@Bean
|
||||
public ErrorPageRegistrar errorPageRegistrar() {
|
||||
|
|
@ -24,8 +24,8 @@ import org.springframework.boot.web.servlet.FilterRegistrationBean;
|
|||
import org.springframework.context.annotation.Bean;
|
||||
import org.springframework.context.annotation.Configuration;
|
||||
|
||||
@Configuration
|
||||
public class ServletFilterConfiguration {
|
||||
@Configuration(proxyBeanMethods = false)
|
||||
public class MyFilterConfiguration {
|
||||
|
||||
@Bean
|
||||
public FilterRegistrationBean<MyFilter> myFilter() {
|
||||
|
|
@ -22,7 +22,7 @@ import org.springframework.context.annotation.Configuration;
|
|||
import org.springframework.http.converter.HttpMessageConverter;
|
||||
|
||||
@Configuration(proxyBeanMethods = false)
|
||||
public class HttpMessageConvertersConfiguration {
|
||||
public class MyHttpMessageConvertersConfiguration {
|
||||
|
||||
@Bean
|
||||
public HttpMessageConverters customConverters() {
|
||||
|
|
@ -29,12 +29,12 @@ import static org.springframework.web.reactive.function.server.RequestPredicates
|
|||
import static org.springframework.web.reactive.function.server.RouterFunctions.route;
|
||||
|
||||
@Configuration(proxyBeanMethods = false)
|
||||
public class RoutingConfiguration {
|
||||
public class MyRoutingConfiguration {
|
||||
|
||||
private static final RequestPredicate ACCEPT_JSON = accept(MediaType.APPLICATION_JSON);
|
||||
|
||||
@Bean
|
||||
public RouterFunction<ServerResponse> monoRouterFunction(UserHandler userHandler) {
|
||||
public RouterFunction<ServerResponse> monoRouterFunction(MyUserHandler userHandler) {
|
||||
// @formatter:off
|
||||
return route(
|
||||
GET("/{user}").and(ACCEPT_JSON), userHandler::getUser).andRoute(
|
||||
|
|
@ -23,7 +23,7 @@ import org.springframework.web.reactive.function.server.ServerRequest;
|
|||
import org.springframework.web.reactive.function.server.ServerResponse;
|
||||
|
||||
@Component
|
||||
public class UserHandler {
|
||||
public class MyUserHandler {
|
||||
|
||||
public Mono<ServerResponse> getUser(ServerRequest request) {
|
||||
/**/ return ServerResponse.ok().build();
|
||||
|
|
@ -32,9 +32,9 @@ import org.springframework.web.reactive.function.server.ServerResponse;
|
|||
import org.springframework.web.reactive.function.server.ServerResponse.BodyBuilder;
|
||||
|
||||
@Component
|
||||
public class CustomErrorWebExceptionHandler extends AbstractErrorWebExceptionHandler {
|
||||
public class MyErrorWebExceptionHandler extends AbstractErrorWebExceptionHandler {
|
||||
|
||||
public CustomErrorWebExceptionHandler(ErrorAttributes errorAttributes, Resources resources,
|
||||
public MyErrorWebExceptionHandler(ErrorAttributes errorAttributes, Resources resources,
|
||||
ApplicationContext applicationContext) {
|
||||
super(errorAttributes, resources, applicationContext);
|
||||
}
|
||||
|
|
@ -24,7 +24,7 @@ import org.springframework.web.reactive.result.view.Rendering;
|
|||
import org.springframework.web.server.ServerWebExchange;
|
||||
|
||||
@Controller
|
||||
public class ExceptionHandlingController {
|
||||
public class MyExceptionHandlingController {
|
||||
|
||||
@GetMapping("/profile")
|
||||
public Rendering userProfile() {
|
||||
|
|
@ -33,7 +33,7 @@ public class ExceptionHandlingController {
|
|||
}
|
||||
|
||||
@ExceptionHandler(IllegalStateException.class)
|
||||
Rendering handleIllegalState(ServerWebExchange exchange, IllegalStateException exc) {
|
||||
public Rendering handleIllegalState(ServerWebExchange exchange, IllegalStateException exc) {
|
||||
exchange.getAttributes().putIfAbsent(ErrorAttributes.ERROR_ATTRIBUTE, exc);
|
||||
return Rendering.view("errorView").modelAttribute("message", exc.getMessage()).build();
|
||||
}
|
||||
|
|
@ -22,7 +22,7 @@ import org.springframework.context.annotation.Configuration;
|
|||
import org.springframework.http.codec.ServerSentEventHttpMessageReader;
|
||||
|
||||
@Configuration(proxyBeanMethods = false)
|
||||
public class CodecConfiguration {
|
||||
public class MyCodecsConfiguration {
|
||||
|
||||
@Bean
|
||||
public CodecCustomizer myCodecCustomizer() {
|
||||
|
|
@ -24,8 +24,8 @@ import org.springframework.boot.context.properties.ConstructorBinding;
|
|||
import org.springframework.boot.context.properties.bind.DefaultValue;
|
||||
|
||||
@ConstructorBinding
|
||||
@ConfigurationProperties("acme")
|
||||
public class AcmeProperties {
|
||||
@ConfigurationProperties("my.service")
|
||||
public class MyProperties {
|
||||
|
||||
// @fold:on // fields...
|
||||
private final boolean enabled;
|
||||
|
|
@ -36,7 +36,7 @@ public class AcmeProperties {
|
|||
|
||||
// @fold:off
|
||||
|
||||
public AcmeProperties(boolean enabled, InetAddress remoteAddress, Security security) {
|
||||
public MyProperties(boolean enabled, InetAddress remoteAddress, Security security) {
|
||||
this.enabled = enabled;
|
||||
this.remoteAddress = remoteAddress;
|
||||
this.security = security;
|
||||
|
|
@ -24,8 +24,8 @@ import org.springframework.boot.context.properties.ConstructorBinding;
|
|||
import org.springframework.boot.context.properties.bind.DefaultValue;
|
||||
|
||||
@ConstructorBinding
|
||||
@ConfigurationProperties("acme")
|
||||
public class AcmeProperties {
|
||||
@ConfigurationProperties("my.service")
|
||||
public class MyProperties {
|
||||
|
||||
private final boolean enabled;
|
||||
|
||||
|
|
@ -34,7 +34,7 @@ public class AcmeProperties {
|
|||
private final Security security;
|
||||
|
||||
// tag::code[]
|
||||
public AcmeProperties(boolean enabled, InetAddress remoteAddress, @DefaultValue Security security) {
|
||||
public MyProperties(boolean enabled, InetAddress remoteAddress, @DefaultValue Security security) {
|
||||
this.enabled = enabled;
|
||||
this.remoteAddress = remoteAddress;
|
||||
this.security = security;
|
||||
|
|
@ -23,9 +23,9 @@ import org.springframework.boot.convert.DataSizeUnit;
|
|||
import org.springframework.util.unit.DataSize;
|
||||
import org.springframework.util.unit.DataUnit;
|
||||
|
||||
@ConfigurationProperties("app.io")
|
||||
@ConfigurationProperties("my")
|
||||
@ConstructorBinding
|
||||
public class AppIoProperties {
|
||||
public class MyProperties {
|
||||
|
||||
// @fold:on // fields...
|
||||
private final DataSize bufferSize;
|
||||
|
|
@ -33,7 +33,7 @@ public class AppIoProperties {
|
|||
private final DataSize sizeThreshold;
|
||||
|
||||
// @fold:off
|
||||
public AppIoProperties(@DataSizeUnit(DataUnit.MEGABYTES) @DefaultValue("2MB") DataSize bufferSize,
|
||||
public MyProperties(@DataSizeUnit(DataUnit.MEGABYTES) @DefaultValue("2MB") DataSize bufferSize,
|
||||
@DefaultValue("512B") DataSize sizeThreshold) {
|
||||
this.bufferSize = bufferSize;
|
||||
this.sizeThreshold = sizeThreshold;
|
||||
|
|
@ -21,8 +21,8 @@ import org.springframework.boot.convert.DataSizeUnit;
|
|||
import org.springframework.util.unit.DataSize;
|
||||
import org.springframework.util.unit.DataUnit;
|
||||
|
||||
@ConfigurationProperties("app.io")
|
||||
public class AppIoProperties {
|
||||
@ConfigurationProperties("my")
|
||||
public class MyProperties {
|
||||
|
||||
@DataSizeUnit(DataUnit.MEGABYTES)
|
||||
private DataSize bufferSize = DataSize.ofMegabytes(2);
|
||||
|
|
@ -24,9 +24,9 @@ import org.springframework.boot.context.properties.ConstructorBinding;
|
|||
import org.springframework.boot.context.properties.bind.DefaultValue;
|
||||
import org.springframework.boot.convert.DurationUnit;
|
||||
|
||||
@ConfigurationProperties("app.system")
|
||||
@ConfigurationProperties("my")
|
||||
@ConstructorBinding
|
||||
public class AppSystemProperties {
|
||||
public class MyProperties {
|
||||
|
||||
// @fold:on // fields...
|
||||
private final Duration sessionTimeout;
|
||||
|
|
@ -34,7 +34,7 @@ public class AppSystemProperties {
|
|||
private final Duration readTimeout;
|
||||
|
||||
// @fold:off
|
||||
public AppSystemProperties(@DurationUnit(ChronoUnit.SECONDS) @DefaultValue("30s") Duration sessionTimeout,
|
||||
public MyProperties(@DurationUnit(ChronoUnit.SECONDS) @DefaultValue("30s") Duration sessionTimeout,
|
||||
@DefaultValue("1000ms") Duration readTimeout) {
|
||||
this.sessionTimeout = sessionTimeout;
|
||||
this.readTimeout = readTimeout;
|
||||
|
|
@ -22,8 +22,8 @@ import java.time.temporal.ChronoUnit;
|
|||
import org.springframework.boot.context.properties.ConfigurationProperties;
|
||||
import org.springframework.boot.convert.DurationUnit;
|
||||
|
||||
@ConfigurationProperties("app.system")
|
||||
public class AppSystemProperties {
|
||||
@ConfigurationProperties("my")
|
||||
public class MyProperties {
|
||||
|
||||
@DurationUnit(ChronoUnit.SECONDS)
|
||||
private Duration sessionTimeout = Duration.ofSeconds(30);
|
||||
|
|
@ -20,7 +20,7 @@ import org.springframework.boot.autoconfigure.SpringBootApplication;
|
|||
import org.springframework.boot.context.properties.ConfigurationPropertiesScan;
|
||||
|
||||
@SpringBootApplication
|
||||
@ConfigurationPropertiesScan({ "com.example.app", "org.acme.another" })
|
||||
@ConfigurationPropertiesScan({ "com.example.app", "com.example.another" })
|
||||
public class MyApplication {
|
||||
|
||||
}
|
||||
|
|
|
|||
|
|
@ -20,7 +20,7 @@ import org.springframework.boot.context.properties.EnableConfigurationProperties
|
|||
import org.springframework.context.annotation.Configuration;
|
||||
|
||||
@Configuration(proxyBeanMethods = false)
|
||||
@EnableConfigurationProperties(AcmeProperties.class)
|
||||
@EnableConfigurationProperties(SomeProperties.class)
|
||||
public class MyConfiguration {
|
||||
|
||||
}
|
||||
|
|
|
|||
|
|
@ -16,6 +16,6 @@
|
|||
|
||||
package org.springframework.boot.docs.features.externalconfig.typesafeconfigurationproperties.enablingannotatedtypes;
|
||||
|
||||
class AcmeProperties {
|
||||
class SomeProperties {
|
||||
|
||||
}
|
||||
|
|
@ -23,8 +23,8 @@ import java.util.List;
|
|||
|
||||
import org.springframework.boot.context.properties.ConfigurationProperties;
|
||||
|
||||
@ConfigurationProperties("acme")
|
||||
public class AcmeProperties {
|
||||
@ConfigurationProperties("my.service")
|
||||
public class MyProperties {
|
||||
|
||||
private boolean enabled;
|
||||
|
||||
|
|
@ -21,8 +21,8 @@ import java.util.List;
|
|||
|
||||
import org.springframework.boot.context.properties.ConfigurationProperties;
|
||||
|
||||
@ConfigurationProperties("acme")
|
||||
public class AcmeProperties {
|
||||
@ConfigurationProperties("my")
|
||||
public class MyProperties {
|
||||
|
||||
private final List<MyPojo> list = new ArrayList<>();
|
||||
|
||||
|
|
@ -21,8 +21,8 @@ import java.util.Map;
|
|||
|
||||
import org.springframework.boot.context.properties.ConfigurationProperties;
|
||||
|
||||
@ConfigurationProperties("acme")
|
||||
public class AcmeProperties {
|
||||
@ConfigurationProperties("my")
|
||||
public class MyProperties {
|
||||
|
||||
private final Map<String, MyPojo> map = new LinkedHashMap<>();
|
||||
|
||||
|
|
@ -18,8 +18,8 @@ package org.springframework.boot.docs.features.externalconfig.typesafeconfigurat
|
|||
|
||||
import org.springframework.boot.context.properties.ConfigurationProperties;
|
||||
|
||||
@ConfigurationProperties(prefix = "acme.my-project.person")
|
||||
public class OwnerProperties {
|
||||
@ConfigurationProperties(prefix = "my.main-project.person")
|
||||
public class MyPersonProperties {
|
||||
|
||||
private String firstName;
|
||||
|
||||
|
|
@ -21,9 +21,9 @@ import org.springframework.stereotype.Service;
|
|||
@Service
|
||||
public class MyService {
|
||||
|
||||
private final AcmeProperties properties;
|
||||
private final SomeProperties properties;
|
||||
|
||||
public MyService(AcmeProperties properties) {
|
||||
public MyService(SomeProperties properties) {
|
||||
this.properties = properties;
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -16,7 +16,7 @@
|
|||
|
||||
package org.springframework.boot.docs.features.externalconfig.typesafeconfigurationproperties.usingannotatedtypes;
|
||||
|
||||
class AcmeProperties {
|
||||
class SomeProperties {
|
||||
|
||||
Object getRemoteAddress() {
|
||||
return null;
|
||||
|
|
@ -23,9 +23,9 @@ import javax.validation.constraints.NotNull;
|
|||
import org.springframework.boot.context.properties.ConfigurationProperties;
|
||||
import org.springframework.validation.annotation.Validated;
|
||||
|
||||
@ConfigurationProperties(prefix = "acme")
|
||||
@ConfigurationProperties("my.service")
|
||||
@Validated
|
||||
public class AcmeProperties {
|
||||
public class MyProperties {
|
||||
|
||||
@NotNull
|
||||
private InetAddress remoteAddress;
|
||||
|
|
@ -25,9 +25,9 @@ import javax.validation.constraints.NotNull;
|
|||
import org.springframework.boot.context.properties.ConfigurationProperties;
|
||||
import org.springframework.validation.annotation.Validated;
|
||||
|
||||
@ConfigurationProperties(prefix = "acme")
|
||||
@ConfigurationProperties("my.service")
|
||||
@Validated
|
||||
public class AcmeProperties {
|
||||
public class MyProperties {
|
||||
|
||||
@NotNull
|
||||
private InetAddress remoteAddress;
|
||||
|
|
@ -23,7 +23,7 @@ import org.springframework.context.annotation.Bean;
|
|||
import org.springframework.context.annotation.Configuration;
|
||||
|
||||
@Configuration(proxyBeanMethods = false)
|
||||
public class RabbitConfiguration {
|
||||
public class MyRabbitConfiguration {
|
||||
|
||||
@Bean
|
||||
public SimpleRabbitListenerContainerFactory myFactory(SimpleRabbitListenerContainerFactoryConfigurer configurer) {
|
||||
|
|
@ -24,7 +24,7 @@ import org.springframework.context.annotation.Configuration;
|
|||
import org.springframework.jms.config.DefaultJmsListenerContainerFactory;
|
||||
|
||||
@Configuration(proxyBeanMethods = false)
|
||||
public class JmsConfiguration {
|
||||
public class MyJmsConfiguration {
|
||||
|
||||
@Bean
|
||||
public DefaultJmsListenerContainerFactory myFactory(DefaultJmsListenerContainerFactoryConfigurer configurer) {
|
||||
|
|
@ -21,7 +21,7 @@ import org.springframework.kafka.test.context.EmbeddedKafka;
|
|||
|
||||
@SpringBootTest
|
||||
@EmbeddedKafka(topics = "someTopic", bootstrapServersProperty = "spring.kafka.bootstrap-servers")
|
||||
public class MyTest {
|
||||
class MyTest {
|
||||
|
||||
// ...
|
||||
|
||||
|
|
|
|||
|
|
@ -20,7 +20,7 @@ import org.springframework.boot.test.context.SpringBootTest;
|
|||
import org.springframework.kafka.test.EmbeddedKafkaBroker;
|
||||
|
||||
@SpringBootTest
|
||||
public class MyTest {
|
||||
class MyTest {
|
||||
|
||||
// tag::code[]
|
||||
static {
|
||||
|
|
|
|||
|
|
@ -16,7 +16,6 @@
|
|||
|
||||
package org.springframework.boot.docs.features.messaging.kafka.sending;
|
||||
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.kafka.core.KafkaTemplate;
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
|
|
@ -25,7 +24,6 @@ public class MyBean {
|
|||
|
||||
private final KafkaTemplate<String, String> kafkaTemplate;
|
||||
|
||||
@Autowired
|
||||
public MyBean(KafkaTemplate<String, String> kafkaTemplate) {
|
||||
this.kafkaTemplate = kafkaTemplate;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -29,7 +29,7 @@ import org.springframework.kafka.support.serializer.JsonSerde;
|
|||
|
||||
@Configuration(proxyBeanMethods = false)
|
||||
@EnableKafkaStreams
|
||||
public class KafkaStreamsConfiguration {
|
||||
public class MyKafkaStreamsConfiguration {
|
||||
|
||||
@Bean
|
||||
public KStream<Integer, String> kStream(StreamsBuilder streamsBuilder) {
|
||||
|
|
@ -24,7 +24,7 @@ import org.springframework.data.couchbase.config.BeanNames;
|
|||
import org.springframework.data.couchbase.core.convert.CouchbaseCustomConversions;
|
||||
|
||||
@Configuration(proxyBeanMethods = false)
|
||||
public class CouchbaseConversionsConfiguration {
|
||||
public class MyCouchbaseConfiguration {
|
||||
|
||||
@Bean(BeanNames.COUCHBASE_CUSTOM_CONVERSIONS)
|
||||
public CouchbaseCustomConversions myCustomConversions() {
|
||||
|
|
@ -24,7 +24,7 @@ import org.springframework.data.neo4j.core.ReactiveDatabaseSelectionProvider;
|
|||
import org.springframework.data.neo4j.core.transaction.ReactiveNeo4jTransactionManager;
|
||||
|
||||
@Configuration(proxyBeanMethods = false)
|
||||
public class Neo4jReactiveTransactionManagerConfiguration {
|
||||
public class MyNeo4jConfiguration {
|
||||
|
||||
@Bean
|
||||
public ReactiveNeo4jTransactionManager reactiveTransactionManager(Driver driver,
|
||||
|
|
@ -22,7 +22,7 @@ import org.springframework.stereotype.Component;
|
|||
@Component
|
||||
public class MyBean {
|
||||
|
||||
private StringRedisTemplate template;
|
||||
private final StringRedisTemplate template;
|
||||
|
||||
public MyBean(StringRedisTemplate template) {
|
||||
this.template = template;
|
||||
|
|
|
|||
|
|
@ -27,7 +27,7 @@ import org.springframework.stereotype.Component;
|
|||
@Component
|
||||
public class MyBean {
|
||||
|
||||
private SolrClient solr;
|
||||
private final SolrClient solr;
|
||||
|
||||
public MyBean(SolrClient solr) {
|
||||
this.solr = solr;
|
||||
|
|
|
|||
|
|
@ -21,7 +21,7 @@ import org.quartz.JobExecutionException;
|
|||
|
||||
import org.springframework.scheduling.quartz.QuartzJobBean;
|
||||
|
||||
public class SampleJob extends QuartzJobBean {
|
||||
public class MySampleJob extends QuartzJobBean {
|
||||
|
||||
// @fold:on // fields ...
|
||||
private MyService myService;
|
||||
|
|
@ -24,7 +24,7 @@ import org.springframework.context.annotation.Bean;
|
|||
import org.springframework.context.annotation.Configuration;
|
||||
|
||||
@Configuration(proxyBeanMethods = false)
|
||||
public class RestTemplateBuilderConfiguration {
|
||||
public class MyRestTemplateBuilderConfiguration {
|
||||
|
||||
@Bean
|
||||
public RestTemplateBuilder restTemplateBuilder(RestTemplateBuilderConfigurer configurer) {
|
||||
|
|
@ -29,7 +29,7 @@ import org.springframework.boot.web.client.RestTemplateCustomizer;
|
|||
import org.springframework.http.client.HttpComponentsClientHttpRequestFactory;
|
||||
import org.springframework.web.client.RestTemplate;
|
||||
|
||||
public class RestTemplateProxyCustomizer implements RestTemplateCustomizer {
|
||||
public class MyRestTemplateCustomizer implements RestTemplateCustomizer {
|
||||
|
||||
@Override
|
||||
public void customize(RestTemplate restTemplate) {
|
||||
|
|
@ -21,8 +21,8 @@ import org.springframework.context.annotation.Configuration;
|
|||
import org.springframework.security.config.annotation.web.builders.HttpSecurity;
|
||||
import org.springframework.security.web.SecurityFilterChain;
|
||||
|
||||
@Configuration
|
||||
public class OAuthClientConfiguration {
|
||||
@Configuration(proxyBeanMethods = false)
|
||||
public class MyOAuthClientConfiguration {
|
||||
|
||||
@Bean
|
||||
public SecurityFilterChain securityFilterChain(HttpSecurity http) throws Exception {
|
||||
|
|
@ -23,7 +23,7 @@ import org.springframework.security.config.web.server.ServerHttpSecurity;
|
|||
import org.springframework.security.web.server.SecurityWebFilterChain;
|
||||
|
||||
@Configuration(proxyBeanMethods = false)
|
||||
public class CustomWebFluxSecurityConfiguration {
|
||||
public class MyWebFluxSecurityConfiguration {
|
||||
|
||||
@Bean
|
||||
public SecurityWebFilterChain springSecurityFilterChain(ServerHttpSecurity http) {
|
||||
|
|
@ -22,9 +22,9 @@ import org.springframework.boot.ApplicationArguments;
|
|||
import org.springframework.stereotype.Component;
|
||||
|
||||
@Component
|
||||
public class ApplicationArgumentsExample {
|
||||
public class MyBean {
|
||||
|
||||
public ApplicationArgumentsExample(ApplicationArguments args) {
|
||||
public MyBean(ApplicationArguments args) {
|
||||
boolean debug = args.containsOption("debug");
|
||||
List<String> files = args.getNonOptionArgs();
|
||||
if (debug) {
|
||||
|
|
@ -22,11 +22,11 @@ import org.springframework.context.ApplicationEventPublisher;
|
|||
import org.springframework.stereotype.Component;
|
||||
|
||||
@Component
|
||||
public class LocalCacheVerifier {
|
||||
public class MyLocalCacheVerifier {
|
||||
|
||||
private final ApplicationEventPublisher eventPublisher;
|
||||
|
||||
public LocalCacheVerifier(ApplicationEventPublisher eventPublisher) {
|
||||
public MyLocalCacheVerifier(ApplicationEventPublisher eventPublisher) {
|
||||
this.eventPublisher = eventPublisher;
|
||||
}
|
||||
|
||||
|
|
@ -22,7 +22,7 @@ import org.springframework.context.event.EventListener;
|
|||
import org.springframework.stereotype.Component;
|
||||
|
||||
@Component
|
||||
public class ReadinessStateExporter {
|
||||
public class MyReadinessStateExporter {
|
||||
|
||||
@EventListener
|
||||
public void onStateChange(AvailabilityChangeEvent<ReadinessState> event) {
|
||||
|
|
@ -20,7 +20,7 @@ import org.springframework.boot.CommandLineRunner;
|
|||
import org.springframework.stereotype.Component;
|
||||
|
||||
@Component
|
||||
public class CommandLineRunnerExample implements CommandLineRunner {
|
||||
public class MyCommandLineRunner implements CommandLineRunner {
|
||||
|
||||
@Override
|
||||
public void run(String... args) {
|
||||
Some files were not shown because too many files have changed in this diff Show More
Loading…
Reference in New Issue