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.

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:

To create the Jar file using embedded web server :

To run Jar file as a stand-alone application :

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

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 :

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.

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.