我有一种情况需要检查maven正在运行的配置文件然后根据我需要配置任务调度程序。有两个配置文件,一个是'全局',另一个是'非全局',我做的是:
<task:scheduler id="customerPortalTaskScheduler" pool-size="1" />
<task:scheduled-tasks scheduler="customerPortalTaskScheduler">
<task:scheduled ref="SubscriptionService" method="updateNextDistributionDateForAllCurrentUsers" cron="${nhst.ncp.instance} == 'global' ? #{customerportal['globalUpdateDistributionDateServiceTuesday.CronTrigger']} : #{customerportal['updateDistributionDateServiceMondayThursday.CronTrigger']}" />
<task:scheduled ref="SubscriptionService" method="updateNextDistributionDateForAllCurrentUsers" cron="${nhst.ncp.instance} == 'global' ? #{customerportal['globalUpdateDistributionDateServiceWednesday.CronTrigger']} : #{customerportal['updateDistributionDateServiceFriday.CronTrigger']}" />
<task:scheduled ref="SubscriptionService" method="updateNextDistributionDateForAllCurrentUsers" cron="${nhst.ncp.instance} == 'global' ? #{customerportal['globalUpdateDistributionDateServiceThursday.CronTrigger']} : #{customerportal['updateDistributionDateServiceWeekend.CronTrigger']}" />
</task:scheduled-tasks>
$ {nhst.ncp.instance}是maven个人资料的实例。它会说它的全球或非全球形象。它工作正常,因为正确加载属性文件。
通过上述配置,我收到屏幕截图中的错误。
任何想法如何解决这个问题?
答案 0 :(得分:2)
不要依赖激活的个人资料。取决于本地配置文件:
<context:property-placeholder ignore-resource-not-found="true" location="file:/etc/mumbojumbo/app.config.properties"/>
/etc/mumbojumbo/app.config.properties 中的
cron.schedule = blabla
您始终可以提供合理的默认值。所以你只需要在你想要的地方覆盖它。
<task:scheduled ref="SubscriptionService" method="updateNextDistributionDateForAllCurrentUsers" cron="${cron.schedule:defaultvalue}" />
那样的东西?