一、配置application.yml:

spring:
  mvc:
    static-path-pattern: /static/**

二、主启动类springbootApplication实现WebMvcConfigurer

public class JavablogApplication implements WebMvcConfigurer {

    public static void main(String[] args) {
        SpringApplication.run(JavablogApplication.class, args);
    }
    @Override
    public void addResourceHandlers(ResourceHandlerRegistry registry) {
        registry.addResourceHandler("/static/**").addResourceLocations("classpath:/static/");
        WebMvcConfigurer.super.addResourceHandlers(registry);
    }
}