使Springboot @service类方法一次仅通过一个线程访问
我需要使我的@Service类方法一次只能访问一个线程。由于该方法调用@Autowied
另一个实例,我无法将静态同步
关键字添加到该方法中。
请就此建议。
谢谢。
在此处添加了示例Java类,
@Service
public class Saver implements DataSaver {
@Autowired
private SaverLogic saverLogic;
@Override
public String process(...) {
Future<String> result = saverLogic.save(repositoryContainer, entities);
}
我需要制作Process()方法静态同步
,但是由于自动实例,我无法执行此操作。 SaverLogic类包含@ASYNC
方法。
请帮助我。
I need to make my @service class a method can be access only one thread at a time. I can't add static synchronized
keywords to the method due to that method call @Autowired
another instances.
Please advice on this.
Thank you.
Added sample java class here,
@Service
public class Saver implements DataSaver {
@Autowired
private SaverLogic saverLogic;
@Override
public String process(...) {
Future<String> result = saverLogic.save(repositoryContainer, entities);
}
I need to make process() method static synchronized
but due to autowired instance I can't do this. SaverLogic class contains a @Async
method.
Please help me on this.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论