4.4 KiB
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. As a bare minimum you will need Eclipse with full Java 8 support, Eclipse Buildship, the Kotlin plugin, and the Groovy plugin.
The following instructions have been tested against STS 4.3.2 (download) (based on Eclipse 4.12) with Eclipse Buildship. The instructions should work with the latest Eclipse distribution as long as you install Buildship. Note that STS 4 comes with Buildship preinstalled.
Steps
When instructed to execute ./gradlew
from the command line, be sure to execute it within your locally cloned spring-framework
working directory.
- Ensure that Eclipse launches with JDK 8.
- For example, on Mac OS this can be configured in the
Info.plist
file located in theContents
folder of the installed Eclipse or STS application (e.g., theEclipse.app
file).
- For example, on Mac OS this can be configured in the
- Install the Kotlin Plugin for Eclipse in Eclipse.
- Install the Eclipse Groovy Development Tools in Eclipse.
- Switch to Groovy 2.5 (Preferences -> Groovy -> Compiler -> Switch to 2.5...) in Eclipse.
- Change the Forbidden reference (access rule) in Eclipse from Error to Warning (Preferences -> Java -> Compiler -> Errors/Warnings -> Deprecated and restricted API -> Forbidden reference (access rule)).
- Optionally install the AspectJ Development Tools (AJDT) if you need to work with the
spring-aspects
project. The AspectJ Development Tools available in the Eclipse Marketplace have been tested with these instructions using STS 4.5 (Eclipse 4.14). - Optionally install the TestNG plugin in Eclipse if you need to execute TestNG tests in the
spring-test
module. - Build
spring-oxm
from the command line with./gradlew :spring-oxm:check
. - To apply project specific settings, run
./gradlew eclipseBuildship
from the command line. - Import into Eclipse (File -> Import -> Gradle -> Existing Gradle Project -> Navigate to the locally cloned
spring-framework
directory -> Select Finish).- If you have not installed AJDT, exclude the
spring-aspects
project from the import, if prompted, or close it after the import. - If you run into errors during the import, you may need to set the Java home for Gradle Buildship to the location of your JDK 8 installation in Eclipse (Preferences -> Gradle -> Java home).
- If you have not installed AJDT, exclude the
- If you need to execute JAXB-related tests in the
spring-oxm
project and wish to have the generated sources available, add thebuild/generated-sources/jaxb
folder to the build path (right click on thejaxb
folder and selectBuild Path -> Use as Source Folder
).- If you do not see the
build
folder in thespring-oxm
project, ensure that the "Gradle build folder" is not filtered out from the view. This setting is available under "Filters" in the configuration of the Package Explorer (available by clicking on the small downward facing arrow in the upper right corner of the Package Explorer).
- If you do not see the
- Code away!
Known Issues
spring-core
andspring-oxm
should be pre-compiled due to repackaged dependencies.- See
*RepackJar
tasks in the build.
- See
spring-aspects
does not compile due to references to aspect types unknown to Eclipse.- If you installed AJDT into Eclipse it should work.
- 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 may 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.