mirror of
https://github.com/dromara/tianai-captcha.git
synced 2026-05-20 08:14:04 +08:00
5618a0594c
Signed-off-by: 蒋小小 <bwcx_jzy@163.com>
26 lines
1.3 KiB
Java
26 lines
1.3 KiB
Java
package example.readme;
|
|
|
|
import cloud.tianai.captcha.common.constant.CaptchaTypeConstant;
|
|
import cloud.tianai.captcha.resource.ImageCaptchaResourceManager;
|
|
import cloud.tianai.captcha.resource.ResourceStore;
|
|
import cloud.tianai.captcha.resource.common.model.dto.Resource;
|
|
import cloud.tianai.captcha.resource.impl.DefaultImageCaptchaResourceManager;
|
|
import cloud.tianai.captcha.resource.impl.provider.ClassPathResourceProvider;
|
|
import cloud.tianai.captcha.resource.impl.provider.URLResourceProvider;
|
|
|
|
/**
|
|
* 图片验证码测试
|
|
*/
|
|
public class TestImageCaptcha {
|
|
public static void main(String[] args) {
|
|
ImageCaptchaResourceManager imageCaptchaResourceManager = new DefaultImageCaptchaResourceManager();
|
|
// 通过资源管理器或者资源存储器
|
|
ResourceStore resourceStore = imageCaptchaResourceManager.getResourceStore();
|
|
// 添加classpath目录下的 aa.jpg 图片
|
|
resourceStore.addResource(CaptchaTypeConstant.SLIDER, new Resource(ClassPathResourceProvider.NAME, "/aa.jpg"));
|
|
// 添加远程url图片资源
|
|
resourceStore.addResource(CaptchaTypeConstant.SLIDER,new Resource(URLResourceProvider.NAME, "http://www.xx.com/aa.jpg"));
|
|
// 内置了通过url 和 classpath读取图片资源,如果想扩展可实现 ResourceProvider 接口,进行自定义扩展
|
|
}
|
|
}
|