简体   繁体   English

如何在gradle中的类路径之外指定quartz属性文件?

[英]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.

相关问题 如何在gradle的应用程序插件“运行”任务的类路径中指定一个额外的文件夹? - How do I specify an extra folder to be on the classpath for gradle's application plugin 'run' task? 在类路径之外访问属性文件 - Access a Property file outside the classpath 如何为JDI启动连接器指定类路径;用Eclipse? - How do I specify the classpath for a JDI launching connector; using Eclipse? 如何在jar清单类路径中为属性文件指定目录? - How do I specify a directory for properties files in a jar manifest classpath? 如何从命令行在类路径中指定mysql jar? - How do I specify the mysql jar in the classpath from the command line? 我如何在 gradle 中打印出 JAVA 类路径? - How do i print out the JAVA classpath in gradle? 如何在apply from:文件中的build.gradle外部的gradle中导入类 - How do I import a class in gradle outside of build.gradle in a apply from: file 如何使用类路径中的文件? - How do I use the file from classpath? 如何使用classpath指定文件位置? - How to use classpath to specify a file location? 如何访问位于项目文件夹外部和项目类路径外部的.properties文件? - How can I access to a .properties file situated outside the project folder and outside the project classpath?
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM