spring-data と scala で neo4j を使用しようとしていますが、次の例外が発生します。
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 クラスに簡単に入れようとしました:
import 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>
アップデート:
私はそれを解決します!
問題は scala のバージョンで、私は 2.10 を使用していましたが、2.9.2 でなければなりませんでした。