[Spring Boot] 정적 리소스 접근 URL 관련 설정

gabrisal·2021년 1월 26일

Spring Boot

목록 보기
1/1

기본적으로 스프링부트에서 정적 리소스를 접근할 때는
src/main/resources/static 이 기본 경로가 된다.

static 폴더 밑에 index.html 이 존재하고, 이 파일에 접근하려고 할 때에는
http://localhost:8080/index.html 로 접근하면 된다.

그런데 만약 기본 경로를 static 폴더 밑이 아닌 다른 곳으로 지정하고 싶다면?

spring.web.resources.static-locations=classpath:/static/vue_example/

src/main/resources 경로 밑의 application.properties 파일을 찾아
위 설정을 해주면 된다.

나는 static 폴더 밑에 vue_example 폴더가 있고 그 안에 모든 정적 리소스가 있었다.
vue_example 경로 안의 리소스를 바로 접근하기 위해 위처럼 설정을 했고
위와 동일하게 http://localhost:8080/index.html 로 접근한다면
src/main/resources/static/vue_example/index.html 파일에 바로 접근이 가능하다.

profile
가브리살

0개의 댓글