I have a component EmbeddedRedis
that depends on a configuration object RedisConfig
parsed from the application's property file. There are different property files, corresponding to the possible application profiles that can be run. Thus, when run in profile master
, the component EmbeddedRedis
will be provisioned according to the master
profile.
In a test class, that is supposed to set-up a local Redis cluster, I also require Redis
objects provisioned according to all other profiles. I sketched my idea below using the @Qualifier
annotation, which does not bring the desired result.
@Autowired @Qualifier("dev-cluster-master")
private Redis embeddedRedisMaster;
@Autowired @Qualifier("dev-cluster-slave-001")
private Redis embeddedRedisSlave1;
@Autowired @Qualifier("dev-cluster-slave-002")
private Redis embeddedRedisSlave2;
How can I archive the desired result in Spring Boot? If that doesn't work directly, would it also suffice to obtain the before-mentioned configuration objects parsed from the different property files.
@Component
@ConfigurationProperties(prefix = "spring.redis")
public class RedisConfig {
....
}
Thanks in advance!