Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion documentation/spring-boot-docs/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -320,7 +320,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"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -193,7 +193,7 @@ public static class Livereload {
/**
* Whether to enable a livereload.com-compatible server.
*/
private boolean enabled = true;
private boolean enabled = false;

/**
* Server port.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -131,7 +131,7 @@ private void logWarnings() {
* 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;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -111,16 +111,11 @@ void resourceCachePeriodIsZero() throws Exception {
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));
Expand All @@ -129,7 +124,9 @@ void liveReloadTriggeredOnContextRefresh() throws Exception {

@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);
Expand All @@ -139,7 +136,9 @@ void liveReloadTriggeredOnClassPathChangeWithoutRestart() throws Exception {

@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);
Expand All @@ -148,10 +147,8 @@ void liveReloadNotTriggeredOnClassPathChangeWithRestart() throws Exception {
}

@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(() -> this.context.getBean(OptionalLiveReloadServer.class));
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -102,8 +102,8 @@ void failIfNoSecret() {
}

@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);
this.clientContext.publishEvent(event);
Expand All @@ -112,8 +112,8 @@ void liveReloadOnClassPathChanged() throws Exception {
}

@Test
void liveReloadDisabled() {
configure("spring.devtools.livereload.enabled:false");
void liveReloadDisabledByDefault() {
configure();
assertThatExceptionOfType(NoSuchBeanDefinitionException.class)
.isThrownBy(() -> this.context.getBean(OptionalLiveReloadServer.class));
}
Expand Down
Loading