【问题标题】:OpenJPA Enhancement in Play FrameworkPlay 框架中的 OpenJPA 增强功能
【发布时间】:2014-08-25 12:51:42
【问题描述】:
我们正在尝试使用OpenJPA 设置Play Framework 2.3.3。我们无法使运行时或构建时增强工作。在 persistance.xml 中将 RuntimeUnenhancedClasses 属性设置为支持时,OpenJPA 可以工作,但不建议将其用于生产并且不可行。
我们尝试使用 javaagent JVM 参数,但运气不佳:
activator -J-javaagent:lib/openjpa-all-2.3.0.jar run.
如何配置增强器?
【问题讨论】:
标签:
playframework
openjpa
playframework-2.3
【解决方案1】:
感谢您的建议。
这是问题的解决方案:
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)