本脚本将指导您把"Spring Framework"项目导入到Eclipse或STS中。
建议您使用最近版本的Eclipse或STS。作为最低限度,Eclipse中需要具备以下功能:完整的Java 8支持、AspectJ开发工具(AJDT)和Groovy编译器。
如果您需要下载和安装Eclipse或STS,请访问以下站点之一:
- Eclipse 下载: http://download.eclipse.org/eclipse/downloads
- STS 下载: http://spring.io/tools/sts/all
- STS 每日构建: http://dist.springsource.com/snapshot/STS/nightly-distributions.html
- ADJT: http://www.eclipse.org/ajdt/downloads/
- Groovy Eclipse: https://github.com/groovy/groovy-eclipse/wiki
不然,按Enter键,我们继续。
-----------------------------------------------------------------------
步骤1:为子项目生成Eclipse元数据
第一步是为每个spring-*子项目生成Eclipse项目元数据。这是通过内置的“Gradle wrapper”脚本(./gradlew在这个目录中)完成的。如果这是您第一次使用Gradle wrapper,那么此步骤可能需要花费几分钟为您下载Gradle发行版。
命令运行将是:
gradlew --no-daemon cleanEclipse :spring-oxm:compileTestJava eclipse -x :eclipse
准备就绪时按回车键。
-----------------------------------------------------------------------
步骤2:将子项目导入到Eclipse/STS中
在Eclipse/STS中,执行以下操作:
File
^> Import...
^> Existing Projects into Workspace
^> 当提示"root directory"时, 提供 %CURRENT_DIR%
^> 按Enter键. 你会看到模块在"Projects"下出现。
^> 所有项目都应该被selected/checked。单击"Finish"。
^> 项目导入完成时,您应该没有错误。
当上述步骤完成后,返回这里并按Enter键。
-----------------------------------------------------------------------
步骤3:生成根项目Eclipse元数据
不幸的是,Eclipse不允许导入项目层次结构,因此我们在步骤1中必须跳过根项目元数据生成。在这个步骤中,我们只生成根项目元数据,这样您就可以在下一个步骤中导入它。
命令运行将是:
gradlew --no-daemon :eclipse
准备好后按回车键。
-----------------------------------------------------------------------
步骤4:将根项目导入Eclipse/STS
按照上面步骤2中列出的项目导入步骤导入根项目。
完成后按回车,然后移动到最后一步。
-----------------------------------------------------------------------
第5步:启用所有项目的GIT支持
-在Eclipse/STS的Package Explorer中,选择所有Spring*项目。
-右击打开上下文菜单并选择Team ^> Share Project...
-在出现的Share Project对话框中,选择Git并按Next
-选中"Use or create repository in parent folder of project"
-单击finish
完成后,你就为所有项目启用了Git支持。
开始编码吧!再见!
原文(import-into-eclipse.bat):
-----------------------------------------------------------------------
Spring Framework - Eclipse/STS project import guide
This script will guide you through the process of importing the Spring Framework projects into Eclipse or the Spring Tool Suite (STS). It is recommended that you have a recent version of Eclipse or STS. As a bare minimum you will need Eclipse with full Java 8 support, the AspectJ Development Tools (AJDT), and the Groovy Compiler.
If you need to download and install Eclipse or STS, please do that now by visiting one of the following sites:
- Eclipse downloads: http://download.eclipse.org/eclipse/downloads
- STS downloads: http://spring.io/tools/sts/all
- STS nightly builds: http://dist.springsource.com/snapshot/STS/nightly-distributions.html
- ADJT: http://www.eclipse.org/ajdt/downloads/
- Groovy Eclipse: https://github.com/groovy/groovy-eclipse/wiki
Otherwise, press enter and we'll begin.
-----------------------------------------------------------------------
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 --no-daemon cleanEclipse :spring-oxm:compileTestJava eclipse -x :eclipse
Press enter when ready.
-----------------------------------------------------------------------
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 %CURRENT_DIR%
^> 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.
-----------------------------------------------------------------------
STEP 3: generate root project Eclipse metadata
Unfortunately, Eclipse does not allow for importing project hierarchies, so we had to skip root project metadata generation in the during step 1. In this step we simply generate root project metadata so you can import it in the next step.
The command run will be:
gradlew --no-daemon :eclipse
Press the enter key when ready.
-----------------------------------------------------------------------
STEP 4: Import root project into Eclipse/STS
Follow the project import steps listed in step 2 above to import the root project.
Press enter when complete, and move on to the final step.
-----------------------------------------------------------------------
STEP 5: Enable Git support for all projects
- In the Eclipse/STS Package Explorer, select all spring* projects.
- Right-click to open the context menu and select Team ^> Share Project...
- In the Share Project dialog that appears, select Git and press Next
- Check "Use or create repository in parent folder of project"
- Click Finish
When complete, you'll have Git support enabled for all projects.
You're ready to code! Goodbye!