加入收藏 | 设为首页 | 会员中心 | 我要投稿 李大同 (https://www.lidatong.com.cn/)- 科技、建站、经验、云计算、5G、大数据,站长网!
当前位置: 首页 > 综合聚焦 > 服务器 > 安全 > 正文

scala – 在SBT中使用Spring-Data-Neo4j高级映射模式

发布时间:2020-12-16 18:28:16 所属栏目:安全 来源:网络整理
导读:我想在我的 Scala SBT项目( hosted on github)中使用 advanced mapping mode的spring-data-neo4j: 我可以使用存储库将节点存储在数据库中,但我不能进行aspectj-weaving工作. 这是我到目前为止: build.sbt: resolvers ++= Seq( "spring" at "http://repo.s
我想在我的 Scala SBT项目( hosted on github)中使用 advanced mapping mode的spring-data-neo4j:

我可以使用存储库将节点存储在数据库中,但我不能进行aspectj-weaving工作.

这是我到目前为止:

build.sbt:

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

项目/ plugins.sbt:

addSbtPlugin("com.typesafe.sbt" % "sbt-aspectj" % "0.9.4")

节点类和存储库:

@NodeEntity
class Node {
  @GraphId
  private var graphId: java.lang.Long = _
}

trait NodeRepository extends GraphRepository[Node]

测试:

@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()
  }

}

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

$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)
...

我究竟做错了什么?

解决方法

如果你将sbt版本提升到0.13.2,它现在可以工作:

project / build.properties – >

sbt.version=0.13.2

我的猜测是关于aspectj插件在较旧的sbt版本中不起作用.

(编辑:李大同)

【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容!

    推荐文章
      热点阅读