2012-12-23 98 views
1

新手问题,Grails - 项目构建系统

将其用于Web应用程序。我正在寻找一种工具,可以帮助我为不同环境构建和部署Grails应用程序(类似于Ant),而不会丢失“编辑>保存>刷新”开发风格。

+0

它们都是内置功能,你是什么意思“不同的环境”?你的意思是客户端,服务器端,都? –

+0

我的意思是发展与生产。例如在dev模式下,密码可以是“1234”,在dev“DFG54 ^&HGFGV”中,但是变量代码是相同的......类似于pass =“{properties.pass}”; –

+0

好的,你喜欢在实时系统上编辑>保存>刷新? –

回答

3

如果要通过环境变量只是增加你的属性是这样的:

environments { 
    production { 
     grails.serverURL = "http://www.changeme.com" 
     grails.dbconsole.enabled = true 
     grails.dbconsole.urlRoot = '/admin/dbconsole' 
    } 
    development { 
     grails.serverURL = "http://localhost:8080/${appName}" 
    } 
    test { 
     grails.serverURL = "http://localhost:8080/${appName}" 
    } 
} 

然后让你的变量是这样的:

${grailsApplication.config.grails.serverURL} 

要切换环境,请使用以下命令:

grails run-app  // runs with the default "development" data source 
grails dev run-app // runs with the "development" data source 
grails run-war // runs with the production data source 
grails -Dgrails.env=mycustomenv run-app // specific a custom environment 
grails test run-app // runs with the test data source 

Documentation

+0

Grails文档不建议使用“grails run-app”命令用于生产。请参阅:http://grails.org/doc/latest/guide/deployment.html –

+0

谢谢,编辑改为建议的'grails run-war'来代替。 –

+0

有没有办法使用不同的文件而不是范围样式? –