- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
我已经实现了从属性文件配置 CronExpression,但该属性文件是 apache-deltaspike.properties,它位于 .jar 文件内。我需要从自定义配置文件中获取 cron 表达式:
import org.apache.deltaspike.core.api.config.PropertyFileConfig;
public class myOwnPropertyFileConfig implements PropertyFileConfig {
private static final long serialVersionUID = 1L;
@Override
public String getPropertyFileName() {
return "cfg/myOwnPropFile.properties";
}
@Override
public boolean isOptional() {
return false;
}
}
myOwnPropFile.properties
deltaspike_ordinal=500
property1=value1
property2=value2
QuartzJob=0 25 17 * * ?
工作:
@Scheduled(cronExpression = "{QuartzJob}")
public class MyQuartzJob implements Job {
//job code
}
当我设置此属性时,一切顺利:QuartzJob=0 25 17 * * ?在 apache-deltaspike.properties 中,但是当我在自己的属性文件中设置它时,我得到:
java.lang.IllegalStateException: No config-value found for config-key: QuartzJob
研究后,我发现我的属性文件在 Quartz 初始化后立即加载,这解释了原因。现在,我在 Deltaspike 文档中读到,可以在我的属性文件中使用 deltaspike_ordinal 来随时加载我的属性文件。所以我尝试了,但它似乎忽略了 deltaspike_ordinal=500,并且错误不断出现。
那么,有人知道如何解决这个问题吗? Deltaspike 文档还讨论了 ConfigSource 等,但不太清楚,也没有示例。
提前致谢!
最佳答案
明白了。关键是查看PropertyFileConfig的javadoc:
- Automatic pickup via java.util.ServiceLoader mechanism In case you have an EAR or you need the configured values already during the CDI container start then you can also register the PropertyFileConfig via the java.util.ServiceLoader mechanism. To not have this configuration picked up twice it is required to annotate your own PropertyFileConfig implementation with org.apache.deltaspike.core.api.exclude.Exclude.
The ServiceLoader mechanism requires to have a file META-INF/services/org.apache.deltaspike.core.api.config.PropertyFileConfig containing the fully qualified Class name of your own PropertyFileConfig implementation class.
com.acme.my.own.SomeSpecialPropertyFileConfig The implementation will look like the following:@Exclude
public class SomeSpecialPropertyFileConfig implements PropertyFileConfig {
public String getPropertyFileName() {
return "myconfig/specialconfig.properties"
}
public boolean isOptional() {
return false;
}
}
工作起来很有魅力
关于java - 来自自定义属性文件的 Deltaspike + Quartz + CronExpressions,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/36780507/
在周一至周六的晚上 7 点至上午 9 点以及周日全天执行作业。 我尝试输入多个 cron 表达式,但它不起作用。谁能帮我解决这个问题? 1. " * * 19-8 ? * MON,TUE,WED,TH
是否可以使用以下命令创建 Cron 表达式: “每天每 20 分钟开火一次,但不在周六 10:00 到 14:00 之间开火”? 像“0 0/20 * ? * MON-SAT”这样的东西很清楚,但它不
不知道下面的表述是否正确: 我尝试将我的触发器配置为每个月的第二天触发,无论年份如何,中午,一周中的某一天必须在周一和周五之间。 如果有人可以帮助我,我将不胜感激。提前致谢。 最佳答案 我假设您的意
我已经实现了从属性文件配置 CronExpression,但该属性文件是 apache-deltaspike.properties,它位于 .jar 文件内。我需要从自定义配置文件中获取 cron 表
我有一些 GUI 控件构成了一个典型的 Windows 调度程序(日期\时间选择器、复选框等),我想从中构建一个 CronExpression 字符串。 有谁知道构建表达式字符串的好方法,可以是预先存
我的应用程序基于 GWT。 我正在尝试使用org.quartz-scheduler.quartz-2.2.1.jar来验证cron表达式。 但是当我尝试进行 Maven 构建时,出现以下错误。 [IN
我正在使用 quartz-scheduler 来安排我的工作。我有一个错误的 cron 表达式: 1 15 10 ? * *ssddddfd 当我这样做时: String cronExpression
来自 Quartz 调度器 javadocs对于 CronTrigger 类的方法 setTimeZone: If setCronExpression(CronExpression) is calle
我猜这个标题是不言自明的。我有一份工作: import org.apache.deltaspike.scheduler.api.Scheduled; import org.quartz.Job; @S
将其作为无效的 CronExpression,无法弄清楚原因 推荐http://www.quartz-scheduler.org/documentation/quartz-1.x/tutorials/
我正在将 UTC±00:00 时间传递给 Quartz 调度程序中的 GetNextValidTimeAfter() 方法,以根据特定的 cron 表达式计算调度的下一个有效时间,但由于我的系统时间是
我是一名优秀的程序员,十分优秀!