Griffon Gsql - 如何在Config.properties文件中配置数据源?

时间:2011-03-28 02:03:16

标签: grails groovy griffon

griffon gsql plugin的datasource配置是用DataSource.groovy编写的, 我希望它在Config.properties中,怎么样? 我试试,它不起作用:

  1. 在conf
  2. 添加Config.properties Config.properties中的

    2.config: dataSource.driverClassName = com.mysql.jdbc.Driver ?dataSource.url = JDBC:MySQL的://本地主机/ SMP了useUnicode =真安培;的characterEncoding = UTF8

    3.从DataSource.groovy

    中删除此配置

    似乎gsql插件必须从DataSource.groovy读取配置。

    ps:是gsql插件opensource吗?

1 个答案:

答案 0 :(得分:1)

sloved。 参考http://markmail.org/thread/gslnhxseaicc5ksp#query:+page:1+mid:beunoxesbbmlmznp+state:results

//read config.properties http://markmail.org/thread/gslnhxseaicc5ksp#query:+page:1+mid:beunoxesbbmlmznp+state:results
def props = new Properties()
props.load(getClass().classLoader.getResourceAsStream("Config.properties"))
def config = new ConfigSlurper().parse(props)

dataSource {
    dbCreate = "skip"
    pooled = config.dataSource.pooled as boolean
    //set this to true if using MySQL or any other RDBMS that requires execution of DDL statements on separate calls
    tokenizeddl = config.dataSource.tokenizeddl as boolean

    driverClassName = config.dataSource.driverClassName
    url = config.dataSource.url
    username = config.dataSource.username
    password = config.dataSource.password
}