gpt4 book ai didi

excel - SOAPUI : unable to resolve class XSSFWorkBook error

转载 作者:行者123 更新时间:2023-12-04 21:36:15 24 4
gpt4 key购买 nike

使用 Apache POI 时出现错误在 SoapUI 中。

unable to resolve class XSSFWorkBook error



我在 SOAPUI 中导入 POI 并将 poi jar 文件放在/bin/ext 中。我尝试了 3.14 版和 3.15 beta 版。 (我附上了错误)。我在这里错过了什么吗?任何帮助将不胜感激。

这是代码:
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$10.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$1.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]

enter image description here

enter image description here

最佳答案

将您从 apache poi 下载的所有 jar 文件添加到soapui/bin/ext 文件夹中并重新启动soapui

添加到 bin/ext 的 jars,为了节省时间,我添加了 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!!!

ISSUE: 你不能像 new XSSFWorkbook() 这样直接实例化类,我们必须使用工厂模式来实例化它。
不要忘记点击回答这花了我很多时间
click here too reference groovy that worked in by box

关于excel - SOAPUI : unable to resolve class XSSFWorkBook error,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/37416900/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com