Home > Software design >  get error, when add external dependency in maven
get error, when add external dependency in maven

Time:04-23

I want to add a dependency to the project (jsoup library) and i get an error

my pom.xml

<?xml version="1.0" encoding="UTF-8"?>

4.0.0

<groupId>org.example</groupId>
<artifactId>training</artifactId>
<version>1.0-SNAPSHOT</version>





<properties>
    <maven.compiler.source>17</maven.compiler.source>
    <maven.compiler.target>17</maven.compiler.target>
</properties>


<dependencies>
    <!-- https://mvnrepository.com/artifact/org.jsoup/jsoup -->
    <dependency>
        <groupId>org.jsoup</groupId>
        <artifactId>jsoup</artifactId>
        <version>1.14.2</version>
    </dependency>

</dependencies>

error enter image description here

Please, help

CodePudding user response:

I have created a pom.xml based on your question.

It works well when I type mvn clean package command.

<?xml version="1.0" encoding="UTF-8"?>
<project xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
  xmlns="http://maven.apache.org/POM/4.0.0"
  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>
  <groupId>org.example</groupId>
  <artifactId>training</artifactId>
  <version>1.0-SNAPSHOT</version>
  <name>YOUR_NAME</name>
  <description>description</description>

  <properties>
    <maven.compiler.source>17</maven.compiler.source>
    <maven.compiler.target>17</maven.compiler.target>
  </properties>

  <dependencies>
    <dependency>
      <groupId>org.jsoup</groupId>
      <artifactId>jsoup</artifactId>
      <version>1.14.2</version>
    </dependency>
  </dependencies>
  
</project>
  • Related