如何在 gradle 的类路径之外指定一个 quartz 属性 文件?
How do I specify a quartz property file outside of the classpath in gradle?
我正在尝试在 gradle 中指定我的石英属性文件。从 'config' 目录而不是资源。
String quartzProperties = System.properties['org.quartz.properties'] ?: "file:config/local/quartz.properties"
System.setProperty("org.quartz.properties", quartzProperties)
来自
的输出
(System.properties).each {
println "Prop ${it}"
}
或者属性任务,是
Prop quartz.properties=file:config/local/quartz.properties
石英的输出是
PropertiesFactoryBean --- Loading properties file from class path resource [quartz.properties]
SchedulerConfig$$EnhancerB --- Cannot load quartz.properties.
未设置的症状是我输入了错误的 sql 方言,因此应用程序在加载时出现数据库错误。
我有同样的问题并查看您的代码,使用 file:config/local/quartz.properties
很可能是错误的。官方文档实际上只是在 属性 中放置了一个路径,没有任何 URI 前缀或任何其他内容。该前缀很可能使路径无效并且 Quartz 无法找到它。下面是一个example from GitHub:
workdir=`dirname [=10=]`
workdir=`cd ${workdir} && pwd`
QUARTZ=${workdir}/../..
[...]
# Set the name and location of the quartz.properties file
QUARTZ_PROPS="-Dorg.quartz.properties=${workdir}/quartz.properties"
至少有一个可用 factory 实际上也只使用一个文件:
String requestedFile = System.getProperty(PROPERTIES_FILE);
String propFileName = requestedFile != null ? requestedFile
: "quartz.properties";
File propFile = new File(propFileName);
除此之外,至少现在 some factories 存在支持直接提供设置的:
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.
我正在尝试在 gradle 中指定我的石英属性文件。从 'config' 目录而不是资源。
String quartzProperties = System.properties['org.quartz.properties'] ?: "file:config/local/quartz.properties"
System.setProperty("org.quartz.properties", quartzProperties)
来自
的输出(System.properties).each {
println "Prop ${it}"
}
或者属性任务,是
Prop quartz.properties=file:config/local/quartz.properties
石英的输出是
PropertiesFactoryBean --- Loading properties file from class path resource [quartz.properties]
SchedulerConfig$$EnhancerB --- Cannot load quartz.properties.
未设置的症状是我输入了错误的 sql 方言,因此应用程序在加载时出现数据库错误。
我有同样的问题并查看您的代码,使用 file:config/local/quartz.properties
很可能是错误的。官方文档实际上只是在 属性 中放置了一个路径,没有任何 URI 前缀或任何其他内容。该前缀很可能使路径无效并且 Quartz 无法找到它。下面是一个example from GitHub:
workdir=`dirname [=10=]`
workdir=`cd ${workdir} && pwd`
QUARTZ=${workdir}/../..
[...]
# Set the name and location of the quartz.properties file
QUARTZ_PROPS="-Dorg.quartz.properties=${workdir}/quartz.properties"
至少有一个可用 factory 实际上也只使用一个文件:
String requestedFile = System.getProperty(PROPERTIES_FILE);
String propFileName = requestedFile != null ? requestedFile
: "quartz.properties";
File propFile = new File(propFileName);
除此之外,至少现在 some factories 存在支持直接提供设置的:
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.