spring quartz:Instantiation of bean failed; nested exception is java.lang.IncompatibleClassChangeErr

2 篇文章 0 订阅

spring 调度类初始化失败,分析是jar包冲突,日志如下:

org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'scheduler' defined in file [D:\InstallApplication\apache-tomcat-7.0.23\wtpwebapps\campaign\WEB-INF\classes\spring\applicationContext-single-quartz.xml]: Cannot create inner bean 'org.springframework.scheduling.quartz.CronTriggerBean#3dc572d0' of type [org.springframework.scheduling.quartz.CronTriggerBean] while setting bean property 'triggers' with key [0]; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'org.springframework.scheduling.quartz.CronTriggerBean#3dc572d0' defined in file [D:\InstallApplication\apache-tomcat-7.0.23\wtpwebapps\campaign\WEB-INF\classes\spring\applicationContext-single-quartz.xml]: Cannot create inner bean 'org.springframework.scheduling.quartz.MethodInvokingJobDetailFactoryBean#7ed6a46e' of type [org.springframework.scheduling.quartz.MethodInvokingJobDetailFactoryBean] while setting bean property 'jobDetail'; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'org.springframework.scheduling.quartz.MethodInvokingJobDetailFactoryBean#7ed6a46e' defined in file [D:\InstallApplication\apache-tomcat-7.0.23\wtpwebapps\campaign\WEB-INF\classes\spring\applicationContext-single-quartz.xml]: Instantiation of bean failed; nested exception is java.lang.IncompatibleClassChangeError: Implementing class
	at org.springframework.beans.factory.support.BeanDefinitionValueResolver.resolveInnerBean(BeanDefinitionValueResolver.java:282)
	at org.springframework.beans.factory.support.BeanDefinitionValueResolver.resolveValueIfNecessary(BeanDefinitionValueResolver.java:121)
	at org.springframework.beans.factory.support.BeanDefinitionValueResolver.resolveManagedList(BeanDefinitionValueResolver.java:353)
	at org.springframework.beans.factory.support.BeanDefinitionValueResolver.resolveValueIfNecessary(BeanDefinitionValueResolver.java:154)
	at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.applyPropertyValues(AbstractAutowireCapableBeanFactory.java:1387)
	at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.populateBean(AbstractAutowireCapableBeanFactory.java:1128)
	at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:519)
	at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:458)
	at org.springframework.beans.factory.support.AbstractBeanFactory$1.getObject(AbstractBeanFactory.java:295)
	at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:223)
	at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:292)
	at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:194)
	at org.springframework.beans.factory.support.DefaultListableBeanFactory.preInstantiateSingletons(DefaultListableBeanFactory.java:610)
	at org.springframework.context.support.AbstractApplicationContext.finishBeanFactoryInitialization(AbstractApplicationContext.java:932)
	at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:479)
	at org.springframework.web.context.ContextLoader.configureAndRefreshWebApplicationContext(ContextLoader.java:389)
	at org.springframework.web.context.ContextLoader.initWebApplicationContext(ContextLoader.java:294)
	at org.springframework.web.context.ContextLoaderListener.contextInitialized(ContextLoaderListener.java:112)
	at org.apache.catalina.core.StandardContext.listenerStart(StandardContext.java:4765)
	at org.apache.catalina.core.StandardContext.startInternal(StandardContext.java:5260)
	at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:150)
	at org.apache.catalina.core.ContainerBase$StartChild.call(ContainerBase.java:1525)
	at org.apache.catalina.core.ContainerBase$StartChild.call(ContainerBase.java:1515)
	at java.util.concurrent.FutureTask$Sync.innerRun(FutureTask.java:334)
	at java.util.concurrent.FutureTask.run(FutureTask.java:166)
	at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1145)
	at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:615)
	at java.lang.Thread.run(Thread.java:724)
Caused by: org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'org.springframework.scheduling.quartz.CronTriggerBean#3dc572d0' defined in file [D:\InstallApplication\apache-tomcat-7.0.23\wtpwebapps\campaign\WEB-INF\classes\spring\applicationContext-single-quartz.xml]: Cannot create inner bean 'org.springframework.scheduling.quartz.MethodInvokingJobDetailFactoryBean#7ed6a46e' of type [org.springframework.scheduling.quartz.MethodInvokingJobDetailFactoryBean] while setting bean property 'jobDetail'; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'org.springframework.scheduling.quartz.MethodInvokingJobDetailFactoryBean#7ed6a46e' defined in file [D:\InstallApplication\apache-tomcat-7.0.23\wtpwebapps\campaign\WEB-INF\classes\spring\applicationContext-single-quartz.xml]: Instantiation of bean failed; nested exception is java.lang.IncompatibleClassChangeError: Implementing class
	at org.springframework.beans.factory.support.BeanDefinitionValueResolver.resolveInnerBean(BeanDefinitionValueResolver.java:282)
	at org.springframework.beans.factory.support.BeanDefinitionValueResolver.resolveValueIfNecessary(BeanDefinitionValueResolver.java:121)
	at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.applyPropertyValues(AbstractAutowireCapableBeanFactory.java:1387)
	at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.populateBean(AbstractAutowireCapableBeanFactory.java:1128)
	at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:519)
	at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:458)
	at org.springframework.beans.factory.support.BeanDefinitionValueResolver.resolveInnerBean(BeanDefinitionValueResolver.java:271)
	... 27 more
Caused by: org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'org.springframework.scheduling.quartz.MethodInvokingJobDetailFactoryBean#7ed6a46e' defined in file [D:\InstallApplication\apache-tomcat-7.0.23\wtpwebapps\campaign\WEB-INF\classes\spring\applicationContext-single-quartz.xml]: Instantiation of bean failed; nested exception is java.lang.IncompatibleClassChangeError: Implementing class
	at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.instantiateBean(AbstractAutowireCapableBeanFactory.java:1007)
	at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBeanInstance(AbstractAutowireCapableBeanFactory.java:953)
	at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:487)
	at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:458)
	at org.springframework.beans.factory.support.BeanDefinitionValueResolver.resolveInnerBean(BeanDefinitionValueResolver.java:271)
	... 33 more
Caused by: java.lang.IncompatibleClassChangeError: Implementing class
	at java.lang.ClassLoader.defineClass1(Native Method)
	at java.lang.ClassLoader.defineClass(ClassLoader.java:792)
	at java.security.SecureClassLoader.defineClass(SecureClassLoader.java:142)
	at org.apache.catalina.loader.WebappClassLoader.findClassInternal(WebappClassLoader.java:2823)
	at org.apache.catalina.loader.WebappClassLoader.findClass(WebappClassLoader.java:1160)
	at org.apache.catalina.loader.WebappClassLoader.loadClass(WebappClassLoader.java:1655)
	at org.apache.catalina.loader.WebappClassLoader.loadClass(WebappClassLoader.java:1533)
	at java.lang.Class.forName0(Native Method)
	at java.lang.Class.forName(Class.java:190)
	at org.springframework.scheduling.quartz.MethodInvokingJobDetailFactoryBean.<clinit>(MethodInvokingJobDetailFactoryBean.java:89)
	at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
	at sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:57)
	at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:45)
	at java.lang.reflect.Constructor.newInstance(Constructor.java:526)
	at org.springframework.beans.BeanUtils.instantiateClass(BeanUtils.java:148)
	at org.springframework.beans.factory.support.SimpleInstantiationStrategy.instantiate(SimpleInstantiationStrategy.java:87)
	at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.instantiateBean(AbstractAutowireCapableBeanFactory.java:1000)
	... 37 more

一月 07, 2015 6:58:18 下午 org.apache.catalina.core.StandardContext startInternal
SEVERE: Error listenerStart
一月 07, 2015 6:58:18 下午 org.apache.catalina.core.StandardContext startInternal
SEVERE: Context [/campaign] startup failed due to previous errors
一月 07, 2015 6:58:18 下午 org.apache.catalina.core.ApplicationContext log
INFO: Closing Spring root WebApplicationContext
2015-01-07 18:58:18,263 [// -  - ] ERROR org.springframework.web.context.ContextLoader - Context initialization failed
org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'scheduler' defined in file [D:\InstallApplication\apache-tomcat-7.0.23\wtpwebapps\campaign\WEB-INF\classes\spring\applicationContext-single-quartz.xml]: Cannot create inner bean 'org.springframework.scheduling.quartz.CronTriggerBean#3dc572d0' of type [org.springframework.scheduling.quartz.CronTriggerBean] while setting bean property 'triggers' with key [0]; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'org.springframework.scheduling.quartz.CronTriggerBean#3dc572d0' defined in file [D:\InstallApplication\apache-tomcat-7.0.23\wtpwebapps\campaign\WEB-INF\classes\spring\applicationContext-single-quartz.xml]: Cannot create inner bean 'org.springframework.scheduling.quartz.MethodInvokingJobDetailFactoryBean#7ed6a46e' of type [org.springframework.scheduling.quartz.MethodInvokingJobDetailFactoryBean] while setting bean property 'jobDetail'; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'org.springframework.scheduling.quartz.MethodInvokingJobDetailFactoryBean#7ed6a46e' defined in file [D:\InstallApplication\apache-tomcat-7.0.23\wtpwebapps\campaign\WEB-INF\classes\spring\applicationContext-single-quartz.xml]: Instantiation of bean failed; nested exception is java.lang.IncompatibleClassChangeError: Implementing class
	at org.springframework.beans.factory.support.BeanDefinitionValueResolver.resolveInnerBean(BeanDefinitionValueResolver.java:282)
	at org.springframework.beans.factory.support.BeanDefinitionValueResolver.resolveValueIfNecessary(BeanDefinitionValueResolver.java:121)
	at org.springframework.beans.factory.support.BeanDefinitionValueResolver.resolveManagedList(BeanDefinitionValueResolver.java:353)
	at org.springframework.beans.factory.support.BeanDefinitionValueResolver.resolveValueIfNecessary(BeanDefinitionValueResolver.java:154)
	at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.applyPropertyValues(AbstractAutowireCapableBeanFactory.java:1387)
	at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.populateBean(AbstractAutowireCapableBeanFactory.java:1128)
	at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:519)
	at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:458)
	at org.springframework.beans.factory.support.AbstractBeanFactory$1.getObject(AbstractBeanFactory.java:295)
	at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:223)
	at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:292)
	at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:194)
	at org.springframework.beans.factory.support.DefaultListableBeanFactory.preInstantiateSingletons(DefaultListableBeanFactory.java:610)
	at org.springframework.context.support.AbstractApplicationContext.finishBeanFactoryInitialization(AbstractApplicationContext.java:932)
	at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:479)
	at org.springframework.web.context.ContextLoader.configureAndRefreshWebApplicationContext(ContextLoader.java:389)
	at org.springframework.web.context.ContextLoader.initWebApplicationContext(ContextLoader.java:294)
	at org.springframework.web.context.ContextLoaderListener.contextInitialized(ContextLoaderListener.java:112)
	at org.apache.catalina.core.StandardContext.listenerStart(StandardContext.java:4765)
	at org.apache.catalina.core.StandardContext.startInternal(StandardContext.java:5260)
	at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:150)
	at org.apache.catalina.core.ContainerBase$StartChild.call(ContainerBase.java:1525)
	at org.apache.catalina.core.ContainerBase$StartChild.call(ContainerBase.java:1515)
	at java.util.concurrent.FutureTask$Sync.innerRun(FutureTask.java:334)
	at java.util.concurrent.FutureTask.run(FutureTask.java:166)
	at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1145)
	at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:615)
	at java.lang.Thread.run(Thread.java:724)
Caused by: org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'org.springframework.scheduling.quartz.CronTriggerBean#3dc572d0' defined in file [D:\InstallApplication\apache-tomcat-7.0.23\wtpwebapps\campaign\WEB-INF\classes\spring\applicationContext-single-quartz.xml]: Cannot create inner bean 'org.springframework.scheduling.quartz.MethodInvokingJobDetailFactoryBean#7ed6a46e' of type [org.springframework.scheduling.quartz.MethodInvokingJobDetailFactoryBean] while setting bean property 'jobDetail'; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'org.springframework.scheduling.quartz.MethodInvokingJobDetailFactoryBean#7ed6a46e' defined in file [D:\InstallApplication\apache-tomcat-7.0.23\wtpwebapps\campaign\WEB-INF\classes\spring\applicationContext-single-quartz.xml]: Instantiation of bean failed; nested exception is java.lang.IncompatibleClassChangeError: Implementing class
	at org.springframework.beans.factory.support.BeanDefinitionValueResolver.resolveInnerBean(BeanDefinitionValueResolver.java:282)
	at org.springframework.beans.factory.support.BeanDefinitionValueResolver.resolveValueIfNecessary(BeanDefinitionValueResolver.java:121)
	at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.applyPropertyValues(AbstractAutowireCapableBeanFactory.java:1387)
	at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.populateBean(AbstractAutowireCapableBeanFactory.java:1128)
	at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:519)
	at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:458)
	at org.springframework.beans.factory.support.BeanDefinitionValueResolver.resolveInnerBean(BeanDefinitionValueResolver.java:271)
	... 27 more
Caused by: org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'org.springframework.scheduling.quartz.MethodInvokingJobDetailFactoryBean#7ed6a46e' defined in file [D:\InstallApplication\apache-tomcat-7.0.23\wtpwebapps\campaign\WEB-INF\classes\spring\applicationContext-single-quartz.xml]: Instantiation of bean failed; nested exception is java.lang.IncompatibleClassChangeError: Implementing class
	at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.instantiateBean(AbstractAutowireCapableBeanFactory.java:1007)
	at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBeanInstance(AbstractAutowireCapableBeanFactory.java:953)
	at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:487)
	at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:458)
	at org.springframework.beans.factory.support.BeanDefinitionValueResolver.resolveInnerBean(BeanDefinitionValueResolver.java:271)
	... 33 more
Caused by: java.lang.IncompatibleClassChangeError: Implementing class
	at java.lang.ClassLoader.defineClass1(Native Method)
	at java.lang.ClassLoader.defineClass(ClassLoader.java:792)
	at java.security.SecureClassLoader.defineClass(SecureClassLoader.java:142)
	at org.apache.catalina.loader.WebappClassLoader.findClassInternal(WebappClassLoader.java:2823)
	at org.apache.catalina.loader.WebappClassLoader.findClass(WebappClassLoader.java:1160)
	at org.apache.catalina.loader.WebappClassLoader.loadClass(WebappClassLoader.java:1655)
	at org.apache.catalina.loader.WebappClassLoader.loadClass(WebappClassLoader.java:1533)
	at java.lang.Class.forName0(Native Method)
	at java.lang.Class.forName(Class.java:190)
	at org.springframework.scheduling.quartz.MethodInvokingJobDetailFactoryBean.<clinit>(MethodInvokingJobDetailFactoryBean.java:89)
	at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
	at sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:57)
	at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:45)
	at java.lang.reflect.Constructor.newInstance(Constructor.java:526)
	at org.springframework.beans.BeanUtils.instantiateClass(BeanUtils.java:148)
	at org.springframework.beans.factory.support.SimpleInstantiationStrategy.instantiate(SimpleInstantiationStrategy.java:87)
	at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.instantiateBean(AbstractAutowireCapableBeanFactory.java:1000)
	... 37 more



bean定义:

<!-- 定义具体的任务类 -->
	<bean id="job_common" class="javacommon.util.CommJob" />
	
	<!-- 全部定义到内部bean中,多个任务 -->
	<bean id="scheduler"
		class="org.springframework.scheduling.quartz.SchedulerFactoryBean">
		<property name="triggers">
			<list>
				<!-- <ref bean="cornTrigger" /> -->
				<!-- 调度任务01 -->
				<bean class="org.springframework.scheduling.quartz.CronTriggerBean">
					<property name="jobDetail">
						<bean class="org.springframework.scheduling.quartz.MethodInvokingJobDetailFactoryBean">
							<!-- 目标类 -->
							<property name="targetObject">
								<ref bean="job_common" />
							</property>
							<!-- 目标类中要执行的方法 ,这个参数是必须的 -->
							<property name="targetMethod">
								<value>quartzMethod_001</value>
							</property>
						</bean>
					</property> 
					<property name="cronExpression" value="0/1 * * * * ?"/>
				</bean>
				
				<!-- 调度任务02 -->
				<bean class="org.springframework.scheduling.quartz.CronTriggerBean">
					<property name="jobDetail">
						<bean class="org.springframework.scheduling.quartz.MethodInvokingJobDetailFactoryBean">
							<!-- 目标类 -->
							<property name="targetObject">
								<ref bean="job_common" />
							</property>
							<!-- 目标类中要执行的方法 ,这个参数是必须的 -->
							<property name="targetMethod">
								<value>quartzMethod_002</value>
							</property> 
						</bean>
					</property> 
					<property name="cronExpression" value="0/2 * * * * ?"/>
				</bean>
				
				<!-- 调度任务03 -->
				<bean class="org.springframework.scheduling.quartz.CronTriggerBean">
					<property name="jobDetail">
						<bean class="org.springframework.scheduling.quartz.MethodInvokingJobDetailFactoryBean">
							<!-- 目标类 -->
							<property name="targetObject">
								<ref bean="job_common" />
							</property>
							<!-- 目标类中要执行的方法 ,这个参数是必须的 -->
							<property name="targetMethod">
								<value>quartzMethod_003</value>
							</property>
						</bean>
					</property> 
					<property name="cronExpression" value="0/3 * * * * ?"/>
				</bean>
			</list>
		</property>
	</bean>

项目用的maven,注释掉pom.xml quartz相关jar引用就好了,如下:

<!-- quartz start -->
		<!-- <dependency>
			<groupId>quartz</groupId>
			<artifactId>quartz</artifactId>
			<version>2.2.0</version>
			<scope>compile</scope>
		</dependency>
		<dependency>
			<groupId>quartz-jobs</groupId> 
			<artifactId>quartz-jobs</artifactId>
			<version>2.2.0</version>
			<scope>compile</scope>
		</dependency> -->
		<!-- quartz end -->



解决,jar包冲突!



补上:------------------------------------------------------------------------------------------------------------------------------------

后面发现jar包版本不对,将pom.xml改成下面也可以

<!-- quartz start --> 
		<dependency> 
			<groupId>quartz</groupId>
			<artifactId>quartz</artifactId>
			<!-- <version>2.2.0</version>  2.2.0 版本和下面的jobs不能配套吗,改成1.8.6就可以了 -->
			<span style="color:#ff0000;"><version>1.8.6</version></span>
			<scope>compile</scope>
		</dependency>
		<dependency>
			<groupId>quartz-jobs</groupId> 
			<artifactId>quartz-jobs</artifactId> 
			<version>2.2.0</version>
			<scope>compile</scope>
		</dependency>
		<!-- quartz end -->


Quartz配置多数据源时,需要为每个数据源设置唯一的名称,以便Quartz能够识别和使用不同的数据源。如果出现“DataSource name not set”错误,可能是因为没有为每个数据源设置名称或设置名称不正确导致的。 解决方法如下: 1. 确保为每个数据源设置唯一的名称,如下所示: ``` # 配置第一个数据源 org.quartz.dataSource.myDS.driver = com.mysql.jdbc.Driver org.quartz.dataSource.myDS.URL = jdbc:mysql://localhost:3306/quartz org.quartz.dataSource.myDS.user = root org.quartz.dataSource.myDS.password = root org.quartz.dataSource.myDS.maxConnections = 10 org.quartz.dataSource.myDS.provider_class = org.quartz.impl.jdbcjobstore.StdJDBCDelegate # 配置第二个数据源 org.quartz.dataSource.myDS2.driver = com.mysql.jdbc.Driver org.quartz.dataSource.myDS2.URL = jdbc:mysql://localhost:3306/quartz2 org.quartz.dataSource.myDS2.user = root org.quartz.dataSource.myDS2.password = root org.quartz.dataSource.myDS2.maxConnections = 10 org.quartz.dataSource.myDS2.provider_class = org.quartz.impl.jdbcjobstore.StdJDBCDelegate ``` 注意,每个数据源的名称必须唯一,如上例中的“myDS”和“myDS2”。 2. 确保在Quartz的配置文件中,为每个数据源设置名称,如下所示: ``` # 配置第一个数据源 org.quartz.jobStore.dataSource = myDS # 配置第二个数据源 org.quartz.jobStore.dataSource2 = myDS2 ``` 注意,数据源名称必须与上一步中设置的名称相同,如上例中的“myDS”和“myDS2”。 通过以上步骤,即可解决“DataSource name not set”错误。
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值