Java spring配置文件中的三元运算符
在这种情况下,我需要检查maven运行的概要文件,然后根据它配置任务调度器。有两个配置文件,一个是“全球”,另一个是“非全球”,我所做的是:Java spring配置文件中的三元运算符,java,jakarta-ee,spring-mvc,maven-3,spring-el,Java,Jakarta Ee,Spring Mvc,Maven 3,Spring El,在这种情况下,我需要检查maven运行的概要文件,然后根据它配置任务调度器。有两个配置文件,一个是“全球”,另一个是“非全球”,我所做的是: <task:scheduler id="customerPortalTaskScheduler" pool-size="1" /> <task:scheduled-tasks scheduler="customerPortalTaskScheduler"> <task:scheduled ref="Su
<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概要文件的实例。它会说它是全球的还是非全球的。它确实可以正常工作,因为属性文件被正确加载
在上面的配置中,我得到了一个屏幕截图中的错误
如何解决这个问题,有什么想法吗?不依赖于激活的配置文件。取决于本地配置文件:
<context:property-placeholder ignore-resource-not-found="true" location="file:/etc/mumbojumbo/app.config.properties"/>
您始终可以提供合理的默认值。所以你只需要在你想覆盖的地方覆盖它
<task:scheduled ref="SubscriptionService" method="updateNextDistributionDateForAllCurrentUsers" cron="${cron.schedule:defaultvalue}" />
类似的东西?我看不清楚屏幕截图,分辨率低。请复制粘贴。不同的配置文件是否在不同的机器上运行(可能是不同的配置?)Cron对
?
有不同的含义。它不支持Java语法。我想您有充分的理由不从外部配置文件加载适当的值?这让您几乎希望可以用Java编程,而不必用XML编程是的,如果没有其他选择,那么我必须照你说的做谢谢
<task:scheduled ref="SubscriptionService" method="updateNextDistributionDateForAllCurrentUsers" cron="${cron.schedule:defaultvalue}" />