本文介绍了如何在线程"main"中修复此异常java.lang.NoSuchMethodError:org.apache.poi.POIXMLDocumentPart.getPackageRelationship的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

public class CreatePdf {

    public static void main(String[] args) {
        CreatePdf pdf = new CreatePdf();
        System.out.println("start");
        pdf.ConvertToPDF("D:\\doctopdf.docx", "D:\\Test1.pdf");
    }

    public void ConvertToPDF(String docPath, String pdfPath) {

        try {
            InputStream doc = new FileInputStream(new File(docPath));
            XWPFDocument document = new XWPFDocument(doc);
            PdfOptions options = PdfOptions.create();
            OutputStream out = new FileOutputStream(new File(pdfPath));
            PdfConverter.getInstance().convert(document, out, options);
            System.out.print("Done");
      /*}catch(FileNotFoundException ex){
            System.out.print(ex.getMessage());*/
        }catch(IOException ex){
            System.out.print(ex.getMessage());
        }
    }
}

推荐答案

关于标题的快速google给了我这个(仍然开放)的问题 https://github.com/opensagres/xdocreport/issues/208

quick google on the title gave me this (still open) issuehttps://github.com/opensagres/xdocreport/issues/208

那里的最后一条评论说

我切换到:编译组:'fr.opensagres.xdocreport',名称:'fr.opensagres.poi.xwpf.converter.xhtml',版本:'2.0.1'

I switched to: compile group: 'fr.opensagres.xdocreport', name: 'fr.opensagres.poi.xwpf.converter.xhtml', version: '2.0.1'

问题已解决.任何人都可以确认这是否是合理可行的升级途径?

And the problem was resolved. Can anyone confirm whether this is a reasonable and viable upgrade path?

这篇关于如何在线程"main"中修复此异常java.lang.NoSuchMethodError:org.apache.poi.POIXMLDocumentPart.getPackageRelationship的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

09-11 11:34