Exception encountered during context initialization - cancelling refresh attempt: org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'quartzScheduler' defined in class path resource [org/springframework/boot/autoconfigure/quartz/QuartzAutoConfiguration.class]: Bean instantiation via factory method failed; nested exception is org.springframework.beans.BeanInstantiationException: Failed to instantiate [org.springframework.scheduling.quartz.SchedulerFactoryBean]: Factory method 'quartzScheduler' threw exception; nested exception is java.lang.NoSuchMethodError: org.springframework.scheduling.quartz.SpringBeanJobFactory.setApplicationContext(Lorg/springframework/context/ApplicationContext;)V
2021-08-12 19:32:26.166 [main] INFO c.a.d.p.DruidDataSource - [close,1928] - {dataSource-1} closed
2021-08-12 19:32:26.189 [main] ERROR o.s.b.d.LoggingFailureAnalysisReporter - [report,40] -
APPLICATION FAILED TO START
Description:
An attempt was made to call a method that does not exist. The attempt was made from the following location:
org.springframework.boot.autoconfigure.quartz.QuartzAutoConfiguration.quartzScheduler(QuartzAutoConfiguration.java:75)
The following method did not exist:
org.springframework.scheduling.quartz.SpringBeanJobFactory.setApplicationContext(Lorg/springframework/context/ApplicationContext;)V
The method's class, org.springframework.scheduling.quartz.SpringBeanJobFactory, is available from the following locations:
jar:file:/C:/Users/uuwatch-yanfa/.m2/repository/org/springframework/spring-context-support/3.2.10.RELEASE/spring-context-support-3.2.10.RELEASE.jar!/org/springframework/scheduling/quartz/SpringBeanJobFactory.class
The class hierarchy was loaded from the following locations:
org.springframework.scheduling.quartz.SpringBeanJobFactory: file:/C:/Users/uuwatch-yanfa/.m2/repository/org/springframework/spring-context-support/3.2.10.RELEASE/spring-context-support-3.2.10.RELEASE.jar
org.springframework.scheduling.quartz.AdaptableJobFactory: file:/C:/Users/uuwatch-yanfa/.m2/repository/org/springframework/spring-context-support/3.2.10.RELEASE/spring-context-support-3.2.10.RELEASE.jar
Action:
Correct the classpath of your application so that it contains a single, compatible version of org.springframework.scheduling.quartz.SpringBeanJobFactory
jar冲突,去删掉任意一个就行了,看看你的pom.xml是不是有相同的依赖如果有就删掉,另外建议你springboot的版本使用2.1以上的,比如
<parent>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-parent</artifactId>
<version>2.5.1</version>
<relativePath/> <!-- lookup parent from repository -->
</parent>
NoSuchMethod,优先考虑是不是依赖冲突了
这是所有导入过的jar包 可以看到是没有红的。
问题找到了 The following method did not exist:
org.springframework.scheduling.quartz.SpringBeanJobFactory.setApplicationContext 调用到了不存在的方法 jar包冲突 冲突包为spring-context-support 3.2.10.RELEASE 移除包版本就有下一个bug了