在Play 2 Framework上配置QueryDSL [英] Configure QueryDSL on Play 2 Framework

查看:141
本文介绍了在Play 2 Framework上配置QueryDSL的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我尝试在Play Framework(使用Java)中配置 QueryDSL ,但是没有成功. 我在Google中搜索了类似的问题,这就是我发现的问题:

I try to configure QueryDSL in Play Framework (with Java) but without success. I've searched for similar problems in Google and this is what I found:

1.. QueryDSL and Play .但是这篇文章确立了与Lombok的对等关系,并且该解决方案对我不起作用.

1. QueryDSL and Play. But this post establishing the equivalence with Lombok and the solution does not work for me.

2..模拟MAVEN过程.这是我真正需要将其应用于其他类似模块的内容,但没有显示如何操作的示例.

2. Emulating MAVEN process. This is what I really need to apply it to other similar modules, but does not show an example of how.

3..

3. Configure multiple modules. In this case includes several modules and is a bit confusing.

那么,如何在Play中配置QueryDSL?任何人都可以举一个如何做的例子吗?

So, how I could configure QueryDSL in Play? Anybody could include an example of how to do?

提前谢谢.

推荐答案

我刚刚使用 play-在Play 2.2.2中使用querydsl .我按照说明进行操作(在plugins.sbt中使用0.1.1作为版本号,而不是0.1.0),它生成了target/scala-2.10/src_managed/main/querydsl的Q *模型类.我使用Eclipse,所以我运行play eclipse将该文件夹包含在类路径中.

I just got it working using play-querydsl with Play 2.2.2. I followed the instructions (using 0.1.1 as the version number in plugins.sbt instead of 0.1.0) and it generated the Q* model classes to target/scala-2.10/src_managed/main/querydsl. I use Eclipse, so I ran play eclipse to include this folder in the classpath.

我试图编译APT批注以直接在Eclipse中工作,但放弃了.

I tried to get the APT annotation compiling to work directly in Eclipse but gave up on that.

作为旁注,我比较了QueryDSL和EasyCriteria,发现EasyCriteria更易于使用,因为它更紧密地反映了Ebean的用户友好查询.但是,如果您想要类型安全,则QueryDSL绝对比JPA的内置标准API更好.

As a side note, I compared QueryDSL and EasyCriteria and I found EasyCriteria easier to use because it more closely mirrors the user-friendly queries of Ebean. However, if you want type safety, QueryDSL is definitely better than JPA's built-in criteria API.

plugins.sbt(播放2.2.2):

plugins.sbt (Play 2.2.2):

// Comment to get more information during initialization
logLevel := Level.Warn

// The Typesafe repository
resolvers += "Typesafe repository" at "http://repo.typesafe.com/typesafe/releases/"

// Use the Play sbt plugin for Play projects
addSbtPlugin("com.typesafe.play" % "sbt-plugin" % "2.2.2")

addSbtPlugin("com.code-troopers.play" % "play-querydsl" % "0.1.1")

build.sbt(播放2.2.2):

build.sbt (Play 2.2.2):

name := "project"

version := "1.0-SNAPSHOT"

libraryDependencies ++= Seq(
  javaJdbc,
  javaJpa.exclude("org.hibernate.javax.persistence", "hibernate-jpa-2.0-api"),
  cache,
  filters,
  "org.hibernate" % "hibernate-entitymanager" % "4.3.5.Final",
  "com.mysema.querydsl" % "querydsl-jpa" % "3.3.4",
  "postgresql" % "postgresql" % "9.1-901-1.jdbc4",
  "org.mindrot" % "jbcrypt" % "0.3m",
  "net.sf.opencsv" % "opencsv" % "2.3"
)     

play.Project.playJavaSettings

playJavaSettings ++ QueryDSLPlugin.queryDSLSettings

val current = project.in(file(".")).configs(QueryDSLPlugin.QueryDSL)

QueryDSLPlugin.queryDSLPackage := "models"

play.Keys.lessEntryPoints <<= baseDirectory { base =>
   (base / "app" / "assets" / "stylesheets" * "*.less")
}

这篇关于在Play 2 Framework上配置QueryDSL的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆