Java 生成随机数据

文章目录

1. Java-faker

依赖

xml 复制代码
<dependency>
    <groupId>com.github.javafaker</groupId>
    <artifactId>javafaker</artifactId>
    <version>1.0.2</version>
</dependency>

https://github.com/HannnnXiao/javafaker

demo

java 复制代码
		Faker faker = new Faker(Locale.CHINA); //指定地区
        final Name name = faker.name();
        System.out.println("firstName : " + name.firstName());
        System.out.println("username : " + name.username());
        System.out.println("bloodGroup : " + name.bloodGroup());
        System.out.println("suffix : " + name.suffix());
        System.out.println("title : " + name.title());
        System.out.println("lastName : " + name.lastName());
        System.out.println("nameWithMiddle : " + name.nameWithMiddle());
        System.out.println("fullName : " + name.fullName());
        System.out.println("name : " + name.name());
        System.out.println("prefix : " + name.prefix());
java 复制代码
生成结果

firstName : 熠彤
username : 烨霖.龙
bloodGroup : A-
suffix : IV
title : Investor Division Engineer
lastName : 范
nameWithMiddle : 胡思
fullName : 孟鸿涛
name : 黎航
prefix : Miss

2. common-random

依赖

xml 复制代码
<dependency>
    <groupId>com.apifan.common</groupId>
    <artifactId>common-random</artifactId>
    <version>1.0.21</version>
</dependency>

https://github.com/yindz/common-random

demo

java 复制代码
统一入口
//地区类虚拟数据
AreaSource areaSource = RandomSource.areaSource();

//日期时间类虚拟数据
DateTimeSource dateTimeSource = RandomSource.dateTimeSource();

//教育类虚拟数据
EducationSource educationSource = RandomSource.educationSource();

//金融类虚拟数据
FinancialSource financialSource = RandomSource.financialSource();

//互联网信息类虚拟数据
InternetSource internetSource = RandomSource.internetSource();

//数字类虚拟数据
NumberSource numberSource = RandomSource.numberSource();

//个人类虚拟数据
PersonInfoSource personInfoSource = RandomSource.personInfoSource();

//体育竞技类虚拟数据
SportSource sportSource = RandomSource.sportSource();

//语言文字类虚拟数据
LanguageSource languageSource = RandomSource.languageSource();

//其它杂项虚拟数据
OtherSource otherSource = RandomSource.otherSource();
相关推荐
Boilermaker19921 小时前
[Java 并发编程] Synchronized 锁升级
java·开发语言
Cherry的跨界思维1 小时前
28、AI测试环境搭建与全栈工具实战:从本地到云平台的完整指南
java·人工智能·vue3·ai测试·ai全栈·测试全栈·ai测试全栈
MM_MS1 小时前
Halcon变量控制类型、数据类型转换、字符串格式化、元组操作
开发语言·人工智能·深度学习·算法·目标检测·计算机视觉·视觉检测
꧁Q༒ོγ꧂2 小时前
LaTeX 语法入门指南
开发语言·latex
njsgcs2 小时前
ue python二次开发启动教程+ 导入fbx到指定文件夹
开发语言·python·unreal engine·ue
alonewolf_992 小时前
JDK17新特性全面解析:从语法革新到模块化革命
java·开发语言·jvm·jdk
一嘴一个橘子2 小时前
spring-aop 的 基础使用(啥是增强类、切点、切面)- 2
java
sheji34162 小时前
【开题答辩全过程】以 中医药文化科普系统为例,包含答辩的问题和答案
java
古城小栈2 小时前
Rust 迭代器产出的引用层数——分水岭
开发语言·rust
ghie90902 小时前
基于MATLAB的TLBO算法优化实现与改进
开发语言·算法·matlab