我可以使用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;
}