Spring p namespace for args constructors?

Is there an p namespace equivalent for args constructors in Spring? I would like to shorten this XML :)

+6
source share
1 answer

No, there is no equivalent for a constructor injection prior to 3.1, but you can consider constructor auto-negotiation in your XML as follows:

<bean id="beanId" class="..." autowire="constructor"/> 

You do not need to specify separate arg constructors here by auto-suppression, since spring will work with them, just make sure that you have only one bean of each type or that spring will not be able to auto-increase them.

EDIT:

as pointed out by @gkamal starting in spring 3.1, you can use the c namespace to embed the constructor .

+5
source

Source: https://habr.com/ru/post/898816/


All Articles