Spring 使用 Cassandra 3.x 驱动程序启动
Spring Boot with Cassandra 3.x driver
我用Spring开机1.3.8.RELEASE
。为了使用 cassandra 3.x 驱动程序,我尝试了类似下面的方法;
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-data-cassandra</artifactId>
<exclusions>
<exclusion>
<groupId>org.springframework.data</groupId>
<artifactId>spring-data-cassandra</artifactId>
</exclusion>
</exclusions>
</dependency>
<dependency>
<groupId>org.springframework.data</groupId>
<artifactId>spring-data-cassandra</artifactId>
<version>1.4.0.RELEASE</version>
<exclusions>
<exclusion>
<groupId>com.datastax.cassandra</groupId>
<artifactId>cassandra-driver-core</artifactId>
</exclusion>
<exclusion>
<groupId>com.datastax.cassandra</groupId>
<artifactId>cassandra-driver-dse</artifactId>
</exclusion>
</exclusions>
</dependency>
<!-- https://mvnrepository.com/artifact/com.datastax.cassandra/cassandra-driver-core -->
<dependency>
<groupId>com.datastax.cassandra</groupId>
<artifactId>cassandra-driver-core</artifactId>
<version>3.1.0</version>
</dependency>
但是我得到错误;
Caused by: java.lang.NoSuchMethodError: com.datastax.driver.core.DataType.asJavaClass()Ljava/lang/Class;
at org.springframework.data.cassandra.mapping.CassandraSimpleTypeHolder.<clinit>(CassandraSimpleTypeHolder.java:62) ~[spring-data-cassandra-1.4.0.RELEASE.jar:?]
我在 https://github.com/spring-projects/spring-boot/issues/5835 试过这个原因,有一个 post ;
Adopting the Cassandra 3 changes in Spring Data Cassandra 1.5
(Ingalls) does not impose breaking changes for Spring Boot. Tested
the upgrade with Boot 1.3.3 and 1.4.0-SNAPSHOT.
不应该像上面那样吗?
我哪里错了?
注意: 我正在尝试这个例子:https://github.com/spring-projects/spring-boot/tree/master/spring-boot-samples/spring-boot-sample-data-cassandra
spring-data-cassandra-1.4.0.RELEASE 取决于 <cassandra.version>2.1.11</cassandra.version>
和 <cassandra-driver-dse.version>2.1.7.1</cassandra-driver-dse.version>
参见 https://github.com/spring-projects/spring-data-cassandra/blob/1.4.0.RELEASE/pom.xml.
如果你想使用 Cassandra 3.x 你应该升级到 spring-boot 1.5.x 以受益于 spring-boot-starter-data-cassandra :1.5.x 取决于 <cassandra.version>3.0.0</cassandra.version>
和 <cassandra-driver.version>3.0.3</cassandra-driver.version>
请参阅 https://github.com/spring-projects/spring-data-cassandra/blob/1.5.0.M1/pom.xml
从 pom 文件中删除 Cassandra 驱动程序依赖项。 Spring 开机会提供正确的版本
我用Spring开机1.3.8.RELEASE
。为了使用 cassandra 3.x 驱动程序,我尝试了类似下面的方法;
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-data-cassandra</artifactId>
<exclusions>
<exclusion>
<groupId>org.springframework.data</groupId>
<artifactId>spring-data-cassandra</artifactId>
</exclusion>
</exclusions>
</dependency>
<dependency>
<groupId>org.springframework.data</groupId>
<artifactId>spring-data-cassandra</artifactId>
<version>1.4.0.RELEASE</version>
<exclusions>
<exclusion>
<groupId>com.datastax.cassandra</groupId>
<artifactId>cassandra-driver-core</artifactId>
</exclusion>
<exclusion>
<groupId>com.datastax.cassandra</groupId>
<artifactId>cassandra-driver-dse</artifactId>
</exclusion>
</exclusions>
</dependency>
<!-- https://mvnrepository.com/artifact/com.datastax.cassandra/cassandra-driver-core -->
<dependency>
<groupId>com.datastax.cassandra</groupId>
<artifactId>cassandra-driver-core</artifactId>
<version>3.1.0</version>
</dependency>
但是我得到错误;
Caused by: java.lang.NoSuchMethodError: com.datastax.driver.core.DataType.asJavaClass()Ljava/lang/Class;
at org.springframework.data.cassandra.mapping.CassandraSimpleTypeHolder.<clinit>(CassandraSimpleTypeHolder.java:62) ~[spring-data-cassandra-1.4.0.RELEASE.jar:?]
我在 https://github.com/spring-projects/spring-boot/issues/5835 试过这个原因,有一个 post ;
Adopting the Cassandra 3 changes in Spring Data Cassandra 1.5 (Ingalls) does not impose breaking changes for Spring Boot. Tested the upgrade with Boot 1.3.3 and 1.4.0-SNAPSHOT.
不应该像上面那样吗? 我哪里错了?
注意: 我正在尝试这个例子:https://github.com/spring-projects/spring-boot/tree/master/spring-boot-samples/spring-boot-sample-data-cassandra
spring-data-cassandra-1.4.0.RELEASE 取决于 <cassandra.version>2.1.11</cassandra.version>
和 <cassandra-driver-dse.version>2.1.7.1</cassandra-driver-dse.version>
参见 https://github.com/spring-projects/spring-data-cassandra/blob/1.4.0.RELEASE/pom.xml.
如果你想使用 Cassandra 3.x 你应该升级到 spring-boot 1.5.x 以受益于 spring-boot-starter-data-cassandra :1.5.x 取决于 <cassandra.version>3.0.0</cassandra.version>
和 <cassandra-driver.version>3.0.3</cassandra-driver.version>
请参阅 https://github.com/spring-projects/spring-data-cassandra/blob/1.5.0.M1/pom.xml
从 pom 文件中删除 Cassandra 驱动程序依赖项。 Spring 开机会提供正确的版本