10
10
import com .github .nosan .embedded .cassandra .api .Cassandra ;
11
11
import com .github .nosan .embedded .cassandra .api .CassandraFactory ;
12
12
import com .github .nosan .embedded .cassandra .api .Version ;
13
- import com .github .nosan .embedded .cassandra .api .cql .CqlScript ;
14
13
import com .github .nosan .embedded .cassandra .artifact .RemoteArtifact ;
15
- import org .springframework .beans .factory .annotation .Value ;
16
14
import org .springframework .context .annotation .Bean ;
17
15
import org .springframework .context .annotation .Configuration ;
18
16
import org .springframework .context .annotation .Scope ;
36
34
@ Configuration
37
35
public class EmbeddedCassandraFactoryConfig {
38
36
39
- @ Value ("${cassandra-keyspace:geo_data}" )
40
- private String keyspaceName ;
41
-
42
37
@ Bean (initMethod = "start" , destroyMethod = "stop" )
43
38
Cassandra cassandra (CassandraFactory cassandraFactory ) {
44
39
return cassandraFactory .create ();
@@ -47,8 +42,7 @@ Cassandra cassandra(CassandraFactory cassandraFactory) {
47
42
@ Bean
48
43
CassandraConnection cassandraConnection (Cassandra cassandra ) {
49
44
CassandraConnection cassandraConnection = new DefaultCassandraConnectionFactory ().create (cassandra );
50
- String [] createKeyspace = CqlScript .ofClasspath ("create_keyspace.cql" ).getStatements ().stream ().map (s -> String .format (s , keyspaceName )).toArray (l -> new String [l ]);
51
- CqlDataSet .ofStrings (createKeyspace ).add (CqlDataSet .ofStrings (String .format ("USE %s;" , keyspaceName ))).add (CqlDataSet .ofClasspaths ("geo_data.cql" )).forEachStatement (cassandraConnection ::execute );
45
+ CqlDataSet .ofClasspaths ("create_keyspace.cql" ).add (CqlDataSet .ofStrings ("USE geo_data;" )).add (CqlDataSet .ofClasspaths ("geo_data.cql" )).forEachStatement (cassandraConnection ::execute );
52
46
return cassandraConnection ;
53
47
}
54
48
0 commit comments