简体   繁体   English

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

[英]how do I use grails.serverURL in config.groovy?

I changed some lines in my config.groovy to this: 我在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}"
    }

}

But when I do run-app it still gives me 但是,当我run-app它仍然给了我

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

Is there somewhere I need to tell it to use config.groovy? 有什么地方我需要告诉它使用config.groovy吗? Why won't it go on 8099? 为什么不进8099?

By default grails run-app always runs on port 8080. The Config.groovy settings don't effect this. 默认情况下,grails run-app始终在端口8080上运行.Config.groovy设置不会影响这一点。 To change the port use the -Dserver.port setting on the run-app command. 要更改端口,请使用run-app命令上的-Dserver.port设置。 You can find out more about it in the documentation . 您可以在文档中找到有关它的更多信息。

grails -Dserver.port=8099 run-app grails -Dserver.port = 8099 run-app

That will start your application on port 8099. The Config.groovy values are used when creating absolute links. 这将在端口8099上启动您的应用程序。在创建绝对链接时使用Config.groovy值。

As a follow up, you can change the default port. 作为后续操作,您可以更改默认端口。 However, this modifies the default port for ALL of your Grails projects. 但是,这会修改所有Grails项目的默认端口。

Edit the following line in $GRAILS_HOME/scripts/_GrailsSettings.groovy (approximately line 92): 编辑$ GRAILS_HOME / scripts / _GrailsS​​ettings.groovy中的以下行(大约第92行):

serverPort = getPropertyValue("server.port", 8080).toInteger() 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 : 您可以通过将以下设置添加到Build.config来执行此操作

grails.server.port.http = 8081

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 如何在部署的Grails 2.1.0应用程序中包含Groovy 2.0? - How to include Groovy 2.0 in a deployed Grails 2.1.0 app? 如何在不同的部署中更改默认的应用程序配置/设置? - How do I change the default application config/setting in different deployments? 使用ac#Setup项目,如何在安装项目的msi中获取配置文件(nlog.config)? - Using a c# Setup project, how do I get a config file (nlog.config) into the msi for the Setup project? 在处理多个发布目标时,如何处理不同实例的多个web.config转换? - How do I handle multiple web.config transforms for different instances when dealing with multiple publish targets? 如何在自定义手枪任务中使用事务? - How do I use transactions within custom capistrano tasks? 如何在本地捆绑 JavaScript 和 CSS 依赖项以供离线使用? - How do I bundle JavaScript and CSS dependencies locally for offline use? 使用MSBuild,如何从命令行构建MVC4解决方案(在此过程中应用Web.config转换)并输出到文件夹? - Using MSBuild, how do I build an MVC4 solution from the command line (applying Web.config transformations in the process) and output to a folder? 为什么我需要使用 kubctl apply 进行保存配置? - Why do I need save-config with kubctl apply? 如何使用rpm更新/替换现有文件? - How do I use rpm to update/replace existing files? 如何部署Grails项目 - How to deploy grails project
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM