playframework-2.4

twitterBootstrap is not recognized in play framework 2.4?

浪尽此生 提交于 2019-12-23 02:26:06
问题 I'm using Play framework 2.4. I tried to use bootstrap as guided at https://www.playframework.com/documentation/2.0/ScalaFormHelpers. In my template, I used the import statement: @import helper.twitterBootstrap._ But I got a compilation error: object twitterBootstrap is not a member of package views.html.helper Am I missing something? 回答1: Maybe it has beed removed as mentioned here: https://www.playframework.com/documentation/2.3.3/Migration23 The in-built Twitter Bootstrap field constructor

Play 2.4 value routesImport is not a member of object play.Play.autoImport.PlayKeys

荒凉一梦 提交于 2019-12-22 08:37:11
问题 I am getting this error after migrating to 2.4 from 2.3. What is the right import statement I should use? error: value routesImport is not a member of object play.Play.autoImport.PlayKeys PlayKeys.routesImport += "se.radley.plugin.salat.Binders._", I have these import statements: import sbt._ import Keys._ import play.Play.autoImport._ import PlayKeys._ import WebKeys._ 回答1: Should be like this: import play.sbt.routes.RoutesKeys ... RoutesKeys.routesImport += "se.radley.plugin.salat.Binders._

Configuration depending on launch mode

╄→尐↘猪︶ㄣ 提交于 2019-12-20 10:42:36
问题 Play can be launched in dev mode (via run ), in production mode (via start ) or in test mode. Is there a way to provide a different config file ( conf/application.conf ) depending on which mode it is launched in? 回答1: I usually have a base configuration ( application.conf ) and three extra configs per environment. In Play Framework 2.4 it can be done by extending GuiceApplicationLoader and merging base conf with your environment specific conf. You can go one step forward and provide different

Can't connect to mysql database with play-slick 1.0.1/slick 3.0 : configuration error

自作多情 提交于 2019-12-20 05:35:15
问题 I'm trying to migrate from anorm to slick, using play 2.4.2, and getting a configuration error: play.api.Configuration$$anon$1: Configuration error[Cannot connect to database [dethcs]] at play.api.Configuration$.configError(Configuration.scala:178) ~[play_2.11-2.4.0.jar:2.4.0] ... Caused by: slick.SlickException: Error getting instance of Slick driver "slick.driver.MySQLDriver" ... Caused by: java.lang.NoSuchMethodException: slick.driver.MySQLDriver.<init>() Previous answers I've found on SO

How to inject something into a form

雨燕双飞 提交于 2019-12-19 09:27:08
问题 Since play 2.4.0, we can use a DI framework. I am trying to use DI in my app. I moved my jpa finders from static methods on my models classes to methods in a service layer that I inject into my controllers. My main problem is that I have some forms with a validate method and in my validate methode I use some finders. For exemple in a login form I use a "User.authenticate" method. Now that I have replaced this static method to a new one on my UserSvc, I want to inject my service into my Form

How to use java.time.LocalDate on a Play Framework JSON Rest?

爷,独闯天下 提交于 2019-12-13 16:11:31
问题 I'm trying, without success, to make Play serialize and deserialize java 8 LocalDate. On Play 2.4, it's said to work out of the box: Play 2.4 now requires JDK 8. Due to this, Play can, out of the box, provide support for Java 8 data types. For example, Play’s JSON APIs now support Java 8 temporal types including Instance, LocalDateTime and LocalDate. But I'm unable to make it work. Here is what I have: I'm using Play 2.4.3, with PlayJava and PlayEbean plugins Model @Entity public class Person

Simplest way to read an array into a list of custom objects with Play JSON API

老子叫甜甜 提交于 2019-12-13 02:35:49
问题 I'm working with Play JSON API (latest version; Play 2.4), reading incoming JSON into objects. When writing JSON, there's absolutely no problem in using a list of custom objects , as long as I have implicit val writes = Json.writes[CustomType] . But apparently the inverse is not true, as the following does not work even though Reads is generated for both top-level type and list item type (using Json.reads[Incoming] and Json.reads[Item] ). Is custom Reads implementation mandatory? Or am I

Play Framework [2.4.x] - Module route specific name fails with `Assets is not a member of package`

徘徊边缘 提交于 2019-12-13 01:28:04
问题 I try to provide module specific routing that can be included in Play applications using the standard route file conf/routes as: -> /psmod1 com.escalesoft.psmod1.ctrl.Routes Compilation error obtained: type Psmod1Assets is not a member of package com.escalesoft.psmod1.ctrl To accomplish this I followed two steps as instructed in the official documentation at Assets and controller classes should be all defined in the controllers.admin package 1. Define Assets and controller classes in their

In Play 2.4 with DI, how to use a service class in “Secured” trait?

早过忘川 提交于 2019-12-12 10:43:53
问题 Here's an authorisation example from Play Documentation (version 2.0.4; I tried to find a newer version of this document but couldn't): trait Secured { def username(request: RequestHeader) = request.session.get(Security.username) def onUnauthorized(request: RequestHeader) = Results.Redirect(routes.Auth.login) def withAuth(f: => String => Request[AnyContent] => Result) = { Security.Authenticated(username, onUnauthorized) { user => Action(request => f(user)(request)) } } def withUser(f: User =>

PlayFramework 2.4 run some code after application has started

我们两清 提交于 2019-12-12 08:44:12
问题 In play 2.4, overriding the builder method in ApplicationLoader or implementing EagerBinding in Abstract module replaces the existing play 2.3 GlobalSettings onStart. However in play 2.3 the onStart method, your application is already started with all the plugins/dependencies loaded. Can you do the same in play 2.4, i.e. run a piece of code after the application has started. In my situation, Slick requires the application to have started before it can access the database. Thanks 回答1: It is