cvc-complex-type.2.3: Element 'dependency' cannot have character [children], because the type's cont

 

 

给pom.xml添加jar包时候报错,本地仓库jar下载正常,但是页面报错,配置代码是从maven中央仓库复制的,

按道理不应该报错,想了想应该是网上复制的编码和本地项目的编码不一致造成的,

手动写了一遍不报错。问题解决,但是如果内容很多重写一遍太麻烦了,

发现从网上复制的代码中有一些特殊字符,删除后,重新复制到pom.xml文件中,错误消失。

转: https://blog.youkuaiyun.com/b452608/article/details/52205026

这个错误信息表明在XML文件中使用了`context:component-scan`元素,但该元素未被当前的XML Schema定义所识别。通常是因为`xsi:schemaLocation`中没有正确引用Spring的相关Schema文件。 ### 解决方案 你需要确保在XML文件的根标签中正确声明了`context`命名空间,并且在`xsi:schemaLocation`中包含了正确的Schema位置。以下是修正后的代码示例: ```xml <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" 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"> <!-- 使用 context 命名空间 --> <context:component-scan base-package="com.example.package"/> </beans> ``` #### 代码解释: 1. **xmlns:context**: 这一行声明了`context`命名空间,并将其绑定到`http://www.springframework.org/schema/context`。 2. **xsi:schemaLocation**: 这一行指定了XML Schema的位置,用于验证XML文件是否符合标准。这里需要同时包含`spring-beans.xsd`和`spring-context.xsd`。 3. **context:component-scan**: 这个元素告诉Spring扫描指定的基础包,自动检测并注册组件(如`@Component`, `@Service`, `@Repository`, `@Controller`等)。 如果你遗漏了`xsi:schemaLocation`中的`spring-context.xsd`,就会导致`context:component-scan`无法被识别,从而引发`cvc-complex-type.2.4.c`错误。 --- ###
评论
成就一亿技术人!
拼手气红包6.0元
还能输入1000个字符
 
红包 添加红包
表情包 插入表情
 条评论被折叠 查看
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值