如何使用 Spring 将 null 连接为方法参数



我正在尝试使用 null 参数调用自定义方法。我正在尝试将参数属性与元素一起使用。但是我得到了以下错误。有什么办法可以做到这一点吗?

<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>

我得到以下错误;

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

我的自定义执行器类方法;

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

尝试以下代码:

<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>

最新更新