• spring5.3.x源码构建


    spring 5.3.x源码构建

    一、fork spring仓库

    把spring的仓库导入到自己的gitee仓库中,拉去速度更快。下面是我自己的仓库地址

    拉取出5.3.x版本的spring源码

    git clone -b 5.3.x https://gitee.com/haijun1998/spring-framework.git

    二、安装gralde

    根据编译spring版本来决定使用什么版本的gradle。查看源码下 gradlewrappergradle-wrapper.properties 中需要什么版本

    在这里插入图片描述

    下载好gradle-7.2版本,配置环境变量

    在这里插入图片描述

    防止spring每次编译都去下载gradle安装包,将distributionUrl改成本地文件路径

    在这里插入图片描述
    在设置里面设置成自己的gradle位置,不然idea每次都会使用gradle-wrapper路径下面的文件进行构建,也就是每次都会去下载包,然后在gradle_user_home下面创建一个wrapper文件,并且安装一个额外的gradle
    在这里插入图片描述
    在这里插入图片描述

    三、编译spring

    导入spring源码到idea中,加入依赖

    buildscript { 
    	repositories { 
    		maven { url "https://repo.spring.io/plugins-release" } 
    	} 
     }
    
    • 1
    • 2
    • 3
    • 4
    • 5

    在这里插入图片描述

    在这里插入图片描述

    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" }  
    	//新增spring插件库 
    	maven { url "https://repo.spring.io/plugins-release" } 
    }
    
    • 1
    • 2
    • 3
    • 4
    • 5
    • 6
    • 7
    • 8
    • 9

    设置项目sdk版本

    在这里插入图片描述

    找到spring-oxm以及spring-core下的compileTestjava进行编译

    编译成功后,编译整个工程,spring>build>build

    在这里插入图片描述

    四、创建新的子模块

    在这里插入图片描述

    引入依赖

    在这里插入图片描述
    注意如果使用compiler() 进行引入模块可能会失败,改为api() 进行引入

    再次编译spring项目,成功后运行测试代码

    @Configuration
    public class ApplicationTestDemo {
    
    	public static void main(String[] args) {
    		System.out.println("hello");
    		AnnotationConfigApplicationContext configApplicationContext = new AnnotationConfigApplicationContext(ApplicationTestDemo.class);
    		A a = configApplicationContext.getBean(A.class);
    		System.out.println(a.name);
    	}
    
    	@Bean
    	public A a(){
    		return new A();
    	}
    
    	public static class A {
    		public String name = "我是张三啊";
    	}
    
    }
    
    • 1
    • 2
    • 3
    • 4
    • 5
    • 6
    • 7
    • 8
    • 9
    • 10
    • 11
    • 12
    • 13
    • 14
    • 15
    • 16
    • 17
    • 18
    • 19
    • 20

    最后可以去掉spring模块下面的 src/checkstyle/checkstyle.xml,内容注释掉,风格检查

    在这里插入图片描述

    五、异常问题

    下面是搜寻到会出现的问题
    在这里插入图片描述

    在这里插入图片描述

    六、模块说明

    在这里插入图片描述

  • 相关阅读:
    C++的结构体
    vulnhub靶机Thoth-Tech
    快速认识什么是:Docker
    网络安全攻击的常见类型
    【JVM】Java内存模型
    有趣的曲线
    机器学习数据预处理—统计分析方法
    Mysql-体系结构
    Linux权限
    在浏览器输入url到页面展示出来
  • 原文地址:https://blog.csdn.net/m0_67394360/article/details/126506353