首先報錯信息
嚴重: Exception sending context initialized event to listener instance of class org.springframework.web.context.ContextLoaderListener
java.lang.NoClassDefFoundError: com/gc/monitor/exception/MonitorException
at java.lang.Class.getDeclaredConstructors0(Native Method)
at java.lang.Class.privateGetDeclaredConstructors(Class.java:2585)
at java.lang.Class.getDeclaredConstructors(Class.java:1906)
at org.springframework.beans.factory.annotation.AutowiredAnnotationBeanPostProcessor.determineCandidateConstructors(AutowiredAnnotationBeanPostProcessor.java:231)
..
Caused by: java.lang.ClassNotFoundException: com.gc.monitor.exception.MonitorException
at org.apache.catalina.loader.WebappClassLoader.loadClass(WebappClassLoader.java:1720)
at org.apache.catalina.loader.WebappClassLoader.loadClass(WebappClassLoader.java:1571)
上面的MonitorException是我自己定義的一個異常,路徑絕對沒有問題
Task類裡面這樣的
public class MonitorScript {
Logger logger = Logger.getLogger(this.getClass());
public void execute(){
System.out.println("----------monitor start----------");
try {
GpsooMonitor gpsooMonitor = GpsooMonitor.getInstance();
gpsooMonitor.run();
} catch (MonitorException e) {
logger.error(e.getMessage());
}
System.out.println("----------monitor end----------");
}
}
後來我改了一下,將MonitorException放到了getInstance裡面catch住了,這時候就麼有問題了。
另外,將application.xml相關信息也貼一下
<!--the object need trigger-->
<bean id="jobBean" class="com.gc.monitor.MonitorScript" />
<bean id="jobDetail" class="org.springframework.scheduling.quartz.MethodInvokingJobDetailFactoryBean">
<property name="targetObject" ref="jobBean" />
<property name="targetMethod" value="execute" />
<!--將並發設置為false-->
<property name="concurrent" value="false" />
</bean>
<bean id="trigger" class="org.springframework.scheduling.quartz.CronTriggerFactoryBean">
<property name="jobDetail" ref="jobDetail" />
<!--表達式,我的是每 30 執行一次-->
<property name="cronExpression" value="0/1 * * * * ?" />
</bean>
<!-- 總管理類如果將lazy-init='false'那麼容器啟動就會執行調度程序 -->
<bean id="startQuertz" class="org.springframework.scheduling.quartz.SchedulerFactoryBean" lazy-init="false" >
<property name="triggers">
<list>
<!--作業調度器,list下可加入其他的調度器-->
<ref bean="trigger" />
</list>
</property>
</bean>
我懷疑是缺什麼包,但是沒有找到缺什麼。網上說xbeans,我也加了
貼下全部maven配置
請問,這是什麼情況啊?
好不可思議啊!!居然是包重名!!