0
我已經定義了一個使用ClassPathResource豆像這樣:如何使用Spring 3從classpath加載文件?
<bean id="ivsInputResource" class="org.springframework.core.io.ClassPathResource">
<qualifier value="ivs" />
<constructor-arg index="0"
value="classpath*:IVS90test.csv"/>
</bean>
但是,當資源豆注入,我的應用程序中斷與此異常:
Caused by: java.lang.IllegalStateException: Input resource must exist (reader is in 'strict' mode): class path resource [classpath*:IVS90test.csv]
at org.springframework.batch.item.file.FlatFileItemReader.doOpen(FlatFileItemReader.java:256)
at org.springframework.batch.item.support.AbstractItemCountingItemStreamItemReader.open(AbstractItemCountingItemStreamItemReader.java:134)
顯然,資源不能被發現。當使用FileSystemResource(調整路徑)我的應用程序確實工作。
如何正確加載類路徑中的文件?
我的項目是奠定了如圖所示:
如果使用使用ClassPathResource類,你需要用「類路徑前綴它*:'? – greyfairer
確實,解決了它,如果你把這個評論作爲答案,我可以接受它。 – jorrebor