Grails框架:groovy.lang.MissingMethodException:方法无签名

时间:2019-02-26 21:51:58

标签: grails groovy

当我尝试将值分配给变量“ newDBName”时,出现错误:

ERROR [grails.app.controllers] groovy.lang.MissingMethodException: 
No signature of method: DataSourceConfigService.$() is applicable for 
argument types: DataSourceConfigService$_injectNewDatasource_closure1_closure3) 
values: [DataSourceConfigService$_injectNewDatasource_closure1_closure3@1e1ae104]

代码:

class DataSourceConfigService {

def injectNewDatasource() {
            String newDBName = ""
            Environment.list().each {env ->
                if( !grailsApplication.mainContext.containsBean( "${env.accountName}" ) ) {

                            def bb = new BeanBuilder()
                            bb.beans {
                                  "${env.accountName}"(ComboPooledDataSource) {bean -> ...}
                                  bb.registerBeans( grailsApplication.mainContext );
                            }
                            log.info "Added bean called ${env.accountName}"

                            newDBName = ${env.accountName}
                }
            }
            return newDBName
}

}

这是我调用函数的方式:

String newDBName = dataSourceConfigService.injectNewDatasource()

1 个答案:

答案 0 :(得分:2)

您在from google.cloud import logging_v2 client = logging_v2.LoggingServiceV2Client() # This defines what object is emitting the logs. See https://cloud.google.com/logging/docs/api/v2/resource-list for a list of options res = {"type": "gce_instance", "labels": { "zone": "us-central1-a", "instance_id": "1235"}} entries = [] # Add a plain text log entry logEntry = {"text_payload": "abc YOUR MESSAGE BLAH"} entries.append(logEntry) # Add a structured log entry (https://cloud.google.com/logging/docs/structured-logging) from google.protobuf.struct_pb2 import Struct s = Struct() s["key"] = ["value1","value2"] logEntry = {"json_payload": s} entries.append(logEntry) # write a batch of logs to Stackdriver. response = client.write_log_entries(entries, log_name='projects/[PROJECT_ID]/logs/[LOG_ID]', resource=res) 分配行上缺少引号。可以使用

MaterialApp

或仅跳过到GString的转换(至少根据此代码段看起来似乎没有必要)并使用

newDBName