springframework使用高版本的jdk编译,可以查看spring要求的jdk版本
Build from Source https://github.com/spring-projects/spring-framework/wiki/Build-from-Source。
git clone [email protected]:spring-projects/spring-framework.git
cd spring-framework
./gradlew build
打开IDEA->Gradle->spring->Tasks->build->build
spring
|--Tasks
|--build
|--assemble
|--build
构建成功
BUILD SUCCESSFUL in xxxxms
Could not determine the dependencies of task ‘:spring-core:cglibRepackJar’.
Could not resolve all files for configuration ‘:spring-core:cglib’.
Could not download cglib-3.3.0.jar (cglib:cglib:3.3.0)
> Could not get resource ‘https://repo.maven.apache.org/maven2/cglib/cglib/3.3.0/cglib
-3.3.0.jar’.
> Could not GET ‘https://repo.maven.apache.org/maven2/cglib/cglib/3.3.0/cglib-3.3.0
.jar’.
> The server may not support the client’s requested TLS protocol versions: (TLSv
1.2). You may need to configure the client to allow other protocols to be used. See: https:/
/docs.gradle.org/6.8.3/userguide/build_environment.html#gradle_system_properties
> sun.security.validator.ValidatorException: PKIX path building failed: sun.s
ecurity.provider.certpath.SunCertPathBuilderException: unable to find valid certification pa
th to requested targetTry:
Run with --stacktrace option to get the stack trace. Run with --info or --debug option to ge
t more log output. Run with --scan to get full insights.
在项目的gradle.properties
中配置代理
# 代理服务器ip或域名
systemProp.http.proxyHost=proxy.xxx.com
# 代理端口
systemProp.http.proxyPort=443
# 代理权限用户名
systemProp.http.proxyUser=user
# 代理权限密码
systemProp.http.proxyPassword=password
# 不需要代理地址,多个以|分割
systemProp.http.nonProxyHosts=localhost|xxx
spring-core\src\main\java\org\springframework\core
metrics\jfr\FlightRecorderStartupEvent.java:19: 错误: 程序包jdk.jfr不存在
import jdk.jfr.Category;
^
spring-core\src\main\java\org\springframework\core
metrics\jfr\FlightRecorderStartupEvent.java:20: 错误: 程序包jdk.jfr不存在
import jdk.jfr.Description;
^
spring-core\src\main\java\org\springframework\core
metrics\jfr\FlightRecorderStartupEvent.java:21: 错误: 程序包jdk.jfr不存在
import jdk.jfr.Event;
^
spring-core\src\main\java\org\springframework\core
metrics\jfr\FlightRecorderStartupEvent.java:22: 错误: 程序包jdk.jfr不存在
import jdk.jfr.Label;
^
spring-core\src\main\java\org\springframework\core
metrics\jfr\FlightRecorderStartupEvent.java:37: 错误: 找不到符号
由于gradle jvm还是采用jdk1.8等低版本导致的,需要修改为高版本jdk
如果使用IDEA直接编译,可以在IDEA中配置。打开settings->Build Tools->Gradle
或者直接在settings中搜索Gradle
编辑Gradle projects的Gradle JVM选择高版本jdk,然后点击Apply。
Execution failed for task ‘:spring-tx:compileKotlin’.
Could not resolve all files for configuration ‘:spring-tx:optional’.
Could not resolve com.ibm.websphere:uow:6.0.2.17.
Required by:
project :spring-tx
> Could not resolve com.ibm.websphere:uow:6.0.2.17.
> Could not get resource ‘https://repo.spring.io/libs-spring-framework-build/com/ibm/websphere/uow/6.0.2.17/uow-6.0.2.17.pom’.
> Could not GET ‘https://repo.spring.io/libs-spring-framework-build/com/ibm/websphere/uow/6.0.2.17/uow-6.0.2.17.pom’.
> The server may not support the client’s requested TLS protocol versions: (TLSv1, TLSv1.1, TLSv1.2). You may need to configure the client to allow other protocols to be used. See: https://docs.gradle.org/6.8.3/userguide/build_environment.html#gradle_system_properties
> PKIX path building failed: sun.security.provider.certpath.SunCertPathBuilderException: unable to find valid certification path to requested target
> Could not resolve com.ibm.websphere:uow:6.0.2.17.
> Could not get resource ‘https://repo.maven.apache.org/maven2/com/ibm/websphere/uow/6.0.2.17/uow-6.0.2.17.pom’.
> Could not GET ‘https://repo.maven.apache.org/maven2/com/ibm/websphere/uow/6.0.2.17/uow-6.0.2.17.pom’.
> The server may not support the client’s requested TLS protocol versions: (TLSv1, TLSv1.1, TLSv1.2). You may need to configure the client to allow other protocols to be used. See: https://docs.gradle.org/6.8.3/userguide/build_environment.html#gradle_system_properties
> PKIX path building failed: sun.security.provider.certpath.SunCertPathBuilderException: unable to find valid certification path to requested targetTry:
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.
在jre/lib/security目录下安装公司证书,并替换公司的仓库地址
修改仓库地址,可以替换为阿里云源
repositories {
mavenCentral()
// maven { url "https://repo.spring.io/libs-spring-framework-build" }
maven { url "https://maven.aliyun.com/repository/public" }
maven { url "https://maven.aliyun.com/repository/spring" }
}
```## 准备工作
### 确认本地有无spring要求的jdk版本
springframework使用高版本的jdk编译,可以查看spring要求的jdk版本
[Build from Source https://github.com/spring-projects/spring-framework/wiki/Build-from-Source](https://github.com/spring-projects/spring-framework/wiki/Build-from-Source)。
### 下载spring的源码
```shell
git clone [email protected]:spring-projects/spring-framework.git
cd spring-framework
./gradlew build
打开IDEA->Gradle->spring->Tasks->build->build
spring
|--Tasks
|--build
|--assemble
|--build
构建成功
BUILD SUCCESSFUL in xxxxms
Could not determine the dependencies of task ‘:spring-core:cglibRepackJar’.
Could not resolve all files for configuration ‘:spring-core:cglib’.
Could not download cglib-3.3.0.jar (cglib:cglib:3.3.0)
> Could not get resource ‘https://repo.maven.apache.org/maven2/cglib/cglib/3.3.0/cglib
-3.3.0.jar’.
> Could not GET ‘https://repo.maven.apache.org/maven2/cglib/cglib/3.3.0/cglib-3.3.0
.jar’.
> The server may not support the client’s requested TLS protocol versions: (TLSv
1.2). You may need to configure the client to allow other protocols to be used. See: https:/
/docs.gradle.org/6.8.3/userguide/build_environment.html#gradle_system_properties
> sun.security.validator.ValidatorException: PKIX path building failed: sun.s
ecurity.provider.certpath.SunCertPathBuilderException: unable to find valid certification pa
th to requested targetTry:
Run with --stacktrace option to get the stack trace. Run with --info or --debug option to ge
t more log output. Run with --scan to get full insights.
在项目的gradle.properties
中配置代理
# 代理服务器ip或域名
systemProp.http.proxyHost=proxy.xxx.com
# 代理端口
systemProp.http.proxyPort=443
# 代理权限用户名
systemProp.http.proxyUser=user
# 代理权限密码
systemProp.http.proxyPassword=password
# 不需要代理地址,多个以|分割
systemProp.http.nonProxyHosts=localhost|xxx
spring-core\src\main\java\org\springframework\core
metrics\jfr\FlightRecorderStartupEvent.java:19: 错误: 程序包jdk.jfr不存在
import jdk.jfr.Category;
^
spring-core\src\main\java\org\springframework\core
metrics\jfr\FlightRecorderStartupEvent.java:20: 错误: 程序包jdk.jfr不存在
import jdk.jfr.Description;
^
spring-core\src\main\java\org\springframework\core
metrics\jfr\FlightRecorderStartupEvent.java:21: 错误: 程序包jdk.jfr不存在
import jdk.jfr.Event;
^
spring-core\src\main\java\org\springframework\core
metrics\jfr\FlightRecorderStartupEvent.java:22: 错误: 程序包jdk.jfr不存在
import jdk.jfr.Label;
^
spring-core\src\main\java\org\springframework\core
metrics\jfr\FlightRecorderStartupEvent.java:37: 错误: 找不到符号
由于gradle jvm还是采用jdk1.8等低版本导致的,需要修改为高版本jdk
如果使用IDEA直接编译,可以在IDEA中配置。打开settings->Build Tools->Gradle
或者直接在settings中搜索Gradle
编辑Gradle projects的Gradle JVM选择高版本jdk,然后点击Apply。
Execution failed for task ‘:spring-tx:compileKotlin’.
Could not resolve all files for configuration ‘:spring-tx:optional’.
Could not resolve com.ibm.websphere:uow:6.0.2.17.
Required by:
project :spring-tx
> Could not resolve com.ibm.websphere:uow:6.0.2.17.
> Could not get resource ‘https://repo.spring.io/libs-spring-framework-build/com/ibm/websphere/uow/6.0.2.17/uow-6.0.2.17.pom’.
> Could not GET ‘https://repo.spring.io/libs-spring-framework-build/com/ibm/websphere/uow/6.0.2.17/uow-6.0.2.17.pom’.
> The server may not support the client’s requested TLS protocol versions: (TLSv1, TLSv1.1, TLSv1.2). You may need to configure the client to allow other protocols to be used. See: https://docs.gradle.org/6.8.3/userguide/build_environment.html#gradle_system_properties
> PKIX path building failed: sun.security.provider.certpath.SunCertPathBuilderException: unable to find valid certification path to requested target
> Could not resolve com.ibm.websphere:uow:6.0.2.17.
> Could not get resource ‘https://repo.maven.apache.org/maven2/com/ibm/websphere/uow/6.0.2.17/uow-6.0.2.17.pom’.
> Could not GET ‘https://repo.maven.apache.org/maven2/com/ibm/websphere/uow/6.0.2.17/uow-6.0.2.17.pom’.
> The server may not support the client’s requested TLS protocol versions: (TLSv1, TLSv1.1, TLSv1.2). You may need to configure the client to allow other protocols to be used. See: https://docs.gradle.org/6.8.3/userguide/build_environment.html#gradle_system_properties
> PKIX path building failed: sun.security.provider.certpath.SunCertPathBuilderException: unable to find valid certification path to requested targetTry:
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.
在jre/lib/security目录下安装公司证书,并替换公司的仓库地址
修改仓库地址,可以替换为阿里云源
repositories {
mavenCentral()
// maven { url "https://repo.spring.io/libs-spring-framework-build" }
maven { url "https://maven.aliyun.com/repository/public" }
maven { url "https://maven.aliyun.com/repository/spring" }
}