Spring Boot中设置静态资源不缓存

Spring Boot中设置静态资源不缓存

package com.scfenzhi.configuration;

import org.springframework.http.CacheControl;
import org.springframework.stereotype.Component;
import org.springframework.web.servlet.config.annotation.ResourceHandlerRegistry;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;

/**
 * @Author: DaiYi
 * @CreateTime 2021/8/6 9:19
 * @Email: [email protected]
 * @PhoneNumber: 18380924397
 * @Description:
 */

@Component
public class ResourceHandler implements WebMvcConfigurer {
    
    

    @Override
    public void addResourceHandlers(ResourceHandlerRegistry registry) {
    
    
        registry.addResourceHandler("/**").addResourceLocations("classpath:/static/").setCacheControl(CacheControl.noStore());
    }

}

猜你喜欢

转载自blog.csdn.net/daiyi666/article/details/119514124