(Quick Reference) # 2.10 Deploying an Application Version: 3.2.8 ## 2.10 Deploying an Application Grails applications can be deployed in a number of different ways. If you are deploying to a traditional container (Tomcat, Jetty etc.) you can create a Web Application Archive (WAR file), and Grails includes the war command for performing this task:
    grails war
This will produce a WAR file under the `build/libs` directory which can then be deployed as per your container’s instructions. Note that by default Grails will include an embeddable version of Tomcat inside the WAR file, this can cause problems if you deploy to a different version of Tomcat. If you don’t intend to use the embedded container then you should change the scope of the Tomcat dependencies to `provided` prior to deploying to your production container in `build.gradle`:
    provided "org.springframework.boot:spring-boot-starter-tomcat"
If you are building a WAR file to deploy on Tomcat 7 then in addition you will need to change the target Tomcat version in the build. Grails is built against Tomcat 8 APIs by default. To target a Tomcat 7 container, insert a line to `build.gradle` above the `dependencies { }` section:
    ext['tomcat.version'] = '7.0.59'
Unlike most scripts which default to the `development` environment unless overridden, the `war` command runs in the `production` environment by default. You can override this like any script by specifying the environment name, for example:
    grails dev war
If you prefer not to operate a separate Servlet container then you can simply run the Grails WAR file as a regular Java application. Example:
    grails war
    java -Dgrails.env=prod -jar build/libs/mywar-0.1.war
When deploying Grails you should always run your containers JVM with the `-server` option and with sufficient memory allocation. A good set of VM flags would be:
    -server -Xmx768M -XX:MaxPermSize=256m
| Quick Reference (hide)