网站开发保存学习进度的方案,网站的根目录怎么找,领导高度重视网站建设,淘宝关键词搜索量排名前言#xff1a; 三年前鄙人有幸在现已几乎报废的Window的DELL中搭建过Spring源码环境#xff0c;今天#xff0c;Mac版的搭建#xff0c;来了。 本篇文章环境搭建#xff1a;Spring5.2.1 Gradle5.6.3-all jdk8 IDEA2022.3版本 文章目录 1、Spring源码下载2、Gradle下载…前言 三年前鄙人有幸在现已几乎报废的Window的DELL中搭建过Spring源码环境今天Mac版的搭建来了。 本篇文章环境搭建Spring5.2.1 Gradle5.6.3-all jdk8 IDEA2022.3版本 文章目录 1、Spring源码下载2、Gradle下载3、配置Gradle环境变量4、配置Gradle镜像等5、编译Spring源码6、新建自己的模块用来学习Debug源码7、编写Demo代码运行测试8、IDEA运行程序加快运行时间指南 1、Spring源码下载
官方下载spring源码 https://github.com/spring-projects/spring-framework 记得下载RELEASE版本
2、Gradle下载
gradle下载地址 https://services.gradle.org/distributions/
3、配置Gradle环境变量
终端运行
open -e ~/.bash_profile内容如下
GRADLE_HOME/Users/mr.guo/gradle-5.6.3
export GRADLE_HOME
export PATH${PATH}:/Users/mr.guo/gradle-5.6.3/bin刷新环境变量
source ~/.bash_profile 执行 gradle -version如下则成功
4、配置Gradle镜像等 打开build.gradle文件这个就相当于是maven的pom文件在文件头部加上如下两个地方 buildscript {repositories {maven { url https://repo.spring.io/plugins-release }}
}repositories {//新增以下2个阿里云镜像maven { url https://maven.aliyun.com/nexus/content/groups/public/ }maven { url https://maven.aliyun.com/nexus/content/repositories/jcenter }mavenCentral()maven { url https://repo.spring.io/libs-spring-framework-build }maven { url https://repo.spring.io/milestone } // Reactor//新增spring插件库maven { url https://repo.spring.io/plugins-release }
}
以上完成后刷新开始构建等待一定时间后如果构建失败重新refresh几次就行了一般就是包下载超时之类的错误。 以上只是Gradle下载依赖如下才是真正的编译源码 5、编译Spring源码 根据官方的import-into-idea.md文档可以得知我们需要如下的操作 经过一段时间编译每个人电脑的性能不一样所需时间也不一样。 编译过程中会出现好几次失败非常正常多刷新几次编译不排除有别的异常确实需要自行goole解决。 6、新建自己的模块用来学习Debug源码 然后需要手工添加spring-contextspring-beansspring-corespring-aop这4个核心模块 7、编写Demo代码运行测试 package demo;
import org.springframework.stereotype.Service;Service
public class UserServiceImpl {public void sayHiSpring(){System.out.println(Hello Spring);}
}
package demo;import org.springframework.context.ApplicationContext;
import org.springframework.context.annotation.AnnotationConfigApplicationContext;
import org.springframework.context.annotation.ComponentScan;
import org.springframework.context.annotation.Configuration;Configuration
ComponentScan(demo)
public class MainStat {public static void main(String[] args) {ApplicationContext contextnew AnnotationConfigApplicationContext(MainStat.class);UserServiceImpl bean context.getBean(UserServiceImpl.class);bean.sayHiSpring();}}完成如下 end…
8、IDEA运行程序加快运行时间指南
如果是运行会打印很多Task是因为默认是Gradle运行的 需要如下设置