Spring Boot 외부 경로 설정

kys·2022년 12월 8일
0

SpringBoot

목록 보기
5/5

스프링부트에서 드라이브에 있는 이미지를 사용하려면
외부 경로 설정을 해줘야한다.

@Override
    public void addResourceHandlers(ResourceHandlerRegistry registry) {

        registry.addResourceHandler("/uploadimage/**")
                .addResourceLocations("file:/Users/xyzcs/Desktop/Springboot/hahahoho/uploadItem/");


    }
    

addResourceHandler : Url path 지정
위처럼 설정하면 /uploadimage/abc.jpg 로 이미지를 가져올 수 있다.

addResourceLocations : 컴퓨터에 저장된 파일을 가져올 경로 설정

profile
:)

0개의 댓글