【问题标题】:Eclipse cannot resolve Spring 3 mvc schemaEclipse 无法解析 Spring 3 mvc 模式
【发布时间】:2014-03-07 10:50:13
【问题描述】:

我正在使用 Spring 3.2.6 并尝试使用该标签。问题是 Eclipse 似乎无法找到 mvc 命名空间。 这是我的 XML:

<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:mvc="http://www.springframework.org/schema/mvc"
        xmlns:context="http://www.springframework.org/schema/context"
        xsi:schemaLocation="http://www.springframework.org/schema/beans
                            http://www.springframework.org/schema/beans/spring-beans.xsd
                            http://www.springframework.org/schema/context
                            http://www.springframework.org/schema/context/spring-context.xsd
                            http://www.springframework.org/schema/mvc/spring-mvc
                http://www.springframework.org/schema/mvc/spring-mvc-3.2.xsd
                            http://www.springframework.org/schema/aop
                            http://www.springframework.org/schema/aop/spring-aop.xsd">

我尝试过不使用“http://www.springframework.org/schema/mvc/spring-mvc.xsd”版本,但仍然无法正常工作。 Eclipse 无法自动完成“mvc”。如果我尝试运行它,我会得到“cvc-complex-type.2.4.c:匹配的通配符是严格的,但找不到元素'mvc:annotation-driven'的声明。”错误,我已经用谷歌搜索并没有太大帮助。

可以完成 aop 和上下文前缀,并且我的类路径中有 spring-webmvc-3.2.6.jar。 任何帮助将不胜感激。问候,Alexx

【问题讨论】:

  • 我建议你检查一下你是否在某些公司防火墙后面,这可能会阻止 eclipse 检查远程 xsd 资源
  • 不,不是这样。我可以看到 Window > Preferences > Network Connection > Cache 中列出的架构。

标签: java eclipse spring spring-mvc


【解决方案1】:

我猜你的 mvc 的 xsi:schemaLocation 有问题。

http://www.springframework.org/schema/mvc/spring-mvc改为

http://www.springframework.org/schema/mvc

【讨论】:

  • 谢谢,它有效。我真的应该以前看过。我想我有隧道视野。有时最好独自离开一会儿。
  • 不客气。如果它有效,请接受答案,以便帮助其他人轻松找到正确答案..... :)
【解决方案2】:

试试这个:

    <beans xmlns="http://www.springframework.org/schema/beans"
        xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
        xmlns:context="http://www.springframework.org/schema/context"
        xmlns:aop="http://www.springframework.org/schema/aop"
        xmlns:mvc="http://www.springframework.org/schema/mvc"
        xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd
            http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context.xsd 
http://www.springframework.org/schema/aop 
            http://www.springframework.org/schema/aop/spring-aop.xsd
            http://www.springframework.org/schema/mvc http://www.springframework.org/schema/mvc/spring-mvc.xsd">

【讨论】:

    【解决方案3】:

    我建议你使用 STS 它会节省你的时间http://spring.io/tools/sts

    【讨论】:

      【解决方案4】:
      <beans xmlns="http://www.springframework.org/schema/beans"
          xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
          xmlns:mvc="http://www.springframework.org/schema/mvc"
          xmlns:p="http://www.springframework.org/schema/p"
          xmlns:context="http://www.springframework.org/schema/context"
          xsi:schemaLocation="http://www.springframework.org/schema/mvc http://www.springframework.org/schema/mvc/spring-mvc.xsd
              http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd
              http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context.xsd">
      

      这是我目前在我的应用程序中使用的试试这个...

      【讨论】:

        猜你喜欢
        • 2014-12-18
        • 2022-11-16
        • 1970-01-01
        • 1970-01-01
        • 2015-05-28
        • 1970-01-01
        • 1970-01-01
        • 2019-02-20
        • 1970-01-01
        相关资源
        最近更新 更多