在springboot 中配置资源缓存过期时间,出错
spring.resources.cache-period 改为 spring.resources.cache.period
Description:
Binding to target [
Bindable@70a3d3b5 type =
org.springframework.boot.autoconfigure.web.ResourceProperties,
value = ‘provided’,
annotations = array[@org.springframework.boot.context.properties.ConfigurationProperties(
prefix=spring.resources,
value=spring.resources,
ignoreUnknownFields=false,
ignoreInvalidFields=false)]
] failed:
Property: spring.resources.cache-period
Value: 3600
Origin: class path resource [application.properties]:48:32
Reason: The elements [spring.resources.cache-period] were left unbound.
Action:
Update your application’s configuration
看描述属性未绑定上。
查看springboot文档
https://docs.spring.io/spring-boot/docs/2.0.4.RELEASE/reference/htmlsingle/
> spring.resources.cache.period= # Cache period for the resources served by the resource handler. If a duration suffix is not specified, seconds will be used.
在最新的2.0.4 改为 spring.resources.cache.period
spring.resources.cache-period= # Cache period for the resources served by the resource handler, in seconds.
spring.resources.cache-period 已弃用,大概是命名奇怪吧
查看源码
https://github.com/spring-projects/spring-boot/blob/v1.5.4.RELEASE/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/web/ResourceProperties.java
public Integer getCachePeriod() {
return this.cachePeriod;
}
public void setCachePeriod(Integer cachePeriod) {
this.cachePeriod = cachePeriod;
}
注意有些配置是下划线,有些是 .
spring.resources.add-mappings=true
spring.resources.static-locations