0
我当前的方法:并发访问安全
private int getStatusCode(String path) throws IOException {
HttpClient client = HttpClients.createDefault();
HttpGet method = new HttpGet(path);
HttpResponse httpResponse = client.execute(method);
return httpResponse.getStatusLine().getStatusCode();
}
我希望把它放在一个春天@Service
类。然后我想使用该类作为@Autowired
。我知道Spring bean是单身人士,所以我只有一个自动装配类的实例。我有不同的@Controller
类使用该服务。在我的情况下并发访问是否会造成问题?例如从另一个请求覆盖路径?