Skip to content

Commit 8dcdbeb

Browse files
committed
Disable LiveReload server by default
This commit changes the default value of configuration property `spring.devtools.livereload.enabled` to `false`. Signed-off-by: Vedran Pavic <vedran@vedranpavic.com>
1 parent aa06ab1 commit 8dcdbeb

File tree

6 files changed

+19
-22
lines changed

6 files changed

+19
-22
lines changed

documentation/spring-boot-docs/src/docs/antora/modules/reference/pages/using/devtools.adoc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -287,7 +287,7 @@ The `spring-boot-devtools` module includes an embedded LiveReload server that ca
287287
LiveReload browser extensions are freely available for Chrome, Firefox and Safari.
288288
You can find these extensions by searching 'LiveReload' in the marketplace or store of your chosen browser.
289289

290-
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`.
290+
If you want to start the LiveReload server when your application runs, you can set the configprop:spring.devtools.livereload.enabled[] property to `true`.
291291

292292
NOTE: You can only run one LiveReload server at a time.
293293
Before starting your application, ensure that no other LiveReload servers are running.

module/spring-boot-devtools/src/main/java/org/springframework/boot/devtools/autoconfigure/DevToolsProperties.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -193,7 +193,7 @@ public static class Livereload {
193193
/**
194194
* Whether to enable a livereload.com-compatible server.
195195
*/
196-
private boolean enabled = true;
196+
private boolean enabled = false;
197197

198198
/**
199199
* Server port.

module/spring-boot-devtools/src/main/java/org/springframework/boot/devtools/autoconfigure/LocalDevToolsAutoConfiguration.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -70,7 +70,7 @@ public final class LocalDevToolsAutoConfiguration {
7070
* Local LiveReload configuration.
7171
*/
7272
@Configuration(proxyBeanMethods = false)
73-
@ConditionalOnBooleanProperty(name = "spring.devtools.livereload.enabled", matchIfMissing = true)
73+
@ConditionalOnBooleanProperty(name = "spring.devtools.livereload.enabled")
7474
static class LiveReloadConfiguration {
7575

7676
@Bean

module/spring-boot-devtools/src/main/java/org/springframework/boot/devtools/remote/client/RemoteClientConfiguration.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -131,7 +131,7 @@ private void logWarnings() {
131131
* LiveReload configuration.
132132
*/
133133
@Configuration(proxyBeanMethods = false)
134-
@ConditionalOnBooleanProperty(name = "spring.devtools.livereload.enabled", matchIfMissing = true)
134+
@ConditionalOnBooleanProperty(name = "spring.devtools.livereload.enabled")
135135
static class LiveReloadConfiguration {
136136

137137
private final DevToolsProperties properties;

module/spring-boot-devtools/src/test/java/org/springframework/boot/devtools/autoconfigure/LocalDevToolsAutoConfigurationTests.java

Lines changed: 11 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -111,16 +111,11 @@ void resourceCachePeriodIsZero() throws Exception {
111111
assertThat(properties.getCache().getPeriod()).isZero();
112112
}
113113

114-
@Test
115-
void liveReloadServer() throws Exception {
116-
this.context = getContext(() -> initializeAndRun(Config.class));
117-
LiveReloadServer server = this.context.getBean(LiveReloadServer.class);
118-
assertThat(server.isStarted()).isTrue();
119-
}
120-
121114
@Test
122115
void liveReloadTriggeredOnContextRefresh() throws Exception {
123-
this.context = getContext(() -> initializeAndRun(ConfigWithMockLiveReload.class));
116+
Map<String, Object> properties = new HashMap<>();
117+
properties.put("spring.devtools.livereload.enabled", true);
118+
this.context = getContext(() -> initializeAndRun(ConfigWithMockLiveReload.class, properties));
124119
LiveReloadServer server = this.context.getBean(LiveReloadServer.class);
125120
reset(server);
126121
this.context.publishEvent(new ContextRefreshedEvent(this.context));
@@ -129,7 +124,9 @@ void liveReloadTriggeredOnContextRefresh() throws Exception {
129124

130125
@Test
131126
void liveReloadTriggeredOnClassPathChangeWithoutRestart() throws Exception {
132-
this.context = getContext(() -> initializeAndRun(ConfigWithMockLiveReload.class));
127+
Map<String, Object> properties = new HashMap<>();
128+
properties.put("spring.devtools.livereload.enabled", true);
129+
this.context = getContext(() -> initializeAndRun(ConfigWithMockLiveReload.class, properties));
133130
LiveReloadServer server = this.context.getBean(LiveReloadServer.class);
134131
reset(server);
135132
ClassPathChangedEvent event = new ClassPathChangedEvent(this.context, Collections.emptySet(), false);
@@ -139,7 +136,9 @@ void liveReloadTriggeredOnClassPathChangeWithoutRestart() throws Exception {
139136

140137
@Test
141138
void liveReloadNotTriggeredOnClassPathChangeWithRestart() throws Exception {
142-
this.context = getContext(() -> initializeAndRun(ConfigWithMockLiveReload.class));
139+
Map<String, Object> properties = new HashMap<>();
140+
properties.put("spring.devtools.livereload.enabled", true);
141+
this.context = getContext(() -> initializeAndRun(ConfigWithMockLiveReload.class, properties));
143142
LiveReloadServer server = this.context.getBean(LiveReloadServer.class);
144143
reset(server);
145144
ClassPathChangedEvent event = new ClassPathChangedEvent(this.context, Collections.emptySet(), true);
@@ -148,10 +147,8 @@ void liveReloadNotTriggeredOnClassPathChangeWithRestart() throws Exception {
148147
}
149148

150149
@Test
151-
void liveReloadDisabled() throws Exception {
152-
Map<String, Object> properties = new HashMap<>();
153-
properties.put("spring.devtools.livereload.enabled", false);
154-
this.context = getContext(() -> initializeAndRun(Config.class, properties));
150+
void liveReloadDisabledByDefault() throws Exception {
151+
this.context = getContext(() -> initializeAndRun(Config.class));
155152
assertThatExceptionOfType(NoSuchBeanDefinitionException.class)
156153
.isThrownBy(() -> this.context.getBean(OptionalLiveReloadServer.class));
157154
}

module/spring-boot-devtools/src/test/java/org/springframework/boot/devtools/remote/client/RemoteClientConfigurationTests.java

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -102,8 +102,8 @@ void failIfNoSecret() {
102102
}
103103

104104
@Test
105-
void liveReloadOnClassPathChanged() throws Exception {
106-
configure();
105+
void liveReloadOnClassPathChanged() {
106+
configure("spring.devtools.livereload.enabled:true");
107107
Set<ChangedFiles> changeSet = new HashSet<>();
108108
ClassPathChangedEvent event = new ClassPathChangedEvent(this, changeSet, false);
109109
this.clientContext.publishEvent(event);
@@ -112,8 +112,8 @@ void liveReloadOnClassPathChanged() throws Exception {
112112
}
113113

114114
@Test
115-
void liveReloadDisabled() {
116-
configure("spring.devtools.livereload.enabled:false");
115+
void liveReloadDisabledByDefault() {
116+
configure();
117117
assertThatExceptionOfType(NoSuchBeanDefinitionException.class)
118118
.isThrownBy(() -> this.context.getBean(OptionalLiveReloadServer.class));
119119
}

0 commit comments

Comments
 (0)