[英]How do I specify a quartz property file outside of the classpath in gradle?
I'm attempting to specify my quartz properties file in gradle.我试图在 gradle 中指定我的石英属性文件。 From a 'config' directory rather than from resources.从“配置”目录而不是资源。
String quartzProperties = System.properties['org.quartz.properties'] ?: "file:config/local/quartz.properties"
System.setProperty("org.quartz.properties", quartzProperties)
The output from输出来自
(System.properties).each {
println "Prop ${it}"
}
or the properties task, is或属性任务,是
Prop quartz.properties=file:config/local/quartz.properties
The output from quartz is石英的输出是
PropertiesFactoryBean --- Loading properties file from class path resource [quartz.properties]
SchedulerConfig$$EnhancerB --- Cannot load quartz.properties.
The symptom of it not being set is that I am getting the wrong sql dialect so the application gives a database error on load.它没有被设置的症状是我得到了错误的 sql 方言,所以应用程序在加载时给出了一个数据库错误。
I had the same question and looking at your code, using file:config/local/quartz.properties
was wrong most likely.我有同样的问题并查看您的代码,使用file:config/local/quartz.properties
很可能是错误的。 The official docs really only put a path into that property, without any URI-prefix or whatsoever.官方文档实际上只在该属性中放置了一个路径,而没有任何 URI 前缀或任何其他内容。 That prefix most likely made the path invalid and Quartz was unable to find it.该前缀很可能使路径无效并且 Quartz 无法找到它。 The following is an example from GitHub :以下是来自 GitHub的示例:
workdir=`dirname $0`
workdir=`cd ${workdir} && pwd`
QUARTZ=${workdir}/../..
[...]
# Set the name and location of the quartz.properties file
QUARTZ_PROPS="-Dorg.quartz.properties=${workdir}/quartz.properties"
At least one available factory really only uses a file as well:至少一个可用的工厂实际上也只使用一个文件:
String requestedFile = System.getProperty(PROPERTIES_FILE);
String propFileName = requestedFile != null ? requestedFile
: "quartz.properties";
File propFile = new File(propFileName);
Besides that, at least nowadays some factories exist which support providing settings directly:除此之外,至少现在存在一些支持直接提供设置的工厂:
StdSchedulerFactory(Properties props)
Create a StdSchedulerFactory that has been initialized via initialize(Properties).
initialize(InputStream propertiesStream)
Initialize the SchedulerFactory with the contents of the Properties file opened with the given InputStream.
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.