Spring AOP的配置问题
好长时间不维护自己的博客了,好象没有维护自己博客的习惯,只要将东西记到电子日记本上就完了。将东西放到网上晒一晒更好。
今天公司的网断了,然后发现Tomcat启动时竞然报错,报错的信息为
cvc-elt.1: Cannot find the declaration of element 'beans'
查了好长时间,最后定位是AOP的配置文件引起的。
配置文件的开头是
<beans xmlns="http://www.springframework.org/schema/beans"
?????? xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
?????? xmlns:aop="http://www.springframework.org/schema/aop"
?????? xmlns:tx="http://www.springframework.org/schema/tx"
?????? xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-2.5.xsd
?????? http://www.springframework.org/schema/aop http://www.springframework.org/schema/aop/spring-aop-2.5.xsd
?????? http://www.springframework.org/schema/tx http://www.springframework.org/schema/tx/spring-tx-2.5.xsd">
发现当Tomcat启动时xsd文档验证要到spring的官网上去查找,思来想去,觉得不应该呀,
使用DTD方式验证的时候也不需要非得联到互联网上呀。这几个文件应该在spring的schema的文件中有相应的
映射呀,解决spring.jar,恍然明白,原来spring是2.0.8版本,验证文件要与版本保持一致,一定可以,于是
配置文件头改为
<beans xmlns="http://www.springframework.org/schema/beans"
?????? xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
?????? xmlns:aop="http://www.springframework.org/schema/aop"
?????? xmlns:tx="http://www.springframework.org/schema/tx"
?????? xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-2.0.xsd
?????? http://www.springframework.org/schema/aop http://www.springframework.org/schema/aop/spring-aop-2.0.xsd
?????? http://www.springframework.org/schema/tx http://www.springframework.org/schema/tx/spring-tx-2.0.xsd">
重启tomcat,果然解决了。
?