我在maven POM中添加了以下依赖项。
<dependency>
<groupId>org.apache.poi</groupId>
<artifactId>poi-ooxml</artifactId>
<version>3.16</version>
</dependency>
<dependency>
<groupId>org.apache.poi</groupId>
<artifactId>poi</artifactId>
<version>3.16</version>
</dependency>
但仍然有以下异常:
java.lang.RuntimeException: java.lang.Error: Unresolved compilation problems: XSSFWorkbook cannot be resolved to a type XSSFWorkbook cannot be resolved to a type XSSFSheet cannot be resolved to a type XSSFWorkbook
cannot be resolved to a type XSSFSheet cannot be resolved to a type at org.apache.maven.surefire.testng.TestNGExecutor.run(TestNGExecutor.java:283) at org.apache.maven.surefire.testng.TestNGXmlTestSuite.execute(TestNGXmlTestSuite.java:75) at org.apache.maven.surefire.testng.TestNGProvider.invoke(TestNGProvider.java:120)
at org.apache.maven.surefire.booter.ForkedBooter.invokeProviderInSameClassLoader(ForkedBooter.java:386) at org.apache.maven.surefire.booter.ForkedBooter.runSuitesInProcess(ForkedBooter.java:323) at org.apache.maven.surefire.booter.ForkedBooter.main(ForkedBooter.java:143)
Caused by: java.lang.Error: Unresolved compilation problems: XSSFWorkbook cannot be resolved to a type XSSFWorkbook cannot be resolved to a type XSSFSheet cannot be resolved to a type XSSFWorkbook cannot be resolved to a type XSSFSheet cannot be resolved
to a type at utility.Utility.getTableArray(Utility.java:47) at test.CS1_TestCase.getPassInfo(CS1_TestCase.java:166) ... 23 more ... Removed 24 stack frames java.lang.RuntimeException: java.lang.Error: Unresolved compilation problems: XSSFWorkbook cannot
be resolved to a type XSSFWorkbook cannot be resolved to a type XSSFSheet cannot be resolved to a type XSSFWorkbook cannot be resolved to a type XSSFSheet cannot be resolved to a type at org.testng.internal.MethodInvocationHelper.invokeDataProvider(MethodInvocationHelper.java:143)
at org.testng.internal.Parameters.handleParameters(Parameters.java:426) at org.testng.internal.Invoker.handleParameters(Invoker.java:1383) at org.testng.internal.Invoker.createParameters(Invoker.java:1075) at org.testng.internal.Invoker.invokeTestMethods(Invoker.java:1180)
at org.testng.internal.TestMethodWorker.invokeTestMethods(TestMethodWorker.java:127) at org.testng.internal.TestMethodWorker.run(TestMethodWorker.java:111) at org.testng.TestRunner.privateRun(TestRunner.java:767) at org.testng.TestRunner.run(TestRunner.java:617)
at org.testng.SuiteRunner.runTest(SuiteRunner.java:334) at org.testng.SuiteRunner.runSequentially(SuiteRunner.java:329) at org.testng.SuiteRunner.privateRun(SuiteRunner.java:291) at org.testng.SuiteRunner.run(SuiteRunner.java:240) at org.testng.SuiteRunnerWorker.runSuite(SuiteRunnerWorker.java:52)
at org.testng.SuiteRunnerWorker.run(SuiteRunnerWorker.java:86) at org.testng.TestNG.runSuitesSequentially(TestNG.java:1198) at org.testng.TestNG.runSuitesLocally(TestNG.java:1123) at org.testng.TestNG.run(TestNG.java:1031) at org.apache.maven.surefire.testng.TestNGExecutor.run(TestNGExecutor.java:283)
at org.apache.maven.surefire.testng.TestNGXmlTestSuite.execute(TestNGXmlTestSuite.java:75) at org.apache.maven.surefire.testng.TestNGProvider.invoke(TestNGProvider.java:120) at org.apache.maven.surefire.booter.ForkedBooter.invokeProviderInSameClassLoader(ForkedBooter.java:386)
at org.apache.maven.surefire.booter.ForkedBooter.runSuitesInProcess(ForkedBooter.java:323) at org.apache.maven.surefire.booter.ForkedBooter.main(ForkedBooter.java:143) Caused by: java.lang.Error: Unresolved compilation problems: XSSFWorkbook cannot be
resolved to a type XSSFWorkbook cannot be resolved to a type XSSFSheet cannot be resolved to a type XSSFWorkbook cannot be resolved to a type XSSFSheet cannot be resolved to a type at utility.Utility.getTableArray(Utility.java:47) at test.CS1_TestCase.getPassInfo(CS1_TestCase.java:166)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62) at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) at java.lang.reflect.Method.invoke(Method.java:498)
at org.testng.internal.MethodInvocationHelper.invokeMethod(MethodInvocationHelper.java:80) at org.testng.internal.MethodInvocationHelper.invokeDataProvider(MethodInvocationHelper.java:117) ... 23 more "
请帮忙解决此问题。