spring-data-neo4j - 创建名为'neo4jTemplate'的bean时出错

时间:2013-01-15 18:13:54

标签: scala neo4j spring-data-neo4j

我正在尝试将neo4j与spring-data和scala一起使用,但我得到了这个例外:

Caused by: org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'neo4jTemplate': Invocation of init method failed; nested exception is java.lang.NoSuchMethodError:scala.collection.JavaConverters$.mapAsScalaMapConverter(Ljava/util/Map;)Lscala/collection/JavaConverters$AsScala;

目前,我不确定如何“注入”JavaConverters ......

有什么想法吗?

更新:

我试图简单地将导入放在Test类中:

导入scala.collection.JavaConverters ._

但是没有用,这是完整的代码:

WordsTest.scala

package com.dimeder.llull.security

import org.junit.runner.RunWith
import org.springframework.test.context.junit4.SpringJUnit4ClassRunner
import org.springframework.test.context.ContextConfiguration
import org.junit.Test
import org.slf4j.LoggerFactory
import org.springframework.transaction.annotation.Transactional
import org.springframework.beans.factory.annotation.Autowired
import org.springframework.data.neo4j.support.Neo4jTemplate
import com.dimeder.llull.models.Word
import scala.collection.JavaConverters._

@RunWith(classOf[SpringJUnit4ClassRunner])
@ContextConfiguration(Array("classpath:applicationContext-test.xml"))
class WordsTest {
         val logger = LoggerFactory.getLogger(classOf[WordsTest])

  @Autowired
  var template:Neo4jTemplate = _

  @Test
  @Transactional
  def speak(){
      val word:Word = new Word
    word.text="sustancia"
    template.save(word)
    val backWord:Word = template.findOne(word.id,classOf[Word])
    logger.info(word.text.equalsIgnoreCase(backWord.text).toString)
  }
}

的applicationContext-的test.xml

<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns="http://www.springframework.org/schema/beans"
       xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
       xmlns:mvc="http://www.springframework.org/schema/mvc"
       xmlns:context="http://www.springframework.org/schema/context"
       xmlns:util="http://www.springframework.org/schema/util"
       xmlns:oxm="http://www.springframework.org/schema/oxm"
       xmlns:jaxws="http://cxf.apache.org/jaxws"
       xmlns:http-conf="http://cxf.apache.org/transports/http/configuration"
       xmlns:p="http://www.springframework.org/schema/p"
       xmlns:task="http://www.springframework.org/schema/task"
       xmlns:neo4j="http://www.springframework.org/schema/data/neo4j"


       xsi:schemaLocation="http://www.springframework.org/schema/mvc
         http://www.springframework.org/schema/mvc/spring-mvc-3.0.xsd
         http://www.springframework.org/schema/beans
         http://www.springframework.org/schema/beans/spring-beans-3.0.xsd
         http://www.springframework.org/schema/context
         http://www.springframework.org/schema/context/spring-context-3.0.xsd
         http://www.springframework.org/schema/util
         http://www.springframework.org/schema/util/spring-util-3.0.xsd
         http://www.springframework.org/schema/aop
         http://www.springframework.org/schema/aop/spring-aop-3.0.xsd
         http://www.springframework.org/schema/task
         http://www.springframework.org/schema/task/spring-task-3.0.xsd
         http://www.springframework.org/schema/data/neo4j
         http://www.springframework.org/schema/data/neo4j/spring-neo4j-2.0.xsd
        ">

    <context:spring-configured/>
    <context:annotation-config/>

    <mvc:annotation-driven/>
    <context:component-scan base-package="java.llull."/>

    <neo4j:config storeDirectory="data/graph.db"/>
    <neo4j:repositories base-package="java.llull.repositories"/>

</beans>

更新

我解决了!

问题是scalaversión,我使用的是2.10,但它必须是2.9.2

0 个答案:

没有答案