Merge pull request #3794 from htynkn/set-cache-period-to-zero
* pr/3794: Disable resource cache when DevTools is enabled
This commit is contained in:
commit
79b9bdec62
1
spring-boot-devtools/src/main/java/org/springframework/boot/devtools/env/DevToolsPropertyDefaultsPostProcessor.java
vendored
Normal file → Executable file
1
spring-boot-devtools/src/main/java/org/springframework/boot/devtools/env/DevToolsPropertyDefaultsPostProcessor.java
vendored
Normal file → Executable file
|
|
@ -46,6 +46,7 @@ public class DevToolsPropertyDefaultsPostProcessor implements EnvironmentPostPro
|
||||||
properties.put("spring.mustache.cache", "false");
|
properties.put("spring.mustache.cache", "false");
|
||||||
properties.put("server.session.persistent", "true");
|
properties.put("server.session.persistent", "true");
|
||||||
properties.put("spring.h2.console.enabled", "true");
|
properties.put("spring.h2.console.enabled", "true");
|
||||||
|
properties.put("spring.resources.cache-period", "0");
|
||||||
PROPERTIES = Collections.unmodifiableMap(properties);
|
PROPERTIES = Collections.unmodifiableMap(properties);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
13
spring-boot-devtools/src/test/java/org/springframework/boot/devtools/autoconfigure/LocalDevToolsAutoConfigurationTests.java
Normal file → Executable file
13
spring-boot-devtools/src/test/java/org/springframework/boot/devtools/autoconfigure/LocalDevToolsAutoConfigurationTests.java
Normal file → Executable file
|
|
@ -28,6 +28,7 @@ import org.junit.rules.ExpectedException;
|
||||||
import org.springframework.beans.factory.NoSuchBeanDefinitionException;
|
import org.springframework.beans.factory.NoSuchBeanDefinitionException;
|
||||||
import org.springframework.boot.SpringApplication;
|
import org.springframework.boot.SpringApplication;
|
||||||
import org.springframework.boot.autoconfigure.thymeleaf.ThymeleafAutoConfiguration;
|
import org.springframework.boot.autoconfigure.thymeleaf.ThymeleafAutoConfiguration;
|
||||||
|
import org.springframework.boot.autoconfigure.web.ResourceProperties;
|
||||||
import org.springframework.boot.devtools.classpath.ClassPathChangedEvent;
|
import org.springframework.boot.devtools.classpath.ClassPathChangedEvent;
|
||||||
import org.springframework.boot.devtools.classpath.ClassPathFileSystemWatcher;
|
import org.springframework.boot.devtools.classpath.ClassPathFileSystemWatcher;
|
||||||
import org.springframework.boot.devtools.filewatch.ChangedFiles;
|
import org.springframework.boot.devtools.filewatch.ChangedFiles;
|
||||||
|
|
@ -89,6 +90,13 @@ public class LocalDevToolsAutoConfigurationTests {
|
||||||
assertThat(resolver.isCacheable(), equalTo(false));
|
assertThat(resolver.isCacheable(), equalTo(false));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void resourceCachePeriodIsZero() throws Exception {
|
||||||
|
this.context = initializeAndRun(WebResourcesConfig.class);
|
||||||
|
ResourceProperties properties = this.context.getBean(ResourceProperties.class);
|
||||||
|
assertThat(properties.getCachePeriod(), equalTo(0));
|
||||||
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void liveReloadServer() throws Exception {
|
public void liveReloadServer() throws Exception {
|
||||||
this.context = initializeAndRun(Config.class);
|
this.context = initializeAndRun(Config.class);
|
||||||
|
|
@ -242,4 +250,9 @@ public class LocalDevToolsAutoConfigurationTests {
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Configuration
|
||||||
|
@Import({ LocalDevToolsAutoConfiguration.class, ResourceProperties.class })
|
||||||
|
public static class WebResourcesConfig {
|
||||||
|
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue