playframework

in play 2.4 logback configurations, where is ${application.home} defined?

心已入冬 提交于 2020-01-02 03:20:07
问题 The link here shows you how to configure your custom logger. https://www.playframework.com/documentation/2.4.x/SettingsLogger I was just wondering where is the ${applicaation.home} defined, as it seems to not have been defined in my production environment. 回答1: As indicated by @user316607, Play should define application.home by itself in the Logger.configure method. If you are seeing the value application.home_IS_UNDEFINED instead, and you're using compile-time dependency injection, you'll

Calling a Scala from Java Play Framework which takes a ClassTag

白昼怎懂夜的黑 提交于 2020-01-02 00:53:28
问题 I am trying to make a call from a Play Java class to a Scala method which takes a ClassTag as a parameter My failing attempt is Option<LocalUser> localUser = Cache.getAs(userId.userId(), app, new ClassTag<LocalUser>() ); The API method looks like this Cache.getAs(String key, Application app, ClassTag<LocalUser> ct ); 回答1: I had the same issue when calling a different Scala API from Java. You'd use: ClassTag<LocalUser> tag = scala.reflect.ClassTag$.MODULE$.apply(LocalUser.class); I'm not sure

Publish asset files of play framework plugin

爱⌒轻易说出口 提交于 2020-01-01 19:42:09
问题 using publishTo in build.sbt file, it can be automation the publishing progress. But asset files( in public folder) does not packaged. how to package and publish asset files? 回答1: For locally publishing assets files , add this snippet in build.sbt file import play.PlayImport.PlayKeys._ packagedArtifacts in publishLocal := { val artifacts: Map[sbt.Artifact, java.io.File] = (packagedArtifacts in publishLocal).value val assets: java.io.File = (playPackageAssets in Compile).value artifacts +

Java Play 2 - How would you define a maxlength constraint from config parameter?

筅森魡賤 提交于 2020-01-01 19:34:10
问题 Using Play 2.3 (Java), I'd like to use a parameter from application.conf as a value for a constraint. Something like: public class Some { @Constraints.MaxLength(Play.application().configuration().getInt("some.text.maxlength", 1000)) public String text; } But of course I can't do this because the annotation parameter must be a constant. What would be the approach, in Java, to bypass this? Should I use a custom validator? Or is there another option? Any help appreciated. 回答1: As you discovered

custom Constraint in Play 2.0-scala?

拟墨画扇 提交于 2020-01-01 17:30:15
问题 I want to write a custom Constraint to use it in my Form for validation. Mappings in Form have a verifying function: verifying (constraints: Constraint[T]*): Mapping[T] . I can obviously use the built in constraints, e.g. "name" -> text.verifying(nonEmpty) . Now I need my own constraint though. The Constraint case class looks like: case class Constraint [-T] (name: Option[String], args: Seq[Any], f: (T) ⇒ ValidationResult) extends Product with Serializable But when I looked at

How do I run a comand line scala script that uses Play Framework app database?

可紊 提交于 2020-01-01 17:01:52
问题 I have this on my app/scripts folder (I created this folder inside app/ ). I'm not sure how I can properly set the classpath here, thus I didn't even run this to know if it will actually connect to the database. How can I run this in a clean way from the command line? package scripts import scala.collection.TraversableOnce import scala.collection.generic.SeqForwarder import scala.io.Source import scala.slick.jdbc.{StaticQuery => Q} import scala.slick.session.Session import scala.slick.session

Play 2.2 with Hibernate JPA and Postgres

爱⌒轻易说出口 提交于 2020-01-01 16:56:11
问题 I'm trying to get a Play 2.2 project to work with Hibernate JPA and a PostgreSQL database. I did it before with Play 2.1.1, where it worked perfectly. I get the following error now: play.api.UnexpectedException: Unexpected exception[NoClassDefFoundError: org/w3c/dom/ElementTraversal] at play.core.ReloadableApplication$$anonfun$get$1$$anonfun$apply$1$$anonfun$1.apply(ApplicationProvider.scala:152) ~[play_2.10.jar:2.2.0] I have no idea where this comes from. My build.sbt looks like this:

Eager fetch does not seem to join

孤街醉人 提交于 2020-01-01 14:33:08
问题 I'm using play 2.0.4 with Java. I'm trying to save and retrieve a value from the in-memory db that play provides (Ebean is the underlying JPA implementation). Here's some sample code: @NoobDisclaimer ("I'm fairly new to Play and JPA") @Entity public class User extends Model { @Id public Long id; public String name; // Does not fetch eagerly. @ManyToOne(fetch=FetchType.EAGER) private Role role; // Role extends Model { has id and name} public static Finder<Long, User> find = new Finder<Long,

Getting “how can getCommonSuperclass() do its job if different class symbols get the same bytecode-level internal name” compile error

北城以北 提交于 2020-01-01 09:43:19
问题 My Play 2.1.1 project uses SBT 0.12.3, and when compiling it on my dev machine, everything's fine, I get no errors, and the app runs without any issues. When I try to compile it on an EC2 instance used for testing, I get the superlong error message below. The only possibly relevant difference between the two environments is that I have java 6 (1.6.0_45) on my dev machine, and java 7 (1.7.0_19) on EC2, but I can't currently change neither. Have you ever seen something like this? What can this

How to use single quotes in i18n in Playframework2?

我怕爱的太早我们不能终老 提交于 2020-01-01 09:07:10
问题 While working on a French app (french language is full of single quotes), I needed to use i18n with single quotes and many other accentuated chars. So here is an extract of my messages.fr-FR file : some.key=C'est la vie! And here is the output : Cest la vie! How can I use strings containing single quotes in my messages? Already tried those : some.key=C\'est la vie! --> C\est la vie! some.key="C'est la vie!" --> "Cest la vie!" EDIT : Thanks to the link KDavid gave I was able to find the