How can I run Play! in production mode, so that it doesn't print source code to the browser window in case of an exception?
To run a Play application: Create a new Run Configuration – From the main menu, select Run -> Edit Configurations. Click on the + to add a new configuration. From the list of configurations, choose “sbt Task”
Go to the project directory and just say play (and nothing after that). That will open the play console. Next, say run 8080. That will start play on port 8080.
To build your application for production, use the build command. By default, this command uses the production build configuration. This command creates a dist folder in the application root directory with all the files that a hosting service needs for serving your application.
There are several methods, the easiest way is to run play start
instead of play run
.
You can find more information on the documentation: Starting your application in production mode
While being in the sbt console, you can also run your app in Prod mode with
[my-first-app] $ testProd
Also useful is to use this command to prevent sbt exiting when pressing CTRL
+D
[my-first-app] $ testProd --no-exit-sbt
In Play 2.6, testProd
was renamed to runProd
:
[my-first-app] $ runProd
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With