Spring AOP schema找不到报错
2013-07-15 22:37
459 查看
问题:
使用jersey+spring构建RESTful服务,并将应用部署在不能连接外网的服务器上。部署时,报错信息如下,WARNING: Ignored XML validation warning org.xml.sax.SAXParseException: schema_reference.4: Failed to read schema document 'http://www.springframework.org/schema/aop/spring-aop-3.0.xsd', because 1) could not find the document; 2) the document could not be read; 3) the root element of the document is not <xsd:schema>. at com.sun.org.apache.xerces.internal.util.ErrorHandlerWrapper.createSAXParseException(ErrorHandlerWrapper.java:195) at com.sun.org.apache.xerces.internal.util.ErrorHandlerWrapper.warning(ErrorHandlerWrapper.java:96) ...
SEVERE: Context initialization failed org.springframework.beans.factory.xml.XmlBeanDefinitionStoreException: Line 16 in XML document from class path resource [cn/edu/seu/herald/ws/applicationContext.xml] is invalid; nested exception is org.xml.sax.SAXParseException: cvc-complex-type.2.4.c: The matching wildcard is strict, but no declaration can be found for element 'aop:aspectj-autoproxy'. at org.springframework.beans.factory.xml.XmlBeanDefinitionReader.doLoadBeanDefinitions(XmlBeanDefinitionReader.java:396) at org.springframework.beans.factory.xml.XmlBeanDefinitionReader.loadBeanDefinitions(XmlBeanDefinitionReader.java:334) at org.springframework.beans.factory.xml.XmlBeanDefinitionReader.loadBeanDefinitions(XmlBeanDefinitionReader.java:302) ...
也就是,找不到如下的元素的声明
<aop:aspectj-autoproxy />
解决:
通过去除spring配置文件中schemaLocation的版本号(如2.0,3.0),让spring自己匹配版本。通常情况下,都是因为所依赖的spring版本号低于配置文件中指定的版本号。修改后如下<beans xmlns="http://www.springframework.org/schema/beans" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:context="http://www.springframework.org/schema/context" xmlns:aop="http://www.springframework.org/schema/aop" 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/aop http://www.springframework.org/schema/aop/spring-aop.xsd">[/code]
如果希望保留spring配置文件中的schema版本号,而所依赖spring版本号不小于配置文件对应版本号,那么问题很有可能出在依赖其他库时没有去除这些库对于spring的依赖(通常它们会依赖于低版本的spring,从而导致整个项目的spring版本出问题)。可以通过在pom.xml中,对于这些库,剔除spring依赖。例如我使用的jersey-spring,则修改pom.xml后如下,<dependency> <groupId>com.sun.jersey.contribs</groupId> <artifactId>jersey-spring</artifactId> <version>1.17.1</version> <exclusions> <exclusion> <groupId>org.springframework</groupId> <artifactId>spring</artifactId> </exclusion> <exclusion> <groupId>org.springframework</groupId> <artifactId>spring-core</artifactId> </exclusion> <exclusion> <groupId>org.springframework</groupId> <artifactId>spring-web</artifactId> </exclusion> <exclusion> <groupId>org.springframework</groupId> <artifactId>spring-beans</artifactId> </exclusion> <exclusion> <groupId>org.springframework</groupId> <artifactId>spring-context</artifactId> </exclusion> <exclusion> <groupId>org.springframework</groupId> <artifactId>spring-aop</artifactId> </exclusion> </exclusions> </dependency>
相关文章推荐
- 在cmd中报错:java找不到或无法加载主类
- com.sun.faces.config.ConfigureListener找不到报错
- spring配置文件xml文件开头总是有个红叉,是找不到schema文件
- 新创建的maven项目无法clean报错,提示在私服上找不到父包 'parent.relativePath' of POM com.tencent:weixin-web-base:[unknown-v
- 关于maven项目报错,但是找不到问题的所在的一个解决办法
- 关于Drupal中使用hook_schema建立数据库报错PDOException: SQLSTATE[42000]的解决办法
- sklearn报错解决 ImportError: DLL load failed: 找不到指定的模块
- pyintaller 打包flask_bootstrap时,会有找不到bootstrap/wtf.html报错的问题,解决方法如下
- gson报错找不到类
- linux下RBAC找不到报错修复
- openfire服务器报错,登录时绑定资源找不到session
- ssm中spring mvc找不到控制器,报错404
- IntelliJ的坑:一个Project里有多个Module时,springboot启动后,报错404,页面找不到
- c++ template 多层继承下找不到纯虚拟函数实现 报错:undefined reference to "xxx"
- 使用eclipse运行项目报错,找不到类的问题
- Javah 使用时报错:找不到类
- window运行gradle build -- --stacktrace出现找不到文件framework-4.3.0.BUILD-SNAPSHOT-schema.zip异常
- Spring的配置文件xml中报错:xml文件报错Referenced file contains errors (http://www.springframework.org/schema/cont
- wince重新导出SDK后 编译应用程序报错找不到"pkfuncs.h"
- Javah 使用时报错:找不到类