As we all know the default port for grails application is 8080, though we can change the port by running the application by following command
[java]
grails -Dserver.port=7070 run-app
[/java]
What if you want the application to run on 7070 by default. Grails provide a very easy way to that as well. You just need to write the following lines in you buildConfig.groovy file
[java]
grails.server.port.http=7070
[/java]
And you are done. Now your application will run on 7070 by default, you dont need to provide the port again and again.
Hope it helps
Uday Pratap Singh
uday@intelligrape.com
Will it work for Grails3+?
I tried but not working
Hi Lalit
Are you trying to say that we should change the port in grails script? I dont think it would be advisable to change the grails default configuration because this will become the default port for all other applications using same GRAILS_HOME.
I dont find it to be a good practice to change the grails code.
You can check the below link for port settings in latest GRAILS distribution
lalitagarw.blogspot.com/2011/06/grails-configuration-port-settings.html
Nice blog.
Recently found this thread http://grails.1312388.n4.nabble.com/how-to-change-1-3-7-built-in-tomcat-port-td3556994.html#a3563468 for this.
The BuildConfig.groovy approach is for per project basis. Try ~/.settings.groovy file for setting the default port for all the projects.