[英]The method map((<no type> cfg) -> {}) is undefined for the type List<capture#1-of ? extends Config>
I am afraid this is the matter of simple lambda map function.恐怕这是简单的 lambda 映射函数的问题。 But I have no idea how.
但我不知道如何。 Below is my java codes,
下面是我的java代码,
public SparkConf createSparkConf(String appName, Config config) {
SparkConf sparkConf = new SparkConf().setMaster(config.getString("system.master")).setAppName(appName);
config.getConfigList("spark").map(cfg -> {
String name = "spark." + cfg.getString("name");
String value = cfg.getString("value");
sparkConf.set(name, value);
});
if(config.hasPath("app")) {
config.getConfigList("app").map(cfg -> {
String name = "spark." + cfg.getString("name");
String value = cfg.getString("value");
sparkConf.set(name, value);
});
}
return sparkConf;
}
But the map function throws the following exception.但是 map 函数抛出以下异常。
The method map((<no type> cfg) -> {}) is undefined for the type List<capture#1-of ? extends Config>
config.getConfigList("app")
line returns List<Config>
, but I have no idea why map function throws such errors. config.getConfigList("app")
行返回List<Config>
,但我不知道为什么 map 函数会抛出这样的错误。 Any idea?任何的想法?
You're looking for the forEach
method, since you're not collecting the results of the map
operation.您正在寻找
forEach
方法,因为您没有收集map
操作的结果。 Also you can call list.stream().map(...)
to reach it.您也可以调用
list.stream().map(...)
来访问它。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.