使用 Play Framework 2 对象化

Objectify with Play Framework 2

当我们不使用 servlet 或 WEB-INF/web.xml 时,有没有办法使用 objectify? 我用玩! Framework 2.5.4 Java 我不知道如何处理...

由此 link : Objectify wiki setup

我找到了一种通过创建新模块来执行此代码的方法:

bind(ObjectifyFilter.class).in(Singleton.class);

但我不知道如何执行:

filter("/*").through(ObjectifyFilter.class);

因为我不知道该怎么做,所以我试了一下:

ObjectifyService.begin();
ofy().save().entity(registration).now();

但我只得到以下异常:

Error saving models.gcd.Registration@54cd7ad7: No API environment is registered for this thread.

感谢您的帮助!

看起来是个有趣的挑战。

虽然不遵循servlet 规范,但在play framework 中注册一个过滤器并不难。

https://www.playframework.com/documentation/2.5.x/JavaHttpFilters

但我看到的主要问题是(就我所读的内容而言)该框架使用线程本地上下文来存储有关事务和异步任务的信息。这与 play 框架使用遵循非阻塞模型的踏板的方式不兼容。 https://www.playframework.com/documentation/2.5.x/ThreadPools

不确定这些信息是否对您有帮助,但可以让您更全面地了解游戏框架。

享受