随笔-193  评论-715  文章-1  trackbacks-0
本Blog所有内容不得随意转载,版权属于作者所有。如需转载请与作者联系( fastzch@163.com )。
未经许可的转载,本人保留一切法律权益。
一直以来,发现有某些人完全不尊重我的劳动成果,随意转载,提醒一下那些人小心哪天惹上官司。


今天在WebSphere Application Server 6.1中部署使用Spring 2.5开发的应用时,遇到了不少网友遇到的问题,即Spring启动时会报如下错误:
cvc-elt.1: Cannot find the declaration of element 'beans'

在网上搜了一下,发现有很多人提供了解决的办法,但我一一试过,最终都不行。
解决方案列表如下:
1、[分享]Spring启动异常: cvc-elt.1: Cannot find the declaration of element 'beans'
2、spring从sun jdk到IBMjdk

这两篇文章中都提供了各自的解决方法,但为何在我的应用中就是不行了?
其实不是不行,而是需要根据Spring的版本不同,进行不同的处理,刚好我用的是Spring2.5,所以解决起来需要另一种方法,即配置文件XML的头部的声明应该为:
<?xml version="1.0" encoding="UTF-8"?>

<!--
  - Application context definition for JPetStore's business layer.
  - Contains bean references to the transaction manager and to the DAOs in
  - dataAccessContext-local/jta.xml (see web.xml's "contextConfigLocation").
  
-->
<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"
>

这段声明,是来自Spring2.5包中自带的Sample目录中的一些例子的代码中,当我把我的XML的头部改成这样以后,果然可以顺利启动。
posted on 2008-11-19 00:27 Robin's Programming World 阅读(24160) 评论(6)  编辑  收藏 所属分类: JavaWebshere

评论:
# re: WebSphere6.1中使用Spring报cvc-elt.1: Cannot find the declaration of element 'beans'异常的解决办法 2008-11-19 09:30 | 低调
本回复不得随意转载,版权属于回复者所有。如需转载请与回复者联系( congdepeng@163.com )。
未经许可的转载回复,本人保留一切法律权益。
一直以来,发现有某些人完全不尊重我的回复成果,随意转载回复,提醒一下那些人小心哪天惹上官司。
  回复  更多评论
  
# re: WebSphere6.1中使用Spring报cvc-elt.1: Cannot find the declaration of element 'beans'异常的解决办法 2008-11-20 18:09 | 隔叶黄莺
说只是这么说,真要到什么程度作者才会动起这种真格来呢?我的许多文章还不被很多人无情的窃走了,不提原作者倒也不很意外,关建还打上他自己的名字。  回复  更多评论
  
# re: WebSphere6.1中使用Spring报cvc-elt.1: Cannot find the declaration of element 'beans'异常的解决办法 2009-04-18 13:58 | 主演的
师大发师大发是  回复  更多评论
  
# re: WebSphere6.1中使用Spring报cvc-elt.1: Cannot find the declaration of element 'beans'异常的解决办法 2009-12-14 14:11 | 8888888
@隔叶黄莺
关你鸟事  回复  更多评论
  
# 我就转了,看你能把我怎么样 2009-12-14 14:13 | 廗kyffvknlhj;lijkljn
我就转了,看你能把我怎么样  回复  更多评论
  
# re: WebSphere6.1中使用Spring报cvc-elt.1: Cannot find the declaration of element 'beans'异常的解决办法[未登录] 2013-12-17 11:05 | eric
谢谢 帮了我一个忙  回复  更多评论
  

只有注册用户登录后才能发表评论。


网站导航: