Auto Refresh and Reload Changes When Using a Custom Env in Grails on your Local Machine
Setup Flags/Params to get Auto-Refresh/Auto-Reload of Changes Behavior in a Custom Grails Env when running Locally
OK, so you need to use a Custom Environment in Grails while developing and running on your local machine. Unlike when using the basic develop Env, when you make some changes and refresh the page, the changes aren't there.
Well, it turns out several flags and settings which are enabled by default in Dev mode will not be set when you create your own custom environment. Many of these flags and settings include features that auto refresh and reload changes you make in the code and deploy those changes. This is because these settings are processor intensive and you would not want these settings going to PROD.
This tutorial will show you how to enable those flags and settings so that you automatically refresh and reload changes on your local machine when running a custom env.
Just to reiterate, these settings are for development. Don't use them on PROD.
STEP 1 - Setup the Run Config
First you want to:
- Right-click your project
- Select "Run As"
- Select "Run Configurations"
Navigate to the Run Configurations Screen |
Then you want to modify the grails command as such:
-reloading -Dgrails.env=custom run-app
Make sure - reloading is the first arg! JIRA link to issue with flags here
Add params to your run config |
What does this do?
It does two things:
- When you do a basic run-app command, it will automatically run the app in the custom environment
- It passes the -reloading flag
STEP 2 - Modify your config.groovy
Yes, you can also pass these params in to the command line and add them as flags in your run config. In my experience, things can get a little buggy and hard to manage if you pass too many flags in your run config.
This way is easier to read, modify and manage as well.
First, open your local config.groovy file.
How to find your config.groovy |
Then update your local configuration by adding the following arguments to your config.groovy file:
Add these params to your config file |
The config parameter, disable.auto.recompile=false and grails.gsp.enable.reload=true will refresh your application after you save your gsp and code changes in your IDE.
Save everything and restart your IDE. You should see changes to GSPs and code immediately without having to restart the server when developing in Grails.
References:
Grails.org Auto Reloading Page
Grails JIRA Issue about this
RTS Labs
This is very good post. it will hep for developer.visit more tricks for spring boot development Spring boot tutorials
ReplyDeleteYes, you can also pass these params in to the command line and add them as flags in your run config. In my experience, things can get a little buggy and hard to manage if you pass too many flags in your run config. waterproof bed protector , razai cover single bed
ReplyDeleteIf you want to improve your software delivery, build a culture of agility and automation, accelerate software releases, and harness the power of the cloud, we can help. The first step is to adopt a modern way of developing and releasing software by unifying software development and IT operations, also called DevOps.
ReplyDeletehttps://rtslabs.com/devops/
This comment has been removed by the author.
ReplyDelete