I devised a project with the usage of Spring boot and Cassandra which runs on Docker Container.
After I implemented the configuration of Cassandra, I ran the project and it threw an error shown below.
Caused by: com.datastax.oss.driver.api.core.InvalidKeyspaceException: Invalid keyspace mykeyspace
How can I fix the issue?
Here is my application.properties file.
spring.cassandra.contactpoints=127.0.0.1
spring.cassandra.port=9042
spring.data.cassandra.keyspace-name=mykeyspace
spring.cassandra.basepackages=com.springboot.cassandra
Here is a configuration file of Cassandra
@Configuration
@EnableCassandraRepositories
public class CassandraConfiguration extends AbstractCassandraConfiguration {
@Value("${spring.cassandra.contactpoints}")
private String contactPoint;
@Value("${spring.cassandra.port}")
private int port;
@Value("${spring.data.cassandra.keyspace-name}")
private String keyspaceName;
@Value("${spring.cassandra.basepackages}")
private String basePackages;
@Override
protected String getKeyspaceName() {
return keyspaceName;
}
@Override
protected int getPort() {
return port;
}
@Override
protected String getContactPoints() {
return contactPoint;
}
@Override
public SchemaAction getSchemaAction() {
return SchemaAction.CREATE_IF_NOT_EXISTS;
}
@Override
public String[] getEntityBasePackages() {
return new String[] {basePackages};
}
}