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.

猜你喜欢

转载自blog.csdn.net/weixin_38094135/article/details/83620419
今日推荐