백엔드/Spring(Boot)
spring 외부 경로 매핑
김어찐
2022. 8. 11. 14:35
728x90
Spring boot에서 외부 경로 매핑하기
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 WebMvcConfig implements WebMvcConfigurer {
@Override
public void addResourceHandlers(ResourceHandlerRegistry registry) {
registry.addResourceHandler("/video_view/**")
.addResourceLocations("file:/DATA/video/"); //리눅스 root에서 시작하는 폴더 경로
}
}
//윈도우일 경우 아래처럼 사용하면 된다.
addResourceLocations("file:///D:/DATA/video/");
참고
https://toshi15shkim.github.io/articles/2019-09/spring-resources-location
Spring boot에서 외부 경로 매핑하기 | Toshi의 개발 블로그
프로젝트 외부 폴더 경로 매핑 방법
toshi15shkim.github.io
728x90