I have created spring boot application with spring cloud task which should executes a few commands(tasks). Each task/command is shorted-lived task, and all tasks are start
You can also make your CommandLineRunner implementations @Component and @ConditionalOnExpression("${someproperty:false}")
then have multiple profiles, that set someproperty to true to include those CommandLineRunners in the Context.
@Component
@Slf4j
@ConditionalOnExpression("${myRunnerEnabled:false}")
public class MyRunner implements CommandLineRunner {
@Override
public void run(String ... args) throws Exception {
log.info("this ran");
}
}
and in the yml application-myrunner.yml
myRunnerEnabled: true
@SpringBootApplication
public class SpringMain {
public static void main(String ... args) {
SpringApplication.run(SpringMain.class, args);
}
}