You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

从search.maven.org获取Maven包最新版本报错,求排查(附PHP代码)

从Maven仓库获取包最新版本时出错

尝试从search.maven.org获取angus-activation-project包的最新版本时触发错误,错误信息如下:

"Error: Failed to retrieve data from the Maven repository"

我编写了以下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;
        }
    }
?>

内容的提问来源于stack exchange,提问作者Dam_Jo

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.07.25 21:05:18