我可以使用Spring注入相同的类吗? [英] Can I inject same class using Spring?
本文介绍了我可以使用Spring注入相同的类吗?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我有一个类说UserService,它实现了Service并使用Service StereoType进行了注释,我正在使用Spring AOP并希望为此做临时解决方法()
I have a class say UserService which implements Service and annotated with Service StereoType, I'm using Spring AOP and want to do temporary workaround for this(I know this can be done in better way)
@Service
public class UserService implements Service{
@Autowired
private Service self;
}
我试过这个但是得到了BeanNotFoundException,我错过了什么吗?
I tried this but got BeanNotFoundException, did I missed anything?
我知道我必须使用带有@Configurable的AspectJ,但只是寻找一点临时解决方法
推荐答案
这很好用 -
@Service(value = "someService")
public class UserService implements Service{
@Resource(name = "someService")
private Service self;
}
这篇关于我可以使用Spring注入相同的类吗?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文