.yml file
cassandra:
keyspaceApp:junit
solr:
keyspaceApp:xyz
Bean
@Component
@ConfigurationProperties(prefix="cassandra")
public class CassandraClientNew {
@Value("${keyspaceApp:@null}") private String keyspaceApp;
Main method file
@EnableAutoConfiguration
@ComponentScan
@PropertySource("application.yml")
public class CommonDataApplication {
public static void main(String[] args) {
ConfigurableApplicationContext context = new SpringApplicationBuilder(CommonDataApplication.class)
.web(false).headless(true).main(CommonDataApplication.class).run(args);
}
}
TestCase
@RunWith(SpringJUnit4ClassRunner.class)
@SpringApplicationConfiguration(classes = CommonDataApplication.class)
@IntegrationTest
@EnableConfigurationProperties
public class CassandraClientTest {
@Autowired
CassandraClientNew cassandraClientNew;
@Test
public void test(){
cassandraClientNew.getSession();
System.out.println(" **** done ****");
}
}
Instead of setting junit as the keyspaceApp it sets xyz.
Looks like prefix="cassandra" not working
See Question&Answers more detail:os