Notice
Recent Posts
Recent Comments
Link
일 | 월 | 화 | 수 | 목 | 금 | 토 |
---|---|---|---|---|---|---|
1 | 2 | 3 | 4 | 5 | ||
6 | 7 | 8 | 9 | 10 | 11 | 12 |
13 | 14 | 15 | 16 | 17 | 18 | 19 |
20 | 21 | 22 | 23 | 24 | 25 | 26 |
27 | 28 | 29 | 30 | 31 |
Tags
- MSSQL
- mybatis
- window
- Java
- tomcat
- vaadin
- Spring
- mapreduce
- es6
- GIT
- plugin
- R
- xPlatform
- Express
- NPM
- Eclipse
- table
- SSL
- SQL
- 공정능력
- react
- 보조정렬
- SPC
- hadoop
- JavaScript
- Sqoop
- IntelliJ
- Python
- Kotlin
- Android
Archives
- Today
- Total
DBILITY
spring boot embedded tomcat docroot change 본문
728x90
반응형
파일업로드 테스트를 위해 경로 설정이 필요했는데, docroot관련은 application.properties에 존재하지 않았다.
아래와 같이 하면 classpath아래 위치를 찾을 수 있기는 하다.
Resource resource = new ClassPathResource("upload"+ File.separator);
String uploadDir = resource.getFile().getAbsolutePath();
server.tomcat.basedir만 존재한다. 존재하지 않는 경우엔 WebServerFactoryCustomizer를 구현해야 한다고 한다.
구글검색을 통해 알게 된 것은 Component로 등록하는 것이었다.
다음과 같다.
package com.dbility.apps.dev.test;
import org.springframework.boot.web.embedded.tomcat.TomcatServletWebServerFactory;
import org.springframework.boot.web.server.WebServerFactoryCustomizer;
import org.springframework.stereotype.Component;
import java.io.File;
@Component
public class EmbeddeTomcatConfig implements WebServerFactoryCustomizer<TomcatServletWebServerFactory> {
@Override
public void customize(TomcatServletWebServerFactory factory) {
factory.setDocumentRoot(new File("C:\\Dev64\\embedded_tomcat"));
}
}
업로드를 실행하고 보니 잘 들어가 있다. 경로설정은 다음과 같이 했다.
String uploadDir = request.getSession().getServletContext().getRealPath("/") +"resources"+File.separator+"images";
728x90
'java > spring boot' 카테고리의 다른 글
maven Blocked mirror for repositories~ (0) | 2022.02.19 |
---|---|
spring data jpa study code (0) | 2022.02.18 |
spring boot rest api cors (0) | 2022.02.17 |
Comments