调整program.cs里注册QuartzJobService,去除掉原有框架内的QuartzCore文件夹中的Factory middlejob等方法
// 注册QuartzJobService builder.Services.AddQuartz(q => { var jobKey = new JobKey("Jobs"); q.AddJob<InterAutoTicketing>(opts => opts.WithIdentity(jobKey)); //var jobKey2 = new JobKey("Jobs2"); //q.AddJob<InterAutoTicketingTest>(opts => opts.WithIdentity(jobKey2)); var quartzThreadCount = ConfigHelper.GetSectionValue("QuartzThreadCount"); var maxThreadCount = string.IsNullOrEmpty(quartzThreadCount) ? 3 : Convert.ToInt32(quartzThreadCount); q.UseDefaultThreadPool(tp => tp.MaxConcurrency = maxThreadCount); var cron = ConfigHelper.GetSectionValue("QuartzCron") ?? "0/1 * * * * ? "; q.AddTrigger(opts => opts .ForJob(jobKey) .WithIdentity($"{nameof(InterAutoTicketingTest)}-trigger") .WithCronSchedule(cron) ); //var cron = ConfigHelper.GetSectionValue("QuartzCron") ?? "0/1 * * * * ? "; //q.AddTrigger(opts => opts //.ForJob(jobKey2) //.WithIdentity("InterAutoTicketingTest-trigger") //.WithCronSchedule(cron)); }); builder.Services.AddQuartzHostedService(q => q.WaitForJobsToComplete = true);
标签:WithIdentity,quartz,示例,GetSectionValue,dbcontext,cron,jobKey,var,opts From: https://www.cnblogs.com/Lvkang/p/18554379