【问题标题】:java.lang.NoSuchMethodError: org.springframework.aop.config.AopNamespaceUtils with Spring 4java.lang.NoSuchMethodError: org.springframework.aop.config.AopNamespaceUtils 与 Spring 4
【发布时间】:2014-04-26 20:45:46
【问题描述】:

您好,我正在使用 Hibernate 4,最近升级到 Spring 4。我在下面的 hibernate.xml 中收到此错误

java.lang.NoSuchMethodError: org.springframework.aop.config.AopNamespaceUtils.registerAutoProxyCreatorIfNecessary

    <beans xmlns="http://www.springframework.org/schema/beans"
    xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:tx="http://www.springframework.org/schema/tx"
    xsi:schemaLocation="http://www.springframework.org/schema/beans
http://www.springframework.org/schema/beans/spring-beans-4.0.xsd
http://www.springframework.org/schema/tx
http://www.springframework.org/schema/tx/spring-tx-4.0.xsd">
    <tx:annotation-driven />
    <!-- Hibernate session factory -->
    <bean id="sessionFactory"
        class="org.springframework.orm.hibernate4.LocalSessionFactoryBean">
        <property name="dataSource">
            <ref bean="dataSource" />
        </property>
        <property name="hibernateProperties">
            <props>
                <prop key="hibernate.dialect">${hibernate.dialect}</prop>
                <prop key="hibernate.show_sql">${hibernate.show_sql}</prop>
                <prop key="hibernate.generate_statistics">${hibernate.generate_statistics}</prop>
                <prop key="hibernate.hbm2ddl.auto">${hibernate.hbm2ddl.auto}</prop>
                <prop key="hibernate.cache.use_second_level_cache">${hibernate.cache.use_second_level_cache}</prop>
                <prop key="hibernate.cache.region.factory_class">${hibernate.cache.region.factory_class}
                </prop>
                <prop key="net.sf.ehcache.configurationResourceName">${net.sf.ehcache.configurationResourceName}</prop>
                <prop key="hibernate.cache.use_query_cache">${hibernate.cache.use_query_cache}</prop>
                <prop key="hibernate.cache.use_structured_entries">${hibernate.cache.use_structured_entries}</prop>
                <prop key="hibernate.jdbc.batch_size">${hibernate.jdbc.batch_size}</prop>
                <prop key="hibernate.order_inserts">${hibernate.order_inserts}</prop>
                <prop key="hibernate.order_updates">${hibernate.order_updates}</prop>
            </props>
        </property>
        <property name="packagesToScan" value="com.pumpkinsafari.store.model">
        </property>
    </bean>
    <bean id="transactionManager"
        class="org.springframework.orm.hibernate4.HibernateTransactionManager">
        <property name="sessionFactory" ref="sessionFactory" />
    </bean>

</beans>    

请帮助我,这似乎是 SPRING 4 aop deprecation 问题。但是有什么办法可以克服这个问题。我也在使用 hibernate jpa api jars

【问题讨论】:

  • 如果您遇到此类错误,您可能正在混合使用 spring 版本。检查您使用的依赖项的实际类路径。使用 maven 时,请使用 mvn dependency:tree 获取依赖项列表。
  • 是的,实际错误是因为 spring dao 的类文件现在包含在 spring tx 4 版本中,因此发生冲突。用于选择后者的类加载器。但是 mvndependecy:tree 确实有帮助跨度>
  • 你可以在这里找到答案:stackoverflow.com/a/20981458/3343174

标签: spring hibernate spring-mvc jpa spring-4


【解决方案1】:

您好,我认为问题是我在之前版本中使用的 2.0.8 依赖项的原因,现在似乎包含在 spring tx 模块中..

问候

【讨论】:

    猜你喜欢
    • 2016-04-29
    • 2016-12-15
    • 2014-08-14
    • 2013-01-12
    • 1970-01-01
    • 1970-01-01
    • 2020-06-20
    • 1970-01-01
    • 2017-05-28
    相关资源
    最近更新 更多