解決CentOS 中部署JasperReport時出錯的問題。錯誤:net.sf.jasperreports.engine.util.JRFontNotFoundException: Font '宋體
阿新 • • 發佈:2019-01-07
解決CentOS 中部署JasperReport時出錯的問題。錯誤:net.sf.jasperreports.engine.util.JRFontNotFoundException: Font '宋體' is not available to the JVM.
CentOS 中部署JasperReport時出錯:
net.sf.jasperreports.engine.util.JRFontNotFoundException: Font '宋體' is not available to the JVM. See the Javadoc for more details.
原因:作業系統預設語言是英文版的。修改為中文並拷貝windows的字型到linux系統中並應用,停止Tomcat等Web伺服器,刪除快取(Tomcat中為tomcat目錄下的work目錄)即可。
方法:
修改系統預設語言:
vim /etc/sysconfig/i18n
內容:
拷貝字型:
將c:\windows\Fonts(從網上下載simsun.ttf,windows中自帶的宋體已經不叫這個名字le)下
的字型拷貝到 /usr/share/fonts/chinese下面(我的是CentOS6,fonts目錄下面我自己建立的chinese目錄)
進入tomcat目錄,停止tomcat服務,刪除work目錄。
重啟系統:reboot
測試。OK!
經測試,以上方法不能永遠解決問題。
以下方法方便快捷的解決了我的問題:
解決方法:
1、把需要用到的字型(可以直接拷貝windows系統的C:\WINDOWS\Fonts 下的相關字型)拷貝當前專案的classpath下,一般為classes目錄下
2、在classpath裡新增 jasperreports.properties 屬性檔案
檔案內容為:
net.sf.jasperreports.awt.ignore.missing.font=true
即可解決