简体   繁体   中英

How to add Spring jars to Java Project mirroring folder in git repo

Long title, but pretty much explains it. I've pulled a git repo (spring rest tutorial http://spring.io/guides/tutorials/rest/ ) which contains multiple standalone java projects each in separate folders. Each of these projects contains gradle build files as well as gradle itself (no need to install gradle), AND the necessary Spring jars (likely in the gradle-wrapper jar). I've created a java project in eclipse that mirrors one of the folders and the changes in eclipse are picked up no problem and it builds fine.

The problem I have is that the Spring dependencies aren't on the Eclipse build path, so I can't use all of the nice Eclipse features (function completion, auto imports, etc.). There's only one jar in each separate folder from the git repo and it's called gradle-wrapper.jar. My guess is that this contains all the Spring dependencies, as the project builds fine, assuming I've typed everything correctly and manually added correct import statements.

Is there a way to set this up so that I'm not getting all these ugly errors in the java project? I attempted to add the gradle jar to the java project build path, but this had no effect. I suppose one option would be to add the spring dependencies separately, but then the Spring on the build path wouldn't necessarily match the Spring dependencies used by gradle for the actual build.

Gradle projects don't package all the dependencies in the repository; one of the primary reasons to use Gradle or Maven is that they'll handle dependencies for you. You need the Gradle Eclipse plugin and to Import->Existing Gradle projects.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM