Could not download spring-boot-autoconfigure.jar (org.springframework.boot: spring-boot-autoconfigur
我在家建立了一個grails工程執行grails run-app,出現如下錯誤:
D:\Projects\Grails\project\HelloWorld>grails run-app
Java HotSpot(TM) Client VM warning: TieredCompilation is disabled in this releas
e.
> Configuring > 0/1 projects > root project > Resolving dependencies ':classpath
1/1 projects > Resolving dependencies ':agent' > Resolving dependencies 'detache
> Resolving dependencies ':runtime' > Resolving dependencies 'detachedConfigura
FAILURE: Build failed with an exception.
* What went wrong:
A problem occurred configuring root project 'HelloWorld'.
> Could not resolve all dependencies for configuration ':runtime'.
> Could not download spring-boot-autoconfigure.jar (org.springframework.boot:
spring-boot-autoconfigure:1.3.3.RELEASE)
> Could not get resource 'https://repo.grails.org/grails/core/org/springfr
amework/boot/spring-boot-autoconfigure/1.3.3.RELEASE/spring-boot-autoconfigure-1
.3.3.RELEASE.jar'.
> Could not GET 'https://repo.grails.org/grails/core/org/springframewor
k/boot/spring-boot-autoconfigure/1.3.3.RELEASE/spring-boot-autoconfigure-1.3.3.R
ELEASE.jar'.
> 這是在主機名解析時通常出現的暫時錯誤,它意味著本地伺服器沒有從權威
伺服器上收到響應。
* Try:
Run with --stacktrace option to get the stack trace. Run with --info or --debug
option to get more log output.
BUILD FAILED
Total time: 48.497 secs
| Error Error initializing classpath: 這是在主機名解析時通常出現的暫時錯誤,它意
味著本地伺服器沒有從權威伺服器上收到響應。 (Use --stacktrace to see the full tra
ce)
D:\Projects\Grails\project\HelloWorld>
-------------------------------------------------------------------------------------------------------
同樣的操作,我在公司操作一切正常,可能是因為我家裡的網路太差了。。。
錯誤原因:
grails在執行我們的工程時,發現工程依賴的jar包,系統中沒有,所以就自動幫我們去下載了,悲催的是竟然下載失敗。。。
解決方法1:
開啟工程根目錄下面的檔案:build.gradle,然後將裡面的兩個網址:
maven { url "https://repo.grails.org/grails/core" }
都改成:maven { url "http://repo.grails.org/grails/core" } // 即去掉s,這樣就可以下載了
------------------------------------------------------------------------------------------------------------------------------------
解決方法2:
我發現grails執行命令grails run-app下載的jar檔案包儲存在以下位置:
C:\Users\Administrator\.gradle\caches\modules-2\files-2.1
所以到其它正常的電腦拷貝該目錄中的檔案到不正常的電腦同一目錄下面即可。
為了保險,我建議還是拷貝整個.gradle目錄吧: C:\Users\Administrator\.gradle