How to make VS Code recognize nested gradle projects?

Viewed 2648

I cloned below git repo:

github.com/PacktPublishing/Hands-On-Microservices-with-Spring-Boot-and-Spring-Cloud

I have installed latest Java and Spring extensions pack. When I open a new folder pointing to one of the folder for example Chapter09, it correctly recognizes 3 nested projects: api, util, eureka-server, but fails to recognize several nested projects under nested microservices folder. At the root level there is settings.gradle that defines all the nested gradle projects. Here is the screenshot:

screenshot

In eclipse it works fine but I need to use VS Code.

2 Answers

I saw these messages in the Problems view (e.g. project product-composite-service not being able to resolve its dependency on the api project):enter image description here

Try removing settings.gradle from folders

microservices\product-composite-service
microservices\product-service
microservices\recommendation-service
microservices\review-service

and then reimport the projects (via command Java: Import Java projects in workspace).

Build Tool Plugins

Spring Boot provides build tool plugins for Maven and Gradle. The plugins offer a variety of features, including the packaging of executable jars.

Running from an IDE: You can run a Spring Boot application from your IDE as a simple Java application. However, you first need to import your project. Import steps vary depending on your IDE and build system. Most IDEs can import Maven projects directly. For example, Eclipse users can select Import…​ → Existing Maven Projects from the File menu.

NOTE: If you cannot directly import your project into your IDE, you may be able to generate IDE metadata by using a build plugin. Maven includes plugins for Eclipse and IDEA. Gradle offers plugins for various IDEs.

The Spring Initializr extension allows you to search for dependencies and generate new Spring Boot projects. To install, launch VS Code and from the Extensions view (Ctrl+Shift+X), search for vscode-spring-initializr. Once you have the extension installed, open the Command Palette (Ctrl+Shift+P) and type Spring Initializr to start generating a Maven or Gradle project and then follow the wizard.

For Detail / Step by Step process please follow the link.Spring Boot in Visual Studio Code

Related