加入收藏 | 设为首页 | 会员中心 | 我要投稿 李大同 (https://www.lidatong.com.cn/)- 科技、建站、经验、云计算、5G、大数据,站长网!
当前位置: 首页 > 大数据 > 正文

java – Android Annotations – 注入超类类型列表

发布时间:2020-12-15 01:33:18 所属栏目:大数据 来源:网络整理
导读:我正在尝试使用Android Annotations实现以下Spring代码: @Autowiredpublic initHandlerList(List 我尝试使用接口和类. Bean定义: @EBeanpublic AbstractHandler implements Handler {} 试图注入: @Beanpublic initHandlersList(List 但总是得到以下错误:

我正在尝试使用Android Annotations实现以下Spring代码:

@Autowired
public initHandlerList(List

我尝试使用接口和类.

Bean定义:

@EBean
public AbstractHandler implements Handler {}

试图注入:

@Bean
public initHandlersList(List

但总是得到以下错误:

Error:(20,5) error: org.androidannotations.annotations.Bean can only be used on an element annotated with @org.androidannotations.annotations.EBean

所以我想因为列表本身没有用@EBean注释它不能用作Bean …任何使用Android Annotations实现它的方法?

谢谢 !

最佳答案
对不起,我无法评论,但我的声誉太低了.

我读了wiki并在基于方法的注射下我看到了你如何注入豆子.我在你的代码中看到的是你确实在创建一个带有AbstractHandler对象的EBean,但是你试图注入一个没有用@EBean注释的List对象,你可以删除List<>并且只需使用AbstractHandler,或者您可以扩展List实现(如ArrayList)并使用@EBean注释它.

@EBean
public class InjectableArrayList

希望这可以帮助.

(编辑:李大同)

【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容!

    推荐文章
      热点阅读