如何正确定位 Spring Context 属性占位符?

问题描述

我正在尝试使用 MuleSoft 的 Anypoint Studio 平台中的 Mule 测试应用程序实现过时的开源属性文件管理器 (https://github.com/Confluex/Zuul/wiki)。这似乎需要 Spring Context Schema,但项目找不到它。它不断声明没有“上下文:属性占位符”。我觉得版本错误可能是问题所在。这是我的尝试:

import collections      

def maxOfAllMin(numComputer,harddiskSpace,segmentLength):
    ans = 0
    q = collections.deque() # store indexes
    l = r = 0
    while r < len(harddiskSpace):
        # pop smaller values from q
        while q and harddiskSpace[q[-1]] > harddiskSpace[r]:
            q.pop()
            print('q in 2nd while: ',q)
        q.append(r)
        print('q in 1st while: ',q)
        
        # remove element outside of window range
        if l > q[0]:
            print('first q in if: ',q[0])
            q.popleft()
            print('q in if: ',q)
            
        # ensure window is size k
        if (r + 1) >= segmentLength:
            ans = max(ans,harddiskSpace[q[0]])
            print(ans)
            l += 1
        r += 1  
    return ans


print(maxOfAllMin(3,[2,4,8],2))
print(maxOfAllMin(8,[10,20,30,40,50,60,70,80],3)

这里是抛出的错误

enter image description here

<mule 
    xmlns="http://www.mulesoft.org/schema/mule/core" 
    xmlns:context="http://www.springframework.org/schema/context"
    xmlns:spring="http://www.springframework.org/schema/beans"
    xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
    xmlns:zuul="zuul-spring-client-1.5.1"
    xsi:schemaLocation="
http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context.xsd
http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-current.xsd
http://www.mulesoft.org/schema/mule/core http://www.mulesoft.org/schema/mule/core/current/mule.xsd
zuul-spring-client-1.5.1 zuul-spring-client-1.5.1.xsd">


        <context:property-placeholder properties-ref="MuleMeetZuul" />
    
</mule>

任何建议将不胜感激。谢谢。

解决方法

如果您尝试在 Mule 4 中使用 Mule 3 实现,它将失败,这是意料之中的。 Mule 3 属性占位符提供者直接在 Spring 属性占位符提供者那里。 Mule 4 使用不同的方式来实现它们。 <context:property-placeholder> 在 Mule 4 中不存在。它的替代品 <configuration-properties> 不适用于这种用法。

相反,您必须使用 Mule SDK for Java 通过在工厂类中实现 ConfigurationPropertiesProviderFactory 接口并扩展 DefaultConfigurationPropertiesProvider 类来实现提供程序来开发自定义配置属性提供程序。在提供程序中,您需要使用 Zuul 库来实现获取键和值的操作。

文档中提供了说明:https://docs.mulesoft.com/mule-runtime/4.3/custom-configuration-properties-provider