Skip to content

Commit 4e41068

Browse files
htynknsnicoll
authored andcommitted
Disable resource cache when DevTools is enabled
Closes spring-projectsgh-3794 Closes spring-projectsgh-3739
1 parent 5aa222a commit 4e41068

File tree

2 files changed

+14
-0
lines changed

2 files changed

+14
-0
lines changed

spring-boot-devtools/src/main/java/org/springframework/boot/devtools/env/DevToolsPropertyDefaultsPostProcessor.java

100644100755
+1
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,7 @@ public class DevToolsPropertyDefaultsPostProcessor implements EnvironmentPostPro
4646
properties.put("spring.mustache.cache", "false");
4747
properties.put("server.session.persistent", "true");
4848
properties.put("spring.h2.console.enabled", "true");
49+
properties.put("spring.resources.cache-period", "0");
4950
PROPERTIES = Collections.unmodifiableMap(properties);
5051
}
5152

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

100644100755
+13
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,7 @@
2828
import org.springframework.beans.factory.NoSuchBeanDefinitionException;
2929
import org.springframework.boot.SpringApplication;
3030
import org.springframework.boot.autoconfigure.thymeleaf.ThymeleafAutoConfiguration;
31+
import org.springframework.boot.autoconfigure.web.ResourceProperties;
3132
import org.springframework.boot.devtools.classpath.ClassPathChangedEvent;
3233
import org.springframework.boot.devtools.classpath.ClassPathFileSystemWatcher;
3334
import org.springframework.boot.devtools.filewatch.ChangedFiles;
@@ -89,6 +90,13 @@ public void thymeleafCacheIsFalse() throws Exception {
8990
assertThat(resolver.isCacheable(), equalTo(false));
9091
}
9192

93+
@Test
94+
public void resourceCachePeriodIsZero() throws Exception {
95+
this.context = initializeAndRun(WebResourcesConfig.class);
96+
ResourceProperties properties = this.context.getBean(ResourceProperties.class);
97+
assertThat(properties.getCachePeriod(), equalTo(0));
98+
}
99+
92100
@Test
93101
public void liveReloadServer() throws Exception {
94102
this.context = initializeAndRun(Config.class);
@@ -242,4 +250,9 @@ public LiveReloadServer liveReloadServer() {
242250

243251
}
244252

253+
@Configuration
254+
@Import({ LocalDevToolsAutoConfiguration.class, ResourceProperties.class })
255+
public static class WebResourcesConfig {
256+
257+
}
245258
}

0 commit comments

Comments
 (0)