繁体   English   中英

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

[英]How to properly locate Spring Context property-placeholder?

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

<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>

这是抛出的错误: 在此处输入图片说明

Caused by: org.mule.runtime.api.exception.MuleRuntimeException: There was '1' error while parsing the given file 'zuultest.xml'.
Full list:
org.xml.sax.SAXParseException; lineNumber: 17; columnNumber: 65; cvc-complex-type.2.4.a: Invalid content was found starting with element 'context:property-placeholder'. One of '{"http://www.mulesoft.org/schema/mule/core":annotations, "http://www.mulesoft.org/schema/mule/core":description, "http://www.mulesoft.org/schema/mule/core":global-property, "http://www.mulesoft.org/schema/mule/core":configuration, "http://www.mulesoft.org/schema/mule/core":notifications, "http://www.mulesoft.org/schema/mule/core":abstract-extension, "http://www.mulesoft.org/schema/mule/core":abstract-shared-extension, "http://www.mulesoft.org/schema/mule/core":abstract-mixed-content-extension, "http://www.mulesoft.org/schema/mule/core":abstract-security-manager, "http://www.mulesoft.org/schema/mule/core":abstract-transaction-manager, "http://www.mulesoft.org/schema/mule/core":abstract-shared-transaction-manager, "http://www.mulesoft.org/schema/mule/core":abstract-connector, "http://www.mulesoft.org/schema/mule/core":abstract-shared-connector, "http://www.mulesoft.org/schema/mule/core":abstract-global-endpoint, "http://www.mulesoft.org/schema/mule/core":abstract-exception-strategy, "http://www.mulesoft.org/schema/mule/core":abstract-on-error, "http://www.mulesoft.org/schema/mule/core":abstract-flow-construct, "http://www.mulesoft.org/schema/mule/core":flow, "http://www.mulesoft.org/schema/mule/core":sub-flow, "http://www.mulesoft.org/schema/mule/core":top-level-processor, "http://www.mulesoft.org/schema/mule/core":abstract-global-intercepting-message-processor, "http://www.mulesoft.org/schema/mule/core":abstract-object-store}' is expected.

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

如果您尝试在 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

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM