为什么 Eclipse 无法解析 spring-dwr 架构?
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/901242/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
Why can't Eclipse resolve the spring-dwr schema?
提问by Robert Campbell
Eclipse is showing the following errors in my Spring's applicationContext.xml:
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
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?
我确认根元素实际上是<xsd:schema>。当我通过键入<dwr:Eclipse使用自动完成功能时,会正确地向我显示各种选项,例如<dwr:configuration>、<dwr:controller>等。Eclipse 如何在不阅读架构的情况下知道这一点?
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:
我毫无问题地使用了许多不同的命名空间;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">
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.handlerscontaining:
我的类路径中有最新的 DWR 3.0.0.116.rc1。如果我打开 DWR jar,我会发现META-INF/spring.handlers包含:
http\://www.directwebremoting.org/schema/spring-dwr=org.directwebremoting.spring.DwrAnnotationNamespaceHandler
and META-INF/spring.schemascontaining:
和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
The escaping of the colon threw me off a bit, but I assume it's all correct, otherwise everyone's DWR would be broken.
冒号的转义让我有点失望,但我认为这一切都是正确的,否则每个人的 DWR 都会被破坏。
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.
在我从 DWR 网站实时获取这个特定模式之前,但是当我的生产系统因为 DWR 站点关闭而崩溃时,我受到了影响。
采纳答案by Rich Seller
You could try adding a user specified catalog contribution to Eclipse. Under Window->Preferences->XML->XML Catalogselect User Specified Entriesand then the Addbutton.
您可以尝试向 Eclipse 添加用户指定的目录贡献。在Window->Preferences->XML->XML Catalog 下选择User Specified Entries,然后选择Add按钮。
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.
然后,您可以添加架构的详细信息(如果连接断开,您可以在本地复制文件)。然后 Eclipse 将可以在验证期间访问该模式。
回答by Will Glass
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.
这是离线使用 Eclipse 时的常见问题。它试图从网络中获取模式。如果找不到,则表示验证错误。
I just ignore these errors. When you are back online, clean the project and they go away.
我只是忽略这些错误。当您重新联机时,清理项目,它们就会消失。
回答by skaffman
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.
我不确定你的问题是什么。您似乎在最后一段中自己回答了 - DWR 站点关闭,Eclipse 中的模式验证失败。请注意,Eclipse(即使使用 Spring IDE 插件)不使用 META-INF/spring.schemas 来解析命名空间,这是由 Eclipse 平台完成的。如果在架构位置找不到架构,则会出现这些错误。
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.
至于自动完成,如果找不到模式,Eclipse 仍会通过从文档中的现有结构进行推断来提供此功能。
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.
这不是应用程序本身的问题,因为 Spring 将使用 META-INF/spring.schemas 文件从 JAR 解析模式。