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();
相关推荐
lly2024063 分钟前
Python 列表(List)详解
开发语言
Han.miracle3 分钟前
Spring Boot 项目从入门到排障:核心结构、依赖管理与启动全解析
java·jar
深蓝电商API10 分钟前
从 “能爬” 到 “稳爬”:Python 爬虫中级核心技术实战
开发语言·爬虫·python
麦麦鸡腿堡11 分钟前
Java_通过反射获取类的结构信息
java·开发语言
还是鼠鼠19 分钟前
SQL语句执行很慢,如何分析呢?
java·数据库·mysql·面试
爱装代码的小瓶子21 分钟前
【c++知识铺子】封装map和set(详细版)
android·java·c++
2201_7578308724 分钟前
tlias的部门的增删改查操作
java·开发语言
云和数据.ChenGuang27 分钟前
批量给100台服务器装系统,还要完成后续的配置和软件部署
运维·服务器·开发语言·mysql
刺客xs29 分钟前
Qt-----QSS样式表
开发语言·javascript·qt
锥锋骚年31 分钟前
golang 发送内网邮件和外网邮件
开发语言·后端·golang