ssh整合,导入structs包后报错 getAnnotation(AnnotatedElement ae,Class<T> annotatetype)找不到...

  今天在整合ssh(spring-framework-3.2.5.RELEASE-dist+struts-2.3.15.3-all+hibernate-release-4.2.6.Final)环境的时候,集成了hibernate和spring,经过单元测试,没有问题,集成成功。但是在导入structs包后,项目报错,具体错误如下:

  Caused by: org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'entityManagerFactory' defined in class path resource [bean.xml]: Cannot resolve reference to bean 'dataSource' while setting bean property 'dataSource'; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'dataSource' defined in class path resource [bean.xml]: Initialization of bean failed; nested exception is java.lang.NoSuchMethodError: org.springframework.core.annotation.AnnotationUtils.getAnnotation(Ljava/lang/reflect/AnnotatedElement;Ljava/lang/Class;)Ljava/lang/annotation/Annotation;

 

   找不到 getAnnotation(AnnotatedElement ae,Class<T> annotatetype)这样的方法,于是我查找了项目中使用spring版本的文档,发现下面这个方法:

 

public static <T extends Annotation> T getAnnotation(AnnotatedElement ae,
                                     Class<T> annotationType)
  Get a single Annotation of annotationType from the supplied Method, Constructor or Field. Meta-annotations will be searched if the annotation is not declared locally on the supplied element.
Parameters:
ae - the Method, Constructor or Field from which to get the annotation
annotationType - the annotation class to look for, both locally and as a meta-annotation
Returns:
the matching annotation or null if not found
Since:
3.1

  文档中显示,3.1以后版本才有这个方法,这是就猜想项目中是不是有3.1一下版本的spring核心包,经过查找,在struts-2.3.15.3这个版本中包含了spring-core-3.0.5.RELEASE.jar这样一个jar包,低于3.1版本。

  在项目中删除spring-core-3.0.5.RELEASE.jar这个jar,问题就解决了

  另外:使用struts-2.3.15.3 需要注意,此版本中包含了包含里除了spring-core-3.0.5.RELEASE.jar以外的spring需要3.0.5版本的jar包,在使用的时候都需要删除

转载于:https://www.cnblogs.com/wolfgump/p/3463170.html

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值