springboot配置虚拟路径

springboot 2.x配置

 

1

2

3

4

5

6

@Configuration

public class MyWebAppConfigurer implements WebMvcConfigurer {

    @Override

    public void addResourceHandlers(ResourceHandlerRegistry registry) {

        registry.addResourceHandler("/image/**").addResourceLocations

("file:D:/temp-rainy/");

    }

}

 

//springboot 1.x配置

@Configuration

public class MyWebMvcConfigurerAdapter extends WebMvcConfigurerAdapter {

 

    @Override

    public void addResourceHandlers(ResourceHandlerRegistry registry) {        /**

         * 资源映射路径

         * addResourceHandler:访问映射路径

         * addResourceLocations:资源绝对路径

         */

   registry.addResourceHandler("/image/**").addResourceLocations

("file:D:/temp/image/");

    }

}

 

在application.yml中 写入: imageFilePath: D:/temp/image/

你可能感兴趣的:(springboot配置虚拟路径)