Disable Spring URL resource loading in context file
I need to specify a url in a Spring context file, but don't want Spring to turn it into a resource, that is, I want the url to be passed as a string to a bean that I create in the context file, not convert it to an object Resource.
How can I avoid Spring resource creation?
Thanks,
Andrew
+2
a source to share
2 answers
Spring will coerce the value to the type of the property no matter what happens. If your bean has a property of Resource
that name, then Spring will try to convert the value to Resource
. If you just want the value to be as String, give your bean property a String property and Spring will pass it as-is.
+2
a source to share