Changing the port of a Grails project
When you load and start a Grails application, it uses the port 8080 by default. If you want to change the port being used by Grails, you have three ways you can do this. In all of these examples, I'm changing the port to be 9000.
you run it like this:
To do this, go to the root directory for your project and then change into the grails-app/conf directory. Create a new file called BuildConfig.groovy (or edit the existing file if there is already one there) and add this line to the file:
The nice thing about this approach is that if you have multiple grails projects you are working on, you can assign them all to a different port and have them running at the same time.
To change the default so that projects always use the 9000 port instead of 8080, go into the .grails directory in your home directory. This is your home directory on your computer, not the grails or grails project home directory. Also note that this directory gets created once you run a grails application. If the directory does not exist, run your grails application and it will get created.
In the .grails directory, create a file called settings.groovy (or edit the existing file if there is one there already) and add the following line:
With this line added, it will change the default port used by all grails projects on your machine that make use of the default port.
1: Run-time change ==================You can change the port used when you start the application by using the the -Dserver.port flag. Instead of running your application like this:
grails run-app
you run it like this:
grails -Dserver.port=9000 run-app
2: Permanent change for project ===============================You can change the port for your project so that every time you run the project, it runs on a new port without having to add command line arguments.
To do this, go to the root directory for your project and then change into the grails-app/conf directory. Create a new file called BuildConfig.groovy (or edit the existing file if there is already one there) and add this line to the file:
grails.server.port.http = 9000
The nice thing about this approach is that if you have multiple grails projects you are working on, you can assign them all to a different port and have them running at the same time.
3: Permanent change to the default ==================================
To change the default so that projects always use the 9000 port instead of 8080, go into the .grails directory in your home directory. This is your home directory on your computer, not the grails or grails project home directory. Also note that this directory gets created once you run a grails application. If the directory does not exist, run your grails application and it will get created.
In the .grails directory, create a file called settings.groovy (or edit the existing file if there is one there already) and add the following line:
grails.server.port.http = 9000
With this line added, it will change the default port used by all grails projects on your machine that make use of the default port.
| Rating: | 100% positive, 1 Vote |
| Categories: | Grails Groovy Java web development configuration |
| Added: | on Nov 04, 2009 at 7:09 am |
| Added By: | an anonymous user |
| Searches: | grail port project directory run |

