This commit enables a more flexible Liquibase/Flyway configuration by
allowing for a combination of the provider's and the primary
DataSource's configuration to be used. This gives developers the
flexibility to specify only a user or a url and having
Liquibase/Flyway fall back to individual datasource properties rather
than ignoring the Liquibase/Flyway properties and falling back to the
default data source.
See gh-11751
Previously, the logging system was cleaned up in response to the
root context's ContextClosedEvent being received. This event is
published early in a context's close processing. As a result, the
logging system is in cleaned up state while, for example, disposable
beans are being destroyed.
This commit reworks the logic that triggers logging system clean up
to use a disposable bean instead. Disposable beans are called in
reverse-registration order. The logging clean up bean is registered as
early as possible so that it should be the last disposable bean to
be called.
Closes gh-11676
Move the "testdb" naming logic to `DataSourceProperties` and expose
the `deduceDatabaseName` method so they can be used in
auto-configuration.
See gh-11719
Previously, Hikari's pool name was auto-configured with the value of
`spring.datasource.name` that defaults to `testdb`, which brings some
confusion.
This commit removes the default `testdb` value on
`spring.datasource.name` as it is a sane default only for an embedded
datasource. It is applied whenever applicable instead.
Closes gh-11719
This commit prevents the default error view from rendering itself if the
response has been committed already. In this case, it is impossible to
change the HTTP response status and write a proper response - trying to
do so often results in a `IllegalStateException` since the response body
has already been written to.
Fixes gh-11580
Previously, the ServletContext was configured after any
ServletContextInitializer beans had been initialized. This meant that
any configuration class that provided such a bean would be initialized
before the ServletContext was configured. If the configuration class
used the ServletContext in its initializtaion that it would see it in
its default, unconfigured state.
This commit reworks the configuration of the ServletContext so that
it happens before any ServletContextInitializer beans are initialized.
Closes gh-10699
This commit updates DefaultErrorAttributes to handle
ResponseStatusException explicitly. This exception is used in a
WebFlux application to signal that the processing of the query has
failed with an HTTP status code and a reason phrase. The latter is now
properly mapped to the `message` attribute of the response body.
Closes gh-11614
This commits improves the cache auto-configuration for Redis by looking
up a custom "RedisCacheConfiguration" bean that allows to take full
control over the `RedisCacheManager`.
Closes gh-11599
This commit applies `server.jetty.*` configuration properties
to Jetty when configured as a reactive web server.
It also removes some infrastructure support for Jetty 8, which
is not supported anymore in Spring Boot 2.0 (partial fix for
gh-11504).
See gh-11500
This commit applies most `server.tomcat.*` configuration
properties to Tomcat when set up as a reactive web server.
Some Servlet-specific properties are not applied:
* server.tomcat.additional-tld-skip-patterns
* server.tomcat.redirect-context-root
* server.tomcat.use-relative-redirects
Fixes gh-11334
Extract functionality from the `RegistrationBean` into a new class
designed to work with dynamic registration. Servet and Filter
registration beans now extend from `DynaimcRegistrationBean`, where as
`ServletListenerRegistrationBean` extends directly from
`RegistrationBean`.
This refactor allows the removal of `ServletListenerRegistrationBean`
deprecated methods.
Fixes gh-11344
This commit adds a new exception type that denotes the value of a
configuration key is invalid, alongside a FailureAnalyzer that reports
a human-readable report when such exception is thrown on startup.
ResourceNotFoundException being a (useless) specialization of this new
exception, its usage has been refactored to use the more general
exception type.
Closes gh-10794
This commit fixes the `responseCommitted` test in
`DefaultErrorWebExceptionHandlerIntegrationTests` and reworks the whole
test class to use the `ContextRunner` infrastructure.
Fixes gh-11519
As HibernateJpaConfiguration is package private, it is no longer
possible to extend the default Spring Boot configuration to apply
advanced settings. The most notable use case for this is the
customization of Hibernate properties using instance value vs. string
value that can be set using the "spring.jpa.properties" namespace.
This commit adds a HibernatePropertiesCustomizer callback interface that
can be implemented to tune Hibernate properties at will.
Closes gh-11211
Prior to this change, the Spring MVC auto-configuration would add a new
formatter to convert `java.util.Date` to/from `String` using the
configured configuration property `spring.mvc.date-format`.
This commit adds a new `WebConversionService` class that registers
date formatters with a custom date format, or register the default ones
if no custom configuration is provided.
This avoids duplicating equivalent formatters in the registry.
With this change, date types from `java.util`, `org.joda.time` and
`java.time` are now all supported.
This commit also replicates this feature for WebFlux applications by
adding a new `spring.webflux.date-format` configuration property.
Closes gh-5523
Closes gh-11402
Rather than using two properties to enable or disable reactive and
imperative repositories for a particular store, this commit introduces
a new repository type condition that's backed by a single
spring.data.<store>.repositories.type property. The type can be
auto (automatically enables whatever's available), imperative (enables
imperative repositories), none (enables nothing), or reactive (enables
reactive repositories). The default is auto.
Repositories do not have a reactive option (such as JPA) continue to
have a spring.data.<store>.repositories.enabled property that takes a
boolean value.
Closes gh-11134
If the WebFlux handler commits the response but still sends an error
signal in the reactive pipeline, Spring Boot error handling should not
try to handle that error: once committed, it is impossible to change the
response status or the response headers. Writing to the body might also
lead to invalid responses.
This commit skips error handling if the response is committed and
delegates to Spring Framework's `HttpWebHandlerAdapter` which will log
the error.
Fixes gh-11168
This commit adds support for basic auto-configuration for the Freemarker
template engine in WebFlux.
A few configuration properties in the `spring.freemarker.*` namespace
aren't supported yet, since they mostly apply to MVC (Servlet request
and session attributes).
Closes gh-10094
Elasticsearch server requires log4j-core but we don't want the entire
module to have a test dependency on log4j-core as it already uses
Logback. This commit uses the modified class path runner to make
log4j-core available specifically to the Elasticsearch-related tests.
See gh-11166
Rename `reactive-repositories` to `reactiverepositories` and replace
`spring.resources.cache-control` with `spring.resources.cache.control`.
Fixes gh-11090
Previously, custom Hibernate naming strategies could only be
configured via properties. This allowed a fully-qualified classname to
be specified, but did not allow a naming strategy instance to be used.
This commit updates HibernateJpaConfiguration to use
ImplicitNamingStrategy and PhysicalNamingStrategy beans if they
exist. If both a bean exists and the equivalent property has been set,
the bean wins.
This commit adds several configuration keys for customizing the
"Cache-Control" HTTP response header when serving static resources.
New keys are located in the "spring.resources.cache-control.*"
namespace; anything configured there will prevail on existing
"spring.resources.cache-period=" values, so as to mirror Spring MVC's
behavior.
Fixes gh-9432
Update appropriate configuration properties to use the `Duration`
type, rather than an ad-hoc mix of milliseconds or seconds.
Configuration properties can now be defined in a consistent and readable
way. For example `server.session.timeout=5m`.
Properties that were previously declared using seconds are annotated
with `@DurationUnit` to ensure a smooth upgrade experience. For example
`server.session.timeout=20` continues to mean 20 seconds.
Fixes gh-11080
Add `spring.kafka.producer.transaction-id-prefix` property that will be
passed to `DefaultKafkaProducerFactory.setTransactionIdPrefix(...)`
See gh-11076
This commit updates `SessionAutoConfiguration` to ensure it is processed
after `MongoDataAutoConfiguration` and
`MongoReactiveDataAutoConfiguration`, instead of `MongoAutoConfiguration`
and `MongoReactiveAutoConfiguration`. This is required in order for
MongoDB Session auto-configuration to work, since
`MongoSessionConfiguration` and `MongoReactiveSessionConfiguration` are
conditional on `MongoOperations` and `ReactiveMongoOperations` beans,
respectively.
Closes gh-11054
Update `RedisProperties` to use an actual String[] for sentinal nodes
rather than a simple String. This allows us to lean on the updated
binder to automatically trim the elements.
Fixes gh-11029
Expose key prefix, TTL and null value settings for spring-data-redis'
RedisCacheConfiguration in Spring .properties/yml configuration files.
Example:
spring.cache.redis.ttl=PT15M
spring.cache.redis.keyPrefix=foo
spring.cache.redis.useKeyPrefix=false
spring.cache.redis.cacheNullValues=false
See gh-10795
Refactor `ReactiveWebApplicationContext` implementations to align closer
with the `WebApplicationContext` implementations defined in
Spring Framework.
The following classes are now provided:
- `AnnotationConfigReactiveWebApplicationContext` -- A refreshable
reactive web context with support for `@Configuration` classes.
- `GenericReactiveWebApplicationContext` -- A non-refreshable reactive
GenericApplicationContext.
- `ReactiveWebServerApplicationContext` -- A non-refreshable reactive
GenericApplicationContext with support for server discovery.
- `AnnotationConfigReactiveWebServerApplicationContext` -- A
non-refreshable reactive `GenericApplicationContext` with support
for `@Configuration` classes and server discovery.
These classes roughly align to the following Servlet equivalents:
- `AnnotationConfigWebApplicationContext` (Spring Framework)
- `GenericWebApplicationContext` (Spring Framework)
- `ServletWebServerApplicationContext` (Spring Boot)
- `AnnotationConfigServletWebServerApplicationContext` (Spring Boot)
An additional `ConfigurableReactiveWebEnvironment` interface as also
been introduced, primarily for `@ConditionalOnWebApplication` to use.
Fixes gh-10852
This commit ensures that all errors handled by the
`DefaultErrorWebExceptionHandler` (Spring WebFlux error convetion
support) logs an error with request information and exception
stacktrace.
This is limited to errors that result in an HTTP 5xx error.
Exceptions that extend `ResponseStatusException` and set a non-5xx
status will not be logged.
Closes gh-10904
This commit adds a new configuration properties class for configuring
HTTP/2 protocol support.
By default, this protocol is disabled as enabling it requires several
manual changes:
* configuring a web server for proper TLS and ALPN support
* configuring a proper SSL certificate
See gh-10043
Flyway implicitly adds classpath: to locations without a prefix but
resource loader fails to find migratons on the classpath without the
prefix.
Add an explicit classpath: prefix so that both Flyway and the resource
loader used to check the locations can find the migration location.
See gh-10807
Move logic from `ParameterNameMapper` into `ReflectiveOperationInvoker`
in order to reduce the surface area of the public API.
Also rename some classes for consistency.
Instead of looking for the presence of `WebSecurityConfiguration`,
this commit checks for the presence of a `Filter` with the name
springSecurityFilterChain. This allows users to configure the Filter
without adding `WebSecurityConfiguration`, making it more flexible.
`springSecurityFilterChain` is somewhat of a contract in Spring Security
and it relies on the name being `springSecurityFilterChain`.
Closes gh-10849
This commit updates `WebFluxSecurityConfiguration` to look for a
`WebFilterChainProxy` rather than the default configuration that
`@EnableWebFluxSecurity` triggers. The latter is now package private.
This commit renames spring.datasource.initialize to
spring.datasource.initialization-mode and use the
DataSourceInitializationMode enum. By default, only an embedded
datasource is initialized.
Closes gh-10773
This commit makes sure that the `replyTemplate` is set if a
KafkaTemplate is available in the context which effectively add support
for `@SendTo`.
Closes gh-10669
Following some changes in the latest snapshot this includes:
- Some updates to oauth2 client auto-config
- Security auto-config no longer relies on GlobalAuthenticationConfigurerAdapter
- Remove reactive security starter
Closes gh-10704
Starting with Hibernate 5.2.10, the JPA property
`hibernate.connection.provider_disables_autocommit` should be set to true
when the datasource has autocommit disabled in order to improve
performance.
See gh-9737
This commit adds support for Spring Boot error conventions with WebFlux.
The Spring MVC support for that is based on an `Controller` that's
mapped on a specific `"/error"` path and configured as an error page in
the Servlet container. With WebFlux, this support leverages a
`WebExceptionHandler`, which catches exceptions flowing through the
reactive pipeline and handles them.
The `DefaultErrorWebExceptionHandler` supports the following:
* return a JSON error response to machine clients
* return error HTML views (templates, static or default HTML view)
One can customize the error information by contributing an
`ErrorAttributes` bean to the application context.
Spring Boot provides an `ErrorWebExceptionHandler` marker interface and a
base implementation that provides high level constructs to handle
errors, based on the Spring WebFlux functional flavor.
The error handling logic can be completely changed by providing a custom
`RouterFunction` there.
Fixes gh-8625
Move projects to better reflect the way that Spring Boot is released.
The following projects are under `spring-boot-project`:
- `spring-boot`
- `spring-boot-autoconfigure`
- `spring-boot-tools`
- `spring-boot-starters`
- `spring-boot-actuator`
- `spring-boot-actuator-autoconfigure`
- `spring-boot-test`
- `spring-boot-test-autoconfigure`
- `spring-boot-devtools`
- `spring-boot-cli`
- `spring-boot-docs`
See gh-9316