转自:https://my.oschina.net/zetaplusae/blog/144821

使用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">

如果希望保留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>

Spring AOP schema找不到报错 原的更多相关文章

  1. Spring AOP环绕异常影响的报错

    最近遇到一个问题,异常是: java.lang.ClassCastException: org.springframework.http.ResponseEntity cannot be cast t ...

  2. Spring AOP Schema aop:config、tx:advice

    Spring AOP Schema  aop:config.tx:advice 一.      利用aop:config标签实现AOP 首先看个例子,如下 接口代码: package com.lei. ...

  3. Highgui.imwrite("/data/pic1111.png", mat)失败,且找不到报错

    ——> Highgui.imwrite("/data/pic1111.png", mat)失败,且找不到报错. ok -->直接使用以下代码,自己保存mat,从而可以跟 ...

  4. 【spring boot】【elasticsearch】spring boot整合elasticsearch,启动报错Caused by: java.lang.IllegalStateException: availableProcessors is already set to [8], rejecting [8

    spring boot整合elasticsearch, 启动报错: Caused by: java.lang.IllegalStateException: availableProcessors ], ...

  5. 【spring boot】spring cloud下spring boot微服务启动没有报错,但是访问访问不到

    spring cloud下spring boot微服务启动没有报错,但是访问访问不到 解决方法: 可能是端口被占用了,但是依旧启用成功了. 更改一下项目启用的端口号,再重新启动查看是否可以正常访问.

  6. Bug集锦-Spring Cloud Feign调用其它接口报错

    问题描述 Spring Cloud Feign调用其它服务报错,错误提示如下:Failed to instantiate [java.util.List]: Specified class is an ...

  7. 关于Spring运用过程中jar包报错问题

    使用Spring进行web开发时,第一步就是导入jar包,今天使用SPring Task开发定时器时,导入了好多次jar包,都是报错,不知道是因为jar包版本不同还是因为需要依赖的jar包没加入,反正 ...

  8. spring框架中beans.xml文件报错XmlBeanDefinitionStoreException

    第一次构建spring,实现简单的注入方式,就发生了beans.xml文件报错,报错信息如下图 org.springframework.beans.factory.xml.XmlBeanDefinit ...

  9. Spring Boot错误——SpringBoot 2.0 报错: Failed to configure a DataSource: 'url' attribute is not specified and no embedded datasource could be configured.

    背景 使用Spring Cloud搭建微服务,服务的注册与发现(Eureka)项目启动时报错,错误如下 *************************** APPLICATION FAILED T ...

随机推荐

  1. Spring的依赖注入概述

    以下内容引用自http://wiki.jikexueyuan.com/project/spring/dependency-injection.html: 每个基于Java应用程序都有几个对象,这些对象 ...

  2. SUPEROBJECT序列数据集为JSON

    // SUPEROBJECT 序列数据集 cxg 2017-1-12// {"data":[{"c1":1,"c2":1}]};// DEL ...

  3. Android访问网络数据的几种方式Demo

    Android应用经常会和服务器端交互,这就需要手机客户端发送网络请求,下面介绍四种常用网络请求方式,我这边是通过Android单元测试来完成这四种方法的,还不清楚Android的单元测试的同学们请看 ...

  4. [转]文件IO详解(二)---文件描述符(fd)和inode号的关系

    原文:https://www.cnblogs.com/frank-yxs/p/5925563.html 文件IO详解(二)---文件描述符(fd)和inode号的关系 ---------------- ...

  5. Solidworks如何标注垂直度,平行度

    1 标注一个基准特征,放到一个平面的线上即可,比如下图生成了一个基准面A   2 点击形位公差,设置形位公差的符号,公差值,相对基准面(主要那一栏),然后不要点确定,直接在图上点击某个面,就生成一个形 ...

  6. weex 项目 创建 远程 icon

    一.创建 远程 icon 步骤一:打开  阿里巴巴矢量图标库 官网:http://www.iconfont.cn/ 步骤二:选择项目需要的 icon 步骤三:添加到项目(没有项目会自动创建) 步骤四: ...

  7. Collection接口和Collections类的简单区别和讲解

    这里仅仅进行一些简单的比较,如果你想要更加详细的信息话,请自己百度. 1.Collection: 是集合类的上层接口.本身是一个Interface,里面包含了一些集合的基本操作. Collection ...

  8. 一场由股票提醒助手插件引发的血案——浅入浅出 jquery autocomplete

    我没有学过前端,所以这篇文章注定要班门弄斧了. 通常,须要用到什么技术什么语言时,我才去学,学了也不一定掌握,就是记不住!所以如今明确了.学习的时候,亦或是攻克难点的时候,一定要记录下来.并不一定非要 ...

  9. 第六十题(在O(1)时间内删除链表结点)

    题目:给定链表的头指针和一个结点指针,在O(1)时间删除该结点. 思路:将待删除节点下一个节点的数据赋给当前节点.删除下一个节点就可以.

  10. 解压Zip

    import java.io.BufferedOutputStream; import java.io.File; import java.io.FileOutputStream; import ja ...