playframework-2.4

ProvisionException using PlayFramework 2.4.2

末鹿安然 提交于 2019-12-10 17:01:49
问题 I am migrating a project from Play 2.2.4 to 2.4.2 and I am getting an exception which I am not able to understand and solve. Unexpected exception ProvisionException: Unable to provision, see the following errors: 1) Error injecting constructor, java.lang.NullPointerException at controllers.Application.<init>(Application.java:33) while locating controllers.Application for parameter 1 at router.Routes.<init>(Routes.scala:36) while locating router.Routes while locating play.api.inject

(Play 2.4.2, Play Slick 1.0.0) How do I apply database Evolutions to a Slick managed database within a test?

僤鯓⒐⒋嵵緔 提交于 2019-12-10 16:47:28
问题 I would like to write database integration tests against a Play Slick managed database and apply and unapply Evolutions using the helper methods described in the Play documentation namely, Evolutions.applyEvolutions(database) and Evolutions.cleanupEvolutions(database) . However these require a play.api.db.Database instance which is not possible to get hold of from what I can see. The jdbc library conflicts with play-slick so how do I get the database instance from slick? I use the following

Run Evolutions in Command Line

谁说胖子不能爱 提交于 2019-12-10 03:19:21
问题 It's my first day tinkering with the Play framework, and I'm having a hard time with evolutions. I'm using Play 2.4. I picked a sample app from the many that come up in activator ui , it uses play-slick and play-slick-evolutions for DB connection and evolutions. I've perused the docs, but I can't seem to find a way to run the evolutions from the command line. When I run activator on bash I get thrown into a shell, and the help doesn't bring up anything about running evolutions, or slick. I've

PlayRunHook does not work in multi module projects

跟風遠走 提交于 2019-12-08 15:19:32
We need a base play framework projects which contains other play and scala projects as module. Those inner independent projects can have different javascript frameworks and build system like webpack, gulp, etc. So I tried the PlayRunHook from https://www.playframework.com/documentation/2.4.x/SBTCookbook . Single project hooking working as expected. But, unable to get it right on multi module project. Some code samples... Project Structure base/build.sbt name := """base""" version := "1.0-SNAPSHOT" lazy val commonSettings = Seq( scalaVersion := "2.11.6", libraryDependencies ++= Seq( jdbc, cache

Why play framework 2.4 is so slow when using @routes.Assets.versioned in twirl?

别等时光非礼了梦想. 提交于 2019-12-08 07:56:49
问题 I have a controller, when i render a twirl template and return it in my action. the play performance decrease about 5 time (15000 Requests per second in apache benchmark). but when i return json in this action play performance increase about 5 time (79000 Requests per second in apache benchmark). I have a very simple twirl template: @(message: String) @main("Welcome to Play") { @message } Update : I find that when i use @routes.Assets.versioned instead of @routes.Assets.at to address assets

Play 2.4.x how use Messages and not MessagesApi I18N

牧云@^-^@ 提交于 2019-12-08 01:03:52
问题 I've done a little bit different form the internationalization guide, at the play I18N guide I forced the result to the language in the query string, it works, but it needs to be done in the "correct way". It's a good form to keep the work and look for better approach later: NOTE: I USED THE "MessagesApi" to make it happen. please see the code below: package controllers import play.api._ import play.api.mvc._ import play.api.i18n.I18nSupport import play.api.i18n.Messages.Implicits._ import

Play Framework 2 Language Code in URL Concept?

99封情书 提交于 2019-12-08 01:01:58
问题 The manual about i18n is short: https://www.playframework.com/documentation/2.4.x/ScalaI18N Is there anything more that explains the concept for handling the user's language choice? What I'd like to achieve is what so many other sites do: put the language code into the URL http://namepedia.org/en/home/ http://namepedia.org/de/home/ ... And then, when calling (Java) Lang.defaultLang().language() or from a Scala template @lang.language I'd like to get that value. Of course with the usual

Slick 3: how to drop and take on collections with some relations

三世轮回 提交于 2019-12-07 12:47:49
问题 I'm working with Play! Scala 2.4 and Slick 3. I have a many to many relations as following: class Artists(tag: Tag) extends Table[Artist](tag, "artists") { def id = column[Long]("artistid", O.PrimaryKey, O.AutoInc) def name = column[String]("name") def * = (id.?, name) <> ((Artist.apply _).tupled, Artist.unapply) } The relation table: class ArtistsGenres(tag: Tag) extends Table[ArtistGenreRelation](tag, "artistsgenres") { def artistId = column[Long]("artistid") def genreId = column[Int](

Play 2.4: intercept and modify response body

﹥>﹥吖頭↗ 提交于 2019-12-07 12:05:21
问题 According to play documentation this is what a custom action should look like: object CustomAction extends ActionBuilder[Request] { def invokeBlock[A](request: Request[A], block: Request[A] => Future[Result]): Future[Result] = { block(request) } } But say if I wanted to append "foo" to every response body, how do I do that? Obviously below doesn't work: block.andThen(result => result.map(r => r.body.toString + "foo")).apply(request) Any ideas? UPDATE: Something worth mentioning is that this

Play framework 2.4: NoClassDefFoundError: play/api/cache/CachePlugin

♀尐吖头ヾ 提交于 2019-12-07 06:09:33
问题 In trying to update from Play 2.2 to Play 2.4, I've hit this stumbling block. I've got the memcached2 plugin also added but disabled. my conf file: # Cache configuration # ~~~~~ # To avoid conflict with play2-memcached's Memcached-based cache module play.modules.disabled+="com.github.mumoshu.play2.memcached.MemcachedModule" play.modules.enabled+="play.api.cache.EhCacheModule" # Well-known configuration provided by Play play.modules.cache.defaultCache=default play.modules.cache.bindCaches=["db