所有栏目 | 云社区 美国云服务器[国内云主机商]
你的位置:首页 > 云社区 » 正文

springmvc继承Runnable接口不能用注解?

发布时间:2020-04-15 16:12:19

资讯分类:接口  runnable  autowired  null  不受  容器  注入
springmvc继承Runnable接口不能用注解?

因为这个现成不受spring容器的监管,所以无法注入bean。采用如下方法:

以下是例子:

ApplicationContext ctx = new AnnotationConfigApplicationContext(BulletinService.class);

BulletinServicebulletinService= ctx.getBean(BulletinService.class);

试试吧。

留言与评论(共有 0 条评论)
   
验证码:
Top