Reputation: 352
I am scheduling a task using Spring Framework and have a cron value set through an environment specific property file. I am looking for a way to disable this task through a property so that only certain environments run this task.
<task:scheduled-tasks>
<task:scheduled ref="theClass" method="theMethod" cron="${scheduler.cron}" />
</task:scheduled-tasks>
<bean id="theClass" class="com.test.TheClass" scope="prototype" />
Upvotes: 4
Views: 6104
Reputation: 8582
You can use Spring environment profiles (example using annotations, example using xml), so you can have different profiles for development, testing, production, etc. And these are set via properties (spring.profiles.active).
Upvotes: 4