Itération 122442
Itération 122442

Reputation: 2962

Problem when adding a dependency to maven

I have a very basic springboot project that has the following 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 https://maven.apache.org/xsd/maven-4.0.0.xsd">
    <modelVersion>4.0.0</modelVersion>
    <parent>
        <groupId>org.springframework.boot</groupId>
        <artifactId>spring-boot-starter-parent</artifactId>
        <version>2.3.4.RELEASE</version>
        <relativePath/> <!-- lookup parent from repository -->
    </parent>



    <properties>
        <java.version>11</java.version>
    </properties>

    <dependencies>
        
        <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-starter-actuator</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>
            <optional>true</optional>
        </dependency>
        <dependency>
            <groupId>org.projectlombok</groupId>
            <artifactId>lombok</artifactId>
            <optional>true</optional>
        </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>
    </dependencies>

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

I want to add this dependency: https://search.maven.org/artifact/org.apache.hive/hive-jdbc/3.1.2/jar

So I added in the dependencies :

<dependency>
  <groupId>org.apache.hive</groupId>
  <artifactId>hive-jdbc</artifactId>
  <version>3.1.2</version>
</dependency>

However, when I have this in my pom.xml, I have the following errors:

The project cannot be built until build path errors are resolved

The container 'Maven Dependencies' references non existing library '/home/hduser/.m2/repository/jdk/tools/jdk.tools/1.6/jdk.tools-1.6.jar'

Missing artifact jdk.tools:jdk.tools:jar:1.6

I am using java 11 and my IDE as well as JAVA_HOME is set to java 11.

How can I solve this ?


Edit 1:

mvn clean package


------------------------------------------------------------------------
[INFO] BUILD FAILURE
[INFO] ------------------------------------------------------------------------
[INFO] Total time:  2.454 s
[INFO] Finished at: 2020-10-06T10:51:20+02:00
[INFO] ------------------------------------------------------------------------
[ERROR] Failed to execute goal on project dataanalytics: Could not resolve dependencies for project com.bla:dataanalytics:jar:0.0.1-SNAPSHOT: Could not find artifact jdk.tools:jdk.tools:jar:1.6 at specified path /usr/lib/jvm/java-11-openjdk-amd64/../lib/tools.jar -> [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/DependencyResolutionException

Upvotes: 2

Views: 1581

Answers (1)

MarkAddison
MarkAddison

Reputation: 565

Interpretting the error message

Could not find artifact jdk.tools:jdk.tools:jar:1.6 at specified path /usr/lib/jvm/java-11-openjdk-amd64/../lib/tools.jar

The tools.jar file is supplied by the JDK - looks like 1.6 is referenced from the included dependency - suggest you explicitly exclude it:

<dependency>
  <groupId>org.apache.hive</groupId>
  <artifactId>hive-jdbc</artifactId>
  <version>3.1.2</version>
  <exclusions>
    <exclusion>
      <artifactId>jdk.tools</artifactId>
      <groupId>jdk.tools</groupId>
    </exclusion>
  </exclusions>

</dependency>

Upvotes: 8

Related Questions