SpringBootVersion2.1.9.发布并使用SpringBootStarter数据的依赖项cassandra
对于以下代码段
WriteOptions ttlOption = WriteOptions.builder().ttl(5).build();
CassandraBatchOperations batchOperations = cassandraTemplate.batchOps();
batchOperations.insert(myEntityClass, ttlOption);
我们当前得到以下异常
Caused by: org.springframework.data.mapping.MappingException: Cannot resolve DataType for property [retryPolicy] in entity [org.springframework.data.cassandra.core.cql.WriteOptions]; Consider adding @CassandraType.
at org.springframework.data.cassandra.core.mapping.CassandraMappingContext.getDataTypeWithUserTypeFactory(CassandraMappingContext.java:612)
at org.springframework.data.cassandra.core.mapping.CassandraMappingContext.getDataType(CassandraMappingContext.java:556)
at org.springframework.data.cassandra.core.convert.MappingCassandraConverter.getPropertyTargetType(MappingCassandraConverter.java:710)
at org.springframework.data.cassandra.core.convert.MappingCassandraConverter.lambda$getTargetType$3(MappingCassandraConverter.java:700)
at java.base/java.util.Optional.orElseGet(Optional.java:369)
at org.springframework.data.cassandra.core.convert.MappingCassandraConverter.getTargetType(MappingCassandraConverter.java:688)
at org.springframework.data.cassandra.core.convert.MappingCassandraConverter.getWriteValue(MappingCassandraConverter.java:731)
at org.springframework.data.cassandra.core.convert.MappingCassandraConverter.writeInsertFromWrapper(MappingCassandraConverter.java:420)
at org.springframework.data.cassandra.core.convert.MappingCassandraConverter.write(MappingCassandraConverter.java:363)
at org.springframework.data.cassandra.core.convert.MappingCassandraConverter.write(MappingCassandraConverter.java:347)
at org.springframework.data.cassandra.core.QueryUtils.createInsertQuery(QueryUtils.java:107)
at org.springframework.data.cassandra.core.CassandraBatchTemplate.insert(CassandraBatchTemplate.java:121)
at org.springframework.data.cassandra.core.CassandraBatchTemplate.insert(CassandraBatchTemplate.java:100)
at org.springframework.data.cassandra.core.CassandraBatchTemplate.insert(CassandraBatchTemplate.java:92)
我错过了什么?
1条答案
按热度按时间ippsafx71#
找到了答案。
原来参数列表是
因此,我需要将参数作为iterable提供,以便能够将writeoptions作为第二个参数。
例如