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
類使用該服務。在我的情況下併發訪問是否會造成問題?例如從另一個請求覆蓋路徑?