12

Eclipse 在我的 Spring 的applicationContext.xml中显示以下错误:

cvc-complex-type.2.4.c: The matching wildcard is strict, but no declaration can be found for element 'dwr:configuration'.   myappservlet-servlet.xml    MyApp/src/main/webapp/WEB-INF   line 23 XML Problem
cvc-complex-type.2.4.c: The matching wildcard is strict, but no declaration can be found for element 'dwr:controller'.  myappservlet-servlet.xml    MyApp/src/main/webapp/WEB-INF   line 21 XML Problem
cvc-complex-type.2.4.c: The matching wildcard is strict, but no declaration can be found for element 'dwr:remote'.  myappservlet-servlet.xml    MyApp/src/main/webapp/WEB-INF   line 41 XML Problem

当我将鼠标悬停在订单项错误上时,它还会显示:

    - schema_reference.4: Failed to read schema document 'http://www.directwebremoting.org/
 schema/spring-dwr-3.0.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>.

我确认根元素实际上是<xsd:schema>。当我通过键入<dwr:使用自动完成功能时, Eclipse 正确地向我显示了各种选项,例如<dwr:configuration><dwr:controller>等。Eclipse 如何在不阅读架构的情况下知道这一点?

我毫无问题地使用了许多不同的名称空间;DWR 模式是唯一未解决的模式。这是声明:

<?xml version="1.0" encoding="utf-8"?>
<beans xmlns="http://www.springframework.org/schema/beans"
    xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
    xmlns:aop="http://www.springframework.org/schema/aop"
    xmlns:context="http://www.springframework.org/schema/context"
    xmlns:dwr="http://www.directwebremoting.org/schema/spring-dwr"
    xsi:schemaLocation="http://www.springframework.org/schema/beans
              http://www.springframework.org/schema/beans/spring-beans-2.5.xsd
              http://www.springframework.org/schema/aop 
              http://www.springframework.org/schema/aop/spring-aop-2.5.xsd
              http://www.springframework.org/schema/context
              http://www.springframework.org/schema/context/spring-context-2.5.xsd
              http://www.directwebremoting.org/schema/spring-dwr
              http://www.directwebremoting.org/schema/spring-dwr-3.0.xsd"
    default-autowire="byName">

我的类路径中有最新的 DWR 3.0.0.116.rc1。如果我打开 DWR jar,我会发现META-INF/spring.handlers包含:

http\://www.directwebremoting.org/schema/spring-dwr=org.directwebremoting.spring.DwrAnnotationNamespaceHandler

META-INF/spring.schemas包含:

http\://www.directwebremoting.org/schema/spring-dwr-2.0.xsd=org/directwebremoting/spring/spring-dwr-2.0.xsd
http\://www.directwebremoting.org/schema/spring-dwr-3.0.xsd=org/directwebremoting/spring/spring-dwr-3.0.xsd

冒号的逃逸让我有点失望,但我认为这一切都是正确的,否则每个人的 DWR 都会被破坏。

在我从 DWR 网站实时获取此特定模式之前,但当我的生产系统因 DWR 网站关闭而崩溃时,我被此所困扰。

4

3 回答 3

11

您可以尝试将用户指定的目录贡献添加到 Eclipse。在Window->Preferences->XML->XML Catalog下选择User Specified Entries,然后选择Add按钮。

然后,您可以添加架构的详细信息(如果连接断开,您可以在本地复制文件)。然后,Eclipse 将在验证期间访问该模式。

于 2009-07-02T15:23:16.557 回答
2

我不确定你的问题是什么。您似乎在最后一段中自己回答了这个问题 - DWR 站点出现故障,Eclipse 中的模式验证失败。请注意,Eclipse(即使使用 Spring IDE 插件)不使用 META-INF/spring.schemas 来解析名称空间,这是由 Eclipse 平台完成的。如果在架构位置找不到架构,则会收到这些错误。

至于自动完成,如果 Eclipse 找不到模式,它仍然会通过从文档中的现有结构推断来提供这一点。

这不是应用程序本身的问题,因为 Spring 将使用 META-INF/spring.schemas 文件来解析 JAR 中的模式。

于 2009-05-25T15:58:33.577 回答
2

这是脱机使用 Eclipse 时的常见问题。它试图从网上获取模式。当它找不到它时,它表示验证错误。

我只是忽略这些错误。当您重新联机时,清理项目,它们就会消失。

于 2009-07-23T03:13:04.707 回答