我有一个非常简单的春季启动应用程序,可以与cassandra进行通信。在我的示例中,当我运行myApplication时,创建了“myTestKeySpace”,但是当我停止从数据库中自动删除的应用程序时。怎么了?
@Configuration
public class CassandraConfig extends AbstractCassandraConfiguration {
public static final String KEYSPACE = "myTestKeySpace";
@Override
public SchemaAction getSchemaAction() {
return SchemaAction.CREATE;
}
@Override
protected List<CreateKeyspaceSpecification> getKeyspaceCreations() {
CreateKeyspaceSpecification specification = CreateKeyspaceSpecification.createKeyspace(KEYSPACE);
return Arrays.asList(specification);
}
@Override
protected List<DropKeyspaceSpecification> getKeyspaceDrops() {
return Arrays.asList(DropKeyspaceSpecification.dropKeyspace(KEYSPACE));
}
@Override
protected String getKeyspaceName() {
return KEYSPACE;
}
@Override
public String[] getEntityBasePackages() {
return new String[]{"com.mySite"};
}
}
@SpringBootApplication
public class Application {
public static void main(String[] args) {
SpringApplication.run(Application.class , args);
}
}
答案 0 :(得分:0)
我从未在Cassandra中使用Springdata,但我想方法getKeyspaceDrops
将以getKeyspaceCreations
创建它的方式删除键空间。