在Grails中注入特定于开发人员的设置

在Grails中注入特定于开发人员的设置,grails,configuration,Grails,Configuration,现在,我们的grails应用程序的conf中有一个DataSource.groovy文件。它有这样的设置 development { dataSource { dbCreate = "create-drop" // one of 'create', 'create-drop', 'update', 'validate', '' url = "jdbc:mysql://localhost/mydb?useUnicode=yes&

现在,我们的grails应用程序的conf中有一个DataSource.groovy文件。它有这样的设置

   development {
        dataSource {
            dbCreate = "create-drop" // one of 'create', 'create-drop', 'update', 'validate', ''
            url = "jdbc:mysql://localhost/mydb?useUnicode=yes&characterEncoding=UTF-8"
            username = "user"
            password = "password"
        }
    }

当不同的开发人员的数据库具有不同的主机/用户名/密码时,在不更改此文件并尝试记住不签入对源代码管理的更改的情况下,交换每个开发人员的设置的好方法是什么?随着应用程序的增长,需要在不同开发人员的机器上更改的设置数量也会随之增加。

我设置开发环境,以查找保存用户名和密码的环境变量,这些变量是开发人员在运行
grails run app
之前创建的

    development {
        dataSource {
          //dbCreate = "update" // one of 'create', 'create-drop','update'
            url = "jdbc:oracle:thin:@myserver:1521:SID"
            username = System.env.grails_user
            password = System.env.grails_password
            dialect = org.hibernate.dialect.OracleDialect
        }
    }
为了避免混淆,我将以下注释块放在文件的开头(我们在Windows中开发)

/***********************************************************************
*开发和测试环境希望找到数据库
*以下系统环境变量中的用户名和密码。
*
*grails\u用户
*grails\u密码
*
*在尝试grails运行应用程序或grails测试之前,请确保设置
*变量。在Windows中,您可以键入以下内容。
*
*设置grails\u用户=
*设置grails\u密码=
*grails run应用程序
*
*只要不关闭密码,系统就会记住密码
*cmd窗口。
*
**********************************************************************/

这有点麻烦,但在我们的源代码和版本控制系统中保留密码是值得的。

我同意@doelleri的观点。将设置外部化,并将其排除在源代码管理的范围之外。doelleri在上面发布的问题中对Neomusashi的回答是最好的方法
/***********************************************************************
 * The development and test environments expect to find the database
 * username and password in the following system environment variables.
 *
 *   grails_user
 *   grails_password
 *
 * Before trying grails run-app or grails test, be sure to set the
 * variables.  In Windows, you can type the following.
 *
 *   set grails_user=<your username>
 *   set grails_password=<your password>
 *   grails run-app
 *
 * The system will remember the password as long as you don't close the
 * cmd window.
 *
 **********************************************************************/