HtmlUnit依赖关系错误-NoClassDefFoundException

时间:2019-01-03 19:25:49

标签: java http maven-2 pom.xml http-unit

最近,我一直在尝试使用HtmlUnit API,但是由于某些原因,我无法获得所需的所有依赖项。我做的第一件事是在HtmlUnit网站上搜索依赖项的完整列表(http://htmlunit.sourceforge.net/dependencies.html)。然后,我搜索了每个对象的maven依赖项,直到创建了最终的pom.xml:

b

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

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

我启动了服务器,但是在加载插件时(我正在开发spigotMC.org插件),我收到了NoClassDefFoundException: <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>

1 个答案:

答案 0 :(得分:0)

您是否尝试过仅用这个替换所有依赖项:

<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存储库的链接: https://mvnrepository.com/artifact/net.sourceforge.htmlunit/htmlunit/2.4