2

我已经绞尽脑汁好几个小时试图弄清楚这一点。每当我尝试对新创建的 Grails 项目(使用全新的 Grails 安装)执行任何类型的操作时,都会收到以下错误消息:

Error There was an error loading the BuildConfig: ivy pattern must be absolute: 
${HOME}/.m2/alpha/repository/[organisation]/[module]/[revision]/[module]-[revision](-
[classifier]).pom (Use --stacktrace to see the full trace)

我可以推断出我的安装存在问题,但正如我所说,它是全新安装,所以我不确定是什么导致了这个问题。

我正在运行Win7。任何帮助将非常感激。

编辑:

grails.servlet.version = "2.5" // Change depending on target container compliance (2.5 or 3.0)
grails.project.class.dir = "target/classes"
grails.project.test.class.dir = "target/test-classes"
grails.project.test.reports.dir = "target/test-reports"
grails.project.target.level = 1.6
grails.project.source.level = 1.6
//grails.project.war.file = "target/${appName}-${appVersion}.war"

grails.project.dependency.resolution = {
    // inherit Grails' default dependencies
    inherits("global") {
        // specify dependency exclusions here; for example, uncomment this to disable ehcache:
        // excludes 'ehcache'
    }
    log "error" // log level of Ivy resolver, either 'error', 'warn', 'info', 'debug' or 'verbose'
    checksums true // Whether to verify checksums on resolve

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

        grailsPlugins()
        grailsHome()
        grailsCentral()

        mavenLocal()
        mavenCentral()

        // uncomment these (or add new ones) to enable remote dependency resolution from public Maven repositories
        //mavenRepo "http://snapshots.repository.codehaus.org"
        //mavenRepo "http://repository.codehaus.org"
        //mavenRepo "http://download.java.net/maven/2/"
        //mavenRepo "http://repository.jboss.com/maven2/"
    }
    dependencies {
        // specify dependencies here under either 'build', 'compile', 'runtime', 'test' or 'provided' scopes eg.

        // runtime 'mysql:mysql-connector-java:5.1.20'
    }

    plugins {
        runtime ":hibernate:$grailsVersion"
        runtime ":jquery:1.7.1"
        runtime ":resources:1.1.6"

        // Uncomment these (or add new ones) to enable additional resources capabilities
        //runtime ":zipped-resources:1.0"
        //runtime ":cached-resources:1.0"
        //runtime ":yui-minify-resources:0.1.4"

        build ":tomcat:$grailsVersion"

        runtime ":database-migration:1.1"

        compile ':cache:1.0.0.RC1'
    }
}
4

4 回答 4

3

问题暂时解决了。

这是一个 Maven 问题,我最初没有考虑过。出于某种原因,/Users/USERNAME/.mp2/settings.xml 中的 localRepository 标记无法解析 HOME 的路径,因此将 ${HOME} 替换为 C:/Users/USERNAME 就可以了。奇怪,但它现在有效。如果有人有更好的解决方案,请告诉我!

于 2012-07-19T19:52:50.903 回答
1

我的解决方案有点不同:

(1) 创建一个指向您的 .m2 存储库位置的变量:

def localMavenRepo = "file://" + new File(System.getProperty('user.home'), '.m2/repository').absolutePath

(2) 创建存储库条目:

repositories { 
    ... 
    mavenRepo name: 'Local', root: localMavenRepo 
}
于 2013-07-06T01:16:12.283 回答
0

我通过将M2_REPO环境变量设置为绝对路径解决了这个问题。在 Linux 上:

export M2_HOME=/home/chris/.m2/repository/

在 Windows 上,您可以在系统属性对话框中设置环境变量(系统属性的快捷方式是WindowsKey + PauseKey)。转到系统属性->高级->环境变量

于 2012-11-01T22:34:18.277 回答
0

I also got the same problem. I think it's not Maven problem, it's Apache Ivy's problem.

I think Apache Maven 2/3 works well, it's just that Apache Ivy didn't pick the correct Maven folder. The Apache Ivy didn't expand the ${user.home} as it should.

于 2012-08-24T17:58:33.993 回答