spring.resources.cache-period 错误

在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

  • 4
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 2
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论 2
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值