4

我有一个 grails 2.3.8 项目和一个 Artifactory 服务器。

Artifactory 服务器需要身份验证。

BuildConfig.groovy 包含:

grails.project.ivy.authentication = {
    repositories {
        mavenRepo "http://SERVER:8081/artifactory/remote-repos"

    }
    credentials {
        realm = "Artifactory Realm"
        host = "SERVER"
        username = "USER"
        password = "PASSWORD"
    }
}


grails.project.dependency.resolver = "maven" // or ivy

grails.project.dependency.resolution = {
    // inherit Grails' default dependencies
    inherits("global") {
        // specify dependency exclusions here; for example, uncomment this to disable ehcache:
        // excludes 'ehcache'
    }
    log "warn" // log level of Ivy resolver, either 'error', 'warn', 'info', 'debug' or 'verbose'
    checksums true // Whether to verify checksums on resolve
    legacyResolve false // whether to do a secondary resolve on plugin installation, not advised and here for backwards compatibility

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

//        mavenLocal()

        mavenRepo id: 'Artifactory', url: "http://SERVER:8081/artifactory/remote-repos"

    }

    dependencies {

        runtime 'com.oracle:ojdbc6:11.2.0.1.0'
        build "commons-dbcp:commons-dbcp:1.4"

        compile 'org.jadira.usertype:usertype.jodatime:1.9'
        compile "net.sf.ehcache:ehcache-core:2.4.6"
    }

    plugins {
        runtime ":hibernate:3.6.10.13"
        runtime ":resources:1.2.7"

        build ":tomcat:7.0.52.1"
        compile ':cache:1.1.5'

        compile ":joda-time:1.4"
    }
}

当我运行时:

grails runApp

我得到:

Starting process on MYPC/IPADDRESS
Loading Grails 2.3.8
|Configuring classpath
Error |
Resolve error obtaining dependencies: Failed to read artifact descriptor for xalan:serializer:jar:2.7.1 (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.

看起来常春藤日志配置不适用于 Maven。如何打开日志记录?为什么我的工件没有解析?

4

4 回答 4

1

A little late on the response, but I ran into this type of issue and traced it to a setting that tells Artifactory to respond with a 404 instead of 401 when someone is requesting an artifact from a repo they can't access.

My guess is that Grails does not preemptively authenticate during dependency resolution, so it never tries to use the supplied credentials in the BuildConfig.groovy after getting the 404.

Try turning off that setting as it fixed the issue for me.

于 2014-05-15T04:45:58.610 回答
0

在 Artifactory 中选中 Admin / Sercurity / General 中的“允许匿名访问”选项

仍然没有回答为什么身份验证不起作用。

我将提出一个关于身份验证的单独问题。 将grails maven身份验证配置到Artifactory的正确方法是什么?

于 2014-05-15T05:09:36.103 回答
0

在 BuildConfig.groovy 中尝试以下配置:

grails.project.dependency.resolver = "maven"
grails.project.ivy.authentication = {
    repositories {
        mavenRepo('http://SERVER:8081/artifactory/remote-repos') {
             auth([
                realm: "Artifactory Realm",
                username: 'user',
                password: 'pass'
            ])
        }
    }
}

grails.project.dependency.resolution = {
    ...
    repositories {
        inherits true
    }
    ...
}
于 2014-04-29T19:44:48.110 回答
0

尝试改变:

grails.project.ivy.authentication = {
    repositories {
        mavenRepo "http://SERVER:8081/artifactory/remote-repos"

    }
    credentials {
        realm = "Artifactory Realm"
        host = "SERVER"
        username = "USER"
        password = "PASSWORD"
    }
}

credentials {
    realm = "Artifactory Realm"
    host = "SERVER"
    username = "USER"
    password = "PASSWORD"
}

最近从 Ivy 到 Maven 的变化并不总是 100% 正确地反映在文档中。您正在使用maven,所以我认为该ivy设置在这里不起作用。

于 2014-04-29T04:34:00.347 回答