Spring XML Bean Configuration - Specify nullable constructor arguments

31 views Asked by At

I am trying to configure a nullable parameter for constructor based dependency injection. I am using XML Bean Configuration.

The question is - is there a way to achieve the same as @Autowired(required = false) or @Nullable from Spring XML Bean configuration?

I am aware that for annotation based config, we have the possibility to use something like:

public MyConfiguration(MyServiceA myServiceA, **@Autowired(required = false)** MyServiceB myServiceB){
  this.myServiceA = myServiceA;
  this.myServiceB = myServiceB;   
}

I would expect that exists something like:

<bean id="recreatePreviewService" class="com.celum.internal.web.preview.RecreatePreviewService">
    <constructor-arg index="0" **required="false"** ref="recreateTicketProcessor">
</bean>

Is that even possible? My Spring version is 5.3.29.

0

There are 0 answers