我正在使用docx4j VariablePrepare,因为我正在处理多次运行。但是在实现它时,我遇到了以下错误。我有xalan 2.7.1和序列化器2.7.0
Exception in thread "main" java.lang.IllegalAccessError: tried to access class org.apache.xml.serializer.ExtendedContentHandler from class org.apache.xalan.transformer.TransformerImpl
at org.apache.xalan.transformer.TransformerImpl.createSerializationHandler(TransformerImpl.java:1233)
at org.apache.xalan.transformer.TransformerImpl.createSerializationHandler(TransformerImpl.java:1060)
at org.apache.xalan.transformer.TransformerImpl.transform(TransformerImpl.java:1268)
at org.apache.xalan.transformer.TransformerImpl.transform(TransformerImpl.java:1251)
at org.docx4j.XmlUtils.transform(XmlUtils.java:992)
at org.docx4j.XmlUtils.transform(XmlUtils.java:883)
at org.docx4j.openpackaging.packages.WordprocessingMLPackage.transform(WordprocessingMLPackage.java:239)
at org.docx4j.openpackaging.packages.WordprocessingMLPackage.filter(WordprocessingMLPackage.java:287)
at org.docx4j.model.datastorage.migration.VariablePrepare.prepare(VariablePrepare.java:80)
我正在使用以下代码进行VariablePrepare。
WordprocessingMLPackage docxFile = WordprocessingMLPackage.load(new File(inputFile));
mainDocumentPart = docxFile.getMainDocumentPart();
VariablePrepare.prepare(docxFile);