问题描述
对于一台闪电般快速的计算机和网络,我的解决依赖关系"大约需要 30 秒.
My 'resolving dependencies' is up around 30 seconds for a lightening fast computer and network.
我看过这个问题 Grails:部署时间非常慢.解决依赖关系..."需要 10 多秒,而且我似乎没有任何快照"依赖关系.我已经清除了我的常春藤缓存并强制重新下载所有内容,没有帮助.启用日志记录,这几行是违规者.没有下载任何内容,但鉴于我的网络流量,似乎每次都尝试远程查找某些内容.请注意,这些是唯一在它们之前有 [some number] 版本的条目,然后是另一个不同的条目 - 这不可能是巧合 - 这是什么意思?如何阻止 grails 尝试找到这些略有不同的版本?
I've looked at this question Grails: Very slow deploy time. 'Resolving Dependencies...' takes 10+ seconds, and I don't appear to have any 'snapshot' dependencies. I've cleared out my ivy cache and forced a redownload of everything, no help. Enabling logging, these few lines are the offenders. Nothing is being downloaded, but it appears that attempts are made to look for something remotely every time, given my network traffic. Note these are the ONLY entries that have the [some number] version before them, and then a different one after - that can't be coincidence - what does it mean? How can I stop grails from trying to find these slightly different versions?
.... these lines take 20+seconds, everything else is in the milliseconds ...
found commons-logging#commons-logging;1.1.1 in grailsPlugins
[1.1.1] commons-logging#commons-logging;[1.1, 2.0)
found org.apache.httpcomponents#httpclient;4.1.2 in default
[4.1.2] org.apache.httpcomponents#httpclient;[4.1, 5.0)
found org.apache.httpcomponents#httpcore;4.1.2 in default
found org.codehaus.jackson#jackson-core-asl;1.9.1 in default
[1.9.1] org.codehaus.jackson#jackson-core-asl;[1.4,)
found javax.mail#mail;1.4.4 in default
[1.4.4] javax.mail#mail;[1.4,)
我正在使用两个插件,它们肯定是违规者,并在下面列出了它们的 dependencies.groovy.我试过注释掉任何显式的远程 URL.
I am using two plugins that must be the offenders, and have listed their dependencies.groovy below. I've tried commenting out any explicit remote URLs.
简单数据库:
grails.project.class.dir = "target/classes"
grails.project.test.class.dir = "target/test-classes"
grails.project.test.reports.dir = "target/test-reports"
grails.project.dependency.resolution = {
inherits "global"
log "warn"
String datastoreVersion = "1.0.0.M9"
repositories {
grailsPlugins()
grailsHome()
grailsCentral()
mavenRepo "http://repo.grails.org/grails/core" //tried commenting this out, no help
mavenLocal()
mavenCentral()
mavenRepo 'http://repository.codehaus.org' //tried commenting this out, no help
}
dependencies {
def excludes = {
transitive = false
}
compile("org.grails:grails-datastore-gorm-simpledb:$datastoreVersion",
"org.grails:grails-datastore-gorm-plugin-support:$datastoreVersion",
"org.grails:grails-datastore-gorm:$datastoreVersion",
"org.grails:grails-datastore-core:$datastoreVersion",
"org.grails:grails-datastore-simpledb:$datastoreVersion",
"org.grails:grails-datastore-web:$datastoreVersion") {
transitive = false
}
runtime("stax:stax:1.2.0", excludes)
runtime('com.amazonaws:aws-java-sdk:1.2.0')
test("org.grails:grails-datastore-gorm-test:$datastoreVersion",
"org.grails:grails-datastore-simple:$datastoreVersion") {
transitive = false
}
}
plugins {
build ":release:1.0.0.RC3", {
exported = false
}
}
}
Ajax 上传器:
grails.project.class.dir = "target/classes"
grails.project.test.class.dir = "target/test-classes"
grails.project.test.reports.dir = "target/test-reports"
grails.release.scm.enabled=false
grails.project.dependency.resolution = {
// inherit Grails' default dependencies
inherits("global") {
// uncomment to disable ehcache
// excludes 'ehcache'
}
log "warn" // log level of Ivy resolver, either 'error', 'warn', 'info', 'debug' or 'verbose'
repositories {
grailsPlugins()
grailsHome()
grailsCentral()
// uncomment the below to enable remote dependency resolution
// from public Maven repositories
mavenLocal()
mavenCentral()
//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.
test 'org.gmock:gmock:0.8.1'
}
plugins {
//build ':release:1.0.0.RC3'
}
}
推荐答案
我找到了罪魁祸首. 如果您使用的插件依赖于 maven 中的库如果有开放式"依赖项,grails 每次都会去查看该范围内是否有更新的版本要下载.我不知道为什么有人会这样指定它.似乎它会导致不可靠的行为.对我来说,罪魁祸首是亚马逊的 java aws 库,它自然是与亚马逊云对话的 simpledb 插件所需要的.
and I've found the culprit. If a plugin you use relies on a library in maven that has 'open ended' dependencies, grails will go and look each time if there are newer versions to download in the range. I have no idea why anyone would specify it like this. It seems it would lead to unreliable behaviour. For me, the culprit is Amazon's java aws library, naturally required by the simpledb plugin that talks to Amazon's cloud.
http://mvnrepository.com/artifact/com.amazonaws/aws-java-sdk/1.2.10
注意它的一些依赖是这样的
note how some of its dependencies are like this
org.apache.httpcomponents httpclient [4.1, 5.0)
org.apache.httpcomponents httpclient [4.1, 5.0)
似乎每次grails都在寻找更新的版本(如果存在就下载,我这次运行时只注意到httpclient的4.2-alpha1下降了).
it appears that every time, grails is looking for a newer version (and downloading if it exists, I just noticed 4.2-alpha1 of httpclient come down when I ran this time).
通过从插件中删除该依赖项并将所需的库手动添加到我的 .lib 文件夹中,我将启动时间从 >30 秒减少到
By removing that dependency from the plugin and manually adding the required libraries to my .lib folder, I reduced my startup time from >30sec to <1sec
这篇关于Grails 解决某些依赖项非常慢的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!