当前位置: 代码迷 >> J2EE >> Cannot find class [org.springframework.scheduling.timer.ScheduledTimerTask] for解决方法
  详细解决方案

Cannot find class [org.springframework.scheduling.timer.ScheduledTimerTask] for解决方法

热度:737   发布时间:2016-04-19 22:05:18.0
Cannot find class [org.springframework.scheduling.timer.ScheduledTimerTask] for
2014-5-13 12:06:38 org.springframework.context.support.AbstractApplicationContext prepareRefresh
信息: Refreshing org.springframework.context.support.ClassPathXmlApplicationContext@5ffb18: startup date [Tue May 13 12:06:38 CST 2014]; root of context hierarchy
2014-5-13 12:06:38 org.springframework.beans.factory.xml.XmlBeanDefinitionReader loadBeanDefinitions
信息: Loading XML bean definitions from class path resource [beans.xml]
Exception in thread "main" org.springframework.beans.factory.CannotLoadBeanClassException: Cannot find class [org.springframework.scheduling.timer.ScheduledTimerTask] for bean with name 'scheduledTimerTask' defined in class path resource [beans.xml]; nested exception is java.lang.ClassNotFoundException: org.springframework.scheduling.timer.ScheduledTimerTask
at org.springframework.beans.factory.support.AbstractBeanFactory.resolveBeanClass(AbstractBeanFactory.java:1327)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.predictBeanType(AbstractAutowireCapableBeanFactory.java:594)
at org.springframework.beans.factory.support.AbstractBeanFactory.isFactoryBean(AbstractBeanFactory.java:1396)
at org.springframework.beans.factory.support.AbstractBeanFactory.isFactoryBean(AbstractBeanFactory.java:959)
at org.springframework.beans.factory.support.DefaultListableBeanFactory.preInstantiateSingletons(DefaultListableBeanFactory.java:683)
at org.springframework.context.support.AbstractApplicationContext.finishBeanFactoryInitialization(AbstractApplicationContext.java:760)
at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:482)
at org.springframework.context.support.ClassPathXmlApplicationContext.<init>(ClassPathXmlApplicationContext.java:139)
at org.springframework.context.support.ClassPathXmlApplicationContext.<init>(ClassPathXmlApplicationContext.java:83)
at com.lyy.test.mask1.main(mask1.java:15)
Caused by: java.lang.ClassNotFoundException: org.springframework.scheduling.timer.ScheduledTimerTask
at java.net.URLClassLoader$1.run(URLClassLoader.java:200)
at java.security.AccessController.doPrivileged(Native Method)
at java.net.URLClassLoader.findClass(URLClassLoader.java:188)
at java.lang.ClassLoader.loadClass(ClassLoader.java:306)
at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:276)
at java.lang.ClassLoader.loadClass(ClassLoader.java:251)
at org.springframework.util.ClassUtils.forName(ClassUtils.java:236)
at org.springframework.beans.factory.support.AbstractBeanDefinition.resolveBeanClass(AbstractBeanDefinition.java:392)
at org.springframework.beans.factory.support.AbstractBeanFactory.doResolveBeanClass(AbstractBeanFactory.java:1348)
at org.springframework.beans.factory.support.AbstractBeanFactory.resolveBeanClass(AbstractBeanFactory.java:1319)
... 9 more



<?xml version="1.0" encoding="UTF-8"?>
<beans
xmlns="http://www.springframework.org/schema/beans"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:context="http://www.springframework.org/schema/context"
xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-2.5.xsd
http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context-2.5.xsd">
   <!-- <bean id="personDao" class="com.lyy.dao.impl.PersonDaoBean"></bean>
   <bean id="personServiceBean" class="com.lyy.services.impl.PersonServiceBean" autowire="byName">   
      <constructor-arg  index="0" type="com.lyy.dao.PersonDao" ref="personDaoBean"> </constructor-arg>
      <constructor-arg  index="1" value="张三"> </constructor-arg>
   </bean>
     <context:annotation-config/> --><!--
      <context:annotation-config/>
      <context:component-scan base-package="com.lyy"/>    
-->
<bean id="myTask" class="com.lyy.task1.MyTask"> </bean>
<!-- 配置任务计划 --> 
<bean id="scheduledTimerTask" class="org.springframework.scheduling.timer.ScheduledTimerTask">
   <!-- 指定要执行的任务 --> 
   <property name="timerTask" ref="myTask"></property>
   <!-- 设置运行间隔 --> 
   <property name="period" value="5000"></property>
   <!-- 设置启动延迟 -->  
    <property name="delay" value="3000"></property>   
</bean>
<!-- 配置执行任务计划安排 --> 
<bean id="timerFactoryBean" class="org.springframework.scheduling.timer.TimerFactoryBean" >
   <property name="scheduledTimerTasks">
      <list>
        <ref bean="scheduledTimerTask"/>
  相关解决方案