Spring Framework 4.2.x - Eclipse/STS專案匯入指南
Spring Framework - Eclipse/STS專案匯入指南
本文件將指導您把"Spring Framework"專案匯入到Eclipse或STS中。
建議您使用最近版本的Eclipse或STS。作為最低限度,Eclipse中需要具備以下功能:完整的Java 8支援、AspectJ開發工具(AJDT)和Groovy編譯器。
以下指令已經針對[Spring Tool Suite](https://spring.io/tools)(_STS_)3.9.4和4.0.0.M11與[Eclipse Buildship](http://..eclipse.org/./tools.build.)(用於Gradle的Eclipse外掛)進行了測試。
只要您安裝[Buildship]外掛(https://marketplace.eclipse.org/content/buildship-gradle-integration),這些指令能夠應用於最新的Eclipse 釋出版本。
請注意,STS 4已經預安裝了[Buildship]外掛。
# 步驟:
進入克隆到本地的"spring-framework"的工作目錄中
1、預編譯"spring-oxm":./gradlew :spring-oxm:compileTestJava
2、匯入到Eclipse中:
File -> Import -> Gradle -> Existing Gradle Project -> Navigate to directory -> Select Finish
3、如果提示,排除"spring-aspects"模組(也可以在匯入之後,關閉或刪除該專案模組)
4、在"spring-oxm"專案中,將"build/generated-sources"中的兩個資料夾"castor"和"jaxb"新增到構建路徑:
資料夾上右擊,選擇Build Path -> Use as Source Folder
5、應用專案特定設定,執行:./gradlew eclipseBuildship
7、code away
## 已知問題
1、`spring-core` 和 `spring-oxm` 應該被預先編譯。原因是重新打包的依賴關係。
在構建中檢視"*RepackJar"任務
2、"spring-aspects"無法編譯。原因是引用了Eclipse未知的aspect型別。
如果 在Eclipse中安裝【AJDT】(https://www.eclipse.org/ajdt/downloads/),它應該能工作。
3、 雖然在命令列中使用Gradle進行Junit測試能夠通過,但是當使用IDE執行時,有些會通不過測試
—— 這一問題正在解決中
—— 如果試圖從IDE中執行所有JUnit測試,您可能需要設定以下VM選項以避免記憶體不足:
-XX:MaxPermSize=2048m -Xmx2048m -XX:MaxHeapSize=2048m
# 提示:
在任何情況下,請不要 check in 你自己生成的".classpath"檔案,".project"檔案,以及".settings"資料夾。
你會注意到這些檔案已經有意地加入到".gitignore"中。
同樣的策略適用於IDEA元資料。
原文(import-into-eclipse.md):
Spring Framework - Eclipse/STS Project Import Guide
This document 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.
The following instructions have been tested against [Spring Tool Suite](https://spring.io/tools) (_STS_) 3.9.4 and 4.0.0.M11 with [Eclipse Buildship](http://projects.eclipse.org/projects/tools.buildship) (Eclipse Plug-ins for Gradle). The instructions should work with the latest Eclipse distribution as long as you install [Buildship](https://marketplace.eclipse.org/content/buildship-gradle-integration). Note that STS 4 comes with Buildship preinstalled.
# Steps
_Within your locally cloned `spring-framework` working directory:_
1. Precompile `spring-oxm` with `./gradlew :spring-oxm:compileTestJava`
2. Import into Eclipse (File -> Import -> Gradle -> Existing Gradle Project -> Navigate to directory -> Select Finish)
3. If prompted, exclude the `spring-aspects` module (or after the import by closing or deleting the project)
4. In the `spring-oxm` project, add the two folders (`castor` and `jaxb`) in `build/generated-sources` to the build path (right click on them and select `Build Path -> Use as Source Folder`)
5. To apply project specific settings run `./gradlew eclipseBuildship`
7. Code away
## Known Issues
1. `spring-core` and `spring-oxm` should be pre-compiled due to repackaged dependencies.
- See `*RepackJar` tasks in the build.
2. `spring-aspects` does not compile due to references to aspect types unknown to Eclipse.
- If you install [AJDT](https://www.eclipse.org/ajdt/downloads/) into Eclipse it should work.
3. While JUnit tests pass from the command line with Gradle, some may fail when run from the IDE.
- Resolving this is a work in progress.
- If attempting to run all JUnit tests from within the IDE, you will likely need to set the following VM options to avoid out of memory errors:
`-XX:MaxPermSize=2048m -Xmx2048m -XX:MaxHeapSize=2048m`
# Tips
In any case, please do not check in your own generated `.classpath` file, `.project` file, or `.settings` folder. You'll notice these files are already intentionally in `.gitignore`. The same policy holds for IDEA metadata.