0

I have a lot of unresolved imports on the project but the dependencies jar files are on the project

enter image description here

and this is the pom.xml

<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
    xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
    <modelVersion>4.0.0</modelVersion>

    <groupId>com.example</groupId>
    <artifactId>easy-notes</artifactId>
    <version>0.0.1-SNAPSHOT</version>
    <packaging>jar</packaging>

    <name>easy-notes</name>
    <description>Demo project for Spring Boot</description>

    <parent>
        <groupId>org.springframework.boot</groupId>
        <artifactId>spring-boot-starter-parent</artifactId>
        <version>1.5.9.RELEASE</version>
        <relativePath/> <!-- lookup parent from repository -->
    </parent>

    <properties>
        <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
        <project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding>
        <java.version>1.8</java.version>
    </properties>

    <dependencies>
        <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-starter-data-jpa</artifactId>
        </dependency>
        <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-starter-web</artifactId>
        </dependency>

        <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-devtools</artifactId>
            <scope>runtime</scope>
        </dependency>
        <dependency>
            <groupId>mysql</groupId>
            <artifactId>mysql-connector-java</artifactId>
            <scope>runtime</scope>
        </dependency>
        <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-starter-test</artifactId>
            <scope>test</scope>
        </dependency>
    </dependencies>

    <build>
        <plugins>
            <plugin>
                <groupId>org.springframework.boot</groupId>
                <artifactId>spring-boot-maven-plugin</artifactId>
            </plugin>
        </plugins>
    </build>


</project>

It's the first time I use IntelliJ Idea and I'm a little bit lost. I don't know what is the problem with the libraries. I think all the needed libraries are in pom.xml file.

June7
  • 19,874
  • 8
  • 24
  • 34
AFS
  • 1,433
  • 6
  • 28
  • 52
  • Did you try to build the project (mvn clean install)? If the problem persists, check this link https://stackoverflow.com/questions/5905896/intellij-inspection-gives-cannot-resolve-symbol-but-still-compiles-code – Oleksandr Pyrohov Jan 14 '18 at 16:55
  • @Oleksandr I can't `[ERROR] Failed to execute goal org.apache.maven.plugins:maven-compiler-plugin:3.1:compile (default-compile) on project easy-notes: Compilation failure: Compilation failure: [ERROR] /home/user/easy-notes/src/main/java/com/example/easynotes/model/Notes.java:[6,2] cannot find symbol [ERROR] symbol: class Entity` – AFS Jan 14 '18 at 16:59
  • I don't see the `maven-compiler-pluging` in your `pom.xml`, but you should add it - https://stackoverflow.com/questions/42525139/maven-build-compilation-error-failed-to-execute-goal-org-apache-maven-plugins/42525941#answer-42525941 – Oleksandr Pyrohov Jan 14 '18 at 17:04
  • First the maven-compiler-plugin is already being define via life cycle etc. The issue is that the error message shows something different than the screen shot...cause in line 6 in the screenshot is an import statement where as the error message shows something different. Can you please put that project somewhere on Github to take a look... – khmarbaise Jan 14 '18 at 19:16
  • Can you tell me what it says when you move your mouse cursor over the red lines ? – whatamidoingwithmylife Jan 14 '18 at 20:38

2 Answers2

0

Judging from your screenshot, it seems the main and test directories are marked as project modules. Also, main/resources is not marked as a resource directory. That looks wrong and done by hand. How did you create the project? Opening the main pom.xml file from the Open... menu entry should be enough. Also, right-clicking on the pom.xml file and selecting Maven > Reimport.

Note: I'm looking at IntelliJ IDEA 2017.1.5. Your version might be a little bit different.

Alessio Stalla
  • 1,022
  • 6
  • 22
0

You might want to go to File->Invalidate Caches/Restart as it's possible that the index needs to be rebuilt after being corrupted for some reason.

zen
  • 591
  • 1
  • 4
  • 5