Referenced file contains errors
(https://www.springframework.org/schema/beans/spring-beans-4.0.xsd).
刪除 <mvc:annotation-driven/> 後不報錯。
Spring 配置文件頂部 <beans ...> 的 xsi:schemaLocation 中,namespace 版本號與項目實際引用的 Spring JAR 版本不一致。
例如:項目用 Spring 5.3.x,但 XML 寫死 spring-beans-4.0.xsd,MyEclipse 驗證時下載 4.0 XSD 校驗,發現 mvc:annotation-driven 在 4.0 中定義不同或缺失,報錯。
xsi:schemaLocation 中的版號統一為項目實際版本(或去掉版號用「無版本」模式)。<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns="https://www.springframework.org/schema/beans"
xmlns:xsi="https://www.w3.org/2001/XMLSchema-instance"
xmlns:context="https://www.springframework.org/schema/context"
xmlns:mvc="https://www.springframework.org/schema/mvc"
xsi:schemaLocation="
https://www.springframework.org/schema/beans https://www.springframework.org/schema/beans/spring-beans.xsd
https://www.springframework.org/schema/context https://www.springframework.org/schema/context/spring-context.xsd
https://www.springframework.org/schema/mvc https://www.springframework.org/schema/mvc/spring-mvc.xsd">
<mvc:annotation-driven/>
<context:component-scan base-package="com"/>
<bean class="org.springframework.web.servlet.view.InternalResourceViewResolver">
<property name="prefix" value="/view/"/>
<property name="suffix" value=".jsp"/>
</bean>
</beans>
Validation → 勾選 Use namespace version from project libraries。Preferences → XML → XML Catalog 添加本地 XSD 映射。Spring XML 的 schemaLocation 版號必須與項目依賴的 Spring 版本一致,建議直接寫無版本路徑(spring-beans.xsd)讓容器自動匹配。