简体   繁体   中英

how do I use grails.serverURL in config.groovy?

I changed some lines in my config.groovy to this:

// set per-environment serverURL stem for creating absolute links
environments {
    production {
        grails.serverURL = "http://www.changeme.com"
    }
    development {
        grails.serverURL = "http://localhost:8099/${appName}"
    }
    test {
        grails.serverURL = "http://localhost:8080/${appName}"
    }

}

But when I do run-app it still gives me

Server running. Browse to http://localhost:8080/myProject

Is there somewhere I need to tell it to use config.groovy? Why won't it go on 8099?

By default grails run-app always runs on port 8080. The Config.groovy settings don't effect this. To change the port use the -Dserver.port setting on the run-app command. You can find out more about it in the documentation .

grails -Dserver.port=8099 run-app

That will start your application on port 8099. The Config.groovy values are used when creating absolute links.

As a follow up, you can change the default port. However, this modifies the default port for ALL of your Grails projects.

Edit the following line in $GRAILS_HOME/scripts/_GrailsSettings.groovy (approximately line 92):

serverPort = getPropertyValue("server.port", 8080).toInteger()

Another option would be to set the port for each of your applications. You can do this by adding the following setting to Build.config :

grails.server.port.http = 8081

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM