“错误:无法从Maven存储库检索数据”
同时从search.maven.org检索最新的版本号。编写以下php代码,我将修改所有其他软件包。
<?php
$url = "https://search.maven.org/solrsearch/select?q=a:angus-activation-project&rows=1&wt=json";
$curl = curl_init();
curl_setopt($curl, CURLOPT_URL, $url);
curl_setopt($curl, CURLOPT_RETURNTRANSFER, true);
$response = curl_exec($curl);
curl_close($curl);
if ($response === false) {
echo "Error: Retrieving data from the Maven repository failed";
} else {
$data = json_decode($response);
if ($data === null || !property_exists($data, 'response') || count($data->response->docs) == 0) {
echo "Error: Failed to retrieve the latest version of the artifact from the Maven repository";
} else {
$latestVersion = $data->response->docs[0]->v;
echo "Latest version is" . $latestVersion;
}
}
?>
1条答案
按热度按时间ee7vknir1#
添加以下内容:
如果你使用curl和默认的user-agent,maven会返回403 forbidden。