gpt4 book ai didi

gradle - 如何在build.gradle中定义Map

转载 作者:行者123 更新时间:2023-12-03 05:28:33 24 4
gpt4 key购买 nike

我有一个如下的插件

class AbstractConfigExtension {
public static final String NAME = "abstract_extension"
Project project

// Configuration extension properties
String service
String substrate
String region
String group
String pod
Map<String,InstanceGridDetails> instanceGridDetails = new HashMap<String,InstanceGridDetails>()
// new HashMap<String,String>()
List<String> tags = new ArrayList<>()
List<String> instances = ["i01"]
int numInstances = 1
boolean generateServiceFiles = true
}

我有一个名为 的其他类InstanceGridDetails.groovy
class InstanceGridDetails {
// Grid Properties
String grid
String dsName
String ddName

public AcdsInstanceGridDetails () {

}

String getGrid() {
return this.grid
}

void grid(String grid) {
this.grid = grid
}

String dsName() {
return this.dsName
}

void dsName(String dsName) {
this.dsName = dsName
}

String ddName() {
return this.ddName
}

void ddName(String ddName) {
this.ddName = ddName
}
}

使用build.gradle将其称为插件,如下所示
apply plugin: 'java'
apply plugin: HoconConfigPlugin
apply plugin: GriddableCaacRpmPlugin

abstract_extension {
service "relay"
substrate "1p"
region "xrd"
instanceGridDetails = ["i01": InstanceGridDetails { gridName "grid1"
dsName "ds1"
ddName "dd1"} ]
numInstances 1
tags = ["medium_mem"]
}

当我如上所述做时,我得到如下问题

FAILURE: Build failed with an exception.

  • Where: Build file 'config-packages/service-cfg-1p-xrd/build.gradle' line: 13

  • What went wrong: A problem occurred evaluating project ':config-packages:service-cfg-1p-xrd'.

    Could not find method InstanceGridDetails() for arguments [build_b1plunv4uhm1dpn66jee47jiz$_run_closure1$_closure2@25cf3fbf] on object of type AbstractConfigExtension.

最佳答案

您的构造函数仍称为AcdsInstanceGridDetails,而您的类称为InstanceGridDetails。它们应该具有相同的名称。

尝试用InstanceGridDetails替换所有出现的AcdsInstanceGridDetails

关于gradle - 如何在build.gradle中定义Map <String,CustomObject>,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/60306934/

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