Translated by zanxus

Recently, I have been using play framework, a high performance and agile development java web framework, which is worth trying. Below are records of problems that i have met in production deployment.

1.Stand-alone Play Application(Precondition is nginx or apache)


In this way, play starts as always like play start app, one thing additional to do is preset nginx agent or load balance before play application.Play provides a PROD mode, in PROD mode, real-time detection and hotswap will be turned off, besides some operations such as initialize database connection in advance are performed to improve performance. Whereas, the most important problem in this way is that you need to put your application source code in your server. So we tried the second way.

2.Using JAVAEE Server


For example Tomcat, Jetty and so on. Same as normal SpringMVC projects, this method always result in a war package which will be deployed in the middlewares mentioned above.

Play provides some commands:

play war myapp -o myapp.war

In this way, we also encountered some weired problems such as can not load some resouces, and there are someone else raised related issue, finally we gave up this method.

3.Using Precomoile

I found a command in play when handing the deployment problem:

precompile      Precompile all Java sources and templates to speed up application start-up

and a documention:


play start myApp -Dprecompiled=true

Use play precompile to compile all source codes and then start application with play start myApp -Dprecompiled=true without source codes.

In conclusion, the actual building steps are as follows:

play clean
play deps --verbose
play precompile
zip -r conf modules lib precompiled public

Clean cache, load dependencies, precompile and finally package all resources exclude source codes into a zip file, after uploading the to production server, play start web -Dprecompiled=true then the application start successfully.

Write a Comment