報(bào)錯(cuò)如下:
error: value foreach is not a member of java.util.List[String]
[ERROR] for (column <- columnsList) {
[ERROR] ^
[ERROR] one error found
相關(guān)代碼:
val columnsList: util.List[String] = ConfigInfo.columns
val dataList = new ListBuffer[String]
for (column <- columnsList) {
dataList += SparkUtil.fetchStrField(dataMap, column)
}
報(bào)錯(cuò)的原因是:
對Java的數(shù)據(jù)結(jié)構(gòu)util.List使用了Scala的api
解決方法:
引入scala與java集合的隱式轉(zhuǎn)換:
import scala.collection.JavaConversions._