ArchTiger MYPI

ArchTiger
접속 : 3075   Lv. 51

Category

Profile

Counter

  • 오늘 : 15 명
  • 전체 : 10881 명
  • Mypi Ver. 0.3.1 β
[프로그래밍] Loading xml resource files in spring maven project (2) 2011/11/08 PM 04:24
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);

신고

 

Jbril    친구신청

요즘엔 태국관광청이 루리웹에서도 홍보를 하네요.

자허토르테    친구신청

안드로이드 만지시나
X