来源:https://*.com/questions/60658247/no-mapping-for-get-bootstrap-js-bootstrap-min-js
springboot 由于添加了添加了WebMvcConfigurer的实现类后,会出现No mapping for GET /bootstrap/js/bootstrap.min.js 的错误。找不到/static/下的静态资源,解决方法为:
@Configuration
public class WebConfig implements WebMvcConfigurer {
private static final String[] CLASSPATH_RESOURCE_LOCATIONS = {
"classpath:/META-INF/resources/", "classpath:/resources/",
"classpath:/static/", "classpath:/public/" };
@Override
public void addResourceHandlers(ResourceHandlerRegistry registry) {
registry.addResourceHandler("/**")
.addResourceLocations(CLASSPATH_RESOURCE_LOCATIONS);
}
}