java 在尝试将Sping Boot 应用程序连接到DataStax中的托管cassandra示例时面临身份验证错误问题

bkkx9g8r  于 2023-03-28  发布在  Java
关注(0)|答案(1)|浏览(91)

[s0]验证错误(AuthenticationException:节点www.example.com上的身份验证错误cdbd07ee-81fe-4adf-85e4-34338172ad24-asia-south1.db.astra.datastax.com/:29042:087b610b-271c-4e87-940d-65f26a2875be:节点cdbd 07 ee-81 fe-4adf-85 e4 - 34338172 ad 24-asia-south 1.db.astra.datastax.com/:29042:087 b610 b-271 c-4 e87 - 940 d-65 f26 a2875 be需要身份验证(org.apache.cassandra.auth.PasswordAuthenticator),但未配置身份验证器)
这是application.yml文件。
Spring:数据:cassandra:keyspace-name:用户名:密码:ovNQAgE+XMMpxg8nXM,1eTZSB0 + Y7U36dZII5JWOsB9IAvUBWH5DSSGA8v0Zg2OKrEGP8WIUM.2QEM15L0oLZ,Z + zoGdSwD6j21RNZSR8c +9P.0KkPtS schema-action:create-if-not-exists请求:超时:10 s连接:连接超时:10s init-query-timeout:10秒
datastax.astra:secure-connect-bundle:secure-connect.zip
astra.db:id:cdbd 07 ee-81 fe-4adf-172 ad 24 -1区域:asia-south 1密钥空间:main application.token:AstraCS:FSvHWqiJPhyZLptJoFziLUNo:bd3997ece2a724a9e6acf10c46fda8ddfa5d57bcf1627e9840

o7jaxewo

o7jaxewo1#

您需要通过添加secure connect bundle来自定义CqlSession。使用Spring Data,您可以使用CqlSessionBuilderCustomizer,如下所示:
1/创建一个Bean来接收您的属性datastax.astra

@ConfigurationProperties(prefix = "datastax.astra")
public class DataStaxAstraProperties {
    private File secureConnectBundle;
    //getter and setters.
}

2/使用此Bean自定义此会话

@Bean
public CqlSessionBuilderCustomizer sessionBuilderCustomizer(DataStaxAstraProperties astraProperties) {
    Path bundle = astraProperties.getSecureConnectBundle().toPath();
    return builder -> builder.withCloudSecureConnectBundle(bundle);
}

下面是一个工作示例:

您可能对Astra Sping Boot Starter感兴趣:

相关问题