天天看點

Spring Boot源碼編譯fork spring boot[可選]clone spring boot編譯遇到問題參考資料

Spring Boot源碼編譯

fork spring boot[可選]

我fork一個Spring boot到自己的github上,主要是為了把閱讀源碼時添加的一些注釋push上去,是以這一步是可選的。

clone spring boot

1、把Spring boot源碼克隆下來

git clone https://github.com/DHBin/spring-boot.git           

複制

官方位址是https://github.com/spring-projects/spring-boot

2、同步2.1.x分支

git checkout -b 2.1.x origin/2.1.x           

複制

為了不污染原來的版本,建立新的分支

git checkout -b 2.1.x_learn           

複制

上傳GitHub

git push origin HEAD -u           

複制

期間可能需要登入GitHub賬号,出現一下資訊證明分支建立成功

Total 0 (delta 0), reused 0 (delta 0)
remote:
remote: Create a pull request for '2.1.x_learn' on GitHub by visiting:
remote:      https://github.com/DHBin/spring-boot/pull/new/2.1.x_learn
remote:
To https://github.com/DHBin/spring-boot.git
 * [new branch]            HEAD -> 2.1.x_learn
Branch '2.1.x_learn' set up to track remote branch '2.1.x_learn' from 'origin'.           

複制

編譯

前期準備

  • 下載下傳maven并配置好環境,切換國内源

執行指令

mvn -Dmaven.test.skip=true -Dmaven.compile.fork=true -Dmaven.test.failure.ignore=true clean install           

複制

  • -Dmaven.test.skip=true 跳過測試
  • -Dmaven.compile.fork 多線程
  • -Dmaven.test.failure.ignore 忽略測試錯誤

如果沒有意外編譯就成功了

遇到問題

  1. 編譯spring-boot-gradle-plugin時執行一些測試用例,導緻報錯。

解決方法:

rm -rf spring-boot-project/spring-boot-tools/spring-boot-gradle-plugin/src/test/java           

複制

再編譯,編譯成功後執行

git checkout spring-boot-project/spring-boot-tools/spring-boot-gradle-plugin/src/test/java           

複制

恢複

參考資料

IDEA 編譯運作 Spring Boot 2.0 源碼

[maven-編譯速度優化