Allow `META-INF/spring-devtools.properties` files to be used by
application developers to declare is specific jars should be included
or excluded from the RestartClassLoader.
A typical example where this might be used is a company that develops
it's own set of internal JARs that are used by developers but not
usually imported into their IDE.
See gh-3316
Update SpringApplication so that startup exceptions are only logged
once. A custom UncaughtExceptionHandler is now used when running in
the main thread to suppress errors that have already been logged.
Fixes gh-4423
During a restart, the Restarter runs all registered shutdown hooks. This
breaks Log4J2 as it leaves it in a shutdown state that leaves logging
switched off such that no output it produced when the application starts
up again.
This commit introduces a new RestartListener abstraction.
RestartListeners are notified prior to the application being restarted.
A Log4J2-specific implementation is provided that prepares Log4J2 for
restart by removing any shutdown callbacks from its shutdown callback
registry. This prevents the restart from shutting down Log4J2, ensuring
that it still functions when the application restarts.
Closes gh-4279
Previously, ConfigFileApplicationListener was listed in spring.factories
as both an EnvironmentPostProcessor and an ApplicationListener. This
was problematic as ConfigFileApplicationListener is stateful and listing
it twice lead to two separate instances with separate state.
This commit restore ConfigFileApplicationListener to only being an
ApplicationListener. The driving of EnvironmentPostProcessors that was
performed by EnvironmentPostProcessingApplicationListener is now
performed by ConfigFileApplicationListener which adds itself as an
EnvironmentPostProcessor. This ensures that there’s only a single
instance of ConfigFileApplicationListener, allowing its state to be
managed correctly.
Closes gh-4258
Previously, the auto-configuration of DevTools’ debug, restart, and
health handlers assumed that the server was running on its default
context path and, if server.context-path was set to a non-default value,
the handlers would not work as expected.
This commit updates the auto-configuration of the three handlers to
consider the server’s context path when configuring their URIs. Now,
when a custom server context path is used, no further configuration is
required other than the inclusion of that context path when providing
the remote URL as an argument to RemoteSpringApplication.
Closes gh-4301
Replace the custom Base64Encoder class with Spring's Base64Utils which
since 4.2 can encode bytes using Java 8's encoder, commons-digest or
Java 6's JAX-B encoder.
Closes gh-4189
Spring HATEOAS’s DummyInvocationUtils, that is used by
ControllerLinkBuilder, uses Objenesis. By default, Objenesis caches
the instances that it creates and uses the class name as the cache key.
This is problematic when DevTools’ restart support is enabled as the
class loader changes with each restart and ClassCastExceptions occur
due to Objenesis returning a cached instance that was created by an
old restart class loader.
This commit works around the problem described above by auto-configuring
a bean that uses reflection to replace DummyInvocationUtils’ default
Objenesis instance with one that has caching disabled.
Closes gh-3784
Previously the default DevTools property source was added in first place
to the environment’s property sources in an unordered environment
post-processor. This made it difficult to override them.
This commit updates the post-processor to be ordered with lowest
precedence and to add the property source in last place. This should
allow any other property sources and to override the defaults.
Closes gh-3851
This commit adds two new properties, spring.devtools.remote.proxy.host
and spring.devtools.remote.proxy.port that can be used to configure
RemoteSpringApplication to connect to the remote application through
an HTTP proxy.
Closes gh-3968
Previously, if a file or non-existent directory was added to
FileSystemWatcher, it would fail with the message “Folder must not be a
file”. While it suggests that the folder needs to be a directory, it
doesn’t make it clear that it also needs to exist. It also doesn’t
tell the user which folder caused the problem.
This commit updates the message to make it clear that the folder must
exist and must be a directory, and the include the name of the
problematic folder in the error message.
Closes gh-3918
Update `DevToolsProperties` to exclude `git.properties` files.
Prior to this commit any application configured to write `git.properties`
could trigger unexpected application restarts. The problem is particularly
prevalent when using Eclipse M2E in combination with the
`git-commit-id-plugin`.
Closes gh-3938
Previously, dev tools would restart the application when any .class
file changed. This included test classes. This commit updates the
default excludes to ignore any classes with a name that ends in
Test.class or Tests.class.
Closes gh-3900
Previously, RemoteDevToolsAutoConfiguration would try to configure
Spring Security if it was on the classpath. This led to a failure if
Spring Security was on the classpath but its auto-configuration was
disabled.
This commit updates the auto-configuration to be conditional on the
presence of Spring Security’s ObjectPostProcessor bean.
See gh-3889
Previously, if an app had Spring Security on the classpath the remote
devtools server would be secured using basic authentication. This
prevented RemoteSpringApplication from uploading changes to the server
as they would be rejected with a 401.
This commit updates RemoteDevToolsAutoConfiguration to allow anonymous
access to the remote server. CSRF protection is also disabled so that
POST requests without a CSRF token will be accepted.
Closes gh-3889
Given that Spring Boot uses java config accross the board, a new `value`
attribute is now aliased to the existing `classes` attribute such that
one could write the following:
@SpringApplicationConfiguration(MyConfig.class)
public class MyTest {}
Closes gh-3635
The default value of `spring.devtools.restart.exclude` is quite long and
any override requires to copy/paste it to add additional exclusions. To
avoid that, a new `spring.devtools.restart.additional-exclude` property
has been added.
Both properties are now used to compute the full list of exclusions that
is used by PatternClassPathRestartStrategy.
Closes gh-3774
Prior to this commit, the devtools used bean factory post processors to
configure the environment with custom, development-time properties. This
meant that the environment was configured as part of the application
context being refreshed. Crucially, this happened after any property
conditions were evaluated making it impossible for the devtools to
change the default auto-configuration behaviour for a bean or
configuration class that was conditional on a property.
This commit moves the configuration of the environment into an
ApplicationListener that listens for the
ApplicationEnvironmentPreparedEvent which is published as soon as the
Environment has been prepared and before the application context is
refreshed.
Closes gh-3726
Previously, only folders on the classpath would be watched and used
to trigger a restart/reload of the application. This commit adds a
new property spring.devtools.restart.additional-paths that can be
used to configure additional paths that should be watched for
changes. When a change occurs in one of those paths a restart or
reload will be triggered, depending on the full restart exclude
patterns configured via the existing spring.devtools.restart.exclude
property.
Closes gh-3469
Three conditions must be met for the console to be enabled:
- H2 is on the classpath
- The application is a web application
- spring.h2.console.enabled is set to true
If spring-boot-devtools is on the classpath, spring.h2.console.enabled
will be set to true automatically. Without the dev tools, the enabled
property will have to be set to true in application.properties.
By default, the console is available at /h2-console. This can be
configured via the spring.h2.console.path property. The value of this
property must begin with a '/'.
When Spring Security is on the classpath the console will be secured
based on the user's security.* configuration. When the console is
secured, CSRF protection is disabled and frame options is set to
SAMEORIGIN for its path. Both settings are required in order for the
console to function.
Closes gh-766
These files are modified by Eclipse for some reason when you change files
like Thymeleaf HTML files. `META-INF/maven/**` has been added to the
default exclusion.
Closes gh-3295
Closes gh-3297
Update `Restarter` to support a `FailureHandler` strategy that can be
used to determine how to deal with errors. The
`LocalDevToolsAutoConfiguration` now uses a strategy that doesn't quit
the application, but instead continues to wait for further file changes.
This helps make restart much more usable in situations where you
accidentally break code.
Fixes gh-3210
Support loading a `.spring-boot-devtools.properties` file from the
users home folder. The property file can be used to customize settings
that make sense on a per-user basis, but might not want to be checked
into the project.
Fixes gh-3151
Update DevToolsPropertyDefaultsPostProcessor to set the following
additional template cache properties to `false`:
spring.freemarker.cache
spring.groovy.template.cache
spring.velocity.cache
spring.mustache.cache
Fixes gh-3125
The FileWatcher sometimes generates multiple events for a single change
and if there is a slow shutdown hook the second one can come in before
the context is closed, leaving it in a tricky state. This change
attempts to stop the file watcher as soon as it detects a change
(the stop() method is called in the listener, which normally happens in
the same thread as the scan).
Fixes gh-3097