1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50
| package com.springboot.springbootvue.config;
import com.google.code.kaptcha.impl.DefaultKaptcha; import org.springframework.context.annotation.Bean; import org.springframework.context.annotation.Configuration; import com.google.code.kaptcha.util.Config; import java.util.Properties;
@Configuration public class CaptchaConfig {
@Bean public DefaultKaptcha defaultKaptcha(){ DefaultKaptcha defaultKaptcha=new DefaultKaptcha(); Properties properties = new Properties(); properties.setProperty("kaptcha.border", "yes"); properties.setProperty("kaptcha.border.color", "105,179,90"); properties.setProperty("kaptcha.session.key","code"); properties.setProperty("kaptcha.textproducer.font.color", "blue"); properties.setProperty("kaptcha.textproducer.font.names", "宋体,楷体,微软雅黑"); properties.setProperty("kaptcha.textproducer.font.size", "30"); properties.setProperty("kaptcha.textproducer.char.length", "4"); properties.setProperty("kaptcha.textproducer.char.space", "4"); properties.setProperty("kaptcha.image.width", "100"); properties.setProperty("kaptcha.image.height", "40"); Config config = new Config(properties); defaultKaptcha.setConfig(config); return defaultKaptcha; }
}
|