Notes on learning Spring source code -- it is not difficult to download and compile Spring source code

Prerequisite preparation:

JDK8+

IDEA

Maven

Download the source code:

Visit the official website of spring.io, then go to Projects, click the kitten in the upper right corner, and download the Spring source code from Github!

Choose a RELEASE version, I choose the RELEASE version of 5.2, choose Download ZIP, no need for Clone!!!

After downloading, directly decompress to the specified directory!

Simply follow the import-into-idea.md operation:

Official guidance is the most reliable!

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

1, Precompile:

Before precompiling, you'd better configure the Alibaba cloud images of Maven and Gradle to improve the download speed!

Add the following to maven's settings.xml:

    <mirror>
      <id>alimaven</id>
      <name>aliyun maven</name>
      <url>http://maven.aliyun.com/nexus/content/groups/public</url>
	  <mirrorOf>aliyun maven</mirrorOf>
    </mirror>

Edit the build.gradle file again:

(The second element)
repositories {
		maven{ url 'https://maven.aliyun.com/nexus/content/groups/public/' }
		maven{ url 'https://maven.aliyun.com/nexus/content/repositories/jcenter' }
	}
(About line 300)
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" }

After configuration, go to the root directory of Spring source code through the command line and execute the following instructions:

gradlew :spring-oxm:compileTestJava(windows)

./gradlew :spring-oxm:compileTestJava(mac)

If there is no error in the above configuration, it will prompt build success:

2, Import source code into IDEA

New Project, or Import Project

Then select the source root directory, and directly OK!

Next, select according to the following figure, and click Next!

Next just wait!!!

If it fails to download a jar package, click the pop-up connection on the console, the browser will download it automatically, and then manually add the jar package to the

. gradle\caches\modules-2\files-2.1.

Like I'm here

Caused by: org.gradle.api.resources.ResourceException: Could not get resource 'https://repo.maven.apache.org/maven2/org/javassist/javassist/3.23.1-GA/javassist-3.23.1-GA.jar'

Click the following link, the jar package will be downloaded automatically, and then the downloaded jar package will be placed in the specified path,

Then refresh, if there are similar problems, follow the above method!!!

3, Exclude the spring aspects module:

Right click the module and click load/unload:

Click OK and build project!

The spring aspects module will turn orange, and the project will not report errors!

Then, you can create new modules to call each other!!!

Of course, I compiled the process is relatively smooth, if you encounter some other errors, you can baidu below!!!

Published 10 original articles, won praise 35, visited 10000+
Private letter follow

Keywords: Maven Spring Gradle nexus

Added by maniac1aw on Sat, 14 Mar 2020 03:43:45 +0200