1、加上注解
@TableId(type = IdType.ASSIGN_ID)
2、编写一个类
@Slf4j
@Component
class CustomIdGenerator implements IdentifierGenerator {
private final AtomicLong al = new AtomicLong(1);
@Override
public Long nextId(Object entity) {
final long id = al.getAndAdd(1);
return System.currentTimeMillis();
}
}