首页
学习
活动
专区
工具
TVP
发布
社区首页 >问答首页 >HtmlUnit依赖项错误- NoClassDefFoundException

HtmlUnit依赖项错误- NoClassDefFoundException
EN

Stack Overflow用户
提问于 2019-01-04 03:25:49
回答 1查看 96关注 0票数 0

最近我一直在尝试使用HtmlUnit应用程序接口,但由于某些原因,我无法拥有所需的所有依赖项。我做的第一件事是访问HtmlUnit站点并搜索依赖项的完整列表(http://htmlunit.sourceforge.net/dependencies.html)。然后,我在maven依赖项中搜索它们,直到我创建了最终的pom.xml:

代码语言:javascript
复制
<?xml version="1.0" encoding="UTF-8"?>

">http://maven.apache.org/xsd/maven-4.0.0.xsd"> 4.0.0

代码语言:javascript
复制
<groupId>it.auties</groupId>
<artifactId>it.auties</artifactId>
<version>1.0-SNAPSHOT</version>
<build>
    <plugins>
        <plugin>
            <groupId>org.apache.maven.plugins</groupId>
            <artifactId>maven-compiler-plugin</artifactId>
            <configuration>
                <source>8</source>
                <target>8</target>
            </configuration>
        </plugin>
    </plugins>
</build>

<repositories>
    <repository>
        <id>spigot-repo</id>
        <url>https://hub.spigotmc.org/nexus/content/repositories/snapshots/</url>
    </repository>
    <repository>
        <id>vault-repo</id>
        <url>http://nexus.hc.to/content/repositories/pub_releases</url>
    </repository>
    <repository>
        <id>wesjd-repo</id>
        <url>https://nexus.wesjd.net/repository/thirdparty/</url>
    </repository>
</repositories>

<dependencies>
    <dependency>
        <groupId>org.spigotmc</groupId>
        <artifactId>spigot-api</artifactId>
        <version>1.13.2-R0.1-SNAPSHOT</version>
        <scope>provided</scope>
    </dependency>
    <dependency>
        <groupId>net.milkbowl.vault</groupId>
        <artifactId>VaultAPI</artifactId>
        <version>1.7</version>
        <scope>provided</scope>
    </dependency>
    <dependency>
        <groupId>net.wesjd</groupId>
        <artifactId>anvilgui</artifactId>
        <version>1.2.1-SNAPSHOT</version>
    </dependency>
    <dependency>
        <groupId>net.sourceforge.htmlunit</groupId>
        <artifactId>htmlunit</artifactId>
        <version>2.33</version>
    </dependency>
    <dependency>
        <groupId>commons-io</groupId>
        <artifactId>commons-io</artifactId>
        <version>2.6</version>
    </dependency>
    <dependency>
        <groupId>commons-logging</groupId>
        <artifactId>commons-logging</artifactId>
        <version>1.2</version>
    </dependency>
    <dependency>
        <groupId>commons-net</groupId>
        <artifactId>commons-net</artifactId>
        <version>3.6</version>
    </dependency>
    <dependency>
        <groupId>net.sourceforge.htmlunit</groupId>
        <artifactId>htmlunit-core-js</artifactId>
        <version>2.33</version>
    </dependency>
    <dependency>
        <groupId>net.sourceforge.htmlunit</groupId>
        <artifactId>htmlunit-cssparser</artifactId>
        <version>1.2.0</version>
    </dependency>
    <dependency>
        <groupId>net.sourceforge.htmlunit</groupId>
        <artifactId>neko-htmlunit</artifactId>
        <version>2.33</version>
    </dependency>
    <dependency>
        <groupId>org.apache.commons</groupId>
        <artifactId>commons-lang3</artifactId>
        <version>3.8</version>
    </dependency>
    <dependency>
        <groupId>org.apache.commons</groupId>
        <artifactId>commons-text</artifactId>
        <version>1.4</version>
    </dependency>
    <dependency>
        <groupId>org.apache.httpcomponents</groupId>
        <artifactId>httpmime</artifactId>
        <version>4.5.6</version>
    </dependency>
    <dependency>
        <groupId>org.eclipse.jetty.websocket</groupId>
        <artifactId>websocket-client</artifactId>
        <version>9.4.12.v20180830</version>
    </dependency>
    <dependency>
        <groupId>xalan</groupId>
        <artifactId>xalan</artifactId>
        <version>2.7.2</version>
    </dependency>
    <dependency>
        <groupId>org.apache.httpcomponents</groupId>
        <artifactId>httpclient</artifactId>
        <version>4.5.6</version>
    </dependency>
</dependencies>

我启动了服务器,但在加载插件时(我正在开发一个spigotMC.org插件),我得到一个NoClassDefFoundException:java.lang.NoClassDefFoundError: com/gargoylesoftware/htmlunit/WebClient

EN

回答 1

Stack Overflow用户

发布于 2019-01-04 03:48:46

您是否尝试过将所有这些依赖项仅替换为以下一个:

代码语言:javascript
复制
<dependency>
  <groupId>net.sourceforge.htmlunit</groupId>
  <artifactId>htmlunit</artifactId>
  <version>2.4</version> <!-- use version that is suitable for you -->
</dependency>

如果您需要使用HtmlUnit,只需将其作为依赖项添加到您的项目中,Mavne将下载所有可传递依赖项本身。这是HtmlUnit的Maven repo的链接:https://mvnrepository.com/artifact/net.sourceforge.htmlunit/htmlunit/2.4

票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/54028590

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档