简体   繁体   中英

Problems with use Jsoup library

I'm trying make a project using Jsoup library. I imported the library using maven. My problem is when I have start to code using Jsoup classes and methods, eclipse don't show me anything available to import and to use from "org.jsoup"

I've already used Maven update project but my project has all dependencies placed right.

Someone got this problem too and could help me?

That is my current pom.xml on dependencies section:

<build>
    <finalName>crawler-api</finalName>
  </build>
  <properties>
    <failOnMissingWebXml>false</failOnMissingWebXml>
    <maven.compiler.source>1.8</maven.compiler.source>
    <maven.compiler.target>1.8</maven.compiler.target>
    <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
  </properties>
    <dependencies>
        <dependency>
          <groupId>javax.enterprise</groupId>
          <artifactId>cdi-api</artifactId>
          <scope>provided</scope>
        </dependency>
        <dependency>
          <groupId>javax.annotation</groupId>
          <artifactId>jsr250-api</artifactId>
          <scope>provided</scope>
        </dependency>
        <dependency>
            <groupId>javax.ws.rs</groupId>
            <artifactId>javax.ws.rs-api</artifactId>
            <version>2.1</version>
            <scope>provided</scope>
        </dependency>
        <dependency>
            <groupId>org.jsoup</groupId>
            <artifactId>jsoup</artifactId>
            <version>1.11.2</version>
            <scope>provided</scope>
        </dependency>
      </dependencies>

and my project libraries screenshot: project libraries

Well. After some struggles I will leave some details about what I did to solve my problem.

Unfortunately for some reason if you try add Jsoup library from maven repository I can get the classes and methods from the api. I found some comments on github from people who said that the only solution for that is including the jars into your project. What sounds a bit old fashion.

Well. Let's get started.

First, create a folder called lib into src/main/webapp/WEB-INF/ and have included the jsoup .jar that I have downloaded from the official web site. After that I've added into pom.xml on dependencies section the follow child tag.

<dependency>
        <groupId>org.jsoup</groupId>
        <artifactId>jsoup</artifactId>
        <version>1.11.2</version>
        <scope>system</scope>
        <systemPath>${pom.basedir}/src/main/webapp/WEB-INF/lib/jsoup-1.11.2.jar</systemPath>
    </dependency>

So when I've started code my app using the classes and methods from the api everything seems available when I called. And after that when I built my artifact using maven the dependencies has been available inside my artifact.

I really hope this could help someone. And I hope that the developers of Jsoup somehow fix that.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM