国产成人精品久久免费动漫-国产成人精品天堂-国产成人精品区在线观看-国产成人精品日本-a级毛片无码免费真人-a级毛片毛片免费观看久潮喷

您的位置:首頁技術文章
文章詳情頁

Idea 搭建Spring源碼環境的超詳細教程

瀏覽:65日期:2023-09-24 08:13:56

本篇主要講解如何使用Ideal 搭建Spring的源碼環境,想必大家都會多多少少去看過Spring的部分源碼,一般我們都是直接點進某個Spring類 然后Idea上面去下載 ,但是確實比較麻煩,而且不能添加自己對源碼的注釋 理解 ,本篇就來解決這個問題,手把手使用Idea 搭建Spring framework ,并且直接在Spring framework項目中添加我們自己的module 來驗證環境是否正確。 本過程會比較耗時 而且容易出錯 慢慢來吧。

1. clone spring-framework 項目1.1 找到github spring-framwwork 項目

先登錄github 找到 spring-framework項目

https://github.com/spring-projects

Idea 搭建Spring源碼環境的超詳細教程

我選擇的是 5.0.x

Idea 搭建Spring源碼環境的超詳細教程

如果你覺得你網速可以,那你可以直接從 github clone 下來, 我這里先把項目傳到 gitee

1.2 fork 到gitee 碼云

Idea 搭建Spring源碼環境的超詳細教程

拉取你要的 分支 git clone -b 分支

Idea 搭建Spring源碼環境的超詳細教程

2. 查看 import-into-idea.md 文件

在下載的源碼中 有一個文件是 import-into-idea 的 md文件 里面有關于導入 idea需要的 注意事項,我們來打開它

The following has been tested against IntelliJ IDEA 2016.2.2## Steps_Within your locally cloned spring-framework working directory:_1. Precompile `spring-oxm` with `./gradlew :spring-oxm:compileTestJava`2. Import into IntelliJ (File -> New -> Project from Existing Sources -> Navigate to directory -> Select build.gradle)3. When prompted exclude the `spring-aspects` module (or after the import via File-> Project Structure -> Modules)4. Code away## Known issues1. `spring-core` and `spring-oxm` should be pre-compiled due to repackaged dependencies.See `*RepackJar` tasks in the build and https://youtrack.jetbrains.com/issue/IDEA-160605).2. `spring-aspects` does not compile due to references to aspect types unknown toIntelliJ IDEA. See https://youtrack.jetbrains.com/issue/IDEA-64446 for details. In the meantime, the’spring-aspects’ can be excluded from the project to avoid compilation errors.3. While JUnit tests pass from the command line with Gradle, some may fail when run fromIntelliJ IDEA. Resolving this is a work in progress. If attempting to run all JUnit tests from withinIntelliJ IDEA, you will likely need to set the following VM options to avoid out of memory errors: -XX:MaxPermSize=2048m -Xmx2048m -XX:MaxHeapSize=2048m4. If you invoke 'Rebuild Project' in the IDE, you’ll have to generate some testresources of the `spring-oxm` module again (`./gradlew :spring-oxm:compileTestJava`) ## TipsIn any case, please do not check in your own generated .iml, .ipr, or .iws files.You’ll notice these files are already intentionally in .gitignore. The same policy goes for eclipse metadata.## FAQQ. What about IntelliJ IDEA’s own [Gradle support](https://confluence.jetbrains.net/display/IDEADEV/Gradle+integration)?A. Keep an eye on https://youtrack.jetbrains.com/issue/IDEA-53476

大致意思就是

2.1 在源碼目錄下執行

./gradlew :spring-oxm:compileTestJava

Idea 搭建Spring源碼環境的超詳細教程

Idea 搭建Spring源碼環境的超詳細教程

2.2 再導入導 idea 中

會開始下載 Gradle 構建工具 等,會根據 gradle-wrapper.properties 中的指定版本下載,最好不要修改它的版本

Idea 搭建Spring源碼環境的超詳細教程

Idea導入 選擇文件夾

Idea 搭建Spring源碼環境的超詳細教程

選擇使用Gradle

![image-20200924103346932](/Users/johnny/Library/Application Support/typora-user-images/image-20200924103346932.jpg)

靜靜的等待

Idea 搭建Spring源碼環境的超詳細教程

Idea 搭建Spring源碼環境的超詳細教程

2.3 排除 'spring-aspects'

排除了 spring-aspects 項目

打開settings.gradle 把 //include 'spring-aspects' 注釋了

Idea 搭建Spring源碼環境的超詳細教程

2.4 下載完依賴后 (耗時可能要個15-30分鐘)

可以發現 依賴都加載完成后,idea 就能識別我們導入的 spring項目了,并且圖標都變亮了

Idea 搭建Spring源碼環境的超詳細教程

3.引入自定義模塊放入SpringFramework 項目下

下面就是來驗證 我們的 源碼環境是否 正常, 需要引入一個自定義的 模塊,并且依賴 core bean 等spring依賴

3.1 新建module

右擊項目 -》 new -》 module 選擇 gradle 項目

Idea 搭建Spring源碼環境的超詳細教程

3.2 添加 依賴

在新建的module下 打開 build.gradle 引入下面的依賴 spring-beans , spring-context , spring-core , spring-expression

dependencies { testCompile group: ’junit’, name: ’junit’, version: ’4.12’ compile(project(':spring-beans')) compile(project(':spring-context')) compile(project(':spring-core')) compile(project(':spring-expression'))}3.3 檢查 module 是否被引入

打開settings.gradle 添加 include ’spring-demo’ ,默認使用我說的創建module 方式 會自動添加的最好檢查一下

3.4 編寫 測試代碼

3.4.1 定義Person類

package com.johnny.bean;/** * @author johnny * @create 2020-09-07 下午11:22 **/public class Person { private String name; private int age; @Override public String toString() { return 'Person{' + 'name=’' + name + ’’’ + ', age=' + age + ’}’; } public String getName() { return name; } public void setName(String name) { this.name = name; } public int getAge() { return age; } public void setAge(int age) { this.age = age; }}

3.4.2 resources 下新建 demo.xml

<?xml version='1.0' encoding='UTF-8'?><beans xmlns='http://www.springframework.org/schema/beans' xmlns:xsi='http://www.w3.org/2001/XMLSchema-instance' xsi:schemaLocation='http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd'> <bean id='person'> <property name='name' value='johnny'/> <property name='age' value='10'/> </bean></beans>

3.4.3 新建main 加載xml 并且從容器中獲取 bean

package com.johnny.bean;import org.springframework.context.support.ClassPathXmlApplicationContext;/** * @author johnny * @create 2020-09-07 下午11:24 **/public class DemoMain { public static void main(String[] args) { ClassPathXmlApplicationContext classPathXmlApplicationContext = new ClassPathXmlApplicationContext('demo.xml'); Person person = classPathXmlApplicationContext.getBean(Person.class); System.out.println(person); }}

可以看到 能獲取到 容器中的Bean ,表示我們的spring環境搭建正確

Idea 搭建Spring源碼環境的超詳細教程

總結

本篇主要講解 如何使用idea 搭建spring源碼環境,過程其實很耗時 而且特別容易出錯,總結就是 1. clone 代碼,2.進入源碼目錄執行 ./gradlew :spring-oxm:compileTestJava3.導入idea 中 4. 排除 exclude the spring-aspects module 5.自定義module 驗證環境 , 祝愿大家環境搭建順利。。。最好開個墻

本文由博客一文多發平臺 OpenWrite 發布!

到此這篇關于Idea 搭建Spring源碼環境的文章就介紹到這了,更多相關Idea Spring源碼環境內容請搜索好吧啦網以前的文章或繼續瀏覽下面的相關文章希望大家以后多多支持好吧啦網!

標簽: Spring
相關文章:
主站蜘蛛池模板: 亚洲经典乱码在线播 | 欧美xx在线观看 | 日韩亚洲欧美一区噜噜噜 | 国产成人高清一区二区私人 | 老司机黄色影院 | 精品欧美成人高清在线观看2021 | 国产综合精品在线 | 日本美女高清在线观看免费 | 日韩天天摸天天澡天天爽视频 | 久草最新在线 | 99久在线| 国产成人综合亚洲 | 日本一级特黄a大片在线 | 日本免费久久 | 99久久精品毛片免费播放 | 欧美成人自拍视频 | 亚洲国产成人久久一区www | 久久精品免费播放 | 亚洲三级视频在线观看 | 国产精品国产精品 | 有码日韩| 日韩一区二区三区在线免费观看 | 亚洲国产剧情在线精品视 | 久久精品国产影库免费看 | 玖玖爱精品 | 夜夜操影院 | 91黑丝国产线观看免费 | 成人做爰视频www网站 | 国产精品久久久久久久久岛 | 亚洲第一成年网站大全亚洲 | 国产日韩欧美一区二区三区综合 | 在线播放成人毛片免费视 | 欧美大尺度免费一级特黄 | 中国女人18xnxx视频 | 91成人免费观看 | 亚洲精品一区二区 | 殴美一级| 天天澡夜夜澡狠狠澡 | 日本a级三级三级三级久久 日本a级特黄三级三级三级 | 国产网站免费 | 特级aa毛片在线播放 |