Alvaro Pedraza
Alvaro Pedraza

Reputation: 1292

Spring STS not recognizing project structure with Gradle

I'm trying to do this getting started guide from Spring. So I cloned the project using git from the command line. As I'm working with Gradle, I removed the Maven files from the repository to clean the project.

After that I open my STS and go to File -> Open Projects from File System and navigate to the /initial folder of the repository. The project is imported correctly but when I try to add some "java stuff" (packages, classes, etc.) I get several errors and I can only add folders and files, which is quite annoying for working.

To be more descriptive, I'll add some images so you can see what's happening. This is the project initially imported into STS as I described above:

Initial Import

Then I try to add some java stuff, let's say for example a source folder. So Right Click on library -> New -> Source folder and this is the result:

Failing to add a source folder

And in the properties of library I have the following:

enter image description here

So the question is: how can I tell to STS to recognize the library folder as a Java Project (or Gradle module, I don't know how to call it) instead of a plain folder so I can add my packages and classes?

Thanks in advance for your answers.

Upvotes: 0

Views: 4155

Answers (1)

Martin Lippert
Martin Lippert

Reputation: 6508

In case you would like to work with Gradle, you should use the Gradle integration for Eclipse (project Buildship) and install that into your STS environment. After that, you should be able to import the projects either from disc as existing Gradle project (not as file system) or via the wizard that integrates the spring guides into STS (Import Getting Started Content). The wizard for the guides also let you choose between the Maven and the Gradle variant, so you don't need to close and delete stuff yourself.

Hope this helps!!!

Upvotes: 1

Related Questions