简体   繁体   中英

grails rendering plugin incompatible return type issue

I am working on a grails 3 (grails version 3.2.3, java version 1.8) project where it needs to convert a gsp into a pdf. I tried to use the rendering plugin provided by grails. I imported the plugin using: compile 'org.grails.plugins:rendering:2.0.3' in my build.gradle file

and in my controller i used:

ByteArrayOutputStream bytes = pdfRenderingService.render(template: "/templates/pdf_PI", model: [proformaInvoice: proformaInvoice])

to render the pdf. The service is injected using def pdfRenderingService

however im getting this error

grails-app/controllers/chsam/re/ProformaInvoiceController.groovy: -1: The return type of java.lang.Object getPdfRenderingService() in chsam.re.ProformaInvoiceController is incompatible with grails.plugins.rendering.pdf.PdfRenderingService in grails.plugins.rendering.RenderingTrait. At [-1:-1]  @ line -1, column -1.

I spent hours trying to get this plugin to work but it just won't work. Please help.

Solved this issue by explicitly using types when declaring the service. Instead of def pdfRenderingService use PdfRenderingService pdfRenderingService .

Works on grails 3.2.11, using org.grails.plugins:rendering:2.0.3

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM