一、图片路径配置
1、第一种方法:在配置文件里配置
#配置访问路径
web-file-path=D://teaPicture/
spring.resources.static-locations=file:${web-file-path}
2、第二种方法:写一个配置类
package com.tea.config;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.context.annotation.Configuration;
import org.springframework.web.servlet.config.annotation.ResourceHandlerRegistry;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;
@Configuration
public class WebConfig implements WebMvcConfigurer {
@Value("${web-file-path}")
private String filePath;
@Override
public void addResourceHandlers(ResourceHandlerRegistry registry) {
//临时文件目录
registry.addResourceHandler("/**").addResourceLocations("classpath:/META-INF/resources/","classpath:/resources/","classpath:/static/","classpath:/public/","classpath:/we