I need to assure data migration using mongock.
The @ChangeUnit class holds the logic for migration. It has a field annotated with @Value
which is always null, even though I properly initialized in application.properties
:
mongock.migration-scan-package=my.package
login-secret=test
Then the MigrationConfiguration
looks as follows:
@ChangeUnit(id = "test", order = "001", author = "test")
@RequiredArgsConstructor
@Configuration
public class InitUsersChangeLog {
private final MyService service;
private final MongoTemplate template;
@Value("${login-secret}")
private String LOGIN;
@Execution
public void initUser() {
service.create(User.builder().login(LOGIN).build());
}
}
Main class:
@EnableMongock
@SpringBootApplication
public class MailServiceApplication {...}
My assumption is that this value is not injected properly into the MongockConfiguration bean. I tried to configure the bean manually (without using mongock.migration-scan-package=my.package) in the properties, but with no success.