Spring project에서 Resource 하위의 파일 경로 정보
public class MainTest {
public static void main(String[] args) throws IOException, ParseException {
JSONParser parser = new JSONParser();
URL in = MainTest.class.getClassLoader().getResource("test.json");
String path = in.getPath();
}
}
/Users/.../Project/test/XXX_test/target/classes/test.json
프로젝트의 target 폴더 path 정보를 얻을 수 있다.
컴파일 시 /src하위의 모든 파일들이 /target 폴터 하위에 생성이 되고 프로그램 실 시 /target 하위의 클래스 파일(*.class)과 resource 파일들을(*.xml , *. properties etc) 가지고 구동이 된다.
评论
发表评论