【问题标题】:Error creating Spring Profiles创建 Spring 配置文件时出错
【发布时间】:2015-06-22 18:16:04
【问题描述】:

我收到错误:

 cvc-complex-type.2.4.a: Invalid content was found starting with element
 'sec:http'. One of '{"http://www.springframework.org/schema/beans":beans}'
 is  expected.

我只是用数据源创建一个本地弹簧配置文件,但不知道我需要包含什么。

我的命名空间配置包括:

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

发生错误是因为:&lt;beans profile="local"&gt;&lt;/beans&gt;

【问题讨论】:

    标签: xml spring spring-profiles


    【解决方案1】:

    该错误与您的个人资料无关。该错误是因为在您的问题中未包含的 xml 中的某处,您正在使用 spring security xml 模式。您尚未在 xsd 中声明它。这个更新的 xml 架构应该可以解决您的问题(如果我猜错了,请修复版本号)...

    <beans xmlns="http://www.springframework.org/schema/beans"
       xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
       xmlns:c="http://www.springframework.org/schema/c"
       xmlns:context="http://www.springframework.org/schema/context"
       xmlns:sec="http://www.springframework.org/schema/security"
       xsi:schemaLocation="http://www.springframework.org/schema/beans
          http://www.springframework.org/schema/beans/spring-beans-3.2.xsd
          http://www.springframework.org/schema/context
          http://www.springframework.org/schema/context/spring-context-3.2.xsd
          http://www.springframework.org/schema/security
          http://www.springframework.org/schema/security/spring-security-3.1.xsd">
    

    【讨论】:

    • 包含 spring 配置文件的 xml 不包含任何与安全相关的内容,这让我感到困惑。我实际上虽然这是原因,但这对我来说没有意义。我将查看我的其他 xml。我真的很感激。
    • 这显然是您发布的错误。如果您需要帮助,您需要发布所有文件和完整的堆栈跟踪
    【解决方案2】:

    问题是由 contextConfigLocation 中的参数值排序引起的。

    【讨论】:

      猜你喜欢
      • 2016-02-26
      • 1970-01-01
      • 1970-01-01
      • 2019-06-22
      • 1970-01-01
      • 2022-11-14
      • 1970-01-01
      • 2020-09-18
      • 1970-01-01
      相关资源
      最近更新 更多