You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I'm trying to have the execution of the change unit only by some conditions, similar as how we have @Profile to execute something for specific Spring profile only. I'm trying to use @ConditionalOnExpression annotation, but it seems that it is ignoring that annotation at all, and Change Unit would be always executed.
PRIORITY
[NORMAL]
Version and environment
Mongock + Environment
mongock-spring-boot-5.4.3
springboot-starter-parent-2.4.3
mongodb-springdata-v3-driver-5.4.3
Autoconfiguration way of using Mongock
Usage
LocalDataPopulationChangeUnit.java
@RequiredArgsConstructor
@Slf4j
@ConditionalOnExpression("${initial.data.population:true}")
//@ConditionalOnProperty(prefix="initial.data", name = "population", havingValue ="true")
@ChangeUnit(id = "local-data-population", order = "999", author = "david.vuletas")
public class LocalDataPopulationChangeUnit {
....
application.yml
initial:
data:
population: false
The text was updated successfully, but these errors were encountered:
you have to take into account that, although ChangeUnits support dependency injection from the Spring context and profiles, they are not beans. They are POJO's managed by Mongock.
We have in our road map adding support for SpEL and that kind of annotations. Meanwhile you can workaround this with @profiles.
Also we wil create a contribution ticket to support this ind of feature, you are welcome to take it and raise a PR. We'll support you all way long and you will be displayed in our contributors page 😄
Description
I'm trying to have the execution of the change unit only by some conditions, similar as how we have
@Profile
to execute something for specific Spring profile only. I'm trying to use@ConditionalOnExpression
annotation, but it seems that it is ignoring that annotation at all, and Change Unit would be always executed.PRIORITY
[NORMAL]
Version and environment
Mongock + Environment
Usage
LocalDataPopulationChangeUnit.java
application.yml
The text was updated successfully, but these errors were encountered: