我正在開發spring引導應用程序。它連接Apache Cassandra DB。我在Cassandra中創建了UDT。同時嘗試使用CassandraOperations保存數據。我得到例外。下面是Cassandra UDT的示例。Cassandra UDT VerifierMappingExceptions
http://www.devjavasource.com/cassandra/cassandra-udts-java-example/
卡桑德拉DB:2.1.11
例外:
org.springframework.data.cassandra.mapping.VerifierMappingExceptions: com.lab.model.OrderLine:
Cassandra entities must have the @Table, @Persistent or @PrimaryKeyClass Annotation
at org.springframework.data.cassandra.mapping.BasicCassandraPersistentEntityMetadataVerifier.verify(BasicCassandraPersistentEntityMetadataVerifier.java:45) ~[spring-data-cassandra-1.4.3.RELEASE.jar:na]
訂單行的Java類只有@UDT沒有@Table,@Persistent或@PrimaryKeyClass註釋
import java.sql.Timestamp;
import java.util.ArrayList;
import java.util.List;
import org.springframework.cassandra.core.PrimaryKeyType;
import org.springframework.data.cassandra.mapping.PrimaryKeyColumn;
import org.springframework.data.cassandra.mapping.Table;
@Table("order")
public class Order {
@PrimaryKeyColumn(name = "ord_id", ordinal = 0, type = PrimaryKeyType.PARTITIONED)
private int ord_id;
private List<OrderLine> order_line;
}
import java.util.UUID;
import com.datastax.driver.mapping.annotations.UDT;
@UDT(name = "order_line")
public class OrderLine {
private UUID po_line_nbr;
private int whpk_qty;
}
的pom.xml
<parent>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-parent</artifactId>
<version>1.4.1.RELEASE</version>
<relativePath /> <!-- lookup parent from repository -->
</parent>
<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding>
<java.version>1.8</java.version>
</properties>
<dependencies>
<dependency>
<groupId>com.datastax.cassandra</groupId>
<artifactId>cassandra-driver-mapping</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-web</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-data-cassandra</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-test</artifactId>
<scope>test</scope>
</dependency>
</dependencies>
<build>
<plugins>
<plugin>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-maven-plugin</artifactId>
</plugin>
</plugins>
</build>
如何來解決這個問題。
我無法找到合適的依賴關係。我更新了pom.xml。你能否糾正我的pom.xml來解決我的問題。謝謝 – Gnana
由於構建了「SNAPSHOT」,UDT支持尚不可用。 – mp911de
是否可以在UDT上用Cassandra開發彈簧?或不可能。你能幫我解決這個問題嗎?我是卡桑德拉的新春 – Gnana