在spring xml中使用quartz static field

时间:2013-10-10 07:37:18

标签: spring quartz-scheduler

<beans xmlns:util="http://www.springframework.org/schema/util">

 <bean id="cronTrigger" class="org.springframework.scheduling.quartz.CronTriggerFactoryBean">
  <property name="misfireInstruction">
    <util:constant static-field="org.quartz.CronTrigger.MISFIRE_INSTRUCTION_FIRE_ONCE_NOW"/>
  </property>
 </bean>

</beans>

我收到的是org.xml.sax.SAXParseException:cvc-complex-type.2.4.c:匹配的通配符是strict,但是找不到元素'util:constant'的声明。

2 个答案:

答案 0 :(得分:0)

您已定义xml命名空间,但未定义架构位置。你应该添加:

<beans xmlns="http://www.springframework.org/schema/beans"       
  xmlns:util="http://www.springframework.org/schema/util"
  xsi:schemaLocation="http://www.springframework.org/schema/beans
    http://www.springframework.org/schema/beans/spring-beans.xsd
    http://www.springframework.org/schema/util 
    http://www.springframework.org/schema/util/spring-util-3.0.xsd">

(对于Sprint 3,对于Spring 2.5,它将是spring-util-2.5.xsd等。)

答案 1 :(得分:0)

使用

解决它
<bean id="myField"
class="org.springframework.beans.factory.config.FieldRetrievingFactoryBean">
<property name="staticField" value="java.sql.Connection.TRANSACTION_SERIALIZABLE"/>
</bean>