• [프로그래밍] Loading xml resource files in spring maven project2011.11.08 PM 04:24

게시물 주소 FONT글자 작게하기 글자 키우기

By default Maven project has resource folder located "src/main/resources"
If your class have to read some resource files try these samples.

assumption you have 1 xml files to read

src/main/resource/yourTest.xml
String RESOURCE_FILE = "yourTest.xml"



URL resourceURL = this.getClass().getClassLoader().getResource(RESOURCE_FILE);

or

org.springframework.core.io.Resource resource = new org.springframework.core.io.ClassPathResource(RESOURCE_FILE);
resource.getURL();


If you don't use maven, don't use spring just create folder in src directory
src/config/yourTest.xml
String RESOURCE_FILE = "/config/yourTest.xml"
URL resourceURL = getClass().getResource(PROFILE_XML);
댓글 : 2 개
  • Jbril
  • 2011/11/08 PM 04:44
요즘엔 태국관광청이 루리웹에서도 홍보를 하네요.
안드로이드 만지시나
친구글 비밀글 댓글 쓰기

user error : Error. B.