gpt4 book ai didi

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

转载 作者:行者123 更新时间:2023-12-02 15:38:41 24 4
gpt4 key购买 nike

griffon gsql插件的数据源配置写入DataSource.groovy中,
我希望它位于Config.properties中,如何?
我尝试,它不起作用:

  • 在conf上添加Config.properties

  • 2.config在Config.properties中:
    dataSource.driverClassName = com.mysql.jdbc.Driver
    dataSource.url = jdbc:mysql:// localhost / smp?useUnicode = true&characterEncoding = UTF8

    3.从DataSource.groovy删除此配置

    看来gsql插件必须从DataSource.groovy中读取配置。

    ps:gsql插件是开源的吗?

    最佳答案

    解决了。
    引用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
    }

    关于grails - Griffon Gsql-如何在Config.properties文件中配置数据源?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/5453956/

    24 4 0
    Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
    广告合作:1813099741@qq.com 6ren.com