Today, I am going to explain How to run grails application standalone.

Let’s start coding and follow the below steps.

Most of the web application is deployed within external web-server. According to the regular way of deployment, that apps are bundled as war file means war packaging. We can deploy the war in web-server like tomcat and jetty.

Nowadays application builds in micro-services. eg. spring boot application.

We don’t require any external web server. We can create a simple jar file and run the jar using java command.


java -jar deepanker.jar (fileName.jar)

In Grails, we have a plugin standalone app which allows to embed a web-server inside the grails application itself. Its provide the advantage to run the grails application as standalone app.

To use this add the plugin dependencies in BuildConfig.groovy file:

compile "org.grails.plugins:standalone:9.0.0.M4"

To create the Jar file using embedded web server :

grails build-standalone

To run Jar file as a stand-alone application :

java -jar /path/to/jar_name.jar

We can also add the environment variables while running the jar to run the container with a specific environment configuration  :

grails -Dgrails.env=prod build-standalone jar_name.jar

This plugin has both Tomcat and Jetty web server functionality, we can set the jetty as a default web server. We need to add a below line in BuildConfig.groovy :

grails.plugin.standalone.useJetty = true

Also, it can be specified at the time of deployment which server will be used to run the application. we can specify the flag values, particularly container.

grails build-standalone --jetty
grails build-standalone --tomcat

It removes the external web server dependency and we can run the standalone application with Jar packaging file.

I hope it was helpful for you.