Is it possible to instantiate a property of type java.io.File directly in the config?
Something like:
<property><file path="..." /></property>
A possible workaround may be to use a String property and while setting it, create the File instance. Is there a more direct way of achieving this?
Thanks!
Yes, you can do this. Simply pass the name of the file as the value of the property:
<bean>
<property name="myFile" value="path-to-file"/>
</bean>
Spring will automatically create an instance of java.io.File for you and inject it into your bean.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With