建筑企业资质查询网站,营销策略论文,深圳企业黄页,最适合新闻资讯建站的cms前些天发现了一个巨牛的人工智能学习网站#xff0c;通俗易懂#xff0c;风趣幽默#xff0c;忍不住分享一下给大家。点击跳转到教程。
1. 启动工程失败#xff0c;报错如题#xff1a;
A component required a bean of type gentle.test.Show that could not be found.…前些天发现了一个巨牛的人工智能学习网站通俗易懂风趣幽默忍不住分享一下给大家。点击跳转到教程。
1. 启动工程失败报错如题
A component required a bean of type gentle.test.Show that could not be found.
2. 原因有一个被我注入其它类的 业务类上没有给注解service 。
PS还有2种原因1) 要求 service 和 controller 需要在同一个包下 。2有可能没有引入依赖的服务bean。 此条来自评论中好心网友的分享。
此类没有在类上给注解
package gentle.test;import org.quartz.Job;
import org.quartz.JobExecutionContext;
import org.quartz.JobExecutionException;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;import java.util.Date;/*** author silence* date 2018/7/17 11:37*/
public class Show implements Job {private static Logger _log LoggerFactory.getLogger(Show.class);Overridepublic void execute(JobExecutionContext arg0) throws JobExecutionException {_log.info(\n\n-------------------------------\n It is running and the time is : new Date()\n-------------------------------\n);}}在此类注入了上面那个类 Show
package gentle.test;import org.quartz.JobExecutionException;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;import javax.annotation.Resource;
import java.text.SimpleDateFormat;
import java.util.Date;public class UserSyncTask {private final Logger logger LoggerFactory.getLogger(this.getClass());ResourceSchedulerTest test;ResourceShow show;public void cronDepartmentsAndUsersJob() {logger.info(\n\n 定时--开始当前时间 dateFormat().format(new Date()));
// test.addJob();try {show.execute(null);} catch (JobExecutionException e) {e.printStackTrace();}logger.info(\n\n 定时--结束当前时间 dateFormat().format(new Date()));}private SimpleDateFormat dateFormat() {return new SimpleDateFormat(HH:mm:ss);}
}3.解决在 Show 类上加上 service 注解 。
改为
package gentle.test;import org.quartz.Job;
import org.quartz.JobExecutionContext;
import org.quartz.JobExecutionException;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.stereotype.Service;import java.util.Date;/*** author silence* date 2018/7/17 11:37*/
Service(show)
public class Show implements Job {private static Logger _log LoggerFactory.getLogger(Show.class);Overridepublic void execute(JobExecutionContext arg0) throws JobExecutionException {_log.info(\n\n-------------------------------\n It is running and the time is : new Date()\n-------------------------------\n);}}4. 启动并运行定时任务正常