次のように ClassPathResource Bean を定義しました。
<bean id="ivsInputResource" class="org.springframework.core.io.ClassPathResource">
<qualifier value="ivs" />
<constructor-arg index="0"
value="classpath*:IVS90test.csv"/>
</bean>
しかし、リソース 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 (調整されたパス) を使用すると、アプリは機能します。
クラスパスからファイルを正しくロードする方法は?
私のプロジェクトは次のようにレイアウトされています。