mirror of
https://github.com/spring-projects/spring-boot.git
synced 2026-09-26 11:39:14 +00:00
Disable LiveReload server by default
Change the default value of the configuration property `spring.devtools.livereload.enabled` to `false`. See gh-47387 Signed-off-by: Vedran Pavic <vedran@vedranpavic.com>
This commit is contained in:
committed by
Phillip Webb
parent
41a399c5ae
commit
b3133d4ec1
@@ -381,7 +381,7 @@ tasks.register("documentDevtoolsPropertyDefaults", org.springframework.boot.buil
|
||||
tasks.register("runRemoteSpringApplicationExample", org.springframework.boot.build.docs.ApplicationRunner) {
|
||||
classpath = configurations.remoteSpringApplicationExample
|
||||
mainClass = "org.springframework.boot.devtools.RemoteSpringApplication"
|
||||
args = ["https://myapp.example.com", "--spring.devtools.remote.secret=secret", "--spring.devtools.livereload.port=0"]
|
||||
args = ["https://myapp.example.com", "--spring.devtools.remote.secret=secret", "--spring.devtools.livereload.enabled=true", "--spring.devtools.livereload.port=0"]
|
||||
output = layout.buildDirectory.file("example-output/remote-spring-application.txt")
|
||||
expectedLogging = "Started RemoteSpringApplication in "
|
||||
applicationJar = "/Users/myuser/.m2/repository/org/springframework/boot/spring-boot-devtools/${project.version}/spring-boot-devtools-${project.version}.jar"
|
||||
|
||||
+1
-1
@@ -287,7 +287,7 @@ The `spring-boot-devtools` module includes an embedded LiveReload server that ca
|
||||
LiveReload browser extensions are freely available for Chrome, Firefox and Safari.
|
||||
You can find these extensions by searching 'LiveReload' in the marketplace or store of your chosen browser.
|
||||
|
||||
If you do not want to start the LiveReload server when your application runs, you can set the configprop:spring.devtools.livereload.enabled[] property to `false`.
|
||||
If you want to start the LiveReload server when your application runs, you can set the configprop:spring.devtools.livereload.enabled[] property to `true`.
|
||||
|
||||
NOTE: You can only run one LiveReload server at a time.
|
||||
Before starting your application, ensure that no other LiveReload servers are running.
|
||||
|
||||
+1
-1
@@ -193,7 +193,7 @@ public class DevToolsProperties {
|
||||
/**
|
||||
* Whether to enable a livereload.com-compatible server.
|
||||
*/
|
||||
private boolean enabled = true;
|
||||
private boolean enabled = false;
|
||||
|
||||
/**
|
||||
* Server port.
|
||||
|
||||
+1
-1
@@ -70,7 +70,7 @@ public final class LocalDevToolsAutoConfiguration {
|
||||
* Local LiveReload configuration.
|
||||
*/
|
||||
@Configuration(proxyBeanMethods = false)
|
||||
@ConditionalOnBooleanProperty(name = "spring.devtools.livereload.enabled", matchIfMissing = true)
|
||||
@ConditionalOnBooleanProperty(name = "spring.devtools.livereload.enabled")
|
||||
static class LiveReloadConfiguration {
|
||||
|
||||
@Bean
|
||||
|
||||
+1
-1
@@ -131,7 +131,7 @@ public class RemoteClientConfiguration implements InitializingBean {
|
||||
* LiveReload configuration.
|
||||
*/
|
||||
@Configuration(proxyBeanMethods = false)
|
||||
@ConditionalOnBooleanProperty(name = "spring.devtools.livereload.enabled", matchIfMissing = true)
|
||||
@ConditionalOnBooleanProperty(name = "spring.devtools.livereload.enabled")
|
||||
static class LiveReloadConfiguration {
|
||||
|
||||
private final DevToolsProperties properties;
|
||||
|
||||
+11
-14
@@ -112,16 +112,11 @@ class LocalDevToolsAutoConfigurationTests {
|
||||
assertThat(properties.getCache().getPeriod()).isZero();
|
||||
}
|
||||
|
||||
@Test
|
||||
void liveReloadServer() throws Exception {
|
||||
this.context = getContext(() -> initializeAndRun(Config.class));
|
||||
LiveReloadServer server = this.context.getBean(LiveReloadServer.class);
|
||||
assertThat(server.isStarted()).isTrue();
|
||||
}
|
||||
|
||||
@Test
|
||||
void liveReloadTriggeredOnContextRefresh() throws Exception {
|
||||
this.context = getContext(() -> initializeAndRun(ConfigWithMockLiveReload.class));
|
||||
Map<String, Object> properties = new HashMap<>();
|
||||
properties.put("spring.devtools.livereload.enabled", true);
|
||||
this.context = getContext(() -> initializeAndRun(ConfigWithMockLiveReload.class, properties));
|
||||
LiveReloadServer server = this.context.getBean(LiveReloadServer.class);
|
||||
reset(server);
|
||||
this.context.publishEvent(new ContextRefreshedEvent(this.context));
|
||||
@@ -130,7 +125,9 @@ class LocalDevToolsAutoConfigurationTests {
|
||||
|
||||
@Test
|
||||
void liveReloadTriggeredOnClassPathChangeWithoutRestart() throws Exception {
|
||||
this.context = getContext(() -> initializeAndRun(ConfigWithMockLiveReload.class));
|
||||
Map<String, Object> properties = new HashMap<>();
|
||||
properties.put("spring.devtools.livereload.enabled", true);
|
||||
this.context = getContext(() -> initializeAndRun(ConfigWithMockLiveReload.class, properties));
|
||||
LiveReloadServer server = this.context.getBean(LiveReloadServer.class);
|
||||
reset(server);
|
||||
ClassPathChangedEvent event = new ClassPathChangedEvent(this.context, Collections.emptySet(), false);
|
||||
@@ -140,7 +137,9 @@ class LocalDevToolsAutoConfigurationTests {
|
||||
|
||||
@Test
|
||||
void liveReloadNotTriggeredOnClassPathChangeWithRestart() throws Exception {
|
||||
this.context = getContext(() -> initializeAndRun(ConfigWithMockLiveReload.class));
|
||||
Map<String, Object> properties = new HashMap<>();
|
||||
properties.put("spring.devtools.livereload.enabled", true);
|
||||
this.context = getContext(() -> initializeAndRun(ConfigWithMockLiveReload.class, properties));
|
||||
LiveReloadServer server = this.context.getBean(LiveReloadServer.class);
|
||||
reset(server);
|
||||
ClassPathChangedEvent event = new ClassPathChangedEvent(this.context, Collections.emptySet(), true);
|
||||
@@ -149,10 +148,8 @@ class LocalDevToolsAutoConfigurationTests {
|
||||
}
|
||||
|
||||
@Test
|
||||
void liveReloadDisabled() throws Exception {
|
||||
Map<String, Object> properties = new HashMap<>();
|
||||
properties.put("spring.devtools.livereload.enabled", false);
|
||||
this.context = getContext(() -> initializeAndRun(Config.class, properties));
|
||||
void liveReloadDisabledByDefault() throws Exception {
|
||||
this.context = getContext(() -> initializeAndRun(Config.class));
|
||||
assertThatExceptionOfType(NoSuchBeanDefinitionException.class).isThrownBy(() -> {
|
||||
assertThat(this.context).isNotNull();
|
||||
this.context.getBean(OptionalLiveReloadServer.class);
|
||||
|
||||
+4
-4
@@ -104,8 +104,8 @@ class RemoteClientConfigurationTests {
|
||||
}
|
||||
|
||||
@Test
|
||||
void liveReloadOnClassPathChanged() throws Exception {
|
||||
configure();
|
||||
void liveReloadOnClassPathChanged() {
|
||||
configure("spring.devtools.livereload.enabled:true");
|
||||
Set<ChangedFiles> changeSet = new HashSet<>();
|
||||
ClassPathChangedEvent event = new ClassPathChangedEvent(this, changeSet, false);
|
||||
assertThat(this.clientContext).isNotNull();
|
||||
@@ -115,8 +115,8 @@ class RemoteClientConfigurationTests {
|
||||
}
|
||||
|
||||
@Test
|
||||
void liveReloadDisabled() {
|
||||
configure("spring.devtools.livereload.enabled:false");
|
||||
void liveReloadDisabledByDefault() {
|
||||
configure();
|
||||
assertThatExceptionOfType(NoSuchBeanDefinitionException.class)
|
||||
.isThrownBy(() -> getContext().getBean(OptionalLiveReloadServer.class));
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user