1. 程式人生 > >spring boot 中配置靜態資源使用

spring boot 中配置靜態資源使用

程式碼如下:

package com.bobo.shopping.manage.config;

import org.springframework.context.annotation.Configuration;
import org.springframework.web.servlet.config.annotation.ResourceHandlerRegistry;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurationSupport;

/**
 * 靜態資源配置
 *
 * @author 
[email protected]
* @create 2018-09-24 19:27 **/ @Configuration public class StaticResourceConfig extends WebMvcConfigurationSupport { @Override protected void addResourceHandlers(ResourceHandlerRegistry registry) { registry.addResourceHandler("/**") .addResourceLocations("classpath:/META-INF/resources/") .addResourceLocations("classpath:/resources/") .addResourceLocations("classpath:/static/") .addResourceLocations("classpath:/public/"); super.addResourceHandlers(registry); } }