playframework-2.4

Run Evolutions in Command Line

不想你离开。 提交于 2019-12-05 02:07:36
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 been doing PHP for a while, so I'm used to being able to run these up/down from the command line. I

How to use RequireJS optimizer in Play framework?

早过忘川 提交于 2019-12-04 23:49:18
问题 As advertised, the rjs in Play can ensure that any JavaScript resources referenced from within a WebJar are automatically referenced from the jsdelivr CDN. In addition if any .min.js file is found then that will be used in place of .js. An added bonus here is that there is no change required to your html! However, I cannot seem to get any of that to work. I tried running my Play app in production mode, and all my webjar javascripts are still being referenced as local. I do not see the .min

Intercept request and check authorization in playframework

此生再无相见时 提交于 2019-12-04 15:07:08
问题 I'm using play framework 2.4.2 with Java and I want to validate that a user is logged in by intercepting all requests and checking if a session value is set. So I have extended the DefaultHttpRequestHandler and overridden the createAction Method to intercept all requests. However, I have not found a good way to validate the session. Option 1 - Fail When I try to fetch the session value I get a runtime exception: There is no HTTP Context available from here Below is the class I'm working with:

How can I override Play's default Ebean server configuration?

别说谁变了你拦得住时间么 提交于 2019-12-04 04:03:41
I don't want to define the default database configuration in the application.conf file. Instead, I want to construct the default EbeanServer programmatically and inject it myself into the DAO. The problem I am having is, if I create a guice binding for a EbeanServer provider and not define any configuration in the application.conf file, play errors out saying it cannot find a default configuration. Here's the code I have: public class EbeanServerProvider implements Provider<EbeanServer> { final Logger.ALogger log = Logger.of(this.getClass()); @Override public EbeanServer get() { ServerConfig

PlayFramework 2.4 run some code after application has started

对着背影说爱祢 提交于 2019-12-04 03:27:34
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 It is common knowledge that when you bind a class eagerly in a Module it will try to initialise an instance of it as

Play Framework 2.4 and IntelliJ Idea

℡╲_俬逩灬. 提交于 2019-12-03 23:23:40
I am trying to open a play 2.4 project in IntelliJ but since things have changed I don't know how to do this. In previous versions I could just run activator idea Or use the activator UI and click on generate intelliJ project, but in 2.4 the idea command doesn't seem to exist [error] Not a valid command: idea (similar: eval, alias) [error] Not a valid project ID: idea [error] Expected ':' (if selecting a configuration) [error] Not a valid key: idea (similar: clean) [error] idea [error] ^ And the UI seems broken, when I click on generate intelliJ project it tries to compile the app and gives

How to do database initialization when using DI in Play 2.4?

天大地大妈咪最大 提交于 2019-12-03 22:28:35
Play 2.4 discourages using GlobalSettings.onStart and whole Global object . I'm using play-slick and it has great DI sample in GitHub , but it is missing a example how to do database initialization. How does one implement the database initialization when using DI and when GlobalSettings.onStart is not available? Common cases for database initialization is: If in DEV mode, add these rows, if PROD do these. Examples wanted. The trick is to place the initialisation in the constructor of the injected class. Here's an example: Add app/modules/Database.scala : package modules import com.google

How to use RequireJS optimizer in Play framework?

依然范特西╮ 提交于 2019-12-03 15:36:33
As advertised, the rjs in Play can ensure that any JavaScript resources referenced from within a WebJar are automatically referenced from the jsdelivr CDN. In addition if any .min.js file is found then that will be used in place of .js. An added bonus here is that there is no change required to your html! However, I cannot seem to get any of that to work. I tried running my Play app in production mode, and all my webjar javascripts are still being referenced as local. I do not see the .min version of javascript files being used in production. I cannot get dependency injection to work in

Play 2.4: How do I disable routes file loading during unit tests?

此生再无相见时 提交于 2019-12-03 12:03:08
问题 Background : I am using Play 2.4 (Java) with InjectedRoutesGenerator and a Guice module to configure various dependencies. But during unit tests, the FakeApplication is trying to load all the Controllers from routes file through the injector and some of them are failing due to external dependencies not available in the unit test environment. How do I disable the default routes file processing during unit tests that extend from play.test.WithApplication? Or how can I replace the default routes

Intercept request and check authorization in playframework

纵饮孤独 提交于 2019-12-03 08:36:57
I'm using play framework 2.4.2 with Java and I want to validate that a user is logged in by intercepting all requests and checking if a session value is set. So I have extended the DefaultHttpRequestHandler and overridden the createAction Method to intercept all requests. However, I have not found a good way to validate the session. Option 1 - Fail When I try to fetch the session value I get a runtime exception: There is no HTTP Context available from here Below is the class I'm working with: public class RequestHandler extends DefaultHttpRequestHandler { @Override public Action createAction