使用 maven\issues with Nexus 调试 Grails 命令“刷新依赖”

MrP*_*low 5 java grails groovy maven

我在公司网络上,所以为了检索我们使用 Nexus 的依赖项。Grails 存储库已添加到 nexus 存储库中,所以现在剩下的就是配置 grails 以使用 nexus。

对于 Java Maven 项目的开发,我只需要指定它settings.xml应该关注哪个文件,因为 Nexus URL 和凭据存储在那里。

现在我们切换到 Grails,在创建新项目时,grails 在配置类路径上挂起大约 200 秒(因为它被配置为在 200 秒后超时),然后说:

Resolve error obtaining dependencies: Failed to read artifact descriptor for jline:jline:jar:2.12 (Use --stacktrace to see the full trace)
Error |
Required Grails build dependencies were not found. This is normally due to internet connectivity issues (such as a misconfigured proxy) or missing repositories in grails-app/conf/BuildConfig.groovy. Please verify your configuration to continue.
Process was killed
Run Code Online (Sandbox Code Playgroud)

现在这可能是 repo 配置的问题,但是我无法正确调试它。

我试过打电话grails refresh-dependencies --stacktrace,我试过将日志从 更改errordebugtracein Config.groovy。尝试设置日志记录verboseBuildConfig.groovy(但这是常春藤,我们正在使用Maven所以当然它什么都不做),现在我不确定,不知道该做什么。

如果有帮助,这是我当前的 repo 配置BuildConfig.groovy

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

    grailsPlugins()
    grailsHome()
    mavenLocal()

    mavenRepo(id:'nexusconf', url:"https://nexusurl/repository/rootrepo/") {
        auth username: "user", password: "pass"
    }
    //grailsCentral()
    //mavenCentral()
    // uncomment these (or add new ones) to enable remote dependency resolution from public Maven repositories          
    //mavenRepo "http://repository.codehaus.org"
    //mavenRepo "http://download.java.net/maven/2/"
    //mavenRepo "http://repository.jboss.com/maven2/"
}
Run Code Online (Sandbox Code Playgroud)

Dan*_*her 2

我认为这取决于您使用的 grails 版本以及您是否使用 aether 还是 ivy 进行依赖项解析(grails.project.dependency.resolver在 BuildConfig 中设置)。根据 grails 2.4.4 文档,要使用 Aether 进行身份验证,需要在 BuildConfig 以及 USER_HOME/.grails/settings.groovy 中进行配置。要使用 Ivy 进行身份验证,配置仅位于 USER_HOME/.grails/settings.groovy 中。

文档是这样说的:


使用以太进行身份验证

要使用 Aether 进行身份验证,您可以在存储库定义中定义凭据:

mavenRepo(url:"http://localhost:8082/myrepo") { auth username: "foo", password: "bar" }

或者您可以在存储库上指定一个 id:

mavenRepo(id:'myrepo', url:"http://localhost:8082/myrepo")

然后在 USER_HOME/.grails/settings.groovy 中声明您的凭据:

grails.project.dependency.authentication = { credentials { id = "myrepo" username = "admin" password = "password" } }

通过 Ivy 进行身份验证

如果您的存储库需要身份验证,您可以使用凭据块进行配置:

credentials { realm = ".." host = "localhost" username = "myuser" password = "mypass" }

可以使用 grails.project.ivy.authentication 设置将其放置在 USER_HOME/.grails/settings.groovy 文件中:

grails.project.ivy.authentication = { credentials { realm = ".." host = "localhost" username = "myuser" password = "mypass" } }

这是完整的文档