电脑知识|欧美黑人一区二区三区|软件|欧美黑人一级爽快片淫片高清|系统|欧美黑人狂野猛交老妇|数据库|服务器|编程开发|网络运营|知识问答|技术教程文章 - 好吧啦网

您的位置:首頁技術(shù)文章
文章詳情頁

Idea 搭建Spring源碼環(huán)境的超詳細(xì)教程

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

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

1. clone spring-framework 項(xiàng)目1.1 找到github spring-framwwork 項(xiàng)目

先登錄github 找到 spring-framework項(xiàng)目

https://github.com/spring-projects

Idea 搭建Spring源碼環(huán)境的超詳細(xì)教程

我選擇的是 5.0.x

Idea 搭建Spring源碼環(huán)境的超詳細(xì)教程

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

1.2 fork 到gitee 碼云

Idea 搭建Spring源碼環(huán)境的超詳細(xì)教程

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

Idea 搭建Spring源碼環(huán)境的超詳細(xì)教程

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

在下載的源碼中 有一個(gè)文件是 import-into-idea 的 md文件 里面有關(guān)于導(dǎo)入 idea需要的 注意事項(xiàng),我們來打開它

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 在源碼目錄下執(zhí)行

./gradlew :spring-oxm:compileTestJava

Idea 搭建Spring源碼環(huán)境的超詳細(xì)教程

Idea 搭建Spring源碼環(huán)境的超詳細(xì)教程

2.2 再導(dǎo)入導(dǎo) idea 中

會(huì)開始下載 Gradle 構(gòu)建工具 等,會(huì)根據(jù) gradle-wrapper.properties 中的指定版本下載,最好不要修改它的版本

Idea 搭建Spring源碼環(huán)境的超詳細(xì)教程

Idea導(dǎo)入 選擇文件夾

Idea 搭建Spring源碼環(huán)境的超詳細(xì)教程

選擇使用Gradle

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

靜靜的等待

Idea 搭建Spring源碼環(huán)境的超詳細(xì)教程

Idea 搭建Spring源碼環(huán)境的超詳細(xì)教程

2.3 排除 'spring-aspects'

排除了 spring-aspects 項(xiàng)目

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

Idea 搭建Spring源碼環(huán)境的超詳細(xì)教程

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

可以發(fā)現(xiàn) 依賴都加載完成后,idea 就能識(shí)別我們導(dǎo)入的 spring項(xiàng)目了,并且圖標(biāo)都變亮了

Idea 搭建Spring源碼環(huán)境的超詳細(xì)教程

3.引入自定義模塊放入SpringFramework 項(xiàng)目下

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

3.1 新建module

右擊項(xiàng)目 -》 new -》 module 選擇 gradle 項(xiàng)目

Idea 搭建Spring源碼環(huán)境的超詳細(xì)教程

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’ ,默認(rèn)使用我說的創(chuàng)建module 方式 會(huì)自動(dòng)添加的最好檢查一下

3.4 編寫 測(cè)試代碼

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環(huán)境搭建正確

Idea 搭建Spring源碼環(huán)境的超詳細(xì)教程

總結(jié)

本篇主要講解 如何使用idea 搭建spring源碼環(huán)境,過程其實(shí)很耗時(shí) 而且特別容易出錯(cuò),總結(jié)就是 1. clone 代碼,2.進(jìn)入源碼目錄執(zhí)行 ./gradlew :spring-oxm:compileTestJava3.導(dǎo)入idea 中 4. 排除 exclude the spring-aspects module 5.自定義module 驗(yàn)證環(huán)境 , 祝愿大家環(huán)境搭建順利。。。最好開個(gè)墻

本文由博客一文多發(fā)平臺(tái) OpenWrite 發(fā)布!

到此這篇關(guān)于Idea 搭建Spring源碼環(huán)境的文章就介紹到這了,更多相關(guān)Idea Spring源碼環(huán)境內(nèi)容請(qǐng)搜索好吧啦網(wǎng)以前的文章或繼續(xù)瀏覽下面的相關(guān)文章希望大家以后多多支持好吧啦網(wǎng)!

標(biāo)簽: Spring
相關(guān)文章:
主站蜘蛛池模板: 真空干燥烘箱_鼓风干燥箱 _高低温恒温恒湿试验箱_光照二氧化碳恒温培养箱-上海航佩仪器 | 恒温槽_恒温水槽_恒温水浴槽-上海方瑞仪器有限公司 | 垃圾清运公司_环卫保洁公司_市政道路保洁公司-华富环境 | 硅胶布|电磁炉垫片|特氟龙胶带-江苏浩天复合材料有限公司 | 耐高温硅酸铝板-硅酸铝棉保温施工|亿欧建设工程 | 电动手术床,医用护理床,led手术无影灯-曲阜明辉医疗设备有限公司 | 辐射仪|辐射检测仪|辐射巡测仪|个人剂量报警仪|表面污染检测仪|辐射报警仪|辐射防护网 | 空冷器|空气冷却器|空水冷却器-无锡赛迪森机械有限公司[官网] | 广域铭岛Geega(际嘉)工业互联网平台-以数字科技引领行业跃迁 | 仿古瓦,仿古金属瓦,铝瓦,铜瓦,铝合金瓦-西安东申景观艺术工程有限公司 | 天津拓展_天津团建_天津趣味运动会_天津活动策划公司-天津华天拓展培训中心 | 托利多电子平台秤-高精度接线盒-托利多高精度电子秤|百科 | 湖南长沙商标注册专利申请,长沙公司注册代理记账首选美创! | 多米诺-多米诺世界纪录团队-多米诺世界-多米诺团队培训-多米诺公关活动-多米诺创意广告-多米诺大型表演-多米诺专业赛事 | 变色龙云 - 打包app_原生app_在线制作平台_短链接_ip查询 | 北京网络营销推广_百度SEO搜索引擎优化公司_网站排名优化_谷歌SEO - 北京卓立海创信息技术有限公司 | PAS糖原染色-CBA流式多因子-明胶酶谱MMP-上海研谨生物科技有限公司 | 喷码机,激光喷码打码机,鸡蛋打码机,手持打码机,自动喷码机,一物一码防伪溯源-恒欣瑞达有限公司 | 陕西自考报名_陕西自学考试网| 土壤有机碳消解器-石油|表层油类分析采水器-青岛溯源环保设备有限公司 | 流变仪-热分析联用仪-热膨胀仪厂家-耐驰科学仪器商贸 | 泵阀展|阀门展|水泵展|流体机械展 -2025上海国际泵管阀展览会flowtech china | 泥沙分离_泥沙分离设备_泥砂分离机_洛阳隆中重工机械有限公司 | 卫生人才网-中国专业的医疗卫生医学人才网招聘网站! | 高防护蠕动泵-多通道灌装系统-高防护蠕动泵-www.bjhuiyufluid.com慧宇伟业(北京)流体设备有限公司 | 上海单片机培训|重庆曙海培训分支机构—CortexM3+uC/OS培训班,北京linux培训,Windows驱动开发培训|上海IC版图设计,西安linux培训,北京汽车电子EMC培训,ARM培训,MTK培训,Android培训 | 打造全球沸石生态圈 - 国投盛世| 玉米深加工设备|玉米加工机械|玉米加工设备|玉米深加工机械-河南成立粮油机械有限公司 | HDPE储罐_厂家-山东九州阿丽贝防腐设备| 外观设计_设备外观设计_外观设计公司_产品外观设计_机械设备外观设计_东莞工业设计公司-意品深蓝 | 气动绞车,山东气动绞车,气动绞车厂家-烟台博海石油机械有限公司 气动隔膜泵厂家-温州永嘉定远泵阀有限公司 | 无菌检查集菌仪,微生物限度仪器-苏州长留仪器百科 | 污水处理设备维修_污水处理工程改造_机械格栅_过滤设备_气浮设备_刮吸泥机_污泥浓缩罐_污水处理设备_污水处理工程-北京龙泉新禹科技有限公司 | 搪玻璃冷凝器_厂家-越宏化工设备 | 光栅尺_Magnescale探规_磁栅尺_笔式位移传感器_苏州德美达 | 等离子空气净化器_医用空气消毒机_空气净化消毒机_中央家用新风系统厂家_利安达官网 | 杭州中央空调维修_冷却塔/新风机柜/热水器/锅炉除垢清洗_除垢剂_风机盘管_冷凝器清洗-杭州亿诺能源有限公司 | 万家财经_财经新闻_在线财经资讯网 | 新型游乐设备,360大摆锤游乐设备「诚信厂家」-山东方鑫游乐设备 新能源汽车电池软连接,铜铝复合膜柔性连接,电力母排-容发智能科技(无锡)有限公司 | 创客匠人-让IP变现不走弯路 | 包装机_厂家_价格-山东包装机有限公司|