Disable Spring Scheduler task via property

I am planning a task using the Spring Framework and has the cron value specified in the environment properties file. I am looking for a way to disable this task using a property so that only certain environments perform 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" /> 
+4
source share
1 answer

You can use Spring environment profiles (example using annotations , example using xml ), so you can have different profiles for development, testing, production, etc. And they are set using properties (spring.profiles.active).

+4
source

All Articles