日期:2014-05-16  浏览次数:20390 次

dbunit2.4.9和poi3.9整合版本问题小述



??????? 每次用开源的框架时,最蛋疼的不是业务逻辑如何如何复杂,而是痛苦的版本问题。开源的框架都不是不同的团队搞出来的东西,因此版本兼容做的不是很全面完善。可是作为一个小程序员也没有必要去指责框架的问题了,毕竟我们自己造轮子还是太费时,还有最重要的是水平达不到啊。在此就先发发牢骚了,下面切入正题了,相信用过unitils的朋友们都遇到过这个问题喽,截图如下:(此为dbunit2.4.9和poi3.9最新版本)

java.lang.NoSuchMethodError: org.apache.poi.hssf.usermodel.HSSFDateUtil.isCellDateFormatted(Lorg/apache/poi/hssf/usermodel/HSSFCell;)Z
	at org.dbunit.dataset.excel.XlsTable.getValue(XlsTable.java:153)
	at unitils.test.excel.MultiSchemaXlsDataSetReader$XlsTable.getValue(MultiSchemaXlsDataSetReader.java:114)
	at org.dbunit.operation.AbstractBatchOperation.isEmpty(AbstractBatchOperation.java:77)
	at org.dbunit.operation.AbstractBatchOperation.execute(AbstractBatchOperation.java:135)
	at org.dbunit.operation.CompositeOperation.execute(CompositeOperation.java:79)
	at org.unitils.dbunit.datasetloadstrategy.impl.CleanInsertLoadStrategy.doExecute(CleanInsertLoadStrategy.java:45)
	at org.unitils.dbunit.datasetloadstrategy.impl.BaseDataSetLoadStrategy.execute(BaseDataSetLoadStrategy.java:44)
	at org.unitils.dbunit.DbUnitModule.insertDataSet(DbUnitModule.java:230)
	at org.unitils.dbunit.DbUnitModule.insertDataSet(DbUnitModule.java:153)
	at org.unitils.dbunit.DbUnitModule$DbUnitListener.beforeTestSetUp(DbUnitModule.java:557)
	at org.unitils.core.Unitils$UnitilsTestListener.beforeTestSetUp(Unitils.java:273)
	at org.unitils.UnitilsJUnit4TestClassRunner$TestListenerInvokingMethodRoadie.runBeforesThenTestThenAfters(UnitilsJUnit4TestClassRunner.java:151)
	at org.junit.internal.runners.MethodRoadie.runTest(MethodRoadie.java:86)
	at org.junit.internal.runners.MethodRoadie.run(MethodRoadie.java:49)
	at org.unitils.UnitilsJUnit4TestClassRunner.invokeTestMethod(UnitilsJUnit4TestClassRunner.java:95)
	at org.junit.internal.runners.JUnit4ClassRunner.runMethods(JUnit4ClassRunner.java:61)
	at org.unitils.UnitilsJUnit4TestClassRunner.access$000(UnitilsJUnit4TestClassRunner.java:44)
	at org.unitils.UnitilsJUnit4TestClassRunner$1.run(UnitilsJUnit4TestClassRunner.java:62)
	at org.junit.internal.runners.ClassRoadie.runUnprotected(ClassRoadie.java:33)
	at org.junit.internal.runners.ClassRoadie.runProtected(ClassRoadie.java:45)
	at org.unitils.UnitilsJUnit4TestClassRunner.run(UnitilsJUnit4TestClassRunner.java:68)
	at org.eclipse.jdt.internal.junit4.runner.JUnit4TestReference.run(JUnit4TestReference.java:50)
	at org.eclipse.jdt.internal.junit.runner.TestExecution.run(TestExecution.java:38)
	at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:467)
	at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:683)
	at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.run(RemoteTestRunner.java:390)
	at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.main(RemoteTestRunner.java:197)

?

?

?????? 这里总是提示NoSuchMethod这个问题,翻看dbunit的pom.xml文件发现他依赖的是poi3.2-FINAL版本,这个真是让人吐血啊,这个版本比较久了,虽然在spring中导出Excel视图我用的是poi3.9版本,这两个版本Cell的创建方式不同,但我还是为了解决它换了poi3.2-FINAL版本,期望问题得以解决。在满怀信心的点击了

Junit Test后我的心凉了,发现又会提示如下错误:

?

org.unitils.core.UnitilsException: Error inserting test data from DbUnit dataset for method public void unitils.test.impl.UserDaoTest.findUserByUserName()
	at org.unitils.dbunit.DbUnitModule.insertDataSet(DbUnitModule.java:156)
	at org.unitils.dbunit.DbUnitModule$DbUnitListener.beforeTestSetUp(DbUnitModule.java:557)
	at org.unitils.core.Unitils$UnitilsTestListener.beforeTestSetUp(Unitils.java:273)
	at org.unitils.UnitilsJUnit4TestClassRunner$TestListenerInvokingMethodRoadie.runBeforesThenTestThenAfters(UnitilsJUnit4TestClassRunner.java:151)
	at org.junit.internal.runners.MethodRoadie.runTest(MethodRoadie.java:86)
	at org.junit.internal.runners.MethodRoadie.run(MethodRoadie.java:49)
	at org.unitils.UnitilsJUnit4TestClassRunner.invokeTestMethod(UnitilsJUnit4TestClassRunner.java: