Bootstrap

使用 Spring Boot 实现图片验证码

  1. 引入依赖

pom.xml 中引入 spring-boot-starter-webspring-boot-starter-validationspring-boot-starter-thymeleafcom.google.code.kaptcha:kaptcha 依赖。

<dependency>
    <groupId>org.springframework.boot</groupId>
    <artifactId>spring-boot-starter-validation</artifactId>
</dependency>

<dependency>
    <groupId>com.github.nkzawa</groupId>
    <artifactId>socket.io-client</artifactId>
    <version>0.5.2</version>
</dependency>

<dependency>
    <groupId>com.google.code.kaptcha</groupId>
    <artifactId>kaptcha</artifactId>
    <version>2.3.2</version>
</dependency>

  1. 添加配置

application.yml 中添加如下配置:

kaptcha:
  border: no
  textproducer.fo
;