为什么 Eclipse 无法解析 spring-dwr 架构?

发布于 2024-07-21 20:26:20 字数 2943 浏览 6 评论 0 原文

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:架构>。 当我通过输入 使用自动完成功能时,Eclipse 会正确显示各种选项,例如 等等。 Eclipse 如何在不读取 schema 的情况下知道这一点?

我毫无问题地使用了许多不同的命名空间; 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 网站宕机而崩溃时,我就受到了影响。

Eclipse is showing the following errors in my Spring's 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

When I hover my mouse over the line-item error, it also says:

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

I confirmed that the root element is in fact <xsd:schema>. When I use autocomplete by typing <dwr: Eclipse correctly shows me the various options like <dwr:configuration>, <dwr:controller>, etc. How can Eclipse know this without reading the schema?

I make use of many different namespaces without issue; the DWR schema is the only one that isn't being resolved. Here is the declaration:

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

I have the latest DWR 3.0.0.116.rc1 in my classpath. If I crack open the DWR jar, I find META-INF/spring.handlers containing:

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

and META-INF/spring.schemas containing:

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

The escaping of the colon threw me off a bit, but I assume it's all correct, otherwise everyone's DWR would be broken.

Before I was grabbing this particular schema in real time from the DWR website, but I got bit by this when my production system crashed because the DWR site was down.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(3

青衫负雪 2024-07-28 20:26:20

您可以尝试向 Eclipse 添加用户指定的目录贡献。 在窗口->首选项->XML->XML 目录下,选择用户指定的条目,然后选择添加按钮。

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

You could try adding a user specified catalog contribution to Eclipse. Under Window->Preferences->XML->XML Catalog select User Specified Entries and then the Add button.

You can then add the details for the schema (you could copy the file locally in case of dropped connection). Eclipse will then have access to the schema during validation.

残龙傲雪 2024-07-28 20:26:20

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

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

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

I'm not sure what your question is here. You seem to answer it yourself in the last paragraph - DWR site goes down, schema validation in Eclipse fails. Note that Eclipse (even with the Spring IDE plugin) doesn't use META-INF/spring.schemas to resolve the namespaces, that's done by the Eclipse platform. If the schema can't be found at the schema location, then you get these errors.

As for the auto-complete, Eclipse will still provide this by inferring from existing structures in your document, if it can't find the schema.

This isn't a problem in the application itself, since Spring will use the META-INF/spring.schemas file to resolve schemas from the JAR.

坦然微笑 2024-07-28 20:26:20

这是离线使用 Eclipse 时的常见问题。 它试图从网络获取模式。 当找不到它时,表明验证错误。

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

This is a common problem when using Eclipse offline. It's trying to grab the schema from the net. When it can't find it, it indicates a validation error.

I just ignore these errors. When you are back online, clean the project and they go away.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文