gpt4 book ai didi

java - "cvc-complex-type.2.4.c: matching wildcard is strict, but no declaration can be found for element ' 上下文 :component-scan '."

转载 作者:行者123 更新时间:2023-12-01 12:45:08 24 4
gpt4 key购买 nike

我在 spring-servlet.xml 中收到以下错误

通配符匹配严格,但找不到元素“context:component-scan”的声明。

我的 spring-servlet.xml 具有以下内容:

<?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:context="http://www.springframework.org/schema/context"
xmlns:oauth="http://www.springframework.org/schema/security/oauth2"
xmlns:sec="http://www.springframework.org/schema/security"
xmlns:mvc="http://www.springframework.org/schema/mvc"
xmlns:tx="http://www.springframework.org/schema/tx"

xsi:schemaLocation="
http://www.springframework.org/schema/security/oauth2
http://www.springframework.org/schema/security/spring-security-oauth2-1.0.xsd
http://www.springframework.org/schema/mvc
http://www.springframework.org/schema/mvc/spring-mvc-3.1.xsd
http://www.springframework.org/schema/tx
http://www.springframework.org/schema/tx/spring-tx-3.1.xsd
http://www.springframework.org/schema/security
http://www.springframework.org/schema/security/spring-security-3.1.xsd
http://www.springframework.org/schema/beans
http://www.springframework.org/schema/beans/spring-beans-3.1.xsd
http://www.springframework.org/schema/context
http://www.springframework.org/schema/context/spring-context.xsd ">



<!-- Scans the classpath of this application for Spring annotations such
as @Component, @Service, @Controller and @Repositry to deploy as beans. For
example, the ClaimsService is annotated with @Service("claimsService") which
means that spring will automatically create a bean with the name claimsService.
-->
<context:component-scan base-package="org.springframework.security.oauth" />

我已经下载了所有依赖项

最佳答案

问题在于 namespaces 检查添加的 spring jar 的版本和命名空间。特别是对于上下文命名空间的架构位置,

xmlns:context="http://www.springframework.org/schema/context"

请查看spring docs还为 spring security 配置 namespace 。不要添加任何不必要的 namespace

关于java - "cvc-complex-type.2.4.c: matching wildcard is strict, but no declaration can be found for element ' 上下文 :component-scan '.",我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/24776177/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com