mirror of
https://github.com/spring-projects/spring-boot.git
synced 2024-07-05 00:56:58 +08:00
Polish
See gh-12812
This commit is contained in:
parent
a9020df9b9
commit
f03849d502
@ -25,13 +25,12 @@ import io.micrometer.core.instrument.binder.MeterBinder;
|
||||
import io.micrometer.core.instrument.composite.CompositeMeterRegistry;
|
||||
import io.micrometer.core.instrument.config.MeterFilter;
|
||||
|
||||
import org.springframework.beans.factory.config.BeanPostProcessor;
|
||||
import org.springframework.boot.util.LambdaSafe;
|
||||
|
||||
/**
|
||||
* {@link BeanPostProcessor} to apply {@link MeterRegistryCustomizer customizers},
|
||||
* Configurer to apply {@link MeterRegistryCustomizer customizers},
|
||||
* {@link MeterFilter filters}, {@link MeterBinder binders} and {@link Metrics#addRegistry
|
||||
* global registration} to {@link MeterRegistry meter registries}. This post processor
|
||||
* global registration} to {@link MeterRegistry meter registries}. This configurer
|
||||
* intentionally skips {@link CompositeMeterRegistry} with the assumptions that the
|
||||
* registries it contains are beans and will be customized directly.
|
||||
*
|
||||
|
@ -34,7 +34,7 @@ import org.springframework.context.annotation.Configuration;
|
||||
|
||||
/**
|
||||
* {@link EnableAutoConfiguration Auto-configuration} for instrumentation of Spring
|
||||
* Webflux MVC annotation-based programming model request mappings.
|
||||
* WebFlux MVC annotation-based programming model request mappings.
|
||||
*
|
||||
* @author Jon Schneider
|
||||
* @since 2.0.0
|
||||
|
@ -85,7 +85,7 @@ public class MeterRegistryCustomizerTests {
|
||||
}
|
||||
|
||||
@Bean
|
||||
public MeterRegistryCustomizer<PrometheusMeterRegistry> prometehusOnlyCommonTags() {
|
||||
public MeterRegistryCustomizer<PrometheusMeterRegistry> prometheusOnlyCommonTags() {
|
||||
return (registry) -> registry.config().commonTags("job", "myjob");
|
||||
}
|
||||
|
||||
|
@ -80,9 +80,7 @@ public class NewRelicMetricsExportAutoConfigurationTests {
|
||||
@Test
|
||||
public void autoConfigurationCanBeDisabled() {
|
||||
this.contextRunner.withUserConfiguration(BaseConfiguration.class)
|
||||
.withPropertyValues("management.metrics.export.newrelic.enabled=false",
|
||||
"management.metrics.export.newrelic.api-key=abcde",
|
||||
"management.metrics.export.newrelic.account-id=12345")
|
||||
.withPropertyValues("management.metrics.export.newrelic.enabled=false")
|
||||
.run((context) -> assertThat(context)
|
||||
.doesNotHaveBean(NewRelicMeterRegistry.class)
|
||||
.doesNotHaveBean(NewRelicConfig.class));
|
||||
|
@ -72,7 +72,6 @@ public class SignalFxMetricsExportAutoConfigurationTests {
|
||||
public void autoConfigurationCanBeDisabled() {
|
||||
this.contextRunner.withUserConfiguration(BaseConfiguration.class)
|
||||
.withPropertyValues(
|
||||
"management.metrics.export.signalfx.access-token=abcde",
|
||||
"management.metrics.export.signalfx.enabled=false")
|
||||
.run((context) -> assertThat(context)
|
||||
.doesNotHaveBean(SignalFxMeterRegistry.class)
|
||||
|
@ -50,7 +50,7 @@ public abstract class AbstractHealthIndicator implements HealthIndicator {
|
||||
* Create a new {@link AbstractHealthIndicator} instance with a default
|
||||
* {@code healthCheckFailedMessage}.
|
||||
*/
|
||||
public AbstractHealthIndicator() {
|
||||
protected AbstractHealthIndicator() {
|
||||
this(NO_MESSAGE);
|
||||
}
|
||||
|
||||
|
@ -30,7 +30,7 @@ import org.springframework.web.server.WebFilter;
|
||||
import org.springframework.web.server.WebFilterChain;
|
||||
|
||||
/**
|
||||
* Intercepts incoming HTTP requests modeled with the Webflux annotation-based programming
|
||||
* Intercepts incoming HTTP requests modeled with the WebFlux annotation-based programming
|
||||
* model.
|
||||
*
|
||||
* @author Jon Schneider
|
||||
|
@ -551,7 +551,7 @@ JMX or an HTTP request is converted to the required types using an instance of
|
||||
|
||||
[[production-ready-endpoints-custom-web]]
|
||||
==== Custom Web Endpoints
|
||||
Operations on a `@Endpoint`, `@WebEndpoint`, or `@WebEndpointExtension` are automatically
|
||||
Operations on an `@Endpoint`, `@WebEndpoint`, or `@WebEndpointExtension` are automatically
|
||||
exposed over HTTP using Jersey, Spring MVC, or Spring WebFlux.
|
||||
|
||||
|
||||
@ -673,7 +673,7 @@ possible.
|
||||
==== Controller endpoints
|
||||
`@ControllerEndpoint` and `@RestControllerEndpoint` can be used to implement an endpoint
|
||||
that is only exposed by Spring MVC or Spring WebFlux. Methods are mapped using the
|
||||
standard annotations Spring MVC and Spring WebFlux annotations such as `@RequestMapping`
|
||||
standard annotations for Spring MVC and Spring WebFlux such as `@RequestMapping`
|
||||
and `@GetMapping`, with the endpoint's ID being used as a prefix for the path. Controller
|
||||
endpoints provide deeper integration with Spring's web frameworks but at the expense of
|
||||
portability. The `@Endpoint` and `@WebEndpoint` annotations should be preferred whenever
|
||||
@ -1763,7 +1763,7 @@ is required. A `CacheMetricsRegistrar` bean is made available to make that proce
|
||||
|
||||
[[production-ready-metrics-jdbc]]
|
||||
==== DataSource Metrics
|
||||
Auto-configuration enables the instrumentation of all available DataSource` objects with a
|
||||
Auto-configuration enables the instrumentation of all available `DataSource` objects with a
|
||||
metric named `jdbc`. Data source instrumentation results in gauges representing the
|
||||
currently active, maximum allowed, and minimum allowed connections in the pool. Each of
|
||||
these gauges has a name that is prefixed by `jdbc`.
|
||||
|
@ -18,7 +18,6 @@ package org.springframework.boot.docs.web.security;
|
||||
|
||||
import org.springframework.boot.autoconfigure.security.reactive.PathRequest;
|
||||
import org.springframework.context.annotation.Bean;
|
||||
import org.springframework.security.config.annotation.web.reactive.EnableWebFluxSecurity;
|
||||
import org.springframework.security.config.web.server.ServerHttpSecurity;
|
||||
import org.springframework.security.web.server.SecurityWebFilterChain;
|
||||
|
||||
@ -27,20 +26,19 @@ import org.springframework.security.web.server.SecurityWebFilterChain;
|
||||
*
|
||||
* @author Madhura Bhave
|
||||
*/
|
||||
@EnableWebFluxSecurity
|
||||
public class CustomWebFluxSecurityExample {
|
||||
|
||||
// @formatter:off
|
||||
// tag::configuration[]
|
||||
@Bean
|
||||
public SecurityWebFilterChain springSecurityFilterChain(ServerHttpSecurity http) {
|
||||
http
|
||||
return http
|
||||
.authorizeExchange()
|
||||
.matchers(PathRequest.toStaticResources().atCommonLocations()).permitAll()
|
||||
.pathMatchers("/foo", "/bar")
|
||||
.authenticated().and()
|
||||
.formLogin();
|
||||
return http.build();
|
||||
.formLogin().and()
|
||||
.build();
|
||||
}
|
||||
// end::configuration[]
|
||||
// @formatter:on
|
||||
|
@ -74,8 +74,7 @@ public class WebTestClientSpringBootTestIntegrationTests {
|
||||
|
||||
@Bean
|
||||
public SecurityWebFilterChain springSecurityFilterChain(ServerHttpSecurity http) {
|
||||
http.authorizeExchange().anyExchange().permitAll();
|
||||
return http.build();
|
||||
return http.authorizeExchange().anyExchange().permitAll().and().build();
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -110,7 +110,7 @@ public class ApplicationContextAssert<C extends ApplicationContext>
|
||||
* Verifies that the application context contains a single bean with the given type.
|
||||
* <p>
|
||||
* Example: <pre class="code">
|
||||
* assertThat(context).hasSingleBean(Foo.class); </pre>
|
||||
* assertThat(context).hasSingleBean(Foo.class, Scope.NO_ANCESTORS); </pre>
|
||||
* @param type the bean type
|
||||
* @param scope the scope of the assertion
|
||||
* @return {@code this} assertion object.
|
||||
@ -159,7 +159,7 @@ public class ApplicationContextAssert<C extends ApplicationContext>
|
||||
* Verifies that the application context does not contain any beans of the given type.
|
||||
* <p>
|
||||
* Example: <pre class="code">
|
||||
* assertThat(context).doesNotHaveBean(Foo.class); </pre>
|
||||
* assertThat(context).doesNotHaveBean(Foo.class, Scope.NO_ANCESTORS); </pre>
|
||||
* @param type the bean type
|
||||
* @param scope the scope of the assertion
|
||||
* @return {@code this} assertion object.
|
||||
@ -255,8 +255,8 @@ public class ApplicationContextAssert<C extends ApplicationContext>
|
||||
* assert on {@code null} is returned.
|
||||
* <p>
|
||||
* Example: <pre class="code">
|
||||
* assertThat(context).getBean(Foo.class).isInstanceOf(DefaultFoo.class);
|
||||
* assertThat(context).getBean(Bar.class).isNull();</pre>
|
||||
* assertThat(context).getBean(Foo.class, Scope.NO_ANCESTORS).isInstanceOf(DefaultFoo.class);
|
||||
* assertThat(context).getBean(Bar.class, Scope.NO_ANCESTORS).isNull();</pre>
|
||||
* @param <T> the bean type
|
||||
* @param type the bean type
|
||||
* @param scope the scope of the assertion
|
||||
@ -374,7 +374,7 @@ public class ApplicationContextAssert<C extends ApplicationContext>
|
||||
* can be found an assert on an empty {@code map} is returned.
|
||||
* <p>
|
||||
* Example: <pre class="code">
|
||||
* assertThat(context).getBeans(Foo.class).containsKey("foo");
|
||||
* assertThat(context).getBeans(Foo.class, Scope.NO_ANCESTORS).containsKey("foo");
|
||||
* </pre>
|
||||
* @param <T> the bean type
|
||||
* @param type the bean type
|
||||
|
@ -142,7 +142,7 @@ public class TestRestTemplateTests {
|
||||
.willReturn(new DefaultUriBuilderFactory());
|
||||
RestTemplateBuilder builder = mock(RestTemplateBuilder.class);
|
||||
given(builder.build()).willReturn(delegate);
|
||||
final TestRestTemplate restTemplate = new TestRestTemplate(builder);
|
||||
TestRestTemplate restTemplate = new TestRestTemplate(builder);
|
||||
ReflectionUtils.doWithMethods(RestOperations.class, new MethodCallback() {
|
||||
|
||||
@Override
|
||||
|
@ -60,7 +60,6 @@ public class ConfigurationPropertySourcesTests {
|
||||
public void attachShouldReAttachInMergedSetup() {
|
||||
ConfigurableEnvironment parent = new StandardEnvironment();
|
||||
ConfigurationPropertySources.attach(parent);
|
||||
parent.getProperty("my.example-property");
|
||||
ConfigurableEnvironment child = new StandardEnvironment();
|
||||
child.merge(parent);
|
||||
child.getPropertySources().addLast(new MapPropertySource("config",
|
||||
|
@ -120,7 +120,7 @@ The following sample applications are provided:
|
||||
| Demonstrates JUnit Jupiter-based testing
|
||||
|
||||
| link:spring-boot-sample-kafka[spring-boot-sample-kafka]
|
||||
| consumer and producer using Apache Kafka
|
||||
| Consumer and producer using Apache Kafka
|
||||
|
||||
| link:spring-boot-sample-liquibase[spring-boot-sample-liquibase]
|
||||
| Database migrations with Liquibase
|
||||
|
@ -2,5 +2,5 @@ spring.kafka.bootstrap-servers=localhost:9092
|
||||
spring.kafka.consumer.group-id=testGroup
|
||||
spring.kafka.consumer.auto-offset-reset=earliest
|
||||
spring.kafka.consumer.value-deserializer=org.springframework.kafka.support.serializer.JsonDeserializer
|
||||
spring.kafka.producer.value-serializer=org.springframework.kafka.support.serializer.JsonSerializer
|
||||
spring.kafka.consumer.properties.spring.json.trusted.packages=sample.kafka
|
||||
spring.kafka.consumer.properties.spring.json.trusted.packages=sample.kafka
|
||||
spring.kafka.producer.value-serializer=org.springframework.kafka.support.serializer.JsonSerializer
|
@ -116,15 +116,14 @@ public class SampleSecureWebFluxCustomSecurityTests {
|
||||
|
||||
@Bean
|
||||
public SecurityWebFilterChain springSecurityFilterChain(ServerHttpSecurity http) {
|
||||
http.authorizeExchange().matchers(EndpointRequest.to("health", "info"))
|
||||
return http.authorizeExchange().matchers(EndpointRequest.to("health", "info"))
|
||||
.permitAll()
|
||||
.matchers(EndpointRequest.toAnyEndpoint()
|
||||
.excluding(MappingsEndpoint.class))
|
||||
.hasRole("ACTUATOR")
|
||||
.matchers(PathRequest.toStaticResources().atCommonLocations())
|
||||
.permitAll().pathMatchers("/login").permitAll().anyExchange()
|
||||
.authenticated().and().httpBasic();
|
||||
return http.build();
|
||||
.authenticated().and().httpBasic().and().build();
|
||||
}
|
||||
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user