开发环境:windows7 + spingboot1.5x + Kaptcha2.3.x
问题:验证码图片在windows下正常显示,在Linux下能显示图片,但不显示文字
相关代码:
@Configuration
public class KaptchaConfig {
@Bean
public DefaultKaptcha getKaptchaBean() {
DefaultKaptcha defaultKaptcha = new DefaultKaptcha();
Properties properties = new Properties();
properties.setProperty("kaptcha.border", "yes");
properties.setProperty("kaptcha.border.color", "105,179,90");
properties.setProperty("kaptcha.textproducer.font.color", "blue");
properties.setProperty("kaptcha.image.width", "100");
properties.setProperty("kaptcha.image.height", "50");
properties.setProperty("kaptcha.session.key", "code");
properties.setProperty("kaptcha.textproducer.char.length", "4");
properties.setProperty("kaptcha.textproducer.font.names", "Arial,Courier");
Config config = new Config(properties);
defaultKaptcha.setConfig(config);
return defaultKaptcha;
}
}
原因及解决方法:由于Linux环境不存在相关字体,需先在Linux下安装字体
安装字体详情:http://www.jhonge.net/Home/Single/26626627
看到别的博客说fc-cache可以代替重启,发现没用,最后重启了一下就可以了