2017-10-10 49 views
0

我想用null參數調用一個自定義方法。我正在嘗試使用元素的參數屬性。但是我得到了錯誤。有沒有辦法做到這一點?如何將null作爲方法參數與Spring進行通信?

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

我的CustomExecutor類方法;

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

回答

2

嘗試下面的代碼:

<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> 
相關問題