resteasy 在另一个服务中调用服务 [英] resteasy invoke service inside another service
本文介绍了resteasy 在另一个服务中调用服务的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我有一个服务 X 和 Y.如果我想在 X 中调用 Y.有没有办法通过注释来做到这一点.我不想为 X/Y 配置 bean,因为所有其他资源都是为 X 自动装配的.
I have a services X and Y. If I want to invoke Y inside X. Is there a way to do that thru annotations. I don't want to configure a bean for X/Y, as all the other resources are Autowired for X.
谢谢!
推荐答案
Spring 只能注入托管实例:
Spring can only inject managed instances:
@Service
public class X {
@Resource
private Y y;
}
@Service
public class Y {
}
<小时>
如果您不喜欢将@Service 添加到Y 类,那么您可以使用它(X 将相同)
If you do not like to add @Service to class Y, then you could use this (X will be the same)
@Configuration
public class AppConfig {
@Bean
public Y y {
return new Y();
}
}
这篇关于resteasy 在另一个服务中调用服务的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文