当前位置: 首页 > 知识库问答 >
问题:

Neo4j-harness为Scala抛出java noclass deffound异常。可序列化

孙经艺
2023-03-14

当尝试使用neo4j-harness测试neo4j服务器时,我在构建嵌入式Neo4j服务器时收到noclass deffound异常

private final Neo4j embeddedNeo4jServer = Neo4jBuilders.newInProcessBuilder()
        .withDisabledServer()
        .withFixture("")
        .build(); // exception here

我的pom.xml是这样的:

xml prettyprint-override">  <dependencies>
  
    <!-- Core Dependencies -->
    
        <dependency><groupId>org.neo4j.driver</groupId><artifactId>neo4j-java-driver</artifactId><version>4.4.5</version></dependency>
        <dependency><groupId>org.apache.kafka</groupId><artifactId>kafka-streams</artifactId><version>3.0.0</version></dependency>
        <dependency><groupId>org.apache.curator</groupId><artifactId>curator-x-discovery</artifactId><version>4.2.0</version></dependency>
        <dependency><groupId>org.json</groupId><artifactId>json</artifactId><version>20211205</version></dependency>
        <dependency><groupId>org.slf4j</groupId><artifactId>slf4j-simple</artifactId><version>1.7.30</version></dependency>
        
    <!-- Test Dependencies -->
        
        <dependency><groupId>org.junit.jupiter</groupId><artifactId>junit-jupiter</artifactId><version>5.8.2</version><scope>test</scope></dependency>
        <dependency><groupId>org.skyscreamer</groupId><artifactId>jsonassert</artifactId><version>1.5.0</version><scope>test</scope></dependency>
        <dependency><groupId>org.neo4j.test</groupId><artifactId>neo4j-harness</artifactId><version>4.4.5</version><scope>test</scope></dependency>
        
        <!-- Spring dependencies for an embedded Kafka instance -->
        <dependency><groupId>org.springframework.kafka</groupId><artifactId>spring-kafka</artifactId><version>2.8.3</version><scope>test</scope></dependency>
        <dependency><groupId>org.springframework.kafka</groupId><artifactId>spring-kafka-test</artifactId><scope>test</scope><version>2.8.3</version></dependency>
        <dependency><groupId>org.springframework.boot</groupId><artifactId>spring-boot-starter-test</artifactId><scope>test</scope><version>2.6.4</version>
            <exclusions><exclusion><groupId>org.junit.vintage</groupId><artifactId>junit-vintage-engine</artifactId></exclusion></exclusions></dependency>
        
        <!-- Mockito dependencies - NOTE: the inline dependency replaces the core one, but might be removed in future versions-->
        <!--<dependency><groupId>org.mockito</groupId><artifactId>mockito-core</artifactId><version>4.4.0</version><scope>test</scope></dependency>-->
        <dependency><groupId>org.mockito</groupId><artifactId>mockito-junit-jupiter</artifactId><version>4.4.0</version><scope>test</scope></dependency>
        <dependency><groupId>org.mockito</groupId><artifactId>mockito-inline</artifactId><version>4.4.0</version><scope>test</scope></dependency>
  </dependencies>

共有1个答案

彭雨华
2023-03-14

SpringKafka测试neo4j线束中使用的scala库版本发生冲突。

要解决这个问题,您可以从spring-kafka-test中排除scala依赖项,这意味着neo4j-harness版本将用于两者。

为此,在pom.xml中添加排除:

<dependency><groupId>org.springframework.kafka</groupId><artifactId>spring-kafka-test</artifactId><scope>test</scope><version>2.8.3</version>
            <exclusions><exclusion><groupId>org.scala-lang</groupId><artifactId>scala-library</artifactId></exclusion></exclusions></dependency>
 类似资料:
  • 我需要从java调用scala代码,因此需要告诉编译器某个方法抛出某些异常。对于一个异常很容易做到这一点,但是我很难声明一个方法抛出多个异常。 这不起作用:

  • 抛出异常的行为是否可能抛出不同的异常? 为了抛出异常,必须(可选地)分配新对象,并调用其构造函数(隐式调用fillinstacktrace)。在某些情况下,听起来像addSupressed也被称为。那么如果没有足够的内存会发生什么呢?JVM是否需要预分配内置异常?例如,(1/0)会抛出OutOfMemoryError而不是ArithmeticException吗? 此外,构造函数是一个方法调用,因

  • 问题在于Spark数据集和INT列表的序列化。Scala版本是2.10.4,Spark版本是1.6。 这和其他问题类似,但是我不能基于这些回答让它工作。我已经简化了代码,以便仅仅显示问题。 我有一门案例课: 我的主要方法是: 我得到以下错误: 如果我从FlightExt中删除列表,那么一切正常,这表明lambda函数序列化没有问题。 Scala本身似乎序列化了一系列Int的优点。也许Spark在序

  • 问题内容: 考虑以下代码: 无需添加方法签名即可编译该代码。(它与同样表现到位,太)。 我理解为什么 可以 安全地运行它,因为实际上不能将其引发在块中,因此不能引发已检查的异常。我有兴趣知道在何处指定此行为。 并非永远都不会达到目标:以下代码也会编译: 但是,如果抛出一个检查的异常,它不会像我期望的那样编译: 在JLS Sec 11.2.2中 ,它说: 一,其抛出的表达式语句(§14.18)具有静

  • 下面是我的代码。当我运行它时,我在线程“main”java.lang.IndexOutOfBoundsException:Index:3、Size:2中得到异常,而不是我的异常消息。谁能解释一下我做错了什么,为什么会这样?谢谢!

  • 在你可以捕获异常之前,一些代码必须抛出一个异常。任何代码都可能会抛出异常:您的代码,来自其他人编写的包(例如Java平台附带的包)或Java运行时环境的代码。无论是什么引发的异常,它总是通过 throw 语句抛出。 您可能已经注意到,Java平台提供了许多异常类。所有类都是Throwable类的后代,并且都允许程序区分在程序执行期间可能发生的各种类型的异常。 您还可以创建自己的异常类来表示在您编写