2017-03-16 14 views
0

私はSpring-Data-Cassandra 1.2.2を使用しています。私は以下のようにXML設定を使用しています。 ConsistencyLevelのデフォルト値は1で、QUORUMに設定したいと思っています。どのようにXMLでそれを設定するのですか? 必要に応じてSpring Data-Cassandraバージョンをアップグレードできます。Springデータの一貫性レベルの設定方法Cassandra XMLの設定

<?xml version='1.0'?> 
<beans xmlns="http://www.springframework.org/schema/beans" 
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:cassandra="http://www.springframework.org/schema/data/cassandra" 
xmlns:context="http://www.springframework.org/schema/context" 
xsi:schemaLocation="http://www.springframework.org/schema/cql http://www.springframework.org/schema/cql/spring-cql.xsd 
    http://www.springframework.org/schema/data/cassandra http://www.springframework.org/schema/data/cassandra/spring-cassandra.xsd 
    http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd 
    http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context.xsd"> 

<!-- Loads the properties into the Spring Context and uses them to fill in placeholders in the bean definitions --> 
<context:property-placeholder location="classpath:resources.properties" /> 

<!-- REQUIRED: The Cassandra Cluster --> 
<cassandra:cluster contact-points="${cassandra.contactpoints}" port="${cassandra.port}" /> 

<!-- REQUIRED: The Cassandra Session, built from the Cluster, and attaching to a keyspace --> 
<cassandra:session keyspace-name="${cassandra.keyspace}" schema-action="CREATE" /> 

<!-- REQUIRED: The Default Cassandra Mapping Context used by CassandraConverter --> 
<cassandra:mapping /> 

<!-- REQUIRED: The Default Cassandra Converter used by CassandraTemplate --> 
<cassandra:converter /> 

<!-- REQUIRED: The Cassandra Template is the building block of all Spring Data Cassandra --> 
<cassandra:template /> 

<!-- OPTIONAL: If you are using Spring Data Cassandra Repositories, add your base packages to scan here --> 
<cassandra:repositories base-package="com.my.package.cassandrarepository" /> 

</beans> 
+0

自分で 'Cluster'を作成してください。 'QueryOptions'の設定はApache Cassandra 1.5用のSpring Dataから' CassandraCqlClusterFactoryBean'で利用できますが、XML設定では利用できません。 – mp911de

+0

@ mp911de - コメントありがとう!私のQへの答えは、JavaConfigが唯一の解決策だとは思われません。 1.2.2から1.5へのアップグレードは、私のprojの他のスプリングデータ(mongoとJPA)の依存関係のビットコサインであることが判明しました。そこで、 'com.datastax.driver.core.Cluster.builder()。withQueryOptions新しいQueryOptions()。setConsistencyLevel(ConsistencyLevel.QUORUM)) ' –

答えて

0

JavaConfigは唯一の解決策です。 1.2.2から1.5へのアップグレードは、私のprojの他のバネデータ(mongo & JPA)依存の少し複雑です。そこで私は1.2.2バージョンで次の設定を使用しました:com.datastax.driver.core.Cluster.builder().withQueryOptions(‌​new QueryOptions().setConsistencyLevel(ConsistencyLevel.QUORUM))

関連する問題