【问题标题】:How to properly locate Spring Context property-placeholder?如何正确定位 Spring Context 属性占位符?
【发布时间】:2021-07-28 19:36:19
【问题描述】:

我正在尝试在 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?
  • @aled Anypoint Studio 版本:7.9.0;骡服务器 4.3.0 EE

标签: java spring schema mule-studio mulesoft


【解决方案1】:

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

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

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

【讨论】:

  • 非常感谢!
  • 不客气。如果您觉得答案有用,请接受它以向其他用户标记答案有效。
猜你喜欢
  • 2011-12-10
  • 2014-07-16
  • 1970-01-01
  • 2016-02-22
  • 2013-05-05
  • 2013-12-14
  • 1970-01-01
  • 1970-01-01
  • 2017-03-21
相关资源
最近更新 更多