Play框架中的OpenJPA增强功能

时间:2014-08-25 12:51:42

标签: playframework openjpa playframework-2.3

我们正尝试使用Play Framework 2.3.3设置OpenJPA。我们无法使运行时或构建时间增强工作。将RuntimeUnenhancedClasses属性设置为 persistance.xml 中支持的属性时,OpenJPA可以正常工作,但不建议用于生产,这是不行的。 我们尝试使用javaagent JVM参数,但没有这样的运气:

activator -J-javaagent:lib/openjpa-all-2.3.0.jar run.

如何配置增强器?

1 个答案:

答案 0 :(得分:0)

感谢您的建议。

以下是问题的解决方案:

https://github.com/kristijanbambir/play-openjpa/blob/master/build.sbt

应该在buid.sbt中添加此PCEnhancer调用

lazy val enhance = taskKey[Unit]("Enhances model classes")

enhance <<= (fullClasspath in Runtime, runner, streams).map({(cp, run, s) =>
  // only files from classpath are needed
  val classpath = cp.files
  // any options that need to be passed to the enhancer
  val options = Seq()
  // returns an option of errormessage
  val result = run.run("org.apache.openjpa.enhance.PCEnhancer", classpath, options, s.log)
  // if case of errormessage, throw an exception
  result.foreach(sys.error)
}) triggeredBy(compile in Compile)
相关问题