我想把硒和Spring一起使用。
如果我在没有Spring的情况下使用Selenium,一切正常。每当我添加Spring依赖项(没有Spring代码)时,执行时会引发以下异常:
线程“main”java中出现异常。lang.NoClassDefFoundError:org/openqa/selenium/MutableCapabilities at java。lang.ClassLoader。在java上定义Class1(本机方法)。lang.ClassLoader。java上的defineClass(ClassLoader.java:763)。安全SecureClassLoader。java上的defineClass(SecureClassLoader.java:142)。网URLClassLoader。java上的defineClass(URLClassLoader.java:467)。网URLClassLoader。在java上访问$100(URLClassLoader.java:73)。网URLClassLoader$1。在java上运行(URLClassLoader.java:368)。网URLClassLoader$1。在java上运行(URLClassLoader.java:362)。安全访问控制器。java上的doPrivileged(本机方法)。网URLClassLoader。java上的findClass(URLClassLoader.java:361)。lang.ClassLoader。sun上的loadClass(ClassLoader.java:424)。杂项。启动器$AppClassLoader。java上的loadClass(Launcher.java:335)。lang.ClassLoader。org上的loadClass(ClassLoader.java:357)。openqa。硒。火狐。火狐司机。(FirefoxDriver.java:98)
...
这是我的maven文件的主要部分:
<build>
<plugins>
<plugin>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-maven-plugin</artifactId>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<configuration>
<source>1.8</source>
<target>1.8</target>
</configuration>
</plugin>
</plugins>
</build>
<parent>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-parent</artifactId>
<version>1.5.10.RELEASE</version>
</parent>
<dependencies>
<!--<dependency>-->
<!--<groupId>org.springframework.boot</groupId>-->
<!--<artifactId>spring-boot-starter-web</artifactId>-->
<!--</dependency>-->
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-data-jpa</artifactId>
</dependency>
<!-- https://mvnrepository.com/artifact/org.hibernate/hibernate-core -->
<dependency>
<groupId>org.hibernate</groupId>
<artifactId>hibernate-core</artifactId>
<version>5.2.15.Final</version>
</dependency>
<!-- https://mvnrepository.com/artifact/org.hibernate/hibernate-entitymanager -->
<dependency>
<groupId>org.hibernate</groupId>
<artifactId>hibernate-entitymanager</artifactId>
<version>5.2.15.Final</version>
</dependency>
<dependency>
<groupId>com.h2database</groupId>
<artifactId>h2</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-test</artifactId>
<scope>test</scope>
</dependency>
<!-- https://mvnrepository.com/artifact/postgresql/postgresql -->
<dependency>
<groupId>postgresql</groupId>
<artifactId>postgresql</artifactId>
<version>9.1-901-1.jdbc4</version>
</dependency>
<!-- https://mvnrepository.com/artifact/org.jadira.usertype/usertype.core -->
<dependency>
<groupId>org.jadira.usertype</groupId>
<artifactId>usertype.core</artifactId>
<version>6.0.1.GA</version>
</dependency>
<!-- https://mvnrepository.com/artifact/org.seleniumhq.selenium/selenium-java -->
<dependency>
<groupId>org.seleniumhq.selenium</groupId>
<artifactId>selenium-java</artifactId>
<version>3.11.0</version>
</dependency>
<dependency>
<groupId>org.seleniumhq.selenium</groupId>
<artifactId>selenium-firefox-driver</artifactId>
<version>3.11.0</version>
</dependency>
<!-- https://mvnrepository.com/artifact/org.seleniumhq.selenium/selenium-htmlunit-driver -->
<dependency>
<groupId>org.seleniumhq.selenium</groupId>
<artifactId>selenium-htmlunit-driver</artifactId>
<version>2.29.0</version>
</dependency>
<!--<dependency>-->
<!--<groupId>com.opera</groupId>-->
<!--<artifactId>operadriver</artifactId>-->
<!--</dependency>-->
<!-- https://mvnrepository.com/artifact/org.apache.commons/commons-exec -->
<dependency>
<groupId>org.apache.commons</groupId>
<artifactId>commons-exec</artifactId>
<version>1.3</version>
</dependency>
<!--<!– https://mvnrepository.com/artifact/com.google.guava/guava –>-->
<dependency>
<groupId>com.google.guava</groupId>
<artifactId>guava</artifactId>
<version>24.1-jre</version>
</dependency>
<!-- https://mvnrepository.com/artifact/org.springframework.boot/spring-boot-starter-log4j2 -->
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-log4j2</artifactId>
<version>2.0.0.RELEASE</version>
</dependency>
<dependency>
<groupId>joda-time</groupId>
<artifactId>joda-time</artifactId>
<version>2.9.9</version>
</dependency>
</dependencies>
<dependencyManagement>
<dependencies>
<dependency>
<groupId>com.opera</groupId>
<artifactId>operadriver</artifactId>
<version>1.5</version>
<exclusions>
<exclusion>
<groupId>org.seleniumhq.selenium</groupId>
<artifactId>selenium-remote-driver</artifactId>
</exclusion>
</exclusions>
</dependency>
</dependencies>
</dependencyManagement>
<repositories>
<repository>
<id>spring-releases</id>
<name>Spring Releases</name>
<url>https://repo.spring.io/libs-release</url>
</repository>
<repository>
<id>org.jboss.repository.releases</id>
<name>JBoss Maven Release Repository</name>
<url>https://repository.jboss.org/nexus/content/repositories/releases</url>
</repository>
</repositories>
<pluginRepositories>
<pluginRepository>
<id>spring-releases</id>
<name>Spring Releases</name>
<url>https://repo.spring.io/libs-release</url>
</pluginRepository>
</pluginRepositories>
这是maven依赖树:
[INFO] +- org.springframework.boot:spring-boot-starter-data-jpa:jar:1.5.10.RELEASE:compile
[INFO] | +- org.springframework.boot:spring-boot-starter:jar:1.5.10.RELEASE:compile
[INFO] | | +- org.springframework.boot:spring-boot:jar:1.5.10.RELEASE:compile
[INFO] | | +- org.springframework.boot:spring-boot-autoconfigure:jar:1.5.10.RELEASE:compile
[INFO] | | +- org.springframework.boot:spring-boot-starter-logging:jar:1.5.10.RELEASE:compile
[INFO] | | | +- ch.qos.logback:logback-classic:jar:1.1.11:compile
[INFO] | | | | \- ch.qos.logback:logback-core:jar:1.1.11:compile
[INFO] | | | \- org.slf4j:log4j-over-slf4j:jar:1.7.25:compile
[INFO] | | \- org.yaml:snakeyaml:jar:1.17:runtime
[INFO] | +- org.springframework.boot:spring-boot-starter-aop:jar:1.5.10.RELEASE:compile
[INFO] | | +- org.springframework:spring-aop:jar:4.3.14.RELEASE:compile
[INFO] | | \- org.aspectj:aspectjweaver:jar:1.8.13:compile
[INFO] | +- org.springframework.boot:spring-boot-starter-jdbc:jar:1.5.10.RELEASE:compile
[INFO] | | +- org.apache.tomcat:tomcat-jdbc:jar:8.5.27:compile
[INFO] | | | \- org.apache.tomcat:tomcat-juli:jar:8.5.27:compile
[INFO] | | \- org.springframework:spring-jdbc:jar:4.3.14.RELEASE:compile
[INFO] | +- javax.transaction:javax.transaction-api:jar:1.2:compile
[INFO] | +- org.springframework.data:spring-data-jpa:jar:1.11.10.RELEASE:compile
[INFO] | | +- org.springframework.data:spring-data-commons:jar:1.13.10.RELEASE:compile
[INFO] | | +- org.springframework:spring-orm:jar:4.3.14.RELEASE:compile
[INFO] | | +- org.springframework:spring-context:jar:4.3.14.RELEASE:compile
[INFO] | | | \- org.springframework:spring-expression:jar:4.3.14.RELEASE:compile
[INFO] | | +- org.springframework:spring-tx:jar:4.3.14.RELEASE:compile
[INFO] | | +- org.springframework:spring-beans:jar:4.3.14.RELEASE:compile
[INFO] | | \- org.slf4j:jcl-over-slf4j:jar:1.7.25:compile
[INFO] | \- org.springframework:spring-aspects:jar:4.3.14.RELEASE:compile
[INFO] +- org.hibernate:hibernate-core:jar:5.2.15.Final:compile
[INFO] | +- org.jboss.logging:jboss-logging:jar:3.3.1.Final:compile
[INFO] | +- org.hibernate.javax.persistence:hibernate-jpa-2.1-api:jar:1.0.0.Final:compile
[INFO] | +- org.javassist:javassist:jar:3.21.0-GA:compile
[INFO] | +- antlr:antlr:jar:2.7.7:compile
[INFO] | +- org.jboss.spec.javax.transaction:jboss-transaction-api_1.2_spec:jar:1.0.1.Final:compile
[INFO] | +- org.jboss:jandex:jar:2.0.3.Final:compile
[INFO] | +- com.fasterxml:classmate:jar:1.3.4:compile
[INFO] | +- dom4j:dom4j:jar:1.6.1:compile
[INFO] | \- org.hibernate.common:hibernate-commons-annotations:jar:5.0.1.Final:compile
[INFO] +- org.hibernate:hibernate-entitymanager:jar:5.2.15.Final:compile
[INFO] | \- net.bytebuddy:byte-buddy:jar:1.6.14:compile
[INFO] +- com.h2database:h2:jar:1.4.196:compile
[INFO] +- org.springframework.boot:spring-boot-starter-test:jar:1.5.10.RELEASE:test
[INFO] | +- org.springframework.boot:spring-boot-test:jar:1.5.10.RELEASE:test
[INFO] | +- org.springframework.boot:spring-boot-test-autoconfigure:jar:1.5.10.RELEASE:test
[INFO] | +- com.jayway.jsonpath:json-path:jar:2.2.0:test
[INFO] | | \- net.minidev:json-smart:jar:2.2.1:test
[INFO] | | \- net.minidev:accessors-smart:jar:1.1:test
[INFO] | | \- org.ow2.asm:asm:jar:5.0.3:test
[INFO] | +- junit:junit:jar:4.12:test
[INFO] | +- org.assertj:assertj-core:jar:2.6.0:test
[INFO] | +- org.mockito:mockito-core:jar:1.10.19:test
[INFO] | | \- org.objenesis:objenesis:jar:2.1:test
[INFO] | +- org.hamcrest:hamcrest-core:jar:1.3:test
[INFO] | +- org.hamcrest:hamcrest-library:jar:1.3:test
[INFO] | +- org.skyscreamer:jsonassert:jar:1.4.0:test
[INFO] | | \- com.vaadin.external.google:android-json:jar:0.0.20131108.vaadin1:test
[INFO] | +- org.springframework:spring-core:jar:4.3.14.RELEASE:compile
[INFO] | \- org.springframework:spring-test:jar:4.3.14.RELEASE:test
[INFO] +- postgresql:postgresql:jar:9.1-901-1.jdbc4:compile
[INFO] +- org.jadira.usertype:usertype.core:jar:6.0.1.GA:compile
[INFO] | +- org.slf4j:slf4j-api:jar:1.7.25:compile
[INFO] | \- org.jadira.usertype:usertype.spi:jar:6.0.1.GA:compile
[INFO] +- org.seleniumhq.selenium:selenium-java:jar:3.11.0:compile
[INFO] | +- org.seleniumhq.selenium:selenium-api:jar:2.53.1:compile
[INFO] | +- org.seleniumhq.selenium:selenium-chrome-driver:jar:2.53.1:compile
[INFO] | +- org.seleniumhq.selenium:selenium-edge-driver:jar:2.53.1:compile
[INFO] | | \- commons-io:commons-io:jar:2.4:compile
[INFO] | +- org.seleniumhq.selenium:selenium-ie-driver:jar:2.53.1:compile
[INFO] | | +- net.java.dev.jna:jna:jar:4.2.2:compile
[INFO] | | \- net.java.dev.jna:jna-platform:jar:4.2.2:compile
[INFO] | +- org.seleniumhq.selenium:selenium-opera-driver:jar:3.11.0:compile
[INFO] | +- org.seleniumhq.selenium:selenium-remote-driver:jar:2.53.1:compile
[INFO] | | \- cglib:cglib-nodep:jar:2.1_3:compile
[INFO] | +- org.seleniumhq.selenium:selenium-safari-driver:jar:2.53.1:compile
[INFO] | | \- io.netty:netty:jar:3.5.7.Final:compile
[INFO] | +- org.seleniumhq.selenium:selenium-support:jar:2.53.1:compile
[INFO] | +- commons-codec:commons-codec:jar:1.10:compile
[INFO] | +- commons-logging:commons-logging:jar:1.2:compile
[INFO] | +- com.google.code.gson:gson:jar:2.8.2:compile
[INFO] | +- org.apache.httpcomponents:httpclient:jar:4.5.5:compile
[INFO] | +- org.apache.httpcomponents:httpcore:jar:4.4.9:compile
[INFO] | +- com.squareup.okhttp3:okhttp:jar:3.9.1:compile
[INFO] | \- com.squareup.okio:okio:jar:1.13.0:compile
[INFO] +- org.seleniumhq.selenium:selenium-firefox-driver:jar:3.11.0:compile
[INFO] +- org.seleniumhq.selenium:selenium-htmlunit-driver:jar:2.29.0:compile
[INFO] | \- net.sourceforge.htmlunit:htmlunit:jar:2.21:compile
[INFO] | +- xalan:xalan:jar:2.7.2:compile
[INFO] | | \- xalan:serializer:jar:2.7.2:compile
[INFO] | +- org.apache.commons:commons-lang3:jar:3.4:compile
[INFO] | +- org.apache.httpcomponents:httpmime:jar:4.5.5:compile
[INFO] | +- net.sourceforge.htmlunit:htmlunit-core-js:jar:2.17:compile
[INFO] | +- net.sourceforge.htmlunit:neko-htmlunit:jar:2.21:compile
[INFO] | | \- xerces:xercesImpl:jar:2.11.0:compile
[INFO] | | \- xml-apis:xml-apis:jar:1.4.01:compile
[INFO] | +- net.sourceforge.cssparser:cssparser:jar:0.9.18:compile
[INFO] | | \- org.w3c.css:sac:jar:1.3:compile
[INFO] | \- org.eclipse.jetty.websocket:websocket-client:jar:9.4.8.v20171121:compile
[INFO] | +- org.eclipse.jetty:jetty-client:jar:9.4.8.v20171121:compile
[INFO] | | \- org.eclipse.jetty:jetty-http:jar:9.4.8.v20171121:compile
[INFO] | +- org.eclipse.jetty:jetty-xml:jar:9.4.8.v20171121:compile
[INFO] | +- org.eclipse.jetty:jetty-util:jar:9.4.8.v20171121:compile
[INFO] | +- org.eclipse.jetty:jetty-io:jar:9.4.8.v20171121:compile
[INFO] | \- org.eclipse.jetty.websocket:websocket-common:jar:9.4.8.v20171121:compile
[INFO] | \- org.eclipse.jetty.websocket:websocket-api:jar:9.4.8.v20171121:compile
[INFO] +- org.apache.commons:commons-exec:jar:1.3:compile
[INFO] +- com.google.guava:guava:jar:24.1-jre:compile
[INFO] | +- com.google.code.findbugs:jsr305:jar:1.3.9:compile
[INFO] | +- org.checkerframework:checker-compat-qual:jar:2.0.0:compile
[INFO] | +- com.google.errorprone:error_prone_annotations:jar:2.1.3:compile
[INFO] | +- com.google.j2objc:j2objc-annotations:jar:1.1:compile
[INFO] | \- org.codehaus.mojo:animal-sniffer-annotations:jar:1.14:compile
[INFO] +- org.springframework.boot:spring-boot-starter-log4j2:jar:2.0.0.RELEASE:compile
[INFO] | +- org.apache.logging.log4j:log4j-slf4j-impl:jar:2.7:compile
[INFO] | | \- org.apache.logging.log4j:log4j-api:jar:2.7:compile
[INFO] | +- org.apache.logging.log4j:log4j-core:jar:2.7:compile
[INFO] | \- org.slf4j:jul-to-slf4j:jar:1.7.25:compile
[INFO] \- joda-time:joda-time:jar:2.9.9:compile
更新:这是我的代码-非常简单,但firefoxdriver甚至无法创建。。
public class Application {
private static Logger log = LogManager.getLogger(Application.class);
public static void main(String[] args) {
FirefoxDriver driver = new FirefoxDriver(); // exception thrown here
driver.close();
}
}
解决方案:
通过查看maven存储库中Selenium的依赖关系,我可以看到运行Selenium需要哪些版本。然后在maven中显式添加这些JAR可以解决依赖冲突。
谢谢你的帮助!
org的版本。硒。selenium:selenium htmlunit驱动程序
和net。sourceforge。htmlunit:htmlunit
应该对齐,但您使用的是前者的2.29和后者的2.21。如果从依赖项声明中删除这些版本,Spring Boot的依赖项管理将为您解决问题。
我想在我的Junit5单元测试中将值注入到带有@Value注释的私有字段。 我引用了这个,并使用了ReflectionTestUtils。setField通过注入值解决了我的问题,但在验证方法被调用的次数时失败。 MyClass(我的类别): 测试类: 运行上述测试时出错 我想kafkaTemplate.sendMessage();被调用一次,但被调用两次后添加反射TestUtils。 需要关于如
我目前正在与apache ivy的conf设置作斗争。也许我会先解释我想实现的目标: 我需要两种配置:编译、运行时 这是我试过的: 但它甚至无法被解析:无法解析ivy文件'...\ivy.xml': 有人能告诉我如何正确地声明conf设置,这样我就可以使用compile或runtime来解析,并获得所有jar,包括可传递的依赖项(在这个示例中,只有ivy的jar)。 使现代化 好的,谢谢你的链接。
#非技术春招备战日记# #校招过来人的经验分享# 4399面经: 春招提前批+游戏运营岗,15mins 1.一面hr 2.没有自我介绍,直接开始提问(问毕业论文和秋招情况) 3.对游戏行业的了解? 4.校园或实习最难忘的一件事? 5.运营需要的能力? 6.学习怎么样?大学怎么分配时间的 7.有自学运营知识吗? 8.最喜欢哪一段实习,为什么 9.反问
问题内容: 我有一个Java应用程序,它从主类开始(不是Spring Boot应用程序)。而且我想使用Spring retry在连接丢失时重试。据我所知,我需要在Spring应用程序的主类之上添加@EnableRetry批注,然后在我的方法之上使用@Retryable进行重试。但是我认为这在非Spring应用程序中将不起作用。是否可以在简单的Java应用程序(而非spring应用程序)中使用s
Java-Spring-骆驼 我想用服务列表发起骆驼路线。 想做下面的事情,但是< code>from方法似乎不是一个生产者。如何定义动态生产者?
Spring Cloud Kafka Streams与Spring Cloud Stream、Spring Cloud Function、Spring AMQP和Spring for Apache Kafka有什么区别?