spring boot 配置本地资源虚拟映射路径

spring boot 配置本地资源映射路径

/**

  • 配置本地资源映射路径
    */
    @Component
    public class WebConfigurer extends WebMvcConfigurerAdapter {

    @Value("${ah.voicePath}")
    String voicePath;

    @Override
    public void addResourceHandlers(ResourceHandlerRegistry registry) {
    //配置server虚拟路径,handler为访问的映射目录,locations为files相对应的本地路径
    registry.addResourceHandler("/voices/**").addResourceLocations(“file:”+voicePath);
    }

}

猜你喜欢

转载自blog.csdn.net/JT1992413/article/details/82965859