如何在Tomcat中使用spring风格的属性文件配置quartz调度程序?
我在 Apache Tomcat 上有一个 Web 应用程序。 Web 应用程序使用 Quartz Scheduler。我使用包含以下属性的 -D
开关从类路径加载 quartz.properties
:
quartz.jndi=java:comp/env/something
org.quartz.dataSource.myJndiName.jndiURL=${quartz.jndi}
但它不起作用。也许,${quartz.jndi}只能在带有PropertyPlaceholderConfigurer
bean的Spring上下文中工作?是否可以在 Spring 中为 Quartz Scheduler 加载此属性文件?
I have a web application on Apache Tomcat. The web application uses the Quartz Scheduler. I load the quartz.properties
from the classpath with the -D
switch which contains the following properties:
quartz.jndi=java:comp/env/something
org.quartz.dataSource.myJndiName.jndiURL=${quartz.jndi}
But it isn't working. Maybe, the ${quartz.jndi}
only works in Spring Context with the PropertyPlaceholderConfigurer
bean? Is it possible to load this properties file in Spring for the Quartz Scheduler?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
一年多后我知道了,但希望对某人有用:您可以通过在 Spring 上下文 xml 中设置属性来完成此操作:
注意,我已将大部分与 JobStore 相关的属性放在这里,因为它们似乎需要位于同一个地方。通常的quartz.properties 文件中还有一些其他配置。
Over a year later I know, but hopefully useful to somebody: you can accomplish this by setting the properties inside your Spring context xml:
Notice I've put most of the JobStore-related properties in here as they seem to need to be in the same place. There is still some other configuration in the usual quartz.properties file.
您可以在 SchedulerFactoryBean 中设置 configLocation:
You can set the
configLocation
in your SchedulerFactoryBean:这取决于你想要什么样的 Quartz 属性,可能已经有一个 Spring 方式来传递它。通常用于引用 Spring 3 之前和之后的属性条目(非 Quartz 特定) 看看这个问题。对于特定于 Quartz 的 Spring 设置和配置,请查看 Spring 调度文档。
It depends what kind of Quartz property you want, there might already be a Spring-way of passing it. Generally for referring to properties entries (non Quartz-specific) pre and post Spring 3 look at this question. For Quartz-specific Spring setup and configuration have a look at the first part of the Spring scheduling documentation.