Skip to content

Commit b3133d4

Browse files
vpavicphilwebb
authored andcommitted
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 <[email protected]>
1 parent 41a399c commit b3133d4

File tree

7 files changed

+20
-23
lines changed

7 files changed

+20
-23
lines changed

documentation/spring-boot-docs/build.gradle

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -381,7 +381,7 @@ tasks.register("documentDevtoolsPropertyDefaults", org.springframework.boot.buil
381381
tasks.register("runRemoteSpringApplicationExample", org.springframework.boot.build.docs.ApplicationRunner) {
382382
classpath = configurations.remoteSpringApplicationExample
383383
mainClass = "org.springframework.boot.devtools.RemoteSpringApplication"
384-
args = ["https://myapp.example.com", "--spring.devtools.remote.secret=secret", "--spring.devtools.livereload.port=0"]
384+
args = ["https://myapp.example.com", "--spring.devtools.remote.secret=secret", "--spring.devtools.livereload.enabled=true", "--spring.devtools.livereload.port=0"]
385385
output = layout.buildDirectory.file("example-output/remote-spring-application.txt")
386386
expectedLogging = "Started RemoteSpringApplication in "
387387
applicationJar = "/Users/myuser/.m2/repository/org/springframework/boot/spring-boot-devtools/${project.version}/spring-boot-devtools-${project.version}.jar"

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
@@ -112,16 +112,11 @@ void resourceCachePeriodIsZero() throws Exception {
112112
assertThat(properties.getCache().getPeriod()).isZero();
113113
}
114114

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

131126
@Test
132127
void liveReloadTriggeredOnClassPathChangeWithoutRestart() throws Exception {
133-
this.context = getContext(() -> initializeAndRun(ConfigWithMockLiveReload.class));
128+
Map<String, Object> properties = new HashMap<>();
129+
properties.put("spring.devtools.livereload.enabled", true);
130+
this.context = getContext(() -> initializeAndRun(ConfigWithMockLiveReload.class, properties));
134131
LiveReloadServer server = this.context.getBean(LiveReloadServer.class);
135132
reset(server);
136133
ClassPathChangedEvent event = new ClassPathChangedEvent(this.context, Collections.emptySet(), false);
@@ -140,7 +137,9 @@ void liveReloadTriggeredOnClassPathChangeWithoutRestart() throws Exception {
140137

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

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

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
@@ -104,8 +104,8 @@ void failIfNoSecret() {
104104
}
105105

106106
@Test
107-
void liveReloadOnClassPathChanged() throws Exception {
108-
configure();
107+
void liveReloadOnClassPathChanged() {
108+
configure("spring.devtools.livereload.enabled:true");
109109
Set<ChangedFiles> changeSet = new HashSet<>();
110110
ClassPathChangedEvent event = new ClassPathChangedEvent(this, changeSet, false);
111111
assertThat(this.clientContext).isNotNull();
@@ -115,8 +115,8 @@ void liveReloadOnClassPathChanged() throws Exception {
115115
}
116116

117117
@Test
118-
void liveReloadDisabled() {
119-
configure("spring.devtools.livereload.enabled:false");
118+
void liveReloadDisabledByDefault() {
119+
configure();
120120
assertThatExceptionOfType(NoSuchBeanDefinitionException.class)
121121
.isThrownBy(() -> getContext().getBean(OptionalLiveReloadServer.class));
122122
}

0 commit comments

Comments
 (0)