重写了静态资源的资源路径
public class ResourcesConfig extends WebMvcConfigurerAdapter {
@Override
public void addResourceHandlers(ResourceHandlerRegistry registry) {
registry.addResourceHandler("/static/**").addResourceLocations("classpath:/static/");
//registry.addResourceHandler("*.css").addResourceLocations("classpath:/static/css/");
}
}
并且配置了:
spring.resources.chain.strategy.content.enabled=true
spring.resources.chain.strategy.content.paths=/**
spring.resources.static-locations=classpath:/static/css/,classpath:/static/images/,classpath:/static/js/
结构如下:
src/main/java
src/main/resources/
src/main/resources/static/css/*.css
src/main/resources/static/images/*.png
src/main/resources/static/js/*.js
这个是我的jar包解压的情况,跟你的不一样啊。。。
There is no need to configure static, springboot will load static into the classpath by default
Source code directory
Unzip the directory into a jar package
Try adding a template engine, such as thymeleaf, and the default configuration of springboot is like yours
No configuration, just use static or other folders