gpt4 book ai didi

java - 在 Play Framework 中启用 JPA 元模型自动生成

转载 作者:行者123 更新时间:2023-11-30 11:18:25 26 4
gpt4 key购买 nike

已更新!

我正在尝试在我的 play 2.3.0 应用程序中启用 JPA 元模型自动生成。使用 type-safe JPA queries in Play 2.0文档

我正在更改我的 build.sbt 文件如下:

    ...
libraryDependencies ++= Seq(
javaCore,
cache,
"org.springframework" % "spring-context" % "4.0.4.RELEASE",
"org.springframework" % "spring-orm" % "4.0.4.RELEASE",
"org.springframework" % "spring-jdbc" % "4.0.4.RELEASE",
"org.springframework" % "spring-tx" % "4.0.4.RELEASE",
"org.springframework" % "spring-expression" % "4.0.4.RELEASE",
"org.springframework" % "spring-aop" % "4.0.4.RELEASE",
"org.springframework" % "spring-test" % "4.0.4.RELEASE" % "test",
"org.hibernate" % "hibernate-entitymanager" % "4.3.5.Final",
"org.hibernate" % "hibernate-jpamodelgen" % "4.3.5.Final",
"cglib" % "cglib" % "2.2.2"
)

javacOptions ++= Seq("-s", "metamodel")
...

我正面临这个错误:

Unexpected exception
The compilation failed without reporting any problem!
No source available, here is the exception stack trace:
->sbt.compiler.CompileFailed:
sbt.compiler.JavaCompiler$JavaTool0.compile(JavaCompiler.scala:77)
sbt.compiler.JavaTool$class.apply(JavaCompiler.scala:35)
sbt.compiler.JavaCompiler$JavaTool0.apply(JavaCompiler.scala:63)
sbt.compiler.JavaCompiler$class.compile(JavaCompiler.scala:21)
sbt.compiler.JavaCompiler$JavaTool0.compile(JavaCompiler.scala:63)
sbt.compiler.AggressiveCompile$$anonfun$3$$anonfun$compileJava$1$1.apply$mcV$sp(AggressiveCompile.scala:127)
sbt.compiler.AggressiveCompile$$anonfun$3$$anonfun$compileJava$1$1.apply(AggressiveCompile.scala:127)
sbt.compiler.AggressiveCompile$$anonfun$3$$anonfun$compileJava$1$1.apply(AggressiveCompile.scala:127)
sbt.compiler.AggressiveCompile.sbt$compiler$AggressiveCompile$$timed(AggressiveCompile.scala:166)
sbt.compiler.AggressiveCompile$$anonfun$3.compileJava$1(AggressiveCompile.scala:126)
sbt.compiler.AggressiveCompile$$anonfun$3.apply(AggressiveCompile.scala:143)
sbt.compiler.AggressiveCompile$$anonfun$3.apply(AggressiveCompile.scala:87)
sbt.inc.IncrementalCompile$$anonfun$doCompile$1.apply(Compile.scala:39)
sbt.inc.IncrementalCompile$$anonfun$doCompile$1.apply(Compile.scala:37)
sbt.inc.IncrementalCommon.cycle(Incremental.scala:99)
sbt.inc.Incremental$$anonfun$1.apply(Incremental.scala:38)
sbt.inc.Incremental$$anonfun$1.apply(Incremental.scala:37)
sbt.inc.Incremental$.manageClassfiles(Incremental.scala:65)
sbt.inc.Incremental$.compile(Incremental.scala:37)
sbt.inc.IncrementalCompile$.apply(Compile.scala:27)
sbt.compiler.AggressiveCompile.compile2(AggressiveCompile.scala:157)
sbt.compiler.AggressiveCompile.compile1(AggressiveCompile.scala:71)
sbt.compiler.AggressiveCompile.apply(AggressiveCompile.scala:46)
sbt.Compiler$.apply(Compiler.scala:75)
sbt.Compiler$.apply(Compiler.scala:66)
sbt.Defaults$.sbt$Defaults$$compileTaskImpl(Defaults.scala:770)
sbt.Defaults$$anonfun$compileTask$1.apply(Defaults.scala:762)
sbt.Defaults$$anonfun$compileTask$1.apply(Defaults.scala:762)
scala.Function1$$anonfun$compose$1.apply(Function1.scala:47)
sbt.$tilde$greater$$anonfun$$u2219$1.apply(TypeFunctions.scala:42)
sbt.std.Transform$$anon$4.work(System.scala:64)
sbt.Execute$$anonfun$submit$1$$anonfun$apply$1.apply(Execute.scala:237)
sbt.Execute$$anonfun$submit$1$$anonfun$apply$1.apply(Execute.scala:237)
sbt.ErrorHandling$.wideConvert(ErrorHandling.scala:18)
sbt.Execute.work(Execute.scala:244)
sbt.Execute$$anonfun$submit$1.apply(Execute.scala:237)
sbt.Execute$$anonfun$submit$1.apply(Execute.scala:237)
sbt.ConcurrentRestrictions$$anon$4$$anonfun$1.apply(ConcurrentRestrictions.scala:160)
sbt.CompletionService$$anon$2.call(CompletionService.scala:30)
java.util.concurrent.FutureTask.run(Unknown Source)
java.util.concurrent.Executors$RunnableAdapter.call(Unknown Source)
java.util.concurrent.FutureTask.run(Unknown Source)
java.util.concurrent.ThreadPoolExecutor.runWorker(Unknown Source)
java.util.concurrent.ThreadPoolExecutor$Worker.run(Unknown Source)
java.lang.Thread.run(Unknown Source)

最佳答案

好的!我的问题解决了!

javacOptions 中,您应该为自动生成的元数据指定一个现有文件夹。意味着 app/everyWhere 但在 hibernate 中存在一个问题,它不能覆盖包名称,如果你在其他任何地方找到 app 目录,因为包名称错误生成的文件,你的程序将无法运行!所以你的 build.sbt 是这样的:

...
libraryDependencies ++= Seq(
javaCore,
cache,
"org.springframework" % "spring-context" % "4.0.4.RELEASE",
"org.springframework" % "spring-orm" % "4.0.4.RELEASE",
"org.springframework" % "spring-jdbc" % "4.0.4.RELEASE",
"org.springframework" % "spring-tx" % "4.0.4.RELEASE",
"org.springframework" % "spring-expression" % "4.0.4.RELEASE",
"org.springframework" % "spring-aop" % "4.0.4.RELEASE",
"org.springframework" % "spring-test" % "4.0.4.RELEASE" % "test",
"org.hibernate" % "hibernate-entitymanager" % "4.3.5.Final",
"org.hibernate" % "hibernate-jpamodelgen" % "4.3.5.Final",
"cglib" % "cglib" % "2.2.2"
)

javacOptions ++= Seq("-s", "app")
...

关于java - 在 Play Framework 中启用 JPA 元模型自动生成,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/23867624/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com