記錄一下學習源碼遇到的問題:
1. 編譯時報錯:Failed to apply plugin [id ‘com.gradle.build-scan’]
把spring源碼clone下來之後,使用gradle編譯不通過,異常日誌如下:
FAILURE: Build failed with an exception.
* Where:
Build file 'E:\code\spring-framework-5.0.2.RELEASE\build.gradle' line: 15
* What went wrong:
An exception occurred applying plugin request [id: 'com.gradle.build-scan', version: '1.8']
> Failed to apply plugin [id 'com.gradle.build-scan']
> This version of Gradle requires version 2.0.2 of the build scan plugin or later.
Please see https://gradle.com/scans/help/gradle-incompatible-plugin-version for more information.
原因是gradle版本太高了,具體參考:https://docs.gradle.com/enterprise/compatibility/#build_scan_plugin
可以移步到這個網站下載:http://services.gradle.org/distributions/
2. 報錯Groovy:compiler mismatch project levelis :2.4 Workspace level is 2.5
在spring-beans
項目下的test文件夾下面新建測試類,提示這個問題。
原因: Groovy編譯器級別與項目版本不匹配。
解決方法:在當前項目上點右鍵,屬性 Properties,Groovy Compiler配置編譯版本與項目的編譯設置版本一致。
我這裏是提示2.4,然後改爲2.5就可以了。
然後spring-context
也提示同樣的問題,修改之後,eclipse就開始重新編譯所有的子項目。這時eclipse會有點卡,右下角綠條走完就好了。