I sometimes may not need to post-construct of a bean at startup according to values passed via JVM argument.
I tried @Conditional
annotation but it only works on @Bean
annotations.
Have you tried/needed such a thing before?
I sometimes may not need to post-construct of a bean at startup according to values passed via JVM argument.
I tried @Conditional
annotation but it only works on @Bean
annotations.
Have you tried/needed such a thing before?
AFAIK Conditional can not be mix with postconstruct. So my suggetions
Add two diferent beans one with postconstruct and one without as use @Conditional
in beans declaration
Add programatic code validatiing your application args like:
import org.springframework.core.env.Environment;
private final Environment env;
public void execute() {
if (env.getProperty("condition") == "condition") {
}
}
Use aproximation in 1 but @Profile
and pass active profile as parameter -Dspring.profiles.active=my_profile
© 2022 - 2024 — McMap. All rights reserved.