【问题标题】:Enabling JPA meta model auto generation in Play Framework在 Play Framework 中启用 JPA 元模型自动生成
【发布时间】:2014-05-26 10:02:41
【问题描述】:

更新!

我正在尝试在我的 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)

【问题讨论】:

    标签: java hibernate jpa playframework playframework-2.3


    【解决方案1】:

    好的!我的问题解决了!

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

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2015-06-19
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2012-04-07
      • 2015-08-17
      • 2011-03-03
      相关资源
      最近更新 更多