我正在使用Spring Framework调度一个任务,并通过一个特定于环境的属性文件来设置cron值。我正在寻找一种通过属性禁用此任务的方法,以便只有特定的环境才能运行此任务。
<task:scheduled-tasks>
<task:scheduled ref="theClass" method="theMethod" cron="${scheduler.cron}" />
</task:scheduled-tasks>
<bean id="theClass" class="com.test.TheClass" scope="prototype" />发布于 2013-04-15 22:07:14
您可以使用Spring环境配置文件( (example using annotations,example using xml),因此您可以有不同的配置文件用于开发、测试、生产等。这些配置文件是通过属性(spring.profiles.active)设置的。
https://stackoverflow.com/questions/16017215
复制相似问题