首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >在SBT中使用Spring Neo4j高级映射模式

在SBT中使用Spring Neo4j高级映射模式
EN

Stack Overflow用户
提问于 2014-01-11 17:38:54
回答 1查看 671关注 0票数 5

我想在我的Scala项目(托管在github上)中使用spring的托管在github上

我可以用存储库在数据库中存储节点,但是我不能让aspectj编织工作。

到目前为止,这就是我所拥有的:

build.sbt:

代码语言:javascript
复制
resolvers ++= Seq(
  "spring" at "http://repo.spring.io/milestone",
  "neo4j-releases" at "http://m2.neo4j.org/releases/"
)

libraryDependencies ++= Seq(
  "org.springframework.data" % "spring-data-neo4j"         % "3.0.0.M1"      % "compile",
  "org.springframework.data" % "spring-data-neo4j-aspects" % "3.0.0.M1"      % "compile",
  "javax.persistence"        % "persistence-api"           % "1.0"           % "compile",
  "javax.validation"         % "validation-api"            % "1.0.0.GA"      % "compile",
  "junit"                    % "junit"                     % "4.11"          % "test",
  "com.novocode"             % "junit-interface"           % "0.9"           % "test",
  "org.springframework"      % "spring-test"               % "4.0.0.RELEASE" % "test"
)


Seq(aspectjSettings: _*)

verbose in Aspectj := false

showWeaveInfo in Aspectj := false

inputs in Aspectj <+= compiledClasses

binaries in Aspectj <++= update map { report:UpdateReport =>
  report.matching(
     moduleFilter(organization = "org.springframework.data", name = "spring-data-neo4j-aspects")
  )
}

products in Compile <<= products in Aspectj

products in Runtime <<= products in Compile

project/plugins.sbt:

代码语言:javascript
复制
addSbtPlugin("com.typesafe.sbt" % "sbt-aspectj" % "0.9.4")

节点类和存储库:

代码语言:javascript
复制
@NodeEntity
class Node {
  @GraphId
  private var graphId: java.lang.Long = _
}

trait NodeRepository extends GraphRepository[Node]

测试:

代码语言:javascript
复制
@ContextConfiguration(locations = Array("classpath*:/META-INF/spring/module-context.xml"))
@RunWith(classOf[SpringJUnit4ClassRunner])
class SDNTest extends AbstractJUnit4SpringContextTests {
  @Autowired private var nodeRepository: NodeRepository = null

  @Test
  def persist {
    val node = new Node()
    //nodeRepository.save(node)
    node.persist()
  }

}

当我尝试运行测试时,我会得到以下错误:

代码语言:javascript
复制
$ sbt test

[info] Weaving 1 input with 1 AspectJ binary to target/scala-2.10/aspectj/classes...
[error] error at sdntest/Node.scala::0 The type sdntest.Node must implement the inherited abstract method org.springframework.data.neo4j.aspects.core.GraphBacked.setPersistentState(Ljava/lang/Object;)
[error]     see also: org/springframework/data/neo4j/aspects/core/GraphBacked.java::0
[error]     see also: org/springframework/data/neo4j/aspects/support/node/Neo4jNodeBacking.aj:66::0
[error] error at sdntest/Node.scala::0 The type sdntest.Node must implement the inherited abstract method org.springframework.data.neo4j.mapping.ManagedEntity.setPersistentState(Ljava/lang/Object;)
[error]     see also: org/springframework/data/neo4j/mapping/ManagedEntity.java::0
[error]     see also: org/springframework/data/neo4j/aspects/support/node/Neo4jNodeBacking.aj:66::0
[warn] warning at /home/felix/.ivy2/cache/org.springframework.data/spring-data-neo4j-aspects/jars/spring-data-neo4j-aspects-3.0.0.M1.jar!org/springframework/data/neo4j/aspects/support/relationship/Neo4jRelationshipBacking.class:64::0 advice defined in org.springframework.data.neo4j.aspects.support.relationship.Neo4jRelationshipBacking has not been applied [Xlint:adviceDidNotMatch]
[warn] warning at /home/felix/.ivy2/cache/org.springframework.data/spring-data-neo4j-aspects/jars/spring-data-neo4j-aspects-3.0.0.M1.jar!org/springframework/data/neo4j/aspects/support/relationship/Neo4jRelationshipBacking.class:167::0 advice defined in org.springframework.data.neo4j.aspects.support.relationship.Neo4jRelationshipBacking has not been applied [Xlint:adviceDidNotMatch]
[warn] warning at /home/felix/.ivy2/cache/org.springframework.data/spring-data-neo4j-aspects/jars/spring-data-neo4j-aspects-3.0.0.M1.jar!org/springframework/data/neo4j/aspects/support/relationship/Neo4jRelationshipBacking.class:174::0 advice defined in org.springframework.data.neo4j.aspects.support.relationship.Neo4jRelationshipBacking has not been applied [Xlint:adviceDidNotMatch]
org.aspectj.bridge.AbortException: AspectJ failed
    at com.typesafe.sbt.SbtAspectj$Ajc$.runAjcMain(SbtAspectj.scala:220)
...

我做错了什么?

EN

回答 1

Stack Overflow用户

发布于 2014-05-01 15:09:58

如果将sbt版本提高到0.13.2,那么它现在可以工作了:

项目/build.properties ->

代码语言:javascript
复制
sbt.version=0.13.2

我猜想aspectj插件在较旧的sbt构建中不起作用。

票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/21065592

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档