我的代码:我已经正确地配置了XML,添加了所有模式,但仍然会出错。
Config.xml
<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns="http://www.springframework.org/schema/beans"
xmlns:p="http://www.springframework.org/schema/p"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
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/spring-context-3.2.xsd"
xmlns:context="http://www.springframework.org/schema/context">
<context:annotation-config />
<context:component-scan base-package="com"/>
<bean id="bean1" class="com.pojos.BookInfo">
</bean>
</beans>
为xmlns:context="http://www.springframework.org/schema/context"
命名空间指定XSD的位置时出错:
更换
http://www.springframework.org/schema/spring-context-3.2.xsd
带有
http://www.springframework.org/schema/context/spring-context-3.2.xsd
总计:
<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns="http://www.springframework.org/schema/beans"
xmlns:p="http://www.springframework.org/schema/p"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
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"
xmlns:context="http://www.springframework.org/schema/context">
<context:annotation-config />
<context:component-scan base-package="com"/>
<bean id="bean1" class="com.pojos.BookInfo">
</bean>
</beans>