NoClassDefFoundError: org/apache/commons/collections4/bidimap/TreeBidiMap

在做通过java中excel模板导出后台数据时,
exportBook.write(byteArrayOut); 报错,原因是配置文件中只有POI的jar包,没有commons-collections4的jar包,在网上下载之后复制到该类所在的lib下,并在MANIFEST.MF文件中Bundle-ClassPath: 下添加 META-INF/lib/commons-collections4-4.1.jar 就可以了。主要是缺少commons-collections4 包导致报错。标记一下加深印象。

public Object exportProjectIntroList( final String typeId,
			final ItemCondition itemCondition, final String modelId) {
		String fileName = "DTKCJJZBMX.xls";
		if ("1".equals(modelId)) { // 
			fileName = "DTKCJJZBMX.xls";
		}
		// 模板文件流
		final InputStream templateFileIs = TemplateUtils.getTemplateFileInputStream(fileName);	
		// 根据条件查询页面需要导出的数据
		List<Map> resultList = iTRpeProjBasicInforQueryContext.getModelResultList(dc, typeId, itemCondition);
		//根据模型Id构建excel表头 不同的模型导出列表不一样
		//final ByteArrayOutputStream byteArrayOut = new ByteArrayOutputStream();
		byte[] bytes = null;
		try {	
			//if (resultList != null && resultList.size()>0) {
				Workbook exportBook = ModelExportExcelUtil.exportModelListInfo(templateFileIs,fileName, resultList);					
				bytes = getExcelBytes(exportBook);
			//}			
		}
		catch (Exception e) {
			e.printStackTrace();
		} finally {
			if (templateFileIs != null) {
				try {
					templateFileIs.close();
				} catch (IOException e) {
					e.printStackTrace();
				}
			}
		}
		return bytes;
	}
private byte[] getExcelBytes(final Workbook exportBook) {
		ByteArrayOutputStream byteArrayOut = null;
		byte[] bytes = null;
		try {
			byteArrayOut = new ByteArrayOutputStream();
			exportBook.write(byteArrayOut);
			bytes = byteArrayOut.toByteArray();
		} catch (Exception e) {
			e.printStackTrace();
		} finally {
			try {
				if (byteArrayOut != null) {
					byteArrayOut.close();
				}
			} catch (IOException e) {
				e.printStackTrace();
			}
		}
		return bytes;
	}
				

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 1
    评论
评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值