zoukankan      html  css  js  c++  java
  • Java——CaptchaUtil生成二维码乱码

    前言

    这个问题就是因为Linux上没有字体,你可以有两种方法,一个在生成的时候设置字体,一个就是安装字体。
    默认的字体为Courier

    乱码情况

    步骤

    安装字体工具

    yum install -y fontconfig mkfontscale
    

    查看服务器字体

    # fc-list
    /usr/share/fonts/dejavu/DejaVuSansCondensed-Oblique.ttf: DejaVu Sans,DejaVu Sans Condensed:style=Condensed Oblique,Oblique
    /usr/share/fonts/dejavu/DejaVuSansCondensed-Bold.ttf: DejaVu Sans,DejaVu Sans Condensed:style=Condensed Bold,Bold
    /usr/share/fonts/dejavu/DejaVuSans.ttf: DejaVu Sans:style=Book
    /usr/share/fonts/dejavu/DejaVuSans-Bold.ttf: DejaVu Sans:style=Bold
    /usr/share/fonts/dejavu/DejaVuSansCondensed.ttf: DejaVu Sans,DejaVu Sans Condensed:style=Condensed,Book
    /usr/share/fonts/dejavu/DejaVuSans-ExtraLight.ttf: DejaVu Sans,DejaVu Sans Light:style=ExtraLight
    /usr/share/fonts/dejavu/DejaVuSansCondensed-BoldOblique.ttf: DejaVu Sans,DejaVu Sans Condensed:style=Condensed Bold Oblique,Bold Oblique
    /usr/share/fonts/dejavu/DejaVuSans-Oblique.ttf: DejaVu Sans:style=Oblique
    /usr/share/fonts/dejavu/DejaVuSans-BoldOblique.ttf: DejaVu Sans:style=Bold Oblique
    

    寻找对应的字体并上传到服务器字体文件目录下

    缓存下字体

    #fc-cache /usr/share/fonts/lyx
    

    拷贝到jdk并缓存

    拷贝字体文件到  jdk安装目录/jre/lib/fonts 目录下
    运行命令  fc-cache jdk安装目录/jre/lib/fonts
    

    重启项目

    重启java项目即可
    
  • 相关阅读:
    kubernetes 中遇见的一些坑(持续更新)
    Docker网络解决方案-Flannel部署记录
    理解Docker :Docker 网络
    全面剖析Redis Cluster原理和应用
    python发送钉钉机器人脚本
    centos 7 部署LDAP服务
    zabbix 同步ldap帐号脚本
    zabbix TCP 连接数监控
    WebDriver基本操作入门及UI自动化练手页面
    Jmeter使用入门
  • 原文地址:https://www.cnblogs.com/wangyang0210/p/11428634.html
Copyright © 2011-2022 走看看