Skip to content

Commit 2d9081e

Browse files
author
yangzhao
committed
更新jackson、hibernateValidator依赖版本
新增RandomUtil生成随机数字+字符串工具类
1 parent 169014b commit 2d9081e

File tree

3 files changed

+49
-3
lines changed

3 files changed

+49
-3
lines changed

common-core/pom.xml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -62,6 +62,10 @@
6262
<groupId>com.fasterxml.jackson.core</groupId>
6363
<artifactId>jackson-databind</artifactId>
6464
</dependency>
65+
<dependency>
66+
<groupId>com.fasterxml.jackson.core</groupId>
67+
<artifactId>jackson-annotations</artifactId>
68+
</dependency>
6569

6670
<!-- https://mvnrepository.com/artifact/com.google.zxing/core -->
6771
<dependency>
Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
package com.yz.common.core.utils;
2+
3+
import java.util.Random;
4+
5+
/**
6+
* @author: yangzhao
7+
* @Date: 2020-05-02 11:47
8+
* @Description:
9+
*/
10+
public class RandomUtil {
11+
/**
12+
* 生成随机字符串
13+
*
14+
* @param len
15+
* @return
16+
*/
17+
public static String getRandomString(int len) {
18+
19+
String[] baseString =
20+
{"0", "1", "2", "3", "4", "5", "6", "7", "8", "9", "a", "b", "c", "d", "e", "f", "g", "h", "i", "j", "k",
21+
"l", "m", "n", "o", "p", "q", "r", "s", "t", "u", "v", "w", "x", "y", "z", "A", "B", "C", "D", "E", "F",
22+
"G", "H", "I", "J", "K", "L", "M", "N", "O", "P", "Q", "R", "S", "T", "U", "V", "W", "X", "Y", "Z"};
23+
Random random = new Random();
24+
int length = baseString.length;
25+
String randomString = "";
26+
for (int i = 0; i < length; i++) {
27+
randomString += baseString[random.nextInt(length)];
28+
}
29+
random = new Random(System.currentTimeMillis());
30+
String resultStr = "";
31+
for (int i = 0; i < len; i++) {
32+
resultStr += randomString.charAt(random.nextInt(randomString.length() - 1));
33+
}
34+
return resultStr;
35+
}
36+
}

pom.xml

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -62,8 +62,9 @@
6262
<solrj.version>5.5.4</solrj.version>
6363
<poi.version>3.17</poi.version>
6464
<org.elasticsearch.version>6.2.4</org.elasticsearch.version>
65-
<org.hibernate.validator.version>6.1.2.Final</org.hibernate.validator.version>
65+
<org.hibernate.validator.version>6.1.5.Final</org.hibernate.validator.version>
6666
<javax.validation.api.version>1.1.0.Final</javax.validation.api.version>
67+
<com.fasterxml.jackson.version>2.11.1</com.fasterxml.jackson.version>
6768
</properties>
6869

6970

@@ -268,12 +269,17 @@
268269
<dependency>
269270
<groupId>com.fasterxml.jackson.core</groupId>
270271
<artifactId>jackson-core</artifactId>
271-
<version>2.9.9</version>
272+
<version>${com.fasterxml.jackson.version}</version>
272273
</dependency>
273274
<dependency>
274275
<groupId>com.fasterxml.jackson.core</groupId>
275276
<artifactId>jackson-databind</artifactId>
276-
<version>2.9.10.1</version>
277+
<version>${com.fasterxml.jackson.version}</version>
278+
</dependency>
279+
<dependency>
280+
<groupId>com.fasterxml.jackson.core</groupId>
281+
<artifactId>jackson-annotations</artifactId>
282+
<version>${com.fasterxml.jackson.version}</version>
277283
</dependency>
278284

279285
<dependency>

0 commit comments

Comments
 (0)