com.github.xiefusi:persistence-service

id generator

License

License

GroupId

GroupId

com.github.xiefusi
ArtifactId

ArtifactId

persistence-service
Last Version

Last Version

1.0.0
Release Date

Release Date

Type

Type

jar
Description

Description

id generator

Download persistence-service

How to add to project

<!-- https://jarcasting.com/artifacts/com.github.xiefusi/persistence-service/ -->
<dependency>
    <groupId>com.github.xiefusi</groupId>
    <artifactId>persistence-service</artifactId>
    <version>1.0.0</version>
</dependency>
// https://jarcasting.com/artifacts/com.github.xiefusi/persistence-service/
implementation 'com.github.xiefusi:persistence-service:1.0.0'
// https://jarcasting.com/artifacts/com.github.xiefusi/persistence-service/
implementation ("com.github.xiefusi:persistence-service:1.0.0")
'com.github.xiefusi:persistence-service:jar:1.0.0'
<dependency org="com.github.xiefusi" name="persistence-service" rev="1.0.0">
  <artifact name="persistence-service" type="jar" />
</dependency>
@Grapes(
@Grab(group='com.github.xiefusi', module='persistence-service', version='1.0.0')
)
libraryDependencies += "com.github.xiefusi" % "persistence-service" % "1.0.0"
[com.github.xiefusi/persistence-service "1.0.0"]

Dependencies

compile (5)

Group / Artifact Type Version
org.apache.logging.log4j : log4j-api jar 2.7
org.apache.logging.log4j : log4j-core jar 2.7
org.slf4j : slf4j-api jar 1.7.2
org.springframework.boot : spring-boot-starter-jdbc jar 2.0.3.RELEASE
org.springframework.boot : spring-boot-starter jar 2.0.3.RELEASE

Project Modules

There are no modules declared in this project.

quick start 该jar包依赖springboot,只能在有数据源的模块中使用 如果使用模块中有spring管理的数据源可以不用配置数据源 如果没有需要手动添加数据源 服务器不同实例是通过数据库的主键生成表来确保id生成唯一的

<dependency>
    <groupId>com.github.xiefusi</groupId>
    <artifactId>key-generator-starter</artifactId>
    <version>${id.generator.version}</version>
</dependency>
key-generator:
  dbcust: true #默认为false(使用使用模块中的连接池)
  datasource:
    driver-class-name: com.mysql.jdbc.Driver
    url: jdbc:mysql://${MYSQL_HOST:localhost}:${MYSQL_PORT:3306}/${MYSQL_DATABASE:id-generator}?useUnicode=true&characterEncoding=UTF8&useSSL=false
    username: ${MYSQL_USERNAME:root}
    password: ${MYSQL_PASSWORD:root}
  businesses:
    - business-id: orderId #业务场景(必填)
      begin: 1 #id开始自增点(非必填默认1L)
      step: 5000 #自增步长(非必填默认5000)
      description: 订单id #业务场景秒速(非必填默认null)
Result result = IdUtil.get("orderId");
if (Status.SUCCESS.equals(result.getStatus())) {
    long orderId = result.getId();
}

Versions

Version
1.0.0