Is there an equivalent of the p namespace for constructor args in Spring? I would love to shorten that XML 🙂
Share
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
No, there is no equivalent for constructor injection prior to 3.1, but you may consider autowiring the constructor in your XML like this:
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.