我尝试使用POJO方式将数据写入InfluxDB2,我想使用POJO中的字段作为测量值,这是我的代码,但它不起作用。有人能告诉我正确的方法吗?
我的环境:
@Bean
public InfluxDBClient influxDBClient() {
return InfluxDBClientFactory.create(url,token.toCharArray());
}
public void write(String bucket,String org,BillingNo billingNo){
var writeApi = client.getWriteApiBlocking();
writeApi.writeMeasurement(bucket,org,WritePrecision.NS,billingNo);
client.close();
}
@Data
@Measurement(name = "#{measurementName}")
public class BillingNo {
private String measurementName;
@Column(tag = true)
private Type type;
@Column(tag = true)
private String code;
@Column(tag = true)
private String sourceId;
@Column
private String info;
@Column
private boolean isRunning;
@Column(timestamp = true)
private Instant time;
public enum Type {
// product , combo
PRODUCT, COMBO;
}
}