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
'백엔드 > Spring(Boot)' 카테고리의 다른 글
springboot 멀티 모듈 프로젝트에서 다른 모듈의 빈을 찾지 못할 때 (0) | 2023.01.09 |
---|---|
springboot multimodule (0) | 2023.01.01 |
spring static 경로 404 (0) | 2022.08.10 |
spring responsebody json 필드명 변경하기 (0) | 2022.08.02 |
springboot 파일업로드 (0) | 2022.07.01 |