我有这个类位于文件中StreamingPOIWriter.groovy
@Grapes([
@Grab(group='org.apache.poi', module='poi', version='3.14'),
@Grab(group='org.apache.poi', module='poi-ooxml', version='3.14'),
@Grab(group='org.apache.poi', module='poi-ooxml-schemas', version='3.14')
])
import org.apache.poi.xslf.usermodel.XMLSlideShow
import org.apache.poi.xslf.usermodel.XSLFSlide
class StreamingPOIWriter {
XMLSlideShow presentation
def withPresentation() {
presentation = new XMLSlideShow()
this
}
def write(filename) {
presentation.write(new FileOutputStream(filename))
}
def withSlide() {
XSLFSlide slide = presentation.createSlide()
this
}
}
我使用groovyc
.
但是当我决定在另一个文件中创建它的实例时 -script.groovy
new StreamingPOIWriter()
.withPresentation()
.withSlide()
.write("presentation.pptx")
当我发现使用它运行它时,groovy script.groovy
我得到了这个错误
Caught: java.lang.NoClassDefFoundError: org/apache/poi/xslf/usermodel/XMLSlideShow
java.lang.NoClassDefFoundError: org/apache/poi/xslf/usermodel/XMLSlideShow
at script.run(script.groovy:2)
Caused by: java.lang.ClassNotFoundException: org.apache.poi.xslf.usermodel.XMLSlideShow
... 1 more
似乎无法找到StreamingPOIWriter
. 如何将它们传播到script.groovy
?
StreamingPOIWriter.groovy
并且script.groovy
在同一个文件夹中。