【问题标题】:How to use spring.schemas and spring.handlers to short-circuit dependcies' schema lookups如何使用 spring.schemas 和 spring.handlers 来短路依赖的模式查找
【发布时间】:2018-03-13 02:58:01
【问题描述】:

我正在尝试升级 https://github.com/mulesoft/mule-module-cache 以在 Mule 3.4.0 CE 下运行,但在命令行上运行 mvn clean install 时得到以下结果

[10-16 13:51:05] WARN  XmlBeanDefinitionReader [main]: Ignored XML validation warning org.xml.sax.SAXParseException: schema_reference.4: Failed to read schema document 'http://www.springframework.org/schema/beans/spring-beans-current.xsd', because 1) could not find the document; 2) the document could not be read; 3) the root element of the document is not <xsd:schema>.
....
testExternalGenerator(org.mule.module.cache.ExpressionTest): Line 6 in XML document from URL [jar:file:/Users/me/.m2/repository/org/mule/modules/mule-module-spring-config/3.4.0/mule-module-spring-config-3.4.0.jar!/mule-spring-config.xml] is invalid; nested exception is org.xml.sax.SAXParseException: cvc-elt.1: Cannot find the declaration of element 'beans'. (org.mule.api.lifecycle.InitialisationException)

这出现是由于 mule-module-spring-config-3.4.0.jar 的 mule-spring-config.xml 使用 current 声明。如果这是我的配置文件,我会修改该文件以明确指向我想要的 URI,但是,唉,事实并非如此。这是第 6 行:

xsi:schemaLocation="
   http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-current.xsd"

有没有办法让我使用Spring handler/schema approachcurrent 指向3.1

http:\//www.springframework.org/schema/beans/spring-beans-current.xsd=META-INF/spring-beans-3.1.xsd

或者我需要采取其他方法吗?

【问题讨论】:

  • 你检查过我在 3.4.0 上编译的 fork 吗? github.com/ddossot/mule-module-cache
  • 我以前没有 - 只是检查了一下,我的问题不再出现。这解决了我的直接问题。
  • Mirrors 在这里可能也对我有用,但我怀疑 mule-config 文件还有其他问题。

标签: spring mule


【解决方案1】:

当前 Spring Beans 模式的 URI 是:

http://www.springframework.org/schema/beans/spring-beans.xsd

不是:

http://www.springframework.org/schema/beans/spring-beans-current.xsd

【讨论】:

  • 但是当 Mule 库中的 xsd 显式调用 http://www.springframework.org/schema/beans/spring-beans-current.xsd 时,我如何让我的应用程序指向 http://www.springframework.org/schema/beans/spring-beans.xsd?我想要做的是拦截调用以在框架 jar 中定义的位置获取 xsd。 This issue 似乎报告了同样的问题,但没有解决方案。
  • 我想我不明白你当时面临的核心问题。
  • 我会尝试澄清一下:我使用的是 Mule CE 3.4.0,其中包括 jar:file:/Users/me/.m2/repository/org/mule/modules/mule-module -spring-config/3.4.0/mule-module-spring-config-3.4.0.jar。这个罐子(这是一个 Mule 罐子,不是我自己制作的)有一个定义 xsi:schemaLocation=" http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-current.xsd" 的 xsd。我认为这是导致我的问题的原因,但要解决它,我知道如何修改我下载的 Mule jar 中的 xsd,将该版本的 jar 放回(续)
  • (来自上一个)我的本地 Maven 存储库。我希望有一种不那么老套的方法让我告诉 Maven 指向 Mule xsd 告诉它的位置以外的其他地方。希望这会令人困惑,因为我面临的问题有一个简单的解决方案。基本上,Mule jar 的 xsd 似乎是错误的,但似乎我不会是第一个发现这个问题的人,所以我的本地设置可能有问题。 forum.mulesoft.org/mulesoft/topics/… 似乎在说 xsd 需要更改,但我无权访问该仓库。
【解决方案2】:

如果我理解您的问题,那么您将创建一个名为 spring.schemas 的文件,将其存储在 WAR 或 EAR 文件的 META-INF 目录中并拥有它包含以下条目:

http:\//www.springframework.org/schema/beans/spring-beans-current.xsd=http://www.springframework.org/schema/beans/spring-beans-3.1.xsd

如果您不想从互联网上获取 XSD,则添加以下条目:

http:\//www.springframework.org/schema/beans/spring-beans-current.xsd=org/springframework/beans/factory/xml/spring-beans-3.1.xsd

第二个假设适当的 spring-beans.jar 在您的类路径中。据我所知,最后一个选项是将 SpringConfig.xml 文件中的条目从:

xsi:schemaLocation=" http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-current.xsd"

xsi:schemaLocation=" http://www.springframework.org/schema/beans classpath:org/springframework/beans/factory/xml/spring-beans-3.1.xsd"

【讨论】:

    猜你喜欢
    • 2012-01-26
    • 2011-07-31
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2021-02-27
    • 1970-01-01
    • 2018-02-23
    相关资源
    最近更新 更多