当前位置: 首页 > news >正文

Java 生成随机数据

文章目录

    • 1. Java-faker
      • 依赖
      • demo
    • 2. common-random
      • 依赖
      • demo

1. Java-faker

依赖

<dependency><groupId>com.github.javafaker</groupId><artifactId>javafaker</artifactId><version>1.0.2</version>
</dependency>

https://github.com/HannnnXiao/javafaker

demo

		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());
生成结果firstName : 熠彤
username : 烨霖.龙
bloodGroup : A-
suffix : IV
title : Investor Division Engineer
lastName : 范
nameWithMiddle : 胡思
fullName : 孟鸿涛
name : 黎航
prefix : Miss

2. common-random

依赖

<dependency><groupId>com.apifan.common</groupId><artifactId>common-random</artifactId><version>1.0.21</version>
</dependency>

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

demo

统一入口
//地区类虚拟数据
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();
http://www.lryc.cn/news/98815.html

相关文章:

  • 基于OpenCV的红绿灯识别
  • JavaScript快速入门:ComPDFKit PDF SDK 快速构建 Web端 PDF阅读器
  • Flutter 网络请求
  • 吃透《西瓜书》第三章 线性模型:多元线性回归
  • 数据结构【排序】
  • 探索APP开发的新趋势:人工智能和大数据的力量
  • 超越传统:深入比较Bootstrap、Foundation、Bulma、Tailwind CSS和Semantic UI的顶级CSS框架!
  • 基于深度学习淡水鱼体重智能识别模型研究
  • Nginx专题(1)--linux安装nginx
  • 系统集成中级计算汇总
  • json.stringify的高级用法,和for of的原理
  • SpringCloudAlibaba微服务实战系列(三)Sentinel1.8.0+流控
  • mybatis - no getter for property,以及@JsonIgnore
  • 云原生周刊:K8s v1.28 中的结构化身份验证配置
  • 支持向量机概述
  • 安装x265
  • 设计模式-观察者模式
  • K8s使用Ceph作为后端存储
  • hive整合es,详细过程。
  • vue中tab隐藏display:none(v-show无效,v-if有效)
  • 2023年进阶测试,从接口测试到接口自动化测试总结,一篇彻底打通...
  • 客户支持工具从被动到主动的演变
  • 网络安全行业相关证书
  • [内网渗透]SUID提权
  • clang 编译器前端 分析
  • 3个月精通Python(基础篇)——第1天:Python和Vscode环境安装
  • react native web RN webpack nginx 部署
  • Jmeter性能测试之Beanshell解析并提取json响应
  • vue-echarts配置项详解
  • 两个csv进行根据相同字段进行合并