Spring工程採用Gradle作項目管理,因此咱們須要在本地安裝Gradle,個人的本地環境以下:java
Windows 10 Professional java 1.8.0_102 Gradle 3.4.1 git version 2.11.0
$ git clone https://github.com/spring-projects/spring-framework.git Cloning into 'spring-framework'... remote: Counting objects: 316377, done. remote: Compressing objects: 100% (98/98), done. remote: Total 316377 (delta 34), reused 0 (delta 0), pack-reused 316257 Receiving objects: 100% (316377/316377), 85.40 MiB | 129.00 KiB/s, done. Resolving deltas: 100% (154808/154808), done. Checking connectivity... done. Checking out files: 100% (7366/7366), done.
Spring源碼工程一覽:git
$ ll total 93 -rw-r--r-- 1 zhenchao.Wang 197609 36887 8月 21 03:22 build.gradle drwxr-xr-x 1 zhenchao.Wang 197609 0 8月 21 03:17 buildSrc/ -rw-r--r-- 1 zhenchao.Wang 197609 11483 8月 21 03:22 CONTRIBUTING.md drwxr-xr-x 1 zhenchao.Wang 197609 0 8月 21 03:22 gradle/ -rw-r--r-- 1 zhenchao.Wang 197609 31 8月 21 03:22 gradle.properties -rwxr-xr-x 1 zhenchao.Wang 197609 5304 8月 21 03:22 gradlew* -rw-r--r-- 1 zhenchao.Wang 197609 2487 8月 21 03:22 gradlew.bat -rw-r--r-- 1 zhenchao.Wang 197609 4140 8月 21 03:22 import-into-eclipse.bat -rw-r--r-- 1 zhenchao.Wang 197609 3560 8月 21 03:22 import-into-eclipse.sh -rw-r--r-- 1 zhenchao.Wang 197609 1376 8月 21 03:22 import-into-idea.md -rw-r--r-- 1 zhenchao.Wang 197609 4906 8月 21 03:22 README.md -rw-r--r-- 1 zhenchao.Wang 197609 786 8月 21 03:22 settings.gradle drwxr-xr-x 1 zhenchao.Wang 197609 0 8月 21 03:17 spring-aop/ drwxr-xr-x 1 zhenchao.Wang 197609 0 8月 21 03:22 spring-aspects/ drwxr-xr-x 1 zhenchao.Wang 197609 0 8月 21 03:17 spring-beans/ drwxr-xr-x 1 zhenchao.Wang 197609 0 8月 21 03:17 spring-context/ drwxr-xr-x 1 zhenchao.Wang 197609 0 8月 21 03:17 spring-context-support/ drwxr-xr-x 1 zhenchao.Wang 197609 0 8月 21 03:17 spring-core/ drwxr-xr-x 1 zhenchao.Wang 197609 0 8月 21 03:17 spring-expression/ drwxr-xr-x 1 zhenchao.Wang 197609 0 8月 21 03:22 spring-framework-bom/ drwxr-xr-x 1 zhenchao.Wang 197609 0 8月 21 03:17 spring-instrument/ drwxr-xr-x 1 zhenchao.Wang 197609 0 8月 21 03:22 spring-instrument-tomcat/ drwxr-xr-x 1 zhenchao.Wang 197609 0 8月 21 03:17 spring-jdbc/ drwxr-xr-x 1 zhenchao.Wang 197609 0 8月 21 03:17 spring-jms/ drwxr-xr-x 1 zhenchao.Wang 197609 0 8月 21 03:17 spring-orm/ drwxr-xr-x 1 zhenchao.Wang 197609 0 8月 21 03:22 spring-orm-hibernate4/ drwxr-xr-x 1 zhenchao.Wang 197609 0 8月 21 03:22 spring-oxm/ drwxr-xr-x 1 zhenchao.Wang 197609 0 8月 21 03:22 spring-struts/ drwxr-xr-x 1 zhenchao.Wang 197609 0 8月 21 03:22 spring-test/ drwxr-xr-x 1 zhenchao.Wang 197609 0 8月 21 03:22 spring-test-mvc/ drwxr-xr-x 1 zhenchao.Wang 197609 0 8月 21 03:17 spring-tx/ drwxr-xr-x 1 zhenchao.Wang 197609 0 8月 21 03:17 spring-web/ drwxr-xr-x 1 zhenchao.Wang 197609 0 8月 21 03:17 spring-webmvc/ drwxr-xr-x 1 zhenchao.Wang 197609 0 8月 21 03:22 spring-webmvc-portlet/ drwxr-xr-x 1 zhenchao.Wang 197609 0 8月 21 03:22 spring-webmvc-tiles3/ drwxr-xr-x 1 zhenchao.Wang 197609 0 8月 21 03:23 src/
第一步,運行import-into-eclipse.bat
,雙擊運行便可,Linux系統運行運行import-into-eclipse.sh
github
----------------------------------------------------------------------- Spring Framework Eclipse/STS project import guide This script will guide you through the process of importing the Spring Framework sources into Eclipse/STS. It is recommended that you have a recent version of the SpringSource Tool Suite (this script has been tested against STS '2.9.2.RELEASE'), but at the minimum you will need Eclipse + AJDT. If you need to download and install STS, please do that now by visiting http://springsource.org/downloads/sts Otherwise, press enter and we will begin. Press any key to continue. . . ----------------------------------------------------------------------- STEP 1: Generate subproject Eclipse metadata The first step will be to generate Eclipse project metadata for each of the spring-* subprojects. This happens via the built-in "Gradle wrapper" script (./gradlew in this directory). If this is your first time using the Gradle wrapper, this step may take a few minutes while a Gradle distribution is downloaded for you. The command run will be: gradlew cleanEclipse :spring-oxm:compileTestJava eclipse -x :eclipse Press enter when ready. Press any key to continue. . .
第二步,導入到eclipse,按照提示的步驟操做便可:web
----------------------------------------------------------------------- STEP 2: Import subprojects into Eclipse/STS Within Eclipse/STS, do the following: File > Import... > Existing Projects into Workspace > When prompted for the 'root directory', provide E:\dev_workspace\git\zhenchao\java\workspace\eclipse\spring-framework\ > Press enter. You will see the modules show up under "Projects" > All projects should be selected/checked. Click Finish. > When the project import is complete, you should have no errors. When the above is complete, return here and press the enter key.
第一步,在項目的spring-framework/spring-oxm
目錄下,執行./gradle cleanIdea :spring-oxm:compileTestJava
spring
$ gradle cleanIdea :spring-oxm:compileTestJava Starting a Gradle Daemon (subsequent builds will be faster) Generating JAR file 'gradle-api-3.4.1.jar' :buildSrc:clean UP-TO-DATE :buildSrc:compileJava NO-SOURCE :buildSrc:compileGroovy :buildSrc:processResources :buildSrc:classes :buildSrc:jar :buildSrc:assemble :buildSrc:compileTestJava NO-SOURCE :buildSrc:compileTestGroovy NO-SOURCE :buildSrc:processTestResources NO-SOURCE :buildSrc:testClasses UP-TO-DATE :buildSrc:test NO-SOURCE :buildSrc:check UP-TO-DATE :buildSrc:build ...... Download https://repo.spring.io/libs-release/org/codehaus/jettison/jettison/1.3.8/jettison-1.3.8.pom Download https://repo.spring.io/libs-release/org/codehaus/jettison/jettison/1.3.8/jettison-1.3.8.jar :spring-oxm:compileTestJava Download https://repo.spring.io/libs-release/org/jibx/jibx-bind/1.2.6/jibx-bind-1.2.6.pom Download https://repo.spring.io/libs-release/org/apache/bcel/bcel/6.0/bcel-6.0.pom Download https://repo.spring.io/libs-release/org/apache/apache/17/apache-17.pom Download https://repo.spring.io/libs-release/log4j/log4j/1.2.17/log4j-1.2.17.pom Download https://repo.spring.io/libs-release/org/codehaus/codehaus-parent/4/codehaus-parent-4.pom Download https://repo.spring.io/libs-release/org/jibx/jibx-bind/1.2.6/jibx-bind-1.2.6.jar Download https://repo.spring.io/libs-release/org/apache/bcel/bcel/6.0/bcel-6.0.jar :spring-oxm:copyTestKotlinClasses BUILD SUCCESSFUL Total time: 8 mins 23.728 secs
第二步,導入IntelliJ工程:express
File -> New -> Project from Existing Sources -> Navigate to directory -> Select build.gradleapache
鑑於做者水平有限,文中難免有錯誤之處,歡迎你們批評指正~api
同步更新站點:www.zhenchao.orgtomcat