java - Groovy:由于缺少依赖项 CTPosH,无法加载类 CTAnchor
问题描述
我正在使用 Idea,这是我的 bulid.gradle
dependencies {
compile project(":signer-core")
compile 'org.codehaus.groovy:groovy-all:2.4.8'
def poi_version = "3.17"
compile "org.apache.poi:poi:${poi_version}"
compile "org.apache.poi:poi-ooxml:${poi_version}"
compile "org.apache.poi:poi-ooxml-schemas:${poi_version}"
compile "org.apache.santuario:xmlsec:2.1.0"
testCompile "junit:junit:4.12"
}
当我在我创建的 *.groovy 中编译此代码时:
private CTAnchor getAnchorWithGraphic(CTDrawing drawing /*inline drawing*/,
String drawingDescr, boolean behind) throws Exception {
CTGraphicalObject graphicalobject = drawing.getInlineArray(0).graphic
long width = drawing.getInlineArray(0).getExtent().getCx()
long height = drawing.getInlineArray(0).getExtent().getCy()
String anchorXML =
"<wp:anchor xmlns:wp=\"http://schemas.openxmlformats.org/drawingml/2006/wordprocessingDrawing\" "
+"simplePos=\"0\" relativeHeight=\"0\" behindDoc=\""+((behind)?1:0)+"\" locked=\"0\" layoutInCell=\"1\""
+"allowOverlap=\"1\">"
+"<wp:simplePos x=\"0\" y=\"0\"/>"
+"<wp:positionH relativeFrom=\"column\"><wp:posOffset>0</wp:posOffset></wp:positionH>"
+"<wp:positionV relativeFrom=\"paragraph\"><wp:posOffset>0</wp:posOffset></wp:positionV>"
+"<wp:extent cx=\""+width+"\" cy=\""+height+"\"/>"
+"<wp:effectExtent l=\"0\" t=\"0\" r=\"0\" b=\"0\"/><wp:wrapNone/>"
+"<wp:docPr id=\"1\" name=\"Drawing 0\" descr=\""+drawingDescr+"\"/><wp:cNvGraphicFramePr/>"
+"</wp:anchor>"
drawing = CTDrawing.Factory.parse(anchorXML)
CTAnchor anchor = drawing.getAnchorArray(0)
anchor.setGraphic(graphicalobject)
return anchor
}
它有一些错误:
错误:Groovyc:编译signer-office_main时:java.lang.RuntimeException:java.lang.NoClassDefFoundError:由于缺少依赖项org/openxmlformats/schemas/drawingml,无法加载类org.openxmlformats.schemas.drawingml.x2006.wordprocessingDrawing.CTAnchor /x2006/wordprocessing绘图/CTPosH
但是代码可以在我创建的 *.java 中运行。我进入CTAnchor.class检查CTPosH,它真的找不到声明去。但这是最新的apache poi版本。
解决方案
推荐阅读
- phpmyadmin - phpmyadmin直接url访问(post方式)
- javascript - 有没有办法创建一个 document.editable 切换?
- swift - 使用 Realm 和 Swift 查询领域以使用多个部分填充 numberOfRowsInSection 和 cellForRowAt
- sql - 迁移后左连接多个表
- javascript - 需要帮助在 .save() 函数中使用 updateMany mongoose 路由更新 mongodb
- modelica - 在 dymola 初始化期间出错,但以成功结束
- video - 替换流中的原始数据(ffmpeg)
- powershell - Powershell - 使用 Get-ChildItem 和 Read-host 搜索具有扩展名的文件
- python - 无法弄清楚为什么 Django 没有将表数据从视图添加到模型
- java - Hybris - 无法增加 MySql DB 中的列大小