在一个maven项目中,如果存在编译需要而发布不需要的jar包,可以用scope标签,值设为provided。如下: <dependency> <groupId>junit</groupId> <artifactId>junit</artifactId> <version>4.12</version> <scope>test</scope> </dependency> scope的其他参数如下: compile…
April 17, 2017
JAVA: 解决报错Exception in thread “main” java.lang.NoSuchMethodError: com.google.common.base.Preconditions.checkState(ZLjava/lang/String;Ljava/lang/Object;Ljava/lang/Object;Ljava/lang/Object;)V
用到selenium webdiver的是,发现报错:
Exception in thread “main” java.lang.NoSuchMethodError: com.google.common.base.Preconditions.checkState(ZLjava/lang/String;Ljava/lang/Object;Ljava/lang/Object;Ljava/lang/Object;)V
解决方法,在maven的porm.xml的配置文件中加载最新版的google guava
<dependency> <groupId>com.google.guava</groupId> <artifactId>guava</artifactId> <version>21.0</version> </dependency>
源自:http://mvnrepository.com/artifact/com.google.guava/guava
Please tune your project settings and add guava [1] version 10+ to the classpath (selenium
distribution package includes guava 15)
[1] https://code.google.com/p/guava-libraries/