网站外链建设培训,精准营销方式有哪些,自己怎么开发app软件,深圳企业管理咨询公司排名这篇文章记录了下载spring源码和在IDEA中打开运行的全过程#xff0c;并且记录了过程中遇到的问题和解决方案#xff0c;适合需要学习spring源码的同学阅读。
1.spring源码下载地址
通过Git下载spring-framework项目源码#xff1a;
git clone https://github.com/spring…
这篇文章记录了下载spring源码和在IDEA中打开运行的全过程并且记录了过程中遇到的问题和解决方案适合需要学习spring源码的同学阅读。
1.spring源码下载地址
通过Git下载spring-framework项目源码
git clone https://github.com/spring-projects/spring-framework.git 2.使用IDEA构建spring-framework源码
笔者用的IDEA版本是社区版IDEAIntelliJ IDEA 2020.34(Community Edition)用IDEA打开源码后IDEA会自动加载Gradle项目依赖。
然后这里就遇到了第一个问题 2.1 SSL证书验证不通过无该问题可跳过 SunCertPathBuilderException: unable to find valid certification path to requested target - Mkyong.com javax.net.ssl.SSLHandshakeException: sun.security.validator.ValidatorException: PKIX path building_迷茫期。。。的博客-CSDN博客 Caused by: sun.security.validator.ValidatorException: PKIX path building failed: sun.security.provider.certpath.SunCertPathBuilderException: unable to find valid certification path to requested targetat sun.security.validator.PKIXValidator.doBuild(PKIXValidator.java:439)at sun.security.validator.PKIXValidator.engineValidate(PKIXValidator.java:306)at sun.security.validator.Validator.validate(Validator.java:271)at sun.security.ssl.X509TrustManagerImpl.validate(X509TrustManagerImpl.java:312)at sun.security.ssl.X509TrustManagerImpl.checkTrusted(X509TrustManagerImpl.java:221)at sun.security.ssl.X509TrustManagerImpl.checkServerTrusted(X509TrustManagerImpl.java:128)at sun.security.ssl.CertificateMessage$T12CertificateConsumer.checkServerCerts(CertificateMessage.java:630)... 126 more
Caused by: sun.security.provider.certpath.SunCertPathBuilderException: unable to find valid certification path to requested targetat sun.security.provider.certpath.SunCertPathBuilder.build(SunCertPathBuilder.java:141)at sun.security.provider.certpath.SunCertPathBuilder.engineBuild(SunCertPathBuilder.java:126)at java.security.cert.CertPathBuilder.build(CertPathBuilder.java:280)at sun.security.validator.PKIXValidator.doBuild(PKIXValidator.java:434) Task :buildSrc:compileJava FAILED
1 actionable task: 1 executedA build scan was not published as you have not authenticated with server ge.spring.io.
For more information, please see https://gradle.com/help/gradle-authenticating-with-gradle-enterprise.
The remote build cache was disabled during the build due to errors. 2.1.1 新建InstallCert .java文件
/*- Copyright 2006 Sun Microsystems, Inc. All Rights Reserved.- - Redistribution and use in source and binary forms, with or without- modification, are permitted provided that the following conditions- are met:- - - Redistributions of source code must retain the above copyright- notice, this list of conditions and the following disclaimer.- - - Redistributions in binary form must reproduce the above copyright- notice, this list of conditions and the following disclaimer in the- documentation and/or other materials provided with the distribution.- - - Neither the name of Sun Microsystems nor the names of its- contributors may be used to endorse or promote products derived- from this software without specific prior written permission.- - THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS AS- IS AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,- THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR- PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR- CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,- EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,- PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR- PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF- LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING- NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS- SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.*/import java.io.*;
import java.net.URL;import java.security.*;
import java.security.cert.*;import javax.net.ssl.*;public class InstallCert {public static void main(String[] args) throws Exception {String host;int port;char[] passphrase;if ((args.length 1) || (args.length 2)) {String[] c args[0].split(:);host c[0];port (c.length 1) ? 443 : Integer.parseInt(c[1]);String p (args.length 1) ? changeit : args[1];passphrase p.toCharArray();} else {System.out.println(Usage: java InstallCert host[:port] [passphrase]);return;}File file new File(jssecacerts);if (file.isFile() false) {char SEP File.separatorChar;File dir new File(System.getProperty(java.home) SEP lib SEP security);file new File(dir, jssecacerts);if (file.isFile() false) {file new File(dir, cacerts);}}System.out.println(Loading KeyStore file ...);InputStream in new FileInputStream(file);KeyStore ks KeyStore.getInstance(KeyStore.getDefaultType());ks.load(in, passphrase);in.close();SSLContext context SSLContext.getInstance(TLS);TrustManagerFactory tmf TrustManagerFactory.getInstance(TrustManagerFactory.getDefaultAlgorithm());tmf.init(ks);X509TrustManager defaultTrustManager (X509TrustManager)tmf.getTrustManagers()[0];SavingTrustManager tm new SavingTrustManager(defaultTrustManager);context.init(null, new TrustManager[] {tm}, null);SSLSocketFactory factory context.getSocketFactory();System.out.println(Opening connection to host : port ...);SSLSocket socket (SSLSocket)factory.createSocket(host, port);socket.setSoTimeout(10000);try {System.out.println(Starting SSL handshake...);socket.startHandshake();socket.close();System.out.println();System.out.println(No errors, certificate is already trusted);} catch (SSLException e) {System.out.println();e.printStackTrace(System.out);}X509Certificate[] chain tm.chain;if (chain null) {System.out.println(Could not obtain server certificate chain);return;}BufferedReader reader new BufferedReader(new InputStreamReader(System.in));System.out.println();System.out.println(Server sent chain.length certificate(s):);System.out.println();MessageDigest sha1 MessageDigest.getInstance(SHA1);MessageDigest md5 MessageDigest.getInstance(MD5);for (int i 0; i chain.length; i) {X509Certificate cert chain[i];System.out.println( (i 1) Subject cert.getSubjectDN());System.out.println( Issuer cert.getIssuerDN());sha1.update(cert.getEncoded());System.out.println( sha1 toHexString(sha1.digest()));md5.update(cert.getEncoded());System.out.println( md5 toHexString(md5.digest()));System.out.println();}System.out.println(Enter certificate to add to trusted keystore or q to quit: [1]);String line reader.readLine().trim();int k;try {k (line.length() 0) ? 0 : Integer.parseInt(line) - 1;} catch (NumberFormatException e) {System.out.println(KeyStore not changed);return;}X509Certificate cert chain[k];String alias host - (k 1);ks.setCertificateEntry(alias, cert);OutputStream out new FileOutputStream(jssecacerts);ks.store(out, passphrase);out.close();System.out.println();System.out.println(cert);System.out.println();System.out.println(Added certificate to keystore jssecacerts using alias alias );}private static final char[] HEXDIGITS 0123456789abcdef.toCharArray();private static String toHexString(byte[] bytes) {StringBuilder sb new StringBuilder(bytes.length * 3);for (int b : bytes) {b 0xff;sb.append(HEXDIGITS[b 4]);sb.append(HEXDIGITS[b 15]);sb.append( );}return sb.toString();}private static class SavingTrustManager implements X509TrustManager {private final X509TrustManager tm;private X509Certificate[] chain;SavingTrustManager(X509TrustManager tm) {this.tm tm;}public X509Certificate[] getAcceptedIssuers() {throw new UnsupportedOperationException();}public void checkClientTrusted(X509Certificate[] chain, String authType)throws CertificateException {throw new UnsupportedOperationException();}public void checkServerTrusted(X509Certificate[] chain, String authType)throws CertificateException {this.chain chain;tm.checkServerTrusted(chain, authType);}}}2.1.2 编译InstallCert .java
javac InstallCert.java
2.1.3 运行InstallCert生成jssecacerts文件
--输入命令域名换成自己idea访问报错的域名或者ip
java InstallCert ge.spring.io:443 命令执行后会要求输入数字1生成证书文件 出现如下信息就代表安装成功 2.1.4 将同目录下生成的jssecacerts文件添加到$JAVA_HOME/jre/lib/security 2.1.5 重启IDEA注意重启不然可能不会生效
这个问题这样就解决啦
不过又出现了新的问题 2.2 KotlinConventions类编译失败 Task :buildSrc:compileJava FAILED
D:\Users\project\spring-framework\buildSrc\src\main\java\org\springframework\build\KotlinConventions.java:44: : ҲfreeCompilerArgs.addAll(List.of(-Xsuppress-version-warnings, -Xjsr305strict, -opt-inkotlin.RequiresOptIn));^: of(java.lang.String,java.lang.String,java.lang.String)λ: ӿ java.util.List
1
2.2.1 问题原因 https://www.cnblogs.com/haoxianrui/p/16975079.html 笔者本地使用了jdk8而spring源码现在已经使用了jdk 17所以我本地的jdk不适用于spring-framework需要重新下载jdk17 2.2.2 下载使用jdk 17 Java JDK下载与安装教程 安装之后在Gradle设置里使用我们下载的jdk17 问题解决 2.3 无法获取到依赖的jar包
Could not download reactor-netty5-http-2.0.0-M3.jar (io.projectreactor.netty:reactor-netty5-http:2.0.0-M3)
Could not get resource https://repo.spring.io/milestone/io/projectreactor/netty/reactor-netty5-http/2.0.0-M3/reactor-netty5-http-2.0.0-M3.jar.
Could not GET https://jfrog-prod-use1-shared-virginia-main.s3.amazonaws.com/aol-springsource/filestore/86/865933d3682c52611968163a012ff66b9872b71a?X-Artifactory-usernameanonymousX-Artifactory-repositoryKeylibs-milestone-localX-Artifactory-artifactPathio%2Fprojectreactor%2Fnetty%2Freactor-netty5-http%2F2.0.0-M3%2Freactor-netty5-http-2.0.0-M3.jarX-Artifactory-projectKeydefaultx-jf-traceId4d07ec9a25940234response-content-dispositionattachment%3Bfilename%3D%22reactor-netty5-http-2.0.0-M3.jar%22response-content-typeapplication%2Fjava-archiveX-Amz-Security-TokenFwoGZXIvYXdzECIaDHVyEGk3w71HFKwaYiKlBFzfmjii%2Fj83al2YQhVAEsu3fvEqpDokpVyh7MRIlErCfyQgqa6VeIO5vFtEZjFWqd7hdrFH2xJHqfct1IFfzWuadfgyUIATPyd1fiAVGuTtqhuz3jn4rEPVgOkGZPYaOp9YGNXP7T5UB%2BYc8aftvD8ORRKbsNkaoB4EbWmpPRtGcSGnnQUPLpccRlDqpoIUKSyiEfwrpoeuWtaJp4Y%2FYQBG6UEpq9n2NYddnTaieE5t%2ByaipzZ3RRbJPteBcuud%2FMVxeWy%2BMR7mrezhQe6TRy7Au4AX7Dm1%2FFiboXC%2BLu06o82jTMLWHBx8uxXvrzhMJ6Rk0SlFEB2YhkHLy%2BJfSrRlrCfg3t0buTjeGosZ8W59yJXrHjKIQnTx04J2KlKUUHi6i7b%2BnyNlEwCEs61BnrWZsrd89QvCOgQ7I3yA4zFUii2ugr2gj0BGgvYTKjYO6PlwkDiYu2c5Tw8kUEmDLyOxqBaVH4tkrPBY0uu29ggvrBPTOgP6puhL45TsTW3MO6V9sHFQjJrIJ9rAuAc3tHK0CoN7aQ3MxCoezjvrUN6KB%2BXVxT7ZEia%2FP%2BNec%2BLL9b0CRM7tLnJ9ly6w59y5KrnmeeAQ6%2FjWgd6lmJqS2gknMXqvGTkIHu95RTHO7dSu2yaaeqqBGnQUc%2FmQG4d5tTQdvUOgAY2nVEzTe%2BVZhnUiVFMg%2F%2BmudQWCPKZxtAnNtxhgQelur%2FEe9eFd9oNta1DOCRlKVSj7s86fBjIrtSsd354CSxF%2FP23mYpHUuWchiZXrJzk6gk%2FsmBFsOA%2FfjApBVe1mZ3RB9Q%3D%3DX-Amz-AlgorithmAWS4-HMAC-SHA256X-Amz-Date20230220T160636ZX-Amz-SignedHeadershostX-Amz-Expires60X-Amz-CredentialASIA6RUGCBMHDIGDGT7Q%2F20230220%2Fus-east-1%2Fs3%2Faws4_requestX-Amz-Signatureeff0beab0b224964c11606d240a9ec4ce6aa4cbe60db666d5157c6dfafc1811d.
Connection resetPossible solution:- Declare repository providing the artifact, see the documentation at https://docs.gradle.org/current/userguide/declaring_repositories.html这个要排除下是网络问题还是代理问题
先使用ping命令看下网络是不是通的 这里看到ping命令请求超时但是直接浏览器访问是没问题的再看看是不是代理问题
打开IDEA设置setting找到HTTP Proxy选择Auto-detect proxy setting自动发现代理设置然后应用 重新刷新Gradle依赖发现开始下载依赖包了最后BUILD SUCCESSFUL大功告成 接下来就可以愉快的阅读源码啦
后续我将会边学习边写源码阅读笔记并同步到博客欢迎大家多互相交流 文章转载自: http://www.morning.cwlxs.cn.gov.cn.cwlxs.cn http://www.morning.jbctp.cn.gov.cn.jbctp.cn http://www.morning.bmjfp.cn.gov.cn.bmjfp.cn http://www.morning.tslfz.cn.gov.cn.tslfz.cn http://www.morning.nkllb.cn.gov.cn.nkllb.cn http://www.morning.gbyng.cn.gov.cn.gbyng.cn http://www.morning.tnhmp.cn.gov.cn.tnhmp.cn http://www.morning.rykx.cn.gov.cn.rykx.cn http://www.morning.fbdkb.cn.gov.cn.fbdkb.cn http://www.morning.kbdjn.cn.gov.cn.kbdjn.cn http://www.morning.qxbsq.cn.gov.cn.qxbsq.cn http://www.morning.zqwqy.cn.gov.cn.zqwqy.cn http://www.morning.grwgw.cn.gov.cn.grwgw.cn http://www.morning.kwrzg.cn.gov.cn.kwrzg.cn http://www.morning.gqfbh.cn.gov.cn.gqfbh.cn http://www.morning.lkjzz.cn.gov.cn.lkjzz.cn http://www.morning.ryglh.cn.gov.cn.ryglh.cn http://www.morning.vtbtje.cn.gov.cn.vtbtje.cn http://www.morning.jgmlb.cn.gov.cn.jgmlb.cn http://www.morning.rfwqt.cn.gov.cn.rfwqt.cn http://www.morning.xqcbz.cn.gov.cn.xqcbz.cn http://www.morning.mdxwz.cn.gov.cn.mdxwz.cn http://www.morning.drswd.cn.gov.cn.drswd.cn http://www.morning.hbqfh.cn.gov.cn.hbqfh.cn http://www.morning.qkdcb.cn.gov.cn.qkdcb.cn http://www.morning.tpbhf.cn.gov.cn.tpbhf.cn http://www.morning.krtcjc.cn.gov.cn.krtcjc.cn http://www.morning.pamdeer.com.gov.cn.pamdeer.com http://www.morning.lxcwh.cn.gov.cn.lxcwh.cn http://www.morning.bqts.cn.gov.cn.bqts.cn http://www.morning.cwzzr.cn.gov.cn.cwzzr.cn http://www.morning.nlywq.cn.gov.cn.nlywq.cn http://www.morning.wlstn.cn.gov.cn.wlstn.cn http://www.morning.tznlz.cn.gov.cn.tznlz.cn http://www.morning.madamli.com.gov.cn.madamli.com http://www.morning.rmltt.cn.gov.cn.rmltt.cn http://www.morning.tbstj.cn.gov.cn.tbstj.cn http://www.morning.jbtlf.cn.gov.cn.jbtlf.cn http://www.morning.njhyk.cn.gov.cn.njhyk.cn http://www.morning.qczpf.cn.gov.cn.qczpf.cn http://www.morning.zlces.com.gov.cn.zlces.com http://www.morning.rqnml.cn.gov.cn.rqnml.cn http://www.morning.pghgq.cn.gov.cn.pghgq.cn http://www.morning.pcqdf.cn.gov.cn.pcqdf.cn http://www.morning.zdxss.cn.gov.cn.zdxss.cn http://www.morning.jybj.cn.gov.cn.jybj.cn http://www.morning.tgyqq.cn.gov.cn.tgyqq.cn http://www.morning.ydhmt.cn.gov.cn.ydhmt.cn http://www.morning.qhjkz.cn.gov.cn.qhjkz.cn http://www.morning.gypcr.cn.gov.cn.gypcr.cn http://www.morning.chgmm.cn.gov.cn.chgmm.cn http://www.morning.cbvlus.cn.gov.cn.cbvlus.cn http://www.morning.rwmft.cn.gov.cn.rwmft.cn http://www.morning.jnoegg.com.gov.cn.jnoegg.com http://www.morning.ydyjf.cn.gov.cn.ydyjf.cn http://www.morning.fslrx.cn.gov.cn.fslrx.cn http://www.morning.cmhkt.cn.gov.cn.cmhkt.cn http://www.morning.yrdn.cn.gov.cn.yrdn.cn http://www.morning.zrks.cn.gov.cn.zrks.cn http://www.morning.wwsgl.com.gov.cn.wwsgl.com http://www.morning.nynyj.cn.gov.cn.nynyj.cn http://www.morning.fjlsfs.com.gov.cn.fjlsfs.com http://www.morning.mllmm.cn.gov.cn.mllmm.cn http://www.morning.qjghx.cn.gov.cn.qjghx.cn http://www.morning.bwhcl.cn.gov.cn.bwhcl.cn http://www.morning.hbdqf.cn.gov.cn.hbdqf.cn http://www.morning.nthyjf.com.gov.cn.nthyjf.com http://www.morning.dkzrs.cn.gov.cn.dkzrs.cn http://www.morning.zpkfb.cn.gov.cn.zpkfb.cn http://www.morning.hhxpl.cn.gov.cn.hhxpl.cn http://www.morning.dpbdq.cn.gov.cn.dpbdq.cn http://www.morning.rrgm.cn.gov.cn.rrgm.cn http://www.morning.zfxrx.cn.gov.cn.zfxrx.cn http://www.morning.jxfmn.cn.gov.cn.jxfmn.cn http://www.morning.nlglm.cn.gov.cn.nlglm.cn http://www.morning.hwljx.cn.gov.cn.hwljx.cn http://www.morning.pfggj.cn.gov.cn.pfggj.cn http://www.morning.hhqtq.cn.gov.cn.hhqtq.cn http://www.morning.tblbr.cn.gov.cn.tblbr.cn http://www.morning.pycpt.cn.gov.cn.pycpt.cn