我想在groovy中创建一个包含列表的地图。
我尝试了类似的东西(这不是我的代码):
def releases = [:]
def versions = ['1','2']
def components = ['prog1']
for (component in components) {
releases[component]=versions
}
当我想解析版本时,我有此错误消息...
an exception which occurred:
in field com.cloudbees.groovy.cps.impl.BlockScopeEnv.locals
in object com.cloudbees.groovy.cps.impl.LoopBlockScopeEnv@2b71fd26
...
Caused: java.io.NotSerializableException: java.util.LinkedHashMap$Entry
at org.jboss.marshalling.river.RiverMarshaller.doWriteObject(RiverMarshaller.java:860)
at org.jboss.marshalling.river.BlockMarshaller.doWriteObject(BlockMarshaller.java:65)
at org.jboss.marshalling.river.BlockMarshaller.writeObject(BlockMarshaller.java:56)
at org.jboss.marshalling.MarshallerObjectOutputStream.writeObjectOverride(MarshallerObjectOutputStream.java:50)
at org.jboss.marshalling.river.RiverObjectOutputStream.writeObjectOverride(RiverObjectOutputStream.java:179)
at java.io.ObjectOutputStream.writeObject(ObjectOutputStream.java:344)
at java.util.HashMap.internalWriteEntries(HashMap.java:1790)
有什么想法吗? 是因为当我想在地图中添加版本时,版本是通过引用而不是按值传递的?
感谢。
答案 0 :(得分:0)
我替换了每个,它工作正常。
感谢。