Joh*_*n M 5 jasper-reports itext gradle maven
我想同时使用Jasper Reports(vanilla,从未使用Grails Jasper插件工作 - 看到这个)和Grails Rendering插件(一个更适合某些报告,另一个适用于其他报告).
如果我包含'com.lowagie:itext:2.1.5'或'com.lowagie:itext:4.2.1'那么我在运行Rendering插件的PDF报告时缺少com.lowagie.text.pdf.BaseFont.getCharBBox.
如果我包含'com.lowagie:itext:2.0.8',那么在运行Jasper的PDF报告时我缺少com.lowagie.text.pdf.PdfWriter.setRgbTransparencyBlending.
两者都失败了java.lang.NoSuchMethodError-s.
我没有尝试过最新的iText版本,但它们有不同的软件包名称和更严格的许可,因此我认为它们不适合.
我的BuildConfig.groovy看起来像这样(前3个依赖项之一被取消注释):
dependencies {
// runtime 'com.lowagie:itext:4.2.1' // missing.BaseFont.getCharBBox
// runtime 'com.lowagie:itext:2.0.8' // missing PdfWriter.setRgbTransparencyBlending
// runtime 'com.lowagie:itext:2.1.5' // missing.BaseFont.getCharBBox
compile 'net.sf.jasperreports:jasperreports:5.2.0' // needed by jasper
runtime 'org.springframework:spring-test:3.2.4.RELEASE' // needed by rendering plugin
runtime 'commons-collections:commons-collections:3.2.1' // needed for jasper
}
plugins {
// ...
compile ":rendering:0.4.4"
// compile ":jasper:1.6.1" // couldn't get this to generate anything, but not sure it would help any
// ...
}
Run Code Online (Sandbox Code Playgroud)
是否有任何"旧"版本的iText(MPL许可),我可以尝试可能有用吗?
有没有办法让Maven/Gradle来制作它,以便我可以让其中一个库/插件使用一个版本的iText,另一个版本使用另一个版本?
解决方案是在包含渲染插件时使用“excludes”子句:
compile(":rendering:0.4.4") {
excludes(
[group:'org.xhtmlrenderer'],
[group:'com.lowagie']
)
}
Run Code Online (Sandbox Code Playgroud)
这并不能真正解决所有问题,因为 Grails 本身包含旧版本的 org.xhtmlrenderer Flying Saucer core-renderer-R8.jar(取决于 grails-docs),但它确实回答了关于如何让 iText 依赖项正常工作(以及排除项,我只是包含了“com.lowagie:itext:2.1.7”,它适用于 Jasper 和渲染插件。
| 归档时间: |
|
| 查看次数: |
3566 次 |
| 最近记录: |