java - Spring 事务管理器(注释样式)运行时错误

标签 java spring exception transactions

所以当我在我的 glassfish 应用程序服务器中加载我的 war 时,基本上我遇到了一个异常。我在我的 mysql 数据库中使用 Spring 的事务管理器。报告的错误(完整堆栈跟踪)如下:

java.lang.Exception: java.lang.IllegalStateException: ContainerBase.addChild: start: org.apache.catalina.LifecycleException: org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'org.springframework.transaction.annotation.AnnotationTransactionAttributeSource#0': 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;

我的applicationContext.xml文件如下:

<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:sws="http://www.springframework.org/schema/web-services"
   xmlns:tx="http://www.springframework.org/schema/tx"
   xmlns:oxm="http://www.springframework.org/schema/oxm"
   xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-3.0.xsd
   http://www.springframework.org/schema/web-services http://www.springframework.org/schema/web-services/web-services-2.0.xsd
   http://www.springframework.org/schema/tx
     http://www.springframework.org/schema/tx/spring-tx-3.0.xsd
   http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context-3.0.xsd
   http://www.springframework.org/schema/oxm http://www.springframework.org/schema/oxm/spring-oxm-3.0.xsd">

    <context:property-placeholder location="classpath:testjdbc.properties"/>

    <!-- enable the configuration of transactional behavior based on annotations -->
    <tx:annotation-driven transaction-manager="txManager"/>

      <bean id="dataSource" class="org.apache.commons.dbcp.BasicDataSource" destroy-method="close">
        <property name="driverClassName" value="${jdbc.driverClassName}" />
        <property name="url" value="${jdbc.url}" />
        <property name="username" value="${jdbc.username}" />
        <property name="passwprd" value="${jdbc.password}" />
      </bean>

      <bean name="licenseGenService" class="org.springframework.remoting.httpinvoker.HttpInvokerServiceExporter">
        <property name="service" ref="LicensingDaoImpl"/>
        <property name="serviceInterface" value="mypackage.LicensingDao"/>
      </bean>

      <bean id="txManager" class="org.springframework.jdbc.datasource.DataSourceTransactionManager">
        <property name ="dataSource" ref="dataSource" />
      </bean>

      <bean id="licenseDAO" class = "myPackage.LicenseDao">
        <constructor-arg ref="dataSource" />
      </bean>

      <bean id="licenseGenerator" class ="myPackage.LicenseGeneratorImpl">
        <constructor-arg ref = "licenseDAO" />
      </bean>

</beans>

我发现这个错误非常神秘,因为它提示的类甚至不在我的应用程序上下文中。顺便说一下,我正在使用 Spring 3.1。感谢您的任何建议或帮助。

最佳答案

查看您的类路径并确保那里只有您的所有 Spring 依赖项的一个 版本。

关于java - Spring 事务管理器(注释样式)运行时错误,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/9164001/

相关文章:

python - 为什么 str(KeyError) 添加额外的引号?

iphone - 应用程序崩溃,需要帮助理解错误

php - 尝试将数据插入 blob 时发生 PDO 异常

Java:将一个列表拆分为两个子列表?

java - Process.waitfor 会使服务/Activity 进入休眠状态还是会消耗 CPU?

java - FusionAuthClient 单例

java - Gradle jettyRuns 可以工作,但 Eclipse 中没有依赖项

java - 带有 Java 的 Google 自然语言 API - setLanguage

java - 安卓:撤销权限

java - 获取 R2DBC 失败,此发布者不支持多订阅者