Du har ret, du vil bruge profiler.
@Bean( name = "customerRepository" )
@Profile( "jpa")
CrudRepository getCustomerRepository()
{
return _customerRepository;
}
@Bean( name = "customerRepository" )
@Profile( "mongo")
MongoRepository getCustomerRepositoryMongo()
{
return _customerRepositoryMongo;
}
@Autowired
@Qualifier("customerRepository")
CrudRepository _crudRepository;
I application.properties kan du nu indstille spring.profiles.active til jpa eller mongo for at skifte mellem databaser.