- zookeeper 3.4.10
- mvn clean install or mvn clean deploy
- add dependency to maven
<dependency>
<groupId>io.github.goudai</groupId>
<artifactId>spring-boot-starter-id-generator-zookeeper</artifactId>
<version>1.0.2</version>
</dependency>
- using on spring boot
# application.yml
goudai:
id:
generator:
zookeeper:
zookeeper-servers: ${ZOO_SERVERS:localhost:2181}
public class XxxController {
@Autowired
IdGenerator idGenerator;
@GetMapping("idString")
public String idString() {
return idGenerator.nextIdAsString();
}
@GetMapping("idLong")
public Long idLong() {
return idGenerator.nextIdAsLong();
}
}