如何在config.groovy中使用grails.serverURL?

Mik*_*key 2 deployment grails config

我在config.groovy中更改了一些行:

// 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}"
    }

}
Run Code Online (Sandbox Code Playgroud)

但是当我这样做run-app时仍然给了我

Server running. Browse to http://localhost:8080/myProject
Run Code Online (Sandbox Code Playgroud)

有什么地方我需要告诉它使用config.groovy吗?为什么不进8099?

Jos*_*ore 7

默认情况下,grails run-app始终在端口8080上运行.Config.groovy设置不会影响这一点.要更改端口,请使用run-app命令上的-Dserver.port设置.您可以在文档中找到有关它的更多信息.

grails -Dserver.port = 8099 run-app

这将在端口8099上启动您的应用程序.在创建绝对链接时使用Config.groovy值.

作为后续操作,您可以更改默认端口.但是,这会修改所有Grails项目的默认端口.

编辑$ GRAILS_HOME/scripts/_GrailsS​​ettings.groovy中的以下行(大约第92行):

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


Jas*_*ker 5

另一种选择是为每个应用程序设置端口.您可以通过将以下设置添加到Build.config来执行此操作:

grails.server.port.http = 8081
Run Code Online (Sandbox Code Playgroud)