1

I used a spring initializr project for creating a REST service (https://spring.io/guides/gs/intellij-idea/) and imported it in IntelliJ using Maven project. That works fine. Unit tests run fine too.

Now, I added some code and imported another package (org.apache.zookeeper). IntelliJ does not seem to get that dependency. The compile error says (Error:(11, 28) java: package org.apache.zookeeper does not exist)

Moreover, I ensured that the pom.xml is updated and the effective POM as shown by Intellij lists the same package (scope - compile). I checked that the Maven settings does not have anything odd, basically empty with the standard root tags. Here is the POM -

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

    <dependency>
        <groupId>org.springframework.boot</groupId>
        <artifactId>spring-boot-starter-test</artifactId>
        <scope>test</scope>
        <exclusions>
            <exclusion>
                <groupId>org.junit.vintage</groupId>
                <artifactId>junit-vintage-engine</artifactId>
            </exclusion>
        </exclusions>
    </dependency>

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

    <dependency>
        <groupId>org.slf4j</groupId>
        <artifactId>slf4j-simple</artifactId>
        <version>1.7.21</version>
    </dependency>
    <dependency>
        <groupId>org.apache.logging.log4j</groupId>
        <artifactId>log4j-api</artifactId>
        <version>2.1</version>
    </dependency>
    <dependency>
        <groupId>org.apache.logging.log4j</groupId>
        <artifactId>log4j-core</artifactId>
        <version>2.1</version>
    </dependency>
    <dependency>
        <groupId>com.fasterxml.jackson.core</groupId>
        <artifactId>jackson-databind</artifactId>
        <version>2.9.3</version>
    </dependency>
    <dependency>
        <groupId>org.apache.zookeeper</groupId>
        <artifactId>zookeeper</artifactId>
        <version>3.6.1</version>
    </dependency>
    <dependency>
        <groupId>org.komamitsu</groupId>
        <artifactId>fluency-core</artifactId>
        <version>2.4.1</version>
    </dependency>

    <dependency>
        <groupId>org.komamitsu</groupId>
        <artifactId>fluency-fluentd</artifactId>
        <version>2.4.1</version>
    </dependency>
</dependencies>

<build>
    <plugins>
        <plugin>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-maven-plugin</artifactId>
        </plugin>
    </plugins>
</build>
Stephane Nicoll
  • 31,977
  • 9
  • 97
  • 89
  • You can try one of these answers: https://stackoverflow.com/questions/20137020/package-doesnt-exist-error-in-intellij – Henrique Forlani Jun 20 '20 at 12:40
  • Thanks @HenriqueForlani. I got it working by downloading fresh -the SpringInitializr with the spring Web MVC added to the initial demo package. Then adding stuff. Somehow everything worked. I am a newcomer to Java and using it occassionally. I must say, this experience has not helped me form a good opinion of the ecosystem and toolset. The stackoverflow pages are full of random trial-n-errors that worked for various situations. Sophisticated all-encompassing tools, consume 200MB and take minutes in startup, attempt to do so much for you, that nobody has a good idea when something goes wrong. – Hrishikesh V K Jun 21 '20 at 12:27

0 Answers0