Spring - Switch SchedulerFactoryBean To Be Used

纵然是瞬间 提交于 2019-12-06 09:22:05
Tomasz Nurkiewicz

From Spring 3.1 you can use Spring profiles:

<bean name="schedulerFactoryBean" profile="dev" ...

<bean name="schedulerFactoryBean" profile="prd" ...

Then you can instruct Spring container which profile to use, see How to set active spring 3.1 environment profile via a properites file and not via an env variable or system property and Spring autowire a stubbed service - duplicate bean.

If you can't use 3.1 or profiles, the old-school of solving such issues is to have two context files: schedulerContext-dev.xml and schedulerContext-prd.xml`. Then you can import them selectively:

<import resource="schedulerContext-${some.property}"/>

A better option would be using quartz properties file. As part of your release you can have different files per environment. The context that way is the same for all the environments, the only thing that changes is the configuration file. Using maven profiles you can solve it

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!