1.情景展示
eclipse中,spring配置文件報錯信息如下:
配置文件頭部引用信息為:
<?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:p="http://www.springframework.org/schema/p" xmlns:context="http://www.springframework.org/schema/context" xmlns:mvc="http://www.springframework.org/schema/mvc" xmlns:task="http://www.springframework.org/schema/task" xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-3.0.xsd http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context-3.0.xsd http://www.springframework.org/schema/task http://www.springframework.org/schema/task/spring-task-3.0.xsd">
2.解決方案
將配置文件中的xsd文件的版本號去掉即可。
<?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:p="http://www.springframework.org/schema/p" xmlns:context="http://www.springframework.org/schema/context" xmlns:mvc="http://www.springframework.org/schema/mvc" xmlns:task="http://www.springframework.org/schema/task" 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/task http://www.springframework.org/schema/task/spring-task-xsd">
去掉之后,已經不報錯了!
3.可能會出現的情況
雖然eclipse不再報錯,但是,在運行該項目時報錯,即找不到對應的xsd,
如果你的也是這種情況,那只能讓eclipse提示報錯了,就是看着難受點。