我正在使用带有 play2 的 java8,具有这种配置。

name := """shipping"""

version := "1.0-SNAPSHOT"

lazy val root = (project in file(".")).enablePlugins(PlayJava)

scalaVersion := "2.11.1"

libraryDependencies ++= Seq(
  javaJdbc,
  javaEbean,
  cache,
  javaWs,
  "org.apache.axis" % "axis" % "1.4",
  "net.sf.barcode4j" % "barcode4j" % "2.1",
  "xml-apis" % "xml-apis" % "1.4.01",
  "javax.xml" % "jaxrpc-api" % "1.1",
  "org.webjars" % "flot" % "0.8.0",
  "org.webjars" % "bootstrap" % "2.3.1",
  "commons-discovery" % "commons-discovery" % "0.4",
  "postgresql" % "postgresql" % "9.1-901.jdbc4",
  "wsdl4j" % "wsdl4j" % "1.6.2",
  "org.apache.xmlgraphics" % "fop" % "1.0"
)

javacOptions ++= Seq("-source", "1.8", "-target", "1.8", "-Xlint")

LessKeys.compress := true

initialize := {
  val _ = initialize.value
  if (sys.props("java.specification.version") != "1.8")
    sys.error("Java 8 is required for this project.")
}

它有效,但在启动时我收到以下异常。
...................................................... …………
...................................................... …………
--- (Running the application from SBT, auto-reloading is enabled) ---

[info] play - Listening for HTTP on /0:0:0:0:0:0:0:0:9000

(Server started, use Ctrl+D to stop and go back to the console...)

java.lang.ArrayIndexOutOfBoundsException: 52264
        at com.avaje.ebean.enhance.asm.ClassReader.readClass(ClassReader.java:1976)
        at com.avaje.ebean.enhance.asm.ClassReader.accept(ClassReader.java:464)
        at com.avaje.ebean.enhance.asm.ClassReader.accept(ClassReader.java:420)
        at com.avaje.ebean.enhance.agent.Transformer.detect(Transformer.java:252)
        at com.avaje.ebean.enhance.agent.Transformer.transform(Transformer.java:106)
        at com.avaje.ebean.enhance.agent.InputStreamTransform.transform(InputStreamTransform.java:55)
        at com.avaje.ebean.enhance.agent.InputStreamTransform.transform(InputStreamTransform.java:39)
        at com.avaje.ebean.enhance.ant.OfflineFileTransform.transformFile(OfflineFileTransform.java:141)
        at com.avaje.ebean.enhance.ant.OfflineFileTransform.processPackage(OfflineFileTransform.java:124)
        at com.avaje.ebean.enhance.ant.OfflineFileTransform.process(OfflineFileTransform.java:90)
        at play.PlayCommands$$anonfun$PostCompile$1.apply(PlayCommands.scala:143)
        at play.PlayCommands$$anonfun$PostCompile$1.apply(PlayCommands.scala:76)
        at scala.Function8$$anonfun$tupled$1.apply(Function8.scala:35)
        at scala.Function8$$anonfun$tupled$1.apply(Function8.scala:34)
        at scala.Function1$$anonfun$compose$1.apply(Function1.scala:47)
        at sbt.$tilde$greater$$anonfun$$u2219$1.apply(TypeFunctions.scala:42)
        at sbt.std.Transform$$anon$4.work(System.scala:64)
        at sbt.Execute$$anonfun$submit$1$$anonfun$apply$1.apply(Execute.scala:237)
        at sbt.Execute$$anonfun$submit$1$$anonfun$apply$1.apply(Execute.scala:237)
        at sbt.ErrorHandling$.wideConvert(ErrorHandling.scala:18)
        at sbt.Execute.work(Execute.scala:244)
        at sbt.Execute$$anonfun$submit$1.apply(Execute.scala:237)
        at sbt.Execute$$anonfun$submit$1.apply(Execute.scala:237)
        at sbt.ConcurrentRestrictions$$anon$4$$anonfun$1.apply(ConcurrentRestrictions.scala:160)
        at sbt.CompletionService$$anon$2.call(CompletionService.scala:30)
        at java.util.concurrent.FutureTask.run(FutureTask.java:266)
        at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:511)
        at java.util.concurrent.FutureTask.run(FutureTask.java:266)
        at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142)
        at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617)
        at java.lang.Thread.run(Thread.java:745)
java.lang.ArrayIndexOutOfBoundsException: 60149
        at com.avaje.ebean.enhance.asm.ClassReader.<init>(ClassReader.java:174)
        at com.avaje.ebean.enhance.asm.ClassReader.<init>(ClassReader.java:153)
        at com.avaje.ebean.enhance.agent.Transformer.detect(Transformer.java:251)
        at com.avaje.ebean.enhance.agent.Transformer.transform(Transformer.java:106)
        at com.avaje.ebean.enhance.agent.InputStreamTransform.transform(InputStreamTransform.java:55)
        at com.avaje.ebean.enhance.agent.InputStreamTransform.transform(InputStreamTransform.java:39)
        at com.avaje.ebean.enhance.ant.OfflineFileTransform.transformFile(OfflineFileTransform.java:141)
        at com.avaje.ebean.enhance.ant.OfflineFileTransform.processPackage(OfflineFileTransform.java:124)
        at com.avaje.ebean.enhance.ant.OfflineFileTransform.process(OfflineFileTransform.java:90)
        at play.PlayCommands$$anonfun$PostCompile$1.apply(PlayCommands.scala:143)
        at play.PlayCommands$$anonfun$PostCompile$1.apply(PlayCommands.scala:76)
        at scala.Function8$$anonfun$tupled$1.apply(Function8.scala:35)
        at scala.Function8$$anonfun$tupled$1.apply(Function8.scala:34)
        at scala.Function1$$anonfun$compose$1.apply(Function1.scala:47)
        at sbt.$tilde$greater$$anonfun$$u2219$1.apply(TypeFunctions.scala:42)
        at sbt.std.Transform$$anon$4.work(System.scala:64)
        at sbt.Execute$$anonfun$submit$1$$anonfun$apply$1.apply(Execute.scala:237)
        at sbt.Execute$$anonfun$submit$1$$anonfun$apply$1.apply(Execute.scala:237)
        at sbt.ErrorHandling$.wideConvert(ErrorHandling.scala:18)
        at sbt.Execute.work(Execute.scala:244)
        at sbt.Execute$$anonfun$submit$1.apply(Execute.scala:237)
        at sbt.Execute$$anonfun$submit$1.apply(Execute.scala:237)
        at sbt.ConcurrentRestrictions$$anon$4$$anonfun$1.apply(ConcurrentRestrictions.scala:160)
        at sbt.CompletionService$$anon$2.call(CompletionService.scala:30)
        at java.util.concurrent.FutureTask.run(FutureTask.java:266)
        at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:511)
        at java.util.concurrent.FutureTask.run(FutureTask.java:266)
        at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142)
        at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617)
        at java.lang.Thread.run(Thread.java:745)
java.lang.ArrayIndexOutOfBoundsException: 45312
        at com.avaje.ebean.enhance.asm.ClassReader.accept(ClassReader.java:465)
        at com.avaje.ebean.enhance.asm.ClassReader.accept(ClassReader.java:420)
        at com.avaje.ebean.enhance.agent.Transformer.detect(Transformer.java:252)
        at com.avaje.ebean.enhance.agent.Transformer.transform(Transformer.java:106)
        at com.avaje.ebean.enhance.agent.InputStreamTransform.transform(InputStreamTransform.java:55)
        at com.avaje.ebean.enhance.agent.InputStreamTransform.transform(InputStreamTransform.java:39)
        at com.avaje.ebean.enhance.ant.OfflineFileTransform.transformFile(OfflineFileTransform.java:141)
        at com.avaje.ebean.enhance.ant.OfflineFileTransform.processPackage(OfflineFileTransform.java:124)
        at com.avaje.ebean.enhance.ant.OfflineFileTransform.process(OfflineFileTransform.java:90)
        at play.PlayCommands$$anonfun$PostCompile$1.apply(PlayCommands.scala:143)
        at play.PlayCommands$$anonfun$PostCompile$1.apply(PlayCommands.scala:76)
        at scala.Function8$$anonfun$tupled$1.apply(Function8.scala:35)
        at scala.Function8$$anonfun$tupled$1.apply(Function8.scala:34)
        at scala.Function1$$anonfun$compose$1.apply(Function1.scala:47)
        at sbt.$tilde$greater$$anonfun$$u2219$1.apply(TypeFunctions.scala:42)
        at sbt.std.Transform$$anon$4.work(System.scala:64)
        at sbt.Execute$$anonfun$submit$1$$anonfun$apply$1.apply(Execute.scala:237)
        at sbt.Execute$$anonfun$submit$1$$anonfun$apply$1.apply(Execute.scala:237)
        at sbt.ErrorHandling$.wideConvert(ErrorHandling.scala:18)
        at sbt.Execute.work(Execute.scala:244)
        at sbt.Execute$$anonfun$submit$1.apply(Execute.scala:237)
        at sbt.Execute$$anonfun$submit$1.apply(Execute.scala:237)
        at sbt.ConcurrentRestrictions$$anon$4$$anonfun$1.apply(ConcurrentRestrictions.scala:160)
        at sbt.CompletionService$$anon$2.call(CompletionService.scala:30)
        at java.util.concurrent.FutureTask.run(FutureTask.java:266)
        at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:511)
        at java.util.concurrent.FutureTask.run(FutureTask.java:266)
        at

最佳答案

问题是您不能在像 lambdas 这样的 play 2.3 类模型中使用任何 java 8 功能,因为 ebean ASM 不理解字节码。

我们需要等待播放新版本,但在路线图中,在下一版本中播放将采用JPA而不是ebean

10-06 10:14