spring源码编译笔记

下载源码

地址https://github.com/spring-projects/spring-framework/tree/v5.2.9.RELEASE
在这里插入图片描述

查看gradle对应版本

spring-framework-5.2.9.RELEASE/gradle/wrapper/gradle-wrapper.properties

# 其他配置暂未了解具体用处,一切默认值
distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
#默认通过网络从https\://services.gradle.org/distributions/gradle-5.6.4-bin.zip地址进行下载,可以下载后放到spring-framework-5.2.9.RELEASE/gradle/wrapper/下,避免因为网络导致下载失败
#distributionUrl=https\://services.gradle.org/distributions/gradle-5.6.4-bin.zip
distributionUrl=gradle-5.6.4-bin.zip
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists

请添加图片描述

进行gradle电脑本地化配置

# 源码解压后目录 spring-framework-5.2.9.RELEASE 中执行命令
sh gradlew

不知道为什么出现下面的问题,百度得到的答案是注释掉依赖

FAILURE: Build failed with an exception.

* Where:
Build file '/***/spring-framework-5.2.9.RELEASE/build.gradle' line: 3

* What went wrong:
Plugin [id: 'io.spring.gradle-enterprise-conventions', version: '0.0.2'] was not found in any of the following sources:

- Gradle Core Plugins (plugin is not in 'org.gradle' namespace)
- Plugin Repositories (could not resolve plugin artifact 'io.spring.gradle-enterprise-conventions:io.spring.gradle-enterprise-conventions.gradle.plugin:0.0.2')
  Searched in the following repositories:
    Gradle Central Plugin Repository
    maven(https://repo.spring.io/plugins-release)

* Try:
Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output. Run with --scan to get full insights.

* Get more help at https://help.gradle.org

BUILD FAILED in 3s

执行成功

> Task :help

Welcome to Gradle 5.6.4.

To run a build, run gradlew <task> ...

To see a list of available tasks, run gradlew tasks

To see a list of command-line options, run gradlew --help

To see more detail about a task, run gradlew help --task <task>

For troubleshooting, visit https://help.gradle.org

BUILD SUCCESSFUL in 4s
1 actionable task: 1 executed

导入idea步骤

根据spring-framework-5.2.9.RELEASE/import-into-idea.md中目录操作
请添加图片描述

  1. 使用 ./gradlew :spring-oxm:compileTestJava 命令编译 spring-oxm

    spring-framework-5.2.9.RELEASE % ./gradlew :spring-oxm:compileTestJava
    
    > Task :spring-oxm:genJaxb
    [ant:javac] : warning: 'includeantruntime' was not set, defaulting to build.sysclasspath=last; set to false for repeatable builds
    [ant:javac] 警告: [options] 未与 -source 8 一起设置引导类路径
    [ant:javac] 1 个警告
    
    BUILD SUCCESSFUL in 6s
    40 actionable tasks: 22 executed, 18 from cache
    
  2. 将项目到入idea中

    File -> New -> Project from Existing sources
    请添加图片描述

选中spring-framework-5.2.9.RELEASE/build.gradle

请添加图片描述

idea配置gradle信息

Use Gradle from :Specified location 使用本地的gradle配置

[外链图片转存失败,源站可能有防盗链机制,建议将图片保存下来直接上传(img-wtM6h7EQ-1688043530376)(spring-framework-5.2.9.RELEASE%E6%BA%90%E7%A0%81%E7%BC%96%E8%AF%91.assets/image-20230629195345193.png)]

错误解决

Kotlin: warnings found and -Weeror specified

使用如下强制措施,关闭Kotlin的-Weeror校验,删除-Weeror。

请添加图片描述
java: 找不到符号
符号: 变量 CoroutinesUtils
位置: 类 org.springframework.core.ReactiveAdapterRegistry.CoroutinesRegistrar

	// 引入依赖
    compile(project(":kotlin-coroutines"))

将编译好的代码上传git后,在其他电脑重新拉取后报org.springframework.aop.target不存在

> Task :spring-aop:compileJava FAILED
/Users/zzw/Documents/sourcecode/spring-framework-5.2.9/spring-aop/src/main/java/org/springframework/aop/framework/AdvisedSupport.java:38: 错误: 程序包org.springframework.aop.target不存在
import org.springframework.aop.target.EmptyTargetSource;
                                    ^
/Users/zzw/Documents/sourcecode/spring-framework-5.2.9/spring-aop/src/main/java/org/springframework/aop/framework/AdvisedSupport.java:39: 错误: 程序包org.springframework.aop.target不存在
import org.springframework.aop.target.SingletonTargetSource;
                                    ^
/Users/zzw/Documents/sourcecode/spring-framework-5.2.9/spring-aop/src/main/java/org/springframework/aop/framework/AbstractSingletonProxyFactoryBean.java:22: 错误: 程序包org.springframework.aop.target不存在
import org.springframework.aop.target.SingletonTargetSource;
                                    ^
/Users/zzw/Documents/sourcecode/spring-framework-5.2.9/spring-aop/src/main/java/org/springframework/aop/framework/autoproxy/AbstractAutoProxyCreator.java:40: 错误: 程序包org.springframework.aop.target不存在
import org.springframework.aop.target.SingletonTargetSource;
                                    ^
/Users/zzw/Documents/sourcecode/spring-framework-5.2.9/spring-aop/src/main/java/org/springframework/aop/framework/ProxyFactoryBean.java:36: 错误: 程序包org.springframework.aop.target不存在
import org.springframework.aop.target.SingletonTargetSource;
                                    ^
/Users/zzw/Documents/sourcecode/spring-framework-5.2.9/spring-aop/src/main/java/org/springframework/aop/framework/AopProxyUtils.java:28: 错误: 程序包org.springframework.aop.target不存在
import org.springframework.aop.target.SingletonTargetSource;
                                    ^
/Users/zzw/Documents/sourcecode/spring-framework-5.2.9/spring-aop/src/main/java/org/springframework/aop/scope/ScopedProxyFactoryBean.java:25: 错误: 程序包org.springframework.aop.target不存在
import org.springframework.aop.target.SimpleBeanTargetSource;

解决
在.gitignore 文件中 target 被忽略了;因此上传git时该目录未上传成功
spring-aop/org.springframework.aop.target

配置国内Maven镜像

// /***/spring-framework-5.2.9.RELEASE/build.gradle	
repositories {
        mavenCentral()
        maven { url "https://repo.spring.io/libs-spring-framework-build" }
        maven { url "https://repo.spring.io/snapshot" } // Reactor
        maven { url 'https://maven.aliyun.com/nexus/content/groups/public/'} //阿里云
        maven { url 'https://maven.aliyun.com/nexus/content/repositories/jcenter'}
} 
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值