How to package the project to war in play2?

2019-01-17 22:02发布

问题:

In play1, we can package the project to a war, then put it in a tomcat:

play war

But how to do the same in play2? play war doesn't work, it reports war is not a valid task.

回答1:

It's not still supported, support won't be released until Play 2.1 (as per current plan)

PS: I know your comment says so, but it's better to have it as an answer for people finding this page.



回答2:

as pointed out by @Freewind, officialy, it's not supported, this is because they need the Servlet 3.1 specifications to support all the nice websocket and other advanced features that play2 provides.

However, if you do not use that, there is a plugin on github to provide play war and be able to deploy on some cloud servers, etc: https://github.com/dlecan/play2-war-plugin/



回答3:

WAR Plugin for Play framework 2.0 bring this feature.

This project is a module for Play framework 2 to package your apps into standard WAR packages. It can be used with Servlet 3.0 and 2.5 containers (Tomcat 6/7, Jetty 7/8/9, JBoss 5/6/7, ...)



回答4:

offered by the official site, if you just want to publish your website, there may be some alternative ways to achieve the goal.

Creating a standalone version of your application

Or, you can use with lighttpd or nginx, here is the configuration doc:

Set-up a front-end HTTP server

If you plan to host several applications in the same server or load balance several instances of your application for scalability or fault tolerance, you can use a front-end HTTP server.