habuma / spring-in-action-6-samples

Sample code from Spring in Action 6
483 stars 339 forks source link

Spring not able to connect with cassandra running on docker #26

Open abcool opened 9 months ago

abcool commented 9 months ago

Caused by: java.lang.IllegalStateException: Since you provided explicit contact points, the local DC must be explicitly set (see basic.load-balancing-policy.local-datacenter in the config, or set it programmatically with SessionBuilder.withLocalDatacenter). Current contact points are: Node(endPoint=/127.0.0.1:9042, hostId=09137d7d-bd7e-46b2-a3d3-fe350c30b5a9, hashCode=69f9f10a)=datacenter1. Current DCs in this cluster are: datacenter1

Application.yml

spring: thymeleaf: cache: true data: cassandra: keyspace-name: taco_cloud schema-action: CREATE_IF_NOT_EXISTS local-datacenter: datacenter1 contact-points: localhost port: 9042

root@15541c9a703e:/# nodetool status Datacenter: datacenter1

cqlsh> desc keyspaces;

system system_distributed system_traces system_virtual_schema system_auth system_schema system_views taco_cloud

Github repo url: https://github.com/abcool/Training/tree/master/Spring%20in%20Action/Taco%20Cloud/Chapter-4

MykhailoShekera commented 2 weeks ago

Starting with Spring Boot 3.0, the prefix for Cassandra properties has changed from spring.data.cassandra. to spring.cassandra.: https://stackoverflow.com/questions/60668792/spring-data-with-cassandra-giving-illegalstateexception