Scala Neo4j OGM - 不会扫描带注释的 NodeEntity 类 - IllegalArgumentException

Scala Neo4j OGM - Will not scan annotated NodeEntity classes - IllegalArgumentException

问题: 带注释的 class 未加载到 class 地图中。

我对如何使用OGM的理解:

this sample project中,域是testdomain,唯一注释的NodeEntityPerson定义在同一个文件中。我希望这会消除在幕后寻找 classes 构建到持久性 class 地图中的任何问题。但是从日志中可以看出,class 映射没有考虑我传递给 SessionFactory.

的域

这会阻止任何数据保存到 Neo。

您可以自己克隆项目和 运行 应用程序来重现问题(README 中的说明)。

堆栈跟踪:

[info] Running testdomain.Test
2018-03-08 13:54:09 INFO  DomainInfo:160 - Starting Post-processing phase
2018-03-08 13:54:09 INFO  DomainInfo:126 - Building annotation class map
2018-03-08 13:54:09 INFO  DomainInfo:139 - Building interface class map for 0 classes
2018-03-08 13:54:09 INFO  DomainInfo:215 - Post-processing complete
[error] (run-main-0) java.lang.IllegalArgumentException: Class class testdomain.Person is not a valid entity class. Please check the entity mapping.
[error] java.lang.IllegalArgumentException: Class class testdomain.Person is not a valid entity class. Please check the entity mapping.
[error]         at org.neo4j.ogm.session.delegates.SaveDelegate.save(SaveDelegate.java:88)
[error]         at org.neo4j.ogm.session.delegates.SaveDelegate.save(SaveDelegate.java:40)
[error]         at org.neo4j.ogm.session.Neo4jSession.save(Neo4jSession.java:469)
[error]         at testdomain.Test$.delayedEndpoint$testdomain$Test(Test.scala:32)
[error]         at testdomain.Test$delayedInit$body.apply(Test.scala:26)
[error]         at scala.Function0.apply$mcV$sp(Function0.scala:34)
[error]         at scala.Function0.apply$mcV$sp$(Function0.scala:34)
[error]         at scala.runtime.AbstractFunction0.apply$mcV$sp(AbstractFunction0.scala:12)
[error]         at scala.App.$anonfun$main$adapted(App.scala:76)
[error]         at scala.collection.immutable.List.foreach(List.scala:389)
[error]         at scala.App.main(App.scala:76)
[error]         at scala.App.main$(App.scala:74)
[error]         at testdomain.Test$.main(Test.scala:26)
[error]         at testdomain.Test.main(Test.scala)
[error]         at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
[error]         at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
[error]         at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
[error]         at java.lang.reflect.Method.invoke(Unknown Source)
[error]         at sbt.Run.invokeMain(Run.scala:93)
[error]         at sbt.Run.run0(Run.scala:87)
[error]         at sbt.Run.execute(Run.scala:65)
[error]         at sbt.Run.$anonfun$run(Run.scala:77)
[error]         at scala.runtime.java8.JFunction0$mcV$sp.apply(JFunction0$mcV$sp.java:12)
[error]         at sbt.util.InterfaceUtil$$anon.get(InterfaceUtil.scala:10)
[error]         at sbt.TrapExit$App.run(TrapExit.scala:252)
[error]         at java.lang.Thread.run(Unknown Source)
[error] java.lang.RuntimeException: Nonzero exit code: 1
[error]         at sbt.Run$.executeTrapExit(Run.scala:124)
[error]         at sbt.Run.run(Run.scala:77)
[error]         at sbt.Defaults$.$anonfun$bgRunTask(Defaults.scala:1169)
[error]         at sbt.Defaults$.$anonfun$bgRunTask$adapted(Defaults.scala:1164)
[error]         at sbt.internal.BackgroundThreadPool.$anonfun$run(DefaultBackgroundJobService.scala:366)
[error]         at scala.runtime.java8.JFunction0$mcV$sp.apply(JFunction0$mcV$sp.java:12)
[error]         at scala.util.Try$.apply(Try.scala:209)
[error]         at sbt.internal.BackgroundThreadPool$BackgroundRunnable.run(DefaultBackgroundJobService.scala:289)
[error]         at java.util.concurrent.ThreadPoolExecutor.runWorker(Unknown Source)
[error]         at java.util.concurrent.ThreadPoolExecutor$Worker.run(Unknown Source)
[error]         at java.lang.Thread.run(Unknown Source)
[error] (Compile / run) Nonzero exit code: 1
[error] Total time: 6 s, completed Mar 8, 2018 1:54:09 PM

我到处搜索以尝试解决此问题。但是,我是 scala 的新手,所以这一定是我缺少的简单东西,对吧?

-skyfer

此问题已通过修改 Neo4j OGM 库得到解决。详细信息在 this issue 中 github。