hellzone
hellzone

Reputation: 5236

How to wire null as method parameter with Spring?

I am trying to call a custom method with null parameter. I am trying to use arguments property with element. But I am getting below error. Is there any way to do this?

<bean id="customJob" class="org.springframework.scheduling.quartz.MethodInvokingJobDetailFactoryBean">
    <property name="targetObject" ref="customExecutor" />
    <property name="targetMethod" value="run" />
    <property name="arguments">
        <null/>
    </property>
</bean>

I am getting below error;

Error creating bean with name 'customJob'
java.lang.NoSuchMethodException: total.scheduler.CustomExecutor.run()

My CustomExecutor class method;

public void run(Object object){
....
}

Upvotes: 0

Views: 178

Answers (1)

Mykola Yashchenko
Mykola Yashchenko

Reputation: 5361

Try following code:

<bean id="customJob" class="org.springframework.scheduling.quartz.MethodInvokingJobDetailFactoryBean">
    <property name="targetObject" ref="customExecutor" />
    <property name="targetMethod" value="run" />
    <property name="arguments">

    <property name="arguments">
        <list>
            <null/>
        </list>
    </property>
</bean>

Upvotes: 2

Related Questions