2012-07-19 160 views
2

我一直在试图弄清楚这个问题已经花费了数小时。每当我尝试执行任何动作来我的新创建Grails项目(用新鲜的Grails的安装),我收到此错误信息:加载BuildConfig时出现错误(Grails 2.1.0)

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' 
    } 
} 
+0

看到你的BuildConfig会很有帮助。 – Gregg 2012-07-19 19:05:49

+0

@Gregg我已经用我的BuildConfig.groovy更新了这篇文章 – 2012-07-19 19:29:14

回答

3

问题解决了现在。

这是一个Maven问题,我最初并没有考虑。出于某种原因,/Users/USERNAME/.mp2/settings.xml中的localRepository标记无法解析到HOME的路径,因此使用C:/ Users/USERNAME替换$ {HOME}也有诀窍。奇怪,但它现在工作。如果有人有更好的解决方案,让我知道!

+0

嗨,本,我认为你的结论是错误的。这仍然是常春藤问题,因为你不运行Apache Maven构建。普通的Maven将能够解析参数化的$ {user.home},而Grails实际上正在使用Ivy,试图解决但失败。 – 2013-02-17 10:08:25

0

我也遇到了同样的问题。 我认为这不是Maven问题,它是Apache Ivy的问题。

我认为Apache Maven 2/3运行良好,只是Apache常春藤没有选择正确的Maven文件夹。 Apache Ivy没有像应该那样扩展$ {user.home}。

0

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

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

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

1

我的解决办法是有一点不同:

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

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

(2)创建一个存储库条目:

repositories { 
    ... 
    mavenRepo name: 'Local', root: localMavenRepo 
} 
+0

它的工作就是这样。我评论了这些行:mavenLocal(); mavenCentral()并添加了本地mavenRepo声明。或者(对于快速测试),有人可以注释掉mavenLocal(),并远程更新(不建议保持这样)。 – atas 2014-08-11 21:10:50

相关问题