SOAPUI:无法解决 class XSSFWorkBook 错误
SOAPUI : unable to resolve class XSSFWorkBook error
我在 SoapUI 中使用 Apache POI
时出现以下错误。
unable to resolve class XSSFWorkBook error
我在 SOAPUI 中导入了 POI,并在 /bin/ext 中删除了 poi jar 文件。我尝试了 3.14 版和 3.15 版测试版。 (我附上了错误)。我在这里错过了什么吗?任何帮助将不胜感激。
代码如下:
import org.apache.poi.xssf.usermodel.*
import org.apache.poi.xssf.usermodel.XSSFWorkbook;
def fs = new FileInputStream ("C:\Users\JDoe\Desktop\SOAP_Learn\SOAP_Test_Data.xlsx")
def wb = new XSSFWorkBook (fs) //-->> gives error in this line
def ws = wb.getSheet("Sheet1")
def r = ws.getPhysicalNumberOfRows()
enter code here << Stack Trace >>
org.codehaus.groovy.control.MultipleCompilationErrorsException: startup failed: Script5.groovy: 14: unable to resolve class XSSFWorkBook @ line 14, column 11. def wb = new XSSFWorkBook (fs) ^ org.codehaus.groovy.syntax.SyntaxException: unable to resolve class XSSFWorkBook @ line 14, column 11. at org.codehaus.groovy.ast.ClassCodeVisitorSupport.addError(ClassCodeVisitorSupport.java:146) at org.codehaus.groovy.control.ResolveVisitor.resolveOrFail(ResolveVisitor.java:222) at org.codehaus.groovy.control.ResolveVisitor.resolveOrFail(ResolveVisitor.java:232) at org.codehaus.groovy.control.ResolveVisitor.transformConstructorCallExpression(ResolveVisitor.java:969) at org.codehaus.groovy.control.ResolveVisitor.transform(ResolveVisitor.java:646) at org.codehaus.groovy.control.ResolveVisitor.transformDeclarationExpression(ResolveVisitor.java:1010) at org.codehaus.groovy.control.ResolveVisitor.transform(ResolveVisitor.java:638) at org.codehaus.groovy.ast.ClassCodeExpressionTransformer.visitExpressionStatement(ClassCodeExpressionTransformer.java:139) at org.codehaus.groovy.ast.stmt.ExpressionStatement.visit(ExpressionStatement.java:40) at org.codehaus.groovy.ast.CodeVisitorSupport.visitBlockStatement(CodeVisitorSupport.java:35) at org.codehaus.groovy.ast.ClassCodeVisitorSupport.visitBlockStatement(ClassCodeVisitorSupport.java:163) at org.codehaus.groovy.control.ResolveVisitor.visitBlockStatement(ResolveVisitor.java:1240) at org.codehaus.groovy.ast.stmt.BlockStatement.visit(BlockStatement.java:69) at org.codehaus.groovy.ast.ClassCodeVisitorSupport.visitClassCodeContainer(ClassCodeVisitorSupport.java:101) at org.codehaus.groovy.ast.ClassCodeVisitorSupport.visitConstructorOrMethod(ClassCodeVisitorSupport.java:112) at org.codehaus.groovy.ast.ClassCodeExpressionTransformer.visitConstructorOrMethod(ClassCodeExpressionTransformer.java:50) at org.codehaus.groovy.control.ResolveVisitor.visitConstructorOrMethod(ResolveVisitor.java:166) at org.codehaus.groovy.ast.ClassCodeVisitorSupport.visitMethod(ClassCodeVisitorSupport.java:123) at org.codehaus.groovy.ast.ClassNode.visitContents(ClassNode.java:1055) at org.codehaus.groovy.ast.ClassCodeVisitorSupport.visitClass(ClassCodeVisitorSupport.java:50) at org.codehaus.groovy.control.ResolveVisitor.visitClass(ResolveVisitor.java:1183) at org.codehaus.groovy.control.ResolveVisitor.startResolving(ResolveVisitor.java:141) at org.codehaus.groovy.control.CompilationUnit.call(CompilationUnit.java:632) at org.codehaus.groovy.control.CompilationUnit.applyToSourceUnits(CompilationUnit.java:912) at org.codehaus.groovy.control.CompilationUnit.doPhaseOperation(CompilationUnit.java:574) at org.codehaus.groovy.control.CompilationUnit.compile(CompilationUnit.java:523) at groovy.lang.GroovyClassLoader.doParseClass(GroovyClassLoader.java:279) at groovy.lang.GroovyClassLoader.parseClass(GroovyClassLoader.java:258) at groovy.lang.GroovyShell.parseClass(GroovyShell.java:613) at groovy.lang.GroovyShell.parse(GroovyShell.java:625) at groovy.lang.GroovyShell.parse(GroovyShell.java:652) at groovy.lang.GroovyShell.parse(GroovyShell.java:643) at com.eviware.soapui.support.scripting.groovy.SoapUIGroovyScriptEngine.compile(SoapUIGroovyScriptEngine.java:138) at com.eviware.soapui.support.scripting.groovy.SoapUIGroovyScriptEngine.run(SoapUIGroovyScriptEngine.java:89) at com.eviware.soapui.impl.wsdl.teststeps.WsdlGroovyScriptTestStep.run(WsdlGroovyScriptTestStep.java:141) at com.eviware.soapui.impl.wsdl.panels.teststeps.GroovyScriptStepDesktopPanel$RunAction.run(GroovyScriptStepDesktopPanel.java:250) at java.util.concurrent.ThreadPoolExecutor.runWorker(Unknown Source) at java.util.concurrent.ThreadPoolExecutor$Worker.run(Unknown Source) at java.lang.Thread.run(Unknown Source) 1 error[![enter image description here][1]][1]
将您从apache poi 下载的所有jar 文件添加到soapui/bin/ext 文件夹中并重新启动soapui
jars 添加到 bin/ext ,为了节省时间,我添加了来自 apache poi 下载的所有 jars
poi-3.14-xxxxxx.jar
poi-examples-3.14-xxxxx.jar
poi-excelant-3.14-xxxxx.jar
poi-ooxml-3.14-xxxxxx.jar
poi-ooxml-schemas-3.14-xxxxxx.jar
poi-scratchpad-3.14-xxxxx.jar
ooxml-lib/curvesapi-1.03.jar
ooxml-lib/xmlbeans-2.6.0.jar
lib/commons-codec-1.10.jar
lib/commons-logging-1.2.jar
lib/junit-4.12.jar
lib/log4j-1.2.17.jar
使用下面的代码将工作簿放入 groovy
import org.apache.poi.ss.usermodel.*
import org.apache.poi.hssf.usermodel.*
import org.apache.poi.xssf.usermodel.*
import org.apache.poi.ss.util.*
def fs = new FileInputStream ("C:\Users\JDoe\Desktop\SOAP_Learn\SOAP_Test_Data.xlsx")
// Use this factory pattern to create/read workbook this is the wrong we are doing and if you find it out in the jarfiles there is no class XSSF
Workbook wb = WorkbookFactory.create(fs);
def ws = wb.getSheet("Sheet1")
def r = ws.getPhysicalNumberOfRows()
log.info r
//enjoy!!!
问题:您不能像 new XSSFWorkbook() 那样直接实例化 class 我们必须使用工厂模式来实例化它。
不要忘记点击回答这花了我很多时间
我在 SoapUI 中使用 Apache POI
时出现以下错误。
unable to resolve class XSSFWorkBook error
我在 SOAPUI 中导入了 POI,并在 /bin/ext 中删除了 poi jar 文件。我尝试了 3.14 版和 3.15 版测试版。 (我附上了错误)。我在这里错过了什么吗?任何帮助将不胜感激。
代码如下:
import org.apache.poi.xssf.usermodel.*
import org.apache.poi.xssf.usermodel.XSSFWorkbook;
def fs = new FileInputStream ("C:\Users\JDoe\Desktop\SOAP_Learn\SOAP_Test_Data.xlsx")
def wb = new XSSFWorkBook (fs) //-->> gives error in this line
def ws = wb.getSheet("Sheet1")
def r = ws.getPhysicalNumberOfRows()
enter code here << Stack Trace >>
org.codehaus.groovy.control.MultipleCompilationErrorsException: startup failed: Script5.groovy: 14: unable to resolve class XSSFWorkBook @ line 14, column 11. def wb = new XSSFWorkBook (fs) ^ org.codehaus.groovy.syntax.SyntaxException: unable to resolve class XSSFWorkBook @ line 14, column 11. at org.codehaus.groovy.ast.ClassCodeVisitorSupport.addError(ClassCodeVisitorSupport.java:146) at org.codehaus.groovy.control.ResolveVisitor.resolveOrFail(ResolveVisitor.java:222) at org.codehaus.groovy.control.ResolveVisitor.resolveOrFail(ResolveVisitor.java:232) at org.codehaus.groovy.control.ResolveVisitor.transformConstructorCallExpression(ResolveVisitor.java:969) at org.codehaus.groovy.control.ResolveVisitor.transform(ResolveVisitor.java:646) at org.codehaus.groovy.control.ResolveVisitor.transformDeclarationExpression(ResolveVisitor.java:1010) at org.codehaus.groovy.control.ResolveVisitor.transform(ResolveVisitor.java:638) at org.codehaus.groovy.ast.ClassCodeExpressionTransformer.visitExpressionStatement(ClassCodeExpressionTransformer.java:139) at org.codehaus.groovy.ast.stmt.ExpressionStatement.visit(ExpressionStatement.java:40) at org.codehaus.groovy.ast.CodeVisitorSupport.visitBlockStatement(CodeVisitorSupport.java:35) at org.codehaus.groovy.ast.ClassCodeVisitorSupport.visitBlockStatement(ClassCodeVisitorSupport.java:163) at org.codehaus.groovy.control.ResolveVisitor.visitBlockStatement(ResolveVisitor.java:1240) at org.codehaus.groovy.ast.stmt.BlockStatement.visit(BlockStatement.java:69) at org.codehaus.groovy.ast.ClassCodeVisitorSupport.visitClassCodeContainer(ClassCodeVisitorSupport.java:101) at org.codehaus.groovy.ast.ClassCodeVisitorSupport.visitConstructorOrMethod(ClassCodeVisitorSupport.java:112) at org.codehaus.groovy.ast.ClassCodeExpressionTransformer.visitConstructorOrMethod(ClassCodeExpressionTransformer.java:50) at org.codehaus.groovy.control.ResolveVisitor.visitConstructorOrMethod(ResolveVisitor.java:166) at org.codehaus.groovy.ast.ClassCodeVisitorSupport.visitMethod(ClassCodeVisitorSupport.java:123) at org.codehaus.groovy.ast.ClassNode.visitContents(ClassNode.java:1055) at org.codehaus.groovy.ast.ClassCodeVisitorSupport.visitClass(ClassCodeVisitorSupport.java:50) at org.codehaus.groovy.control.ResolveVisitor.visitClass(ResolveVisitor.java:1183) at org.codehaus.groovy.control.ResolveVisitor.startResolving(ResolveVisitor.java:141) at org.codehaus.groovy.control.CompilationUnit.call(CompilationUnit.java:632) at org.codehaus.groovy.control.CompilationUnit.applyToSourceUnits(CompilationUnit.java:912) at org.codehaus.groovy.control.CompilationUnit.doPhaseOperation(CompilationUnit.java:574) at org.codehaus.groovy.control.CompilationUnit.compile(CompilationUnit.java:523) at groovy.lang.GroovyClassLoader.doParseClass(GroovyClassLoader.java:279) at groovy.lang.GroovyClassLoader.parseClass(GroovyClassLoader.java:258) at groovy.lang.GroovyShell.parseClass(GroovyShell.java:613) at groovy.lang.GroovyShell.parse(GroovyShell.java:625) at groovy.lang.GroovyShell.parse(GroovyShell.java:652) at groovy.lang.GroovyShell.parse(GroovyShell.java:643) at com.eviware.soapui.support.scripting.groovy.SoapUIGroovyScriptEngine.compile(SoapUIGroovyScriptEngine.java:138) at com.eviware.soapui.support.scripting.groovy.SoapUIGroovyScriptEngine.run(SoapUIGroovyScriptEngine.java:89) at com.eviware.soapui.impl.wsdl.teststeps.WsdlGroovyScriptTestStep.run(WsdlGroovyScriptTestStep.java:141) at com.eviware.soapui.impl.wsdl.panels.teststeps.GroovyScriptStepDesktopPanel$RunAction.run(GroovyScriptStepDesktopPanel.java:250) at java.util.concurrent.ThreadPoolExecutor.runWorker(Unknown Source) at java.util.concurrent.ThreadPoolExecutor$Worker.run(Unknown Source) at java.lang.Thread.run(Unknown Source) 1 error[![enter image description here][1]][1]
将您从apache poi 下载的所有jar 文件添加到soapui/bin/ext 文件夹中并重新启动soapui
jars 添加到 bin/ext ,为了节省时间,我添加了来自 apache poi 下载的所有 jars
poi-3.14-xxxxxx.jar
poi-examples-3.14-xxxxx.jar
poi-excelant-3.14-xxxxx.jar
poi-ooxml-3.14-xxxxxx.jar
poi-ooxml-schemas-3.14-xxxxxx.jar
poi-scratchpad-3.14-xxxxx.jar
ooxml-lib/curvesapi-1.03.jar
ooxml-lib/xmlbeans-2.6.0.jar
lib/commons-codec-1.10.jar
lib/commons-logging-1.2.jar
lib/junit-4.12.jar
lib/log4j-1.2.17.jar
使用下面的代码将工作簿放入 groovy
import org.apache.poi.ss.usermodel.*
import org.apache.poi.hssf.usermodel.*
import org.apache.poi.xssf.usermodel.*
import org.apache.poi.ss.util.*
def fs = new FileInputStream ("C:\Users\JDoe\Desktop\SOAP_Learn\SOAP_Test_Data.xlsx")
// Use this factory pattern to create/read workbook this is the wrong we are doing and if you find it out in the jarfiles there is no class XSSF
Workbook wb = WorkbookFactory.create(fs);
def ws = wb.getSheet("Sheet1")
def r = ws.getPhysicalNumberOfRows()
log.info r
//enjoy!!!
问题:您不能像 new XSSFWorkbook() 那样直接实例化 class 我们必须使用工厂模式来实例化它。
不要忘记点击回答这花了我很多时间