您当前的位置: 首页 >  java持续实践 spring

Spring源码编译 (基于Spring5.2.0 RELEASE 版本)

java持续实践 发布时间:2021-02-11 15:41:42 ,浏览量:4

文章目录

      • 一. 下载源码
      • 二. 编译源码
      • 三. 编译oxm 模块
      • 四. 导入IDE
      • 五. 排除spring-aspects 模块

一. 下载源码

https://github.com/spring-projects/spring-framework/tree/v5.2.0.RELEASE
在Spring的GitHub仓库中, 选择5.2.0.RELEASE的版本进行下载到本地. 可以下载zip 包, 或者使用git clone命令进行下载

二. 编译源码

在源码的readme中, 有编译源码的教程 ,点击下面的超链接.

跳转到如下的网址
https://github.com/spring-projects/spring-framework/wiki/Build-from-Source
点击页面最下方导入到ide的方法.

跳转到如下的页面
https://github.com/spring-projects/spring-framework/blob/master/import-into-idea.md
根据链接中内容, 需要如下的这几步来进行编译操作 .

Precompile spring-oxm with ./gradlew :spring-oxm:compileTestJava
Import into IntelliJ (File -> New -> Project from Existing Sources -> Navigate to directory -> Select build.gradle)
When prompted exclude the spring-aspects module (or after the import via File-> Project Structure -> Modules)
Code away

首先需要预编译 spring-oxm

下载的源码中, 有gradlew文件, 此文件会自动去下载gradle

用编辑器打开build.gradle 文件, 此文件, 类似于maven的pom.xml文件. 在此文件中配置阿里云的进行, 便于快速下载依赖的jar包.

在文件的开头处, 添加阿里云镜像.

repositories {
        maven{ url 'https://maven.aliyun.com/nexus/content/groups/public/' }
        maven{ url 'https://maven.aliyun.com/nexus/content/repositories/jcenter'}
    }

接着在文件中搜索allprojects
在其底部找到repositories, 也添加上阿里云的依赖.

repositories {
			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" }
		}

三. 编译oxm 模块

保存上一步修改的文件, 在源码的目录中

cmd中执行如下的命令
gradlew :spring-oxm:compileTestJava 进行编译 .

等待完成后, 可以看到编译成功的信息.

四. 导入IDE

按照如下的步骤, 进行项目的导入.



导入到idea 后, 需要等待其jar包的下载.

经过10 分钟的等待后 , 可以看到jar包下载完成.

五. 排除spring-aspects 模块

之所以排除spring-aspects , 是因为spring-aspects 使用的是自己的编译器, 会影响其他模块的编译和加载,
打开spring-aspects 模块中某一个类, 可以看到其飘红的代码.

选择spring-aspects 模块, 右键 , 选择Load/Unload Modules

关注
打赏
查看更多评论

java持续实践

暂无认证

  • 4浏览

    0关注

    583博文

    0收益

  • 0浏览

    0点赞

    0打赏

    0留言

私信
关注
热门博文
立即登录/注册

微信扫码登录