当前位置: 首页 > 知识库问答 >
问题:

无法构建grails 2.3.7项目,因为maven中央存储库已经转移到https

顾涵衍
2023-03-14
RemoteRepository mavenCentral(Closure configurer = null) {
    final existing = repositories.find { ArtifactRepository ar -> ar.id == "mavenCentral" }
    if (!existing) {
        final repositoryBuilder = new RemoteRepository.Builder("mavenCentral", "default", "http://repo1.maven.org/maven2/")

        configureRepository(repositoryBuilder, configurer)
        final repository = repositoryBuilder.build()
        repositories << repository
        return repository
    }
    else {
        return existing
    }
}

如何解决此问题?由于几个原因,我无法将项目迁移到新的Grails版本。这是我的错误。

共有1个答案

吕嘉荣
2023-03-14

您必须注释掉repositories下的mavenCentral()并添加相应的https url,如此处建议的:https://support.sonatype.com/hc/en-us/articles/360041287334

示例:

repositories {
        inherits true // Whether to inherit repository definitions from plugins

        grailsPlugins()
        grailsHome()
        mavenLocal()
        grailsCentral()

        //comment following line to prevent use of default http url
//        mavenCentral()

        //add following https counterparts
        mavenRepo 'https://repo1.maven.org/maven2/'
        mavenRepo 'https://repo.maven.apache.org/maven2/'
        //if by any chance you can't connect to https url use this insecure url
//      mavenRepo 'http://insecure.repo1.maven.org/maven2/'

        mavenRepo 'https://repo.spring.io/milestone'
    }

我在grails 2.3.11和Java1.7.0_242中尝试了这种方法,结果对我有效。希望这有帮助。

 类似资料:
  • 我是个彻头彻尾的Jenkins noob,所以如果我错过了一些显而易见的事情,我会提前道歉! 我正在使用Visual Studio 2010构建一个intranet web应用程序,并使用AnkhSVN将更改提交到存储在运行Visual SVN server的服务器上的存储库中。 由于预算限制,该服务器还充当我们的web服务器,并运行Jenkins。它连接到我们的内部网络,但没有外部互联网接入,所

  • 问题内容: 我公司的政策不支持自动下载的工件(必须经过批准),因此,要使用Maven,我需要禁用对Maven中央存储库的访问。 换句话说,我不希望Maven尝试从Central下载任何内容。 我知道如何配置本地存储库(是否联网),我的想法是使用“受祝福的”计算机来更新本地存储库。 PS:我可以在代理/网络级别阻止请求,但是我在问如何使用Maven的配置来完成请求。 UPDATE 我终于想出了怎么做

  • 我有两个私人JFrog存储库设置。一个存储库处理发布,另一个处理快照。下面是我如何在我的设置中定义它的。xml文件。 我的多模块maven项目中的多个内部依赖项都收到了这个错误: 从外观上看,Maven似乎并没有试图联系官方的Maven Central repo以获取这些依赖项,而是在我的私有存储库上失败了。我的印象是,如果私有存储库不包含特定工件,它将尝试联系Maven Central。 从Ma

  • 由于“需要HTTPS”错误,我最近在构建项目时遇到了问题。这个问题通过如下所述修改我的pom.xml得到了解决,添加了以下内容: 然而,为我的每个项目更新每个pom.xml是一件麻烦的事。 我尝试将相同的代码片段添加到我的settings.xml,但没有成功。 我知道更新版本的Maven解决了这个问题。然而,由于工作限制,我无法更新我的环境。 我目前已经安装了Java8和Maven,由Netbea

  • 我刚刚使用Maven,我需要从一个Ant项目上传一些库。为了开发这个任务,我有一个文件夹,其中包含许多“pom.xml”文件,这些文件引用了我希望使用Maven在Eclipse中添加到我的项目中的jar,还有另一个xml文件,即Ant项目本身。 欢迎所有想法。谢谢