SpringBoot配置虚拟路径
对虚拟路径不太了解的可以查看我以前的文章
一文读懂tomcat配置虚拟路径 https://www.haohaowang.top/article/106
这里主要介绍SpringBoot的配置方法。
我这里使用的方法主要是重写addResourceHandlers映射文件路径
废话不多说,还是直接上代码
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.WebMvcConfigurerAdapter;
@Configuration
public class DirConfig extends WebMvcConfigurerAdapter {
@Value("${localUploadAPK}")
private String localUploadAPK;
@Override
public void addResourceHandlers(ResourceHandlerRegistry registry) {
registry.addResourceHandler( "/apk/**").addResourceLocations("file:"+localUploadAPK);
}
}
application.properties
中添加配置
localUploadAPK=/data/apk
完成!
参考文章
https://blog.csdn.net/qq_37859539/article/details/82912851
正文到此结束(点击广告是对作者最大的支持)
- 本文标签: SpringBoot
- 版权声明: 本站原创文章,于2019年09月24日由好好网发布,转载请注明出处