Injecting Resources into Spring Beans


(Recovered from my old Blog).

This is mentioned in passing in the Spring documentation – but to highlight:

Spring will automatically convert a String in a bean definition into a Resource if required.

If the target Resource is a specific class (e.g. UrlResource) then the passed in string must match the format, or a runtime error will ensue.

For example:

view source


Leave a Reply

Your email address will not be published. Required fields are marked *

%d bloggers like this: