简体   繁体   中英

Imports cannot be resolved - Visual Studio Code for Java

I am working on a Java project which is managed by Maven.

The project actually is composed of three sub-projects : - Backend - Builder - Frontend

Every single of those projects is Maven based and the Builder works as a bridge between Frontend and backend. In fact the Builder is the parent project for all of them. The pom.xml of the Builder is as follows:

...
<modules>
    <module>Model</module>
</modules>
...

Whereas the Model has pom.xml like this:

  ...
  <parent>
    <groupId>...</groupId>
    <artifactId>Builder</artifactId>
    <version>1.0.0.0</version>
  </parent>
  <artifactId>Model</artifactId>
  <build>
    *Backend build directives*      
  </build>
  ...

The problem is that from Visual studio Code i can build every single module successfully without errors but the code editor gives me " import cannot be resolved .." wherever i have dependecies towards backend . I came to think that this is a bug of the "Java Language Support by RedHat" which cannot find dependencies ... Has this happened to anybody?

--- Edit 28/11/2019 ---

I forgot to clearify that all of the Builder's dependencies (so towards Backend and other Util libraries) are resolved correctly as I can see those Jars inside Frontend's resolved dependencies folder.

you could try like this:

in your parent project pom.xml:

<groupId>com.blackr</groupId>
<artifactId>cloudtest</artifactId>
<version>0.0.1-SNAPSHOT</version>
<packaging>pom</packaging>

in your child project pom.xml:

<artifactId>module</artifactId>
<version>0.0.1-SNAPSHOT</version>
<packaging>jar</packaging>

<parent>
    <groupId>com.blackr</groupId>
    <artifactId>cloudtest</artifactId>
    <version>0.0.1-SNAPSHOT</version>
    <relativePath>../parent/pom.xml</relativePath> //Location of the parent project's pom.xml file
</parent>

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