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

2019-05-18 19:29发布

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?

2条回答
一纸荒年 Trace。
2楼-- · 2019-05-18 19:52

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
查看更多
做个烂人
3楼-- · 2019-05-18 20:12

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()

查看更多
登录 后发表回答