Skip to content

Commit 32bf2d0

Browse files
发布到maven仓库
1 parent 2fff485 commit 32bf2d0

File tree

3 files changed

+120
-63
lines changed

3 files changed

+120
-63
lines changed

README.md

+12-31
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
# EasyCaptcha
22

3-
![JitPack](https://img.shields.io/jitpack/v/whvcse/EasyCaptcha.svg?style=flat-square)
3+
![MavenCentral](https://img.shields.io/maven-central/v/com.github.whvcse/easy-captcha)
44
![Hex.pm](https://img.shields.io/hexpm/l/plug.svg?style=flat-square)
55

66

@@ -53,52 +53,33 @@
5353
## 3.导入项目
5454

5555
### 3.1.gradle方式的引入
56-
需要先在project的build.gradle中添加:
57-
```text
58-
allprojects {
59-
repositories {
60-
maven { url 'https://jitpack.io' }
61-
}
62-
}
63-
```
64-
在项目的build.gradle中添加
6556
```text
6657
dependencies {
67-
compile 'com.github.whvcse:EasyCaptcha:1.6.2'
58+
compile 'com.github.whvcse:easy-captcha:1.6.2'
6859
}
6960
```
7061

7162
### 3.2.maven方式引入
72-
在你的pom.xml中添加如下代码:
7363
```xml
74-
<project>
75-
<repositories>
76-
<repository>
77-
<id>jitpack.io</id>
78-
<url>https://jitpack.io</url>
79-
</repository>
80-
</repositories>
81-
82-
<dependencies>
83-
<dependency>
84-
<groupId>com.github.whvcse</groupId>
85-
<artifactId>EasyCaptcha</artifactId>
86-
<version>1.6.2</version>
87-
</dependency>
88-
</dependencies>
89-
</project>
64+
<dependencies>
65+
<dependency>
66+
<groupId>com.github.whvcse</groupId>
67+
<artifactId>easy-captcha</artifactId>
68+
<version>1.6.2</version>
69+
</dependency>
70+
</dependencies>
9071
```
9172

9273
### 3.3.jar包下载
93-
[EasyCaptcha-1.6.2.jar](https://gitee.com/whvse/EasyCaptcha/releases)
74+
[easy-captcha-1.6.2.jar](https://gitee.com/whvse/EasyCaptcha/releases)
9475

9576
maven导入jar包,在项目根目录创建`libs`文件夹,然后pom.xml添加如下:
9677
```
9778
<dependency>
9879
<groupId>com.github.whvcse</groupId>
99-
<artifactId>EasyCaptcha</artifactId>
80+
<artifactId>easy-captcha</artifactId>
10081
<version>1.6.1</version>
101-
<systemPath>${basedir}/libs/EasyCaptcha-1.6.2.jar</systemPath>
82+
<systemPath>${basedir}/libs/easy-captcha-1.6.2.jar</systemPath>
10283
</dependency>
10384
```
10485

pom.xml

+100-27
Original file line numberDiff line numberDiff line change
@@ -2,16 +2,52 @@
22
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
33
<modelVersion>4.0.0</modelVersion>
44

5-
<groupId>org.wf</groupId>
5+
<groupId>com.github.whvcse</groupId>
66

77
<artifactId>easy-captcha</artifactId>
8-
<version>1.6.2-RELEASE</version>
8+
<version>1.6.2</version>
9+
<build>
10+
<plugins>
11+
<plugin>
12+
<groupId>org.apache.maven.plugins</groupId>
13+
<artifactId>maven-compiler-plugin</artifactId>
14+
<configuration>
15+
<source>8</source>
16+
<target>8</target>
17+
</configuration>
18+
</plugin>
19+
</plugins>
20+
</build>
921
<packaging>jar</packaging>
1022

1123
<name>EasyCaptcha</name>
12-
<description>Java图形验证码,支持gif验证码、中文验证码,适用于Java Web、JavaSE项目。</description>
24+
<description>Java web graphics verification code, support gif verification code.</description>
1325
<url>https://github.com/whvcse/EasyCaptcha</url>
1426

27+
<licenses>
28+
<license>
29+
<name>The Apache Software License, Version 2.0</name>
30+
<url>http://www.apache.org/licenses/LICENSE-2.0.txt</url>
31+
</license>
32+
</licenses>
33+
<developers>
34+
<developer>
35+
<name>whvcse</name>
36+
<email>[email protected]</email>
37+
</developer>
38+
</developers>
39+
<scm>
40+
<connection>scm:[email protected]:whvcse/EasyCaptcha.git</connection>
41+
<developerConnection>scm:[email protected]:whvcse/EasyCaptcha.git</developerConnection>
42+
<url>https://github.com/whvcse/EasyCaptcha</url>
43+
</scm>
44+
45+
<properties>
46+
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
47+
<project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding>
48+
<java.version>1.8</java.version>
49+
</properties>
50+
1551
<dependencies>
1652
<!-- j2ee环境 -->
1753
<dependency>
@@ -28,28 +64,65 @@
2864
</dependency>
2965
</dependencies>
3066

31-
<build>
32-
<plugins>
33-
<plugin>
34-
<groupId>org.apache.maven.plugins</groupId>
35-
<artifactId>maven-compiler-plugin</artifactId>
36-
<configuration>
37-
<source>6</source>
38-
<target>6</target>
39-
<encoding>UTF-8</encoding>
40-
</configuration>
41-
</plugin>
42-
</plugins>
43-
</build>
44-
45-
<distributionManagement>
46-
<repository>
47-
<id>rdc-releases</id>
48-
<url>https://repo.rdc.aliyun.com/repository/70786-release-exL3mB/</url>
49-
</repository>
50-
<snapshotRepository>
51-
<id>rdc-snapshots</id>
52-
<url>https://repo.rdc.aliyun.com/repository/70786-snapshot-Y0tgOa/</url>
53-
</snapshotRepository>
54-
</distributionManagement>
67+
<profiles>
68+
<profile>
69+
<id>release</id>
70+
<build>
71+
<plugins>
72+
<!-- Source -->
73+
<plugin>
74+
<groupId>org.apache.maven.plugins</groupId>
75+
<artifactId>maven-source-plugin</artifactId>
76+
<version>2.2.1</version>
77+
<executions>
78+
<execution>
79+
<phase>package</phase>
80+
<goals>
81+
<goal>jar-no-fork</goal>
82+
</goals>
83+
</execution>
84+
</executions>
85+
</plugin>
86+
<!-- Javadoc -->
87+
<plugin>
88+
<groupId>org.apache.maven.plugins</groupId>
89+
<artifactId>maven-javadoc-plugin</artifactId>
90+
<version>2.9.1</version>
91+
<executions>
92+
<execution>
93+
<phase>package</phase>
94+
<goals>
95+
<goal>jar</goal>
96+
</goals>
97+
</execution>
98+
</executions>
99+
</plugin>
100+
<!-- GPG -->
101+
<plugin>
102+
<groupId>org.apache.maven.plugins</groupId>
103+
<artifactId>maven-gpg-plugin</artifactId>
104+
<version>1.5</version>
105+
<executions>
106+
<execution>
107+
<phase>verify</phase>
108+
<goals>
109+
<goal>sign</goal>
110+
</goals>
111+
</execution>
112+
</executions>
113+
</plugin>
114+
</plugins>
115+
</build>
116+
<distributionManagement>
117+
<snapshotRepository>
118+
<id>oss</id>
119+
<url>https://oss.sonatype.org/content/repositories/snapshots/</url>
120+
</snapshotRepository>
121+
<repository>
122+
<id>oss</id>
123+
<url>https://oss.sonatype.org/service/local/staging/deploy/maven2/</url>
124+
</repository>
125+
</distributionManagement>
126+
</profile>
127+
</profiles>
55128
</project>

src/main/java/com/wf/captcha/base/Captcha.java

+8-5
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,12 @@
11
package com.wf.captcha.base;
22

3-
import sun.misc.BASE64Encoder;
4-
53
import java.awt.*;
64
import java.awt.geom.CubicCurve2D;
75
import java.awt.geom.QuadCurve2D;
86
import java.io.ByteArrayOutputStream;
9-
import java.io.File;
107
import java.io.IOException;
118
import java.io.OutputStream;
9+
import java.util.Base64;
1210

1311
/**
1412
* 验证码抽象类
@@ -111,18 +109,23 @@ protected Color color() {
111109
*/
112110
public abstract boolean out(OutputStream os);
113111

112+
/**
113+
* 输出base64编码
114+
*
115+
* @return base64编码字符串
116+
*/
114117
public abstract String toBase64();
115118

116119
/**
117120
* 输出base64编码
118121
*
119122
* @param type 编码头
120-
* @return
123+
* @return base64编码字符串
121124
*/
122125
public String toBase64(String type) {
123126
ByteArrayOutputStream outputStream = new ByteArrayOutputStream();
124127
out(outputStream);
125-
return type + new BASE64Encoder().encode(outputStream.toByteArray());
128+
return type + Base64.getEncoder().encodeToString(outputStream.toByteArray());
126129
}
127130

128131
/**

0 commit comments

Comments
 (0)