我知道这个问题经常被重复 - 但我与现有报道的问题没有任何相似之处! :(我的没有静态字段,并且在Spring框架平台应用程序中。请求帮助...
当您看到给定的控制台输出时,当我循环返回阵列列表内容时,阵列列表会重复打印最后一项
以下是我的代码片段,罪魁祸首:)
for (Map.Entry<Integer, List<String>> entry : fileDataCollection
.entrySet()) {
rowDataHolder=getRowDataBucket(); // Spring Based
int currrentRowIndex = entry.getKey();
if ((currrentRowIndex > startRange) && currrentRowIndex < endRange) {
List<String> rowDataValue=entry.getValue();
if(null!=(rowDataValue)){
SectionDataVO rowDataHolder=extractSectionSpecificData(entry.getValue());
if(null!=rowDataHolder){
System.out.println("Now Adding rowDataHolder Value");
System.out.println("----"+rowDataHolder);
DTOCollectionList.add(rowDataHolder);
}
}
现在我的系统out println for rowDataHolder清楚地显示它每次都收集唯一的SectionDataVO。但是,当我尝试将它们添加到另一个ArrayList中时 - 它只添加最后一个但是三次!这里没有静态字段 - 所有都是基于弹簧的bean。我在这里搜索了很多选项......想知道接下来要做什么......
控制台输出:
现在将rowData添加到List -
TransSummaryDataVO [transactionName = 01_C01_OMS_AddNote,min = 0.061,avg = 0.138,max = 25.607,stdDeviation = 0.725,ninetyPerc = 0.16]
TransSummaryDataVO [transactionName = 02_C01_OMS_GetNote,min = 0.09,avg = 0.374,max = 26.003,stdDeviation = 0.801,ninetyPerc = 0.404]
TransSummaryDataVO [transactionName = OMSWillingToWait,min = 0.062,avg = 0.249,max = 64.869,stdDeviation = 2.441,ninetyPerc = 0.156]
DTOCollectionList Size
[TransSummaryDataVO [transactionName = OMSWillingToWait,min = 0.062,avg = 0.249,max = 64.869,stdDeviation = 2.441,ninetyPerc = 0.156],TransSummaryDataVO [transactionName = OMSWillingToWait,min = 0.062,avg = 0.249,max = 64.869,stdDeviation = 2.441,ninetyPerc = 0.156],TransSummaryDataVO [transactionName = OMSWillingToWait,min = 0.062,avg = 0.249,max = 64.869,stdDeviation = 2.441,ninetyPerc = 0.156]]
阅读DTOCollectionList ----------------------阅读交易摘要部分------------------------ ------
现在行数据已恢复3
TransSummaryDataVO [transactionName = OMSWillingToWait,min = 0.062,avg = 0.249,max = 64.869,stdDeviation = 2.441,ninetyPerc = 0.156]
TransSummaryDataVO [transactionName = OMSWillingToWait,min = 0.062,avg = 0.249,max = 64.869,stdDeviation = 2.441,ninetyPerc = 0.156]
TransSummaryDataVO [transactionName = OMSWillingToWait,min = 0.062,avg = 0.249,max = 64.869,stdDeviation = 2.441,ninetyPerc = 0.156] 测试App Bean启动..