我正在使用Cassandra 3.7。我正在使用AuthProvider
进行身份验证。我尝试了两种方法:
AuthProvider authProvider = new PlainTextAuthProvider("abcd", "xyz");
Cluster cluster = Cluster.builder().addContactPoint(node).withAuthProvider(authProvider).build();
Session session = cluster.connect();
和
Cluster cluster = Cluster.builder().addContactPoint(node)..withCredentials("abcd", "xyz").build();
Session session = cluster.connect();
我收到以下错误:
Exception in thread "main" com.datastax.driver.core.exceptions.AuthenticationException: Authentication error on host /127.0.0.1:9042: Host /127.0.0.1:9042 requires authentication, but no authenticator found in Cluster configuration
at com.datastax.driver.core.AuthProvider$1.newAuthenticator(AuthProvider.java:40)
导致错误的原因是什么?如何解决?
答案 0 :(得分:1)
更改cassandra.yaml中的身份验证器和授权程序的值:
authenticator:PasswordAuthenticator
授权人:CassandraAuthorizer