Home > Software design >  How to do configuration for spring bean for constructor injection where bin contain variable argumen
How to do configuration for spring bean for constructor injection where bin contain variable argumen

Time:04-14

Can we write Spring bean in XML and configure it? so that it uses constructor injection when that constructor has a variable argument parameter type?

For example

class DemoClass{
    MyClass(String... args) {
    }
}

CodePudding user response:

<bean name="demoBean" >
    <constructor-arg>
        <list>
            <value>101</value>
            <value>102</value>
            <value>103</value>
            <value>104</value>
        </list>
    </constructor-arg>
</bean>
  • Related