1

I followed a tutorial and get this dependency file in maven project in intelliJ IDEA 2018.3

My 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>kafka.sample.firstProject</groupId>
        <artifactId>kafka-first-sample</artifactId>
        <version>1.0-SNAPSHOT</version>

        <properties>
            <java.version>1.8</java.version>
            <kafka.version>2.1.0</kafka.version>
        </properties>

        <build>
            <plug

ins>
            <!-- Maven Compiler Plugin-->
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-compiler-plugin</artifactId>
                <version>3.6.0</version>
                <configuration>
                    <source>${java.version}</source>
                    <target>${java.version}</target>
                </configuration>
            </plugin>
        </plugins>
    </build>

    <dependencies>
    <!-- Apache Kafka Clients-->
    <dependency>
        <groupId>org.apache.kafka</groupId>
        <artifactId>kafka-clients</artifactId>
        <version>2.0.0</version>
    </dependency>
    <!-- Apache Kafka Streams-->
    <dependency>
        <groupId>org.apache.kafka</groupId>
        <artifactId>kafka-streams</artifactId>
        <version>2.0.0</version>
    </dependency>
    <!-- Apache Log4J2 binding for SLF4J -->
    <dependency>
        <groupId>org.apache.logging.log4j</groupId>
        <artifactId>log4j-slf4j-impl</artifactId>
        <version>2.11.0</version>
    </dependency>
    <!-- JUnit5 Jupiter -->
    <dependency>
        <groupId>org.junit.jupiter</groupId>
        <artifactId>junit-jupiter-api</artifactId>
        <version>5.3.1</version>
        <scope>test</scope>
    </dependency>
    <!-- JUnit 5 Jupiter Engine -->
    <dependency>
        <groupId>org.junit.jupiter</groupId>
        <artifactId>junit-jupiter-engine</artifactId>
        <version>5.3.1</version>
        <scope>test</scope>
    </dependency>
    <!-- JUnit 5 Jupiter Parameterized Testing -->
    <dependency>
        <groupId>org.junit.jupiter</groupId>
        <artifactId>junit-jupiter-params</artifactId>
        <version>5.3.1</version>
        <scope>test</scope>
    </dependency>
    </dependencies>
</project>

but whenever i try to run my build it throws this:

enter image description here

Error:(3, 41) java: package org.apache.kafka.clients.producer does not exist and so on ...

Even after trying to run maven build still the problem persist.

Believe it or not i have get stuck in this problem from last many days.

Edit: As @Parsecer asked to show maven build log, i found that there is an error as well

[INFO] Scanning for projects... [INFO]
[INFO] ------------------------------------------------------------------------ [INFO] Building kafka-first-sample 1.0-SNAPSHOT [INFO] ------------------------------------------------------------------------ Downloading: https://repo.maven.apache.org/maven2/org/apache/maven/plugins/maven-clean-plugin/2.5/maven-clean-plugin-2.5.pom [INFO] ------------------------------------------------------------------------ [INFO] BUILD FAILURE [INFO] ------------------------------------------------------------------------ [INFO] Total time: 0.329 s [INFO] Finished at: 2019-02-20T09:10:30+05:00 [INFO] Final Memory: 7M/34M [INFO] ------------------------------------------------------------------------ [ERROR] Plugin org.apache.maven.plugins:maven-clean-plugin:2.5 or one of its dependencies could not be resolved: Failed to read artifact descriptor for org.apache.maven.plugins:maven-clean-plugin:jar:2.5: Could not transfer artifact org.apache.maven.plugins:maven-clean-plugin:pom:2.5 from/to central (https://repo.maven.apache.org/maven2): No such host is known (repo.maven.apache.org) -> [Help 1] [ERROR] [ERROR] To see the full stack trace of the errors, re-run Maven with the -e switch. [ERROR] Re-run Maven using the -X switch to enable full debug logging. [ERROR] [ERROR] For more information about the errors and possible solutions, please read the following articles: [ERROR] [Help 1] http://cwiki.apache.org/confluence/display/MAVEN/PluginResolutionException

Process finished with exit code 1

Muhammad Faizan Khan
  • 10,013
  • 18
  • 97
  • 186

3 Answers3

1

1) Check settings of IntelliJ by Ctrl-Alt-S. Type 'Maven' and see if you have proper Maven distribution (not the bundled one).

2) Refresh your Maven project from the right hand side of IntelliJ window.

mate00
  • 2,727
  • 5
  • 26
  • 34
0

This happens due to several issues which normally fixed after an IDE restart. Well you can try several things,

  1. Do a maven reimport
  2. Do a maven Download sources and documentation
  3. And restart the JIdea IDE

You can try to use a latest maven version and see also.

prime
  • 14,464
  • 14
  • 99
  • 131
0

My System was behind a Proxy which not allowing me to get these packages. I remove the proxy and now it is working fine.

Muhammad Faizan Khan
  • 10,013
  • 18
  • 97
  • 186