我使用网站建议的
将htmlunit添加到我的POM文件中<dependency>
<groupId>net.sourceforge.htmlunit</groupId>
<artifactId>htmlunit</artifactId>
<version>2.22</version>
</dependency>
但我正在尝试创建一个webclient,如下所示:
WebClient webClient = new WebClient(BrowserVersion.BEST_SUPPORTED);
但它给了我这个错误:
BEST_SUPPORTED cannot be resolved or is not a field
看起来它们来自HTMLUnit的旧版本,因为根据他javadocs他们有Firefox 45和Microsoft Edge等...我没有选择。
如何让Eclipse中的Maven使用更新版本的HTMLunit?
我已经尝试过安装mvn mvn clean&gt; mvn install
右键单击Eclipse中的项目&gt; Maven&gt;更新项目。
这是来自mvn dependency:tree
--- maven-dependency-plugin:2.8:tree (default-cli) @ vaadin-app ---
[INFO] org.test:vaadin-app:war:1.0-SNAPSHOT
[INFO] +- com.vaadin.external.streamhtmlparser:streamhtmlparser-jsilver:jar:0.0.10.vaadin1:compile
[INFO] +- javax.servlet:javax.servlet-api:jar:3.0.1:provided
[INFO] +- org.apache.httpcomponents:httpmime:jar:4.5.2:compile
[INFO] | \- org.apache.httpcomponents:httpclient:jar:4.5.2:compile
[INFO] +- com.vaadin:vaadin-server:jar:7.6.7:compile
[INFO] | +- com.vaadin:vaadin-sass-compiler:jar:0.9.13:compile
[INFO] | | +- com.vaadin.external.flute:flute:jar:1.3.0.gg2:compile
[INFO] | | \- com.yahoo.platform.yui:yuicompressor:jar:2.4.8:compile
[INFO] | | \- rhino:js:jar:1.7R2:compile
[INFO] | +- com.vaadin:vaadin-shared:jar:7.6.7:compile
[INFO] | | \- com.vaadin.external.google:guava:jar:16.0.1.vaadin1:compile
[INFO] | \- org.jsoup:jsoup:jar:1.8.3:compile
[INFO] +- com.vaadin:vaadin-push:jar:7.6.7:compile
[INFO] | \- com.vaadin.external.atmosphere:atmosphere-runtime:jar:2.2.7.vaadin1:compile
[INFO] | \- com.vaadin.external.slf4j:vaadin-slf4j-jdk14:jar:1.6.1:compile
[INFO] +- com.vaadin:vaadin-client:jar:7.6.7:provided
[INFO] | +- org.w3c.css:sac:jar:1.3:compile
[INFO] | +- javax.validation:validation-api:jar:1.0.0.GA:provided
[INFO] | \- javax.validation:validation-api:jar:sources:1.0.0.GA:provided
[INFO] +- com.vaadin:vaadin-client-compiler:jar:7.6.7:provided
[INFO] | +- commons-collections:commons-collections:jar:3.2.2:compile
[INFO] | +- commons-logging:commons-logging:jar:1.1.3:compile
[INFO] | +- ant:ant:jar:1.6.5:provided
[INFO] | +- net.sourceforge.cssparser:cssparser:jar:0.9.11:compile
[INFO] | +- ant:ant-launcher:jar:1.6.5:provided
[INFO] | +- org.ow2.asm:asm:jar:5.0.3:provided
[INFO] | +- org.ow2.asm:asm-util:jar:5.0.3:provided
[INFO] | | \- org.ow2.asm:asm-tree:jar:5.0.3:provided
[INFO] | +- org.ow2.asm:asm-commons:jar:5.0.3:provided
[INFO] | +- org.eclipse.jetty:jetty-annotations:jar:8.1.12.v20130726:provided
[INFO] | | +- org.eclipse.jetty:jetty-plus:jar:8.1.12.v20130726:provided
[INFO] | | | +- org.eclipse.jetty.orbit:javax.transaction:jar:1.1.1.v201105210645:provided
[INFO] | | | \- org.eclipse.jetty:jetty-jndi:jar:8.1.12.v20130726:provided
[INFO] | | | +- org.eclipse.jetty:jetty-server:jar:8.1.12.v20130726:provided
[INFO] | | | | \- org.eclipse.jetty.orbit:javax.servlet:jar:3.0.0.v201112011016:provided
[INFO] | | | \- org.eclipse.jetty.orbit:javax.mail.glassfish:jar:1.4.1.v201005082020:provided
[INFO] | | | \- org.eclipse.jetty.orbit:javax.activation:jar:1.1.0.v201105071233:provided
[INFO] | | +- org.eclipse.jetty:jetty-webapp:jar:8.1.12.v20130726:provided
[INFO] | | | +- org.eclipse.jetty:jetty-xml:jar:8.1.12.v20130726:provided
[INFO] | | | \- org.eclipse.jetty:jetty-servlet:jar:8.1.12.v20130726:provided
[INFO] | | | \- org.eclipse.jetty:jetty-security:jar:8.1.12.v20130726:provided
[INFO] | | +- org.eclipse.jetty.orbit:javax.annotation:jar:1.1.0.v201108011116:provided
[INFO] | | \- org.eclipse.jetty.orbit:org.objectweb.asm:jar:3.1.0.v200803061910:provided
[INFO] | +- org.eclipse.jetty:jetty-servlets:jar:8.1.12.v20130726:provided
[INFO] | | +- org.eclipse.jetty:jetty-continuation:jar:8.1.12.v20130726:provided
[INFO] | | \- org.eclipse.jetty:jetty-client:jar:8.1.12.v20130726:provided
[INFO] | | \- org.eclipse.jetty:jetty-http:jar:8.1.12.v20130726:provided
[INFO] | +- org.eclipse.jetty:jetty-util:jar:8.1.12.v20130726:compile
[INFO] | +- org.jdesktop:swing-worker:jar:1.1:provided
[INFO] | +- commons-codec:commons-codec:jar:1.8:compile
[INFO] | +- commons-io:commons-io:jar:2.4:compile
[INFO] | +- org.apache.commons:commons-lang3:jar:3.1:compile
[INFO] | +- org.apache.james:apache-mime4j:jar:0.6:provided
[INFO] | +- org.apache.httpcomponents:httpcore:jar:4.3:compile
[INFO] | +- net.sourceforge.nekohtml:nekohtml:jar:1.9.19:provided
[INFO] | +- xalan:serializer:jar:2.7.1:compile
[INFO] | +- xerces:xercesImpl:jar:2.11.0:compile
[INFO] | +- xml-apis:xml-apis:jar:1.4.01:compile
[INFO] | +- com.ibm.icu:icu4j:jar:50.1.1:provided
[INFO] | \- com.vaadin:vaadin-client-compiler-deps:jar:1.2.0:provided
[INFO] +- com.vaadin:vaadin-themes:jar:7.6.7:compile
[INFO] +- net.sf.ucanaccess:ucanaccess:jar:3.0.6:compile
[INFO] | +- org.hsqldb:hsqldb:jar:2.3.1:compile
[INFO] | \- com.healthmarketscience.jackcess:jackcess:jar:2.1.3:compile
[INFO] | \- commons-lang:commons-lang:jar:2.6:compile
[INFO] +- net.sourceforge.htmlunit:htmlunit:jar:2.22:compile
[INFO] | +- xalan:xalan:jar:2.7.2:compile
[INFO] | +- net.sourceforge.htmlunit:htmlunit-core-js:jar:2.22:compile
[INFO] | +- net.sourceforge.htmlunit:neko-htmlunit:jar:2.21:compile
[INFO] | \- org.eclipse.jetty.websocket:websocket-client:jar:9.2.17.v20160517:compile
[INFO] | +- org.eclipse.jetty:jetty-io:jar:9.2.17.v20160517:compile
[INFO] | \- org.eclipse.jetty.websocket:websocket-common:jar:9.2.17.v20160517:compile
[INFO] | \- org.eclipse.jetty.websocket:websocket-api:jar:9.2.17.v20160517:compile
[INFO] \- org.vaadin:viritin:jar:1.54:compile
[INFO] +- org.vaadin.addon:confirmdialog:jar:2.1.3:compile
[INFO] +- org.commonjava.googlecode.markdown4j:markdown4j:jar:2.2-cj-1.1:compile
[INFO] +- commons-beanutils:commons-beanutils:jar:1.9.2:compile
[INFO] \- javax.el:javax.el-api:jar:2.2.4:compile
答案 0 :(得分:0)
尝试删除htmlunit的本地repo目录,然后尝试更新项目。