英文:
Prevent running an spring boot task which implements CommandLineRunner
问题
我正在编写一个使用Cucumber进行集成测试的Spring Boot任务(非Web应用程序),该任务实现了CommandLineRunner。由于commandLineRunner的默认行为,即使将cucumber feature作为JUnit运行,它也会先运行任务,然后再返回到cucumber feature文件。相反,我希望它不要运行任务,并且一旦配置完成,控制应该回到feature文件。
我该如何阻止CommandLineRunner运行其run方法?
英文:
I am writing a spring boot integration test using cucumber for a task (non web application) which implements CommandLineRunner. Due to default behavior of commandLineRunner, even after running the cucumber feature as junit, it runs the task first and then come backs to cucumber feature file. Instead I expect it not to run the task and control should come to feature file once the configuration is done.
How can I prevent CommandLineRunner from running its run method?
答案1
得分: 1
将@Bean声明添加@Profile("!profile_name")注解,然后在需要排除该配置时设置该配置文件。
英文:
Add @Profile(“!profile_name”) annotation to the bean declaration and then set that profile when you need to exclude it
通过集体智慧和协作来改善编程学习和解决问题的方式。致力于成为全球开发者共同参与的知识库,让每个人都能够通过互相帮助和分享经验来进步。
评论