日韩性视频-久久久蜜桃-www中文字幕-在线中文字幕av-亚洲欧美一区二区三区四区-撸久久-香蕉视频一区-久久无码精品丰满人妻-国产高潮av-激情福利社-日韩av网址大全-国产精品久久999-日本五十路在线-性欧美在线-久久99精品波多结衣一区-男女午夜免费视频-黑人极品ⅴideos精品欧美棵-人人妻人人澡人人爽精品欧美一区-日韩一区在线看-欧美a级在线免费观看

歡迎訪問 生活随笔!

生活随笔

當(dāng)前位置: 首頁 > 前端技术 > javascript >内容正文

javascript

idea 编译spring_Spring 源码阅读环境的搭建

發(fā)布時間:2024/7/23 javascript 58 豆豆
生活随笔 收集整理的這篇文章主要介紹了 idea 编译spring_Spring 源码阅读环境的搭建 小編覺得挺不錯的,現(xiàn)在分享給大家,幫大家做個參考.

" 前言
本文記錄了 Spring 源碼環(huán)境的搭建方式,以及踩過的那些坑!?當(dāng)前版本:5.3.2-SNAPSHOT。

環(huán)境準(zhǔn)備

  • Git
  • JDK
  • master 分支需要 JDK 11
  • 5.2.x 分支, JDK8 即可
  • Gradle 6.5.1
  • IDEA 最新 (2020.2.3)
  • Spring 源碼倉庫地址:https://github.com/spring-projects/spring-framework

    下載源碼

  • clone 源碼
  • git clone https://github.com/spring-projects/spring-framework.git

    2. 使用 IDEA 打開

    3. 等待 IDEA 加載完成即可。

    注: 也可以指定 clone 的分支

    git clone -b 5.2.x https://github.com/spring-projects/spring-framework.git

    或者先 fork 到自己的倉庫,然后再 clone。

    這里我是 fork 到我的倉庫,然后再 clone 的。

    當(dāng)前 master 分支代表的版本為 5.3.2-SNAPSHOT。

    執(zhí)行測試

    • 在項目右鍵創(chuàng)建 module

    • 選擇 Gradle Java

    • 創(chuàng)建 module

    • 在 build.gradle 中添加配置
    compile(project(":spring-context"))

    • 創(chuàng)建測試類并測試

    其中 UserComponent 添加了 @Component 注解, 程序正常執(zhí)行則一切 OK??梢蚤_始愉快的調(diào)試代碼了。

    問題總結(jié)

    編譯失敗

    有小伙伴直接下載 zip 包,可能遇到以下問題:(非常不建議直接下載 zip 包構(gòu)建,想知道原因可以繼續(xù)看,最后我也沒有構(gòu)建成功,而是直接通過 clone 構(gòu)建的。)

  • 報錯如下:
  • fatal: not a git repository (or any of the parent directories): .gitBUILD SUCCESSFUL in 14s Build scan background action failed. org.gradle.process.internal.ExecException: Process 'command 'git'' finished with non-zero exit value 128 ... 其他省略

    看意思是沒有 git 配置,那就添加上吧!

    2. 這時候想著添加 git

    VCS -> Enable Version Control Integration... -> 右上角 Reload All Gradle Projects

    依然報錯

    fatal: Needed a single revision

    3. 查詢問題

    issues 地址:https://github.com/spring-projects/spring-framework/issues/24467

    建議使用

    $ git clone git@github.com:spring-projects/spring-framework.git

    意思就是 zip 發(fā)行版主要是用來共享源代碼,但不一定用于構(gòu)建它。

    4. 最后我選擇了使用 clone 的方式,直接 clone 下來,然后 build 通過。

    缺少 cglib 和 objenesis 包

    Kotlin: warnings found and -Weeror specified

    沒有 spring-cglib-repack 和 spring-objenesis-repack 包

    執(zhí)行這兩個即可。

    找不到包 jdk.jfr

    import jdk.jfr.Category; import jdk.jfr.Description; import jdk.jfr.Event; import jdk.jfr.Label;

    JDK 升級為 11。因為我本地使用的是 JDK8,發(fā)現(xiàn)報錯,jfr 包需要升級 JDK 11 才有。

    如果不生效,可以通過:

    IDEA -> File -> Project Structure -> Project 檢查下是否修改為 JDK 11

    快捷鍵:? + ;

    相關(guān)資料

  • Spring 倉庫:https://github.com/spring-projects/spring-framework
  • Spring 構(gòu)建文檔:https://github.com/spring-projects/spring-framework/wiki/Build-from-Source
  • 歷史文章

    • ReentrantLock 源碼、畫圖一起看一看!
    • ReentrantReadWriteLock 的原理!
    • Spring 自調(diào)用事務(wù)失效,你是怎么解決的?

    總結(jié)

    以上是生活随笔為你收集整理的idea 编译spring_Spring 源码阅读环境的搭建的全部內(nèi)容,希望文章能夠幫你解決所遇到的問題。

    如果覺得生活随笔網(wǎng)站內(nèi)容還不錯,歡迎將生活随笔推薦給好友。