我正在使用 Apache FOP 1.1(Java) 生成 PDF 文件。 它在 Windows 机器上工作正常,但是当我使用 Ubuntu 机器时,我收到此错误
org.apache.xmlgraphics.image.loader.ImageException: The file format is not supported. No ImagePreloader found
我有点困惑。请给我解决方案来解决这个问题。 谢谢
最佳答案
问题是 fop
jar 文件和 xmlgraphics-commons
jar 中 META-INF/services/
中存在的配置文件之间存在冲突文件。
如果您使用maven并希望避免有时可能会造成麻烦的排除,您可以使用maven shade插件构建jar并强制连接META中的配置文件-INF/服务/
。像这样的片段对我有用:
<build>
<finalName>desired_jar_name</finalName>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-shade-plugin</artifactId>
<version>3.1.0</version>
<configuration>
<transformers>
<transformer
implementation="org.apache.maven.plugins.shade.resource.ServicesResourceTransformer" />
<transformer
implementation="org.apache.maven.plugins.shade.resource.ManifestResourceTransformer">
<mainClass>my.main.class</mainClass>
</transformer>
</transformers>
</configuration>
<executions>
<execution>
<phase>package</phase>
<goals>
<goal>shade</goal>
</goals>
</execution>
</executions>
</plugin>
</plugins>
</build>
关于java - org.apache.xmlgraphics.image.loader.ImageException : The file format is not supported. 未找到 ImagePreloader,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/27401158/