Is there an equivalent of the p namespace for constructor args in Spring? I would love to shorten that XML :)
No, there is no equivalent for constructor injection prior to 3.1, but you may consider autowiring the constructor in your XML like this:
<bean id="beanId" class="..." autowire="constructor"/>
By autowiring, you do not have to specify the individual constructor args here as spring will work them out, just make sure you only have one bean of each type or spring will not be able to autowire them.
EDIT:
as @gkamal stated, from spring 3.1 onwards you can use the c namespace for constructor injection.
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