2017-02-22 53 views
0

我正在使用grails 3(grails版本3.2.3,java版本1.8)項目,它需要將gsp轉換爲pdf。我試圖使用grails提供的渲染插件。 我進口使用插件: compile 'org.grails.plugins:rendering:2.0.3' 在我的build.gradle文件grails渲染插件不兼容返回類型問題

,並在我的控制器 我用:

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

渲染PDF格式。該服務使用def pdfRenderingService

但是我爲得到這個錯誤

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. 

我花了幾個小時試圖讓這個插件的工作,但它是行不通的注入。請幫忙。

+0

PLZ添加依賴這個dependencie,依賴性{ 運行 'org.springframework:彈簧試驗:4.1.6.RELEASE' } –

+0

請添加這個編譯「組織.grails.plugins:渲染:2.0.0-SNAPSHOT「而不是添加此編譯」org.grails.plugins:rendering:2.0.3' –

回答

0

通過在聲明服務時明確使用類型來解決此問題。而不是def pdfRenderingService使用PdfRenderingService pdfRenderingService

中,Grails 3.2.11工程,採用org.grails.plugins:rendering:2.0.3