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();
相关推荐
caihuayuan43 分钟前
Redis奇幻之旅(三)1.redis客户端与服务端
java·大数据·sql·spring·课程设计
匆匆整棹还1 小时前
关于tomcat乱码和idea中控制台乱码的问题
java·tomcat·intellij-idea
有杨既安然1 小时前
Python自动化办公
开发语言·人工智能·深度学习·机器学习
何似在人间5752 小时前
SpringAI+DeepSeek大模型应用开发——1 AI概述
java·人工智能·spring·springai
匹马夕阳2 小时前
Java开发中的设计模式之观察者模式详细讲解
java·观察者模式·设计模式
风铃儿~2 小时前
Java微服务注册中心深度解析:环境隔离、分级模型与Eureka/Nacos对比
java·分布式·微服务·面试
King.6242 小时前
从 SQL2API 到 Text2API:开启数据应用开发的新征程
大数据·开发语言·数据库·sql·低代码
赤橙红的黄2 小时前
Spring Boot中接入DeepSeek的流式输出
java·服务器·javascript
小样vvv2 小时前
【AI】IDEA 集成 AI 工具的背景与意义
java·人工智能·intellij-idea
奇谱2 小时前
Quipus,LightRag的Go版本的实现
开发语言·后端·语言模型·golang·知识图谱