问题描述
// set per-environment serverURL stem用于创建绝对路径链接
环境{
生产{
grails.serverURL =http://www.changeme.com
}
开发{
grails.serverURL = HTTP://本地主机:8099 / $ {AppName} 是
}
测试{
grails.serverURL = HTTP://本地主机:8080 / $ {AppName} 是
$ b $ / code>
但是当我做 run-app
它仍然给我
服务器正在运行。浏览到http:// localhost:8080 / myProject
是否有某处我需要告诉它使用Config.groovy中?为什么不说下去8099?
默认情况下的Grails运行的应用程序始终运行在8080端口上的Config.groovy中设置不会影响这一点。要更改端口,请在run-app命令中使用-Dserver.port设置。您可以在中找到更多关于它的信息。
作为后续,您可以更改默认端口。但是,这会修改所有Grails项目的默认端口。
编辑在$ GRAILS_HOME /脚本/ _GrailsSettings.groovy(大约线92)下面的行:
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.
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):
这篇关于如何在config.groovy中使用grails.serverURL?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!