vendredi 20 mars 2015

java spring dependency injection class path

I don't understand why classpath is not working in my code. I'm trying to initialise MatFileReader with the external file resource.



<bean id="contents" class="org.apache.commons.io.IOUtils" factory-method="toString">
<constructor-arg
value="classpath:data/nps/power_spectrum/input.mat"
type="java.io.InputStream" />
</bean>
<bean id="matInput" class="com.jmatio.io.MatFileReader">
<constructor-arg
name="fileName"
value="classpath:data/nps/power_spectrum/input.mat" />
</bean>


classpath is working with the first bean (id=contents). I can read the contents of input.mat file. But, in the second beans (id=matinput). I got FileNotFoundException. It looks like compiler failed to replace the keyword classpath. The constructor of MatFileReader takes String as a parameter. If I use the absolute path instead of classpath, it works. But, I want to use the classpath, how can I fix it?


Aucun commentaire:

Enregistrer un commentaire