【问题标题】:How do I specify a quartz property file outside of the classpath in gradle?如何在 gradle 的类路径之外指定一个石英属性文件?
【发布时间】:2017-10-26 02:08:55
【问题描述】:

我正在尝试在 gradle 中指定我的石英属性文件。从“配置”目录而不是资源。

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 方言,因此应用程序在加载时给出了数据库错误。

【问题讨论】:

    标签: java gradle quartz


    【解决方案1】:

    我有同样的问题,查看您的代码,使用 file:config/local/quartz.properties 很可能是错误的。官方文档实际上只是在该属性中添加了一个路径,没有任何 URI 前缀或任何东西。该前缀很可能使路径无效,并且 Quartz 无法找到它。以下是example from 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"
    

    至少有一个可用的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.
    

    【讨论】:

      猜你喜欢
      • 2012-01-19
      • 2010-12-02
      • 1970-01-01
      • 2014-05-29
      • 2023-03-18
      • 1970-01-01
      • 2015-08-10
      • 2018-10-12
      • 1970-01-01
      相关资源
      最近更新 更多