Jarell Hell问题与elasticsearch-test api

时间:2017-05-03 08:30:45

标签: elasticsearch junit jar

我正在尝试使用Junit在我的本地环境中对ES进行模拟测试。 Eclipse IDE上的简单Junit测试有效,但Maven运行没有。

我正面临着一个Jar Hell Runtime问题。

以下是我使用的Maven依赖项。

<dependencies>
<dependency>
  <groupId>junit</groupId>
  <artifactId>junit</artifactId>
  <version>4.11</version>
  <scope>test</scope>
  <exclusions>
    <exclusion>
        <groupId>org.hamcrest</groupId>
        <artifactId>hamcrest-core</artifactId>
    </exclusion>
  </exclusions>
</dependency>
<dependency>
  <groupId>org.elasticsearch.test</groupId>
  <artifactId>framework</artifactId>
  <version>5.0.0</version>
  <scope>test</scope>
</dependency>
<dependency>
  <groupId>org.apache.logging.log4j</groupId>
  <artifactId>log4j-core</artifactId>
  <version>2.7</version>
  <scope>test</scope>
</dependency>

以下是我使用Elasticsearch-test api编写的Junit类

import org.elasticsearch.test.ESTestCase;
import org.junit.Test;
public class SampleTest extends ESTestCase {
  @Test
  public void runtTest() throws Exception{
    System.out.println("HI Suman");

    setUp();
  }
}

我得到以下异常,像这样运行它

mvn clean install -Deststs.security.manager = false -Deststs.asserts = false

java.lang.RuntimeException: found jar hell in test classpath
at org.elasticsearch.bootstrap.BootstrapForTesting.<clinit>(BootstrapForTesting.java:90)
at org.elasticsearch.test.ESTestCase.<clinit>(ESTestCase.java:138)
at java.lang.Class.forName0(Native Method)
at java.lang.Class.forName(Class.java:348)
at com.carrotsearch.randomizedtesting.RandomizedRunner$2.run(RandomizedRunner.java:585)
Caused by: java.nio.file.NoSuchFileException: C:\CodeRepo\mock-es\build\resources\test
at sun.nio.fs.WindowsException.translateToIOException(WindowsException.java:79)
at sun.nio.fs.WindowsException.rethrowAsIOException(WindowsException.java:97)
at sun.nio.fs.WindowsException.rethrowAsIOException(WindowsException.java:102)
at sun.nio.fs.WindowsFileAttributeViews$Basic.readAttributes(WindowsFileAttributeViews.java:53)
at sun.nio.fs.WindowsFileAttributeViews$Basic.readAttributes(WindowsFileAttributeViews.java:38)
at sun.nio.fs.WindowsFileSystemProvider.readAttributes(WindowsFileSystemProvider.java:193)
at java.nio.file.Files.readAttributes(Files.java:1737)
at java.nio.file.FileTreeWalker.getAttributes(FileTreeWalker.java:219)
at java.nio.file.FileTreeWalker.visit(FileTreeWalker.java:276)
at java.nio.file.FileTreeWalker.walk(FileTreeWalker.java:322)
at java.nio.file.Files.walkFileTree(Files.java:2662)
at java.nio.file.Files.walkFileTree(Files.java:2742)
at org.elasticsearch.bootstrap.JarHell.checkJarHell(JarHell.java:196)
at org.elasticsearch.bootstrap.JarHell.checkJarHell(JarHell.java:88)
at org.elasticsearch.bootstrap.BootstrapForTesting.<clinit>(BootstrapForTesting.java:88)
... 4 more

它没有显示导致Jar Hell问题的罐子。

我尝试使用提供的解决方案进行修复 Java Jar hell Runtime Exception

我创建了如上所述的JarHell类。但即使这样也无法解决它。

0 个答案:

没有答案