spring 1.x 使用DOCTYPE,而2.x是用schema,
1.x需要这样定义xml
<!DOCTYPE beans PUBLIC "-//SPRING//DTD BEAN//EN" "http://www.springframework.org/dtd/spring-beans.dtd">
2.x
<beans
xmlns="http://www.springframework.org/schema/beans"
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-2.0.xsd">
jar包和xml不匹配 会出现xml加载错误 告诉你beans都没有定义。
我的项目出错原因是由于前面的其他错误怀疑spring版本问题把spring2.0换成了spring1.2,而我使用的Spring IDE是以前配置的Spring1.x版本。改用配置文件为XML DTD解析方式就可以了,或者更新Spring IDE为2.x版本也可以解决问题。
1.x需要这样定义xml
<!DOCTYPE beans PUBLIC "-//SPRING//DTD BEAN//EN" "http://www.springframework.org/dtd/spring-beans.dtd">
2.x
<beans
xmlns="http://www.springframework.org/schema/beans"
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-2.0.xsd">
jar包和xml不匹配 会出现xml加载错误 告诉你beans都没有定义。
我的项目出错原因是由于前面的其他错误怀疑spring版本问题把spring2.0换成了spring1.2,而我使用的Spring IDE是以前配置的Spring1.x版本。改用配置文件为XML DTD解析方式就可以了,或者更新Spring IDE为2.x版本也可以解决问题。