Is there any way to connect a Spring Boot application to two different Cassandra data sources by using Spring Boot and Spring Data?
I tried to configure 2 different data sources but Spring Boot chooses the first one and ignores the other.
Thank you
Spring Boot supports out of the box only singleton data sources and it configures a single Session
with a single CassandraTemplate
.
Since Spring Data 2.0, CassandraTemplate
supports a SessionFactory
that can route calls to different Cassandra Session
s. That's something you need to configure yourself:
@Configuration
class MyConfig {
@Bean
CassandraTemplate cassandraTemplate(CassandraConverter converter) {
SessionFactory factory = …;
return new CassandraTemplate(factory, converter);
}
}
You might want to take a look into AbstractRoutingSessionFactory
for building your own Session
router.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.