Java Spring@Transactional未在事务中执行

Java Spring@Transactional未在事务中执行,java,spring,transactions,annotations,Java,Spring,Transactions,Annotations,我知道以前有人问过这个问题,这就是为什么我在请求帮助之前花了两天时间试图让@Transactional顺利工作的原因 在my applicationContext.xml中: 我创建了一个JpaTransactionManager 在我的中,我只在我的MVC层上使用我的组件扫描,而不是我的服务层。我正在将服务自动连接到我的mvc控制器中。您是否认为该服务自动连线错误?仅因为导致检测和使用可缓存批注而进行检查,并不意味着这将检测和使用您的事务批注。首先,有两种类型的缓存,上面的一种用于Sprin

我知道以前有人问过这个问题,这就是为什么我在请求帮助之前花了两天时间试图让@Transactional顺利工作的原因

在my applicationContext.xml中:

  • 我创建了一个JpaTransactionManager

  • 在我的中,我只在我的MVC层上使用我的组件扫描,而不是我的服务层。我正在将服务自动连接到我的mvc控制器中。您是否认为该服务自动连线错误?仅因为导致检测和使用可缓存批注而进行检查,并不意味着这将检测和使用您的事务批注。首先,有两种类型的缓存,上面的一种用于Spring方法缓存。我只提到@cacable,以表明aspectj在我的项目中起作用。如图所示,我在与
    <properties>
        <hibernate.version>3.6.0.Final</hibernate.version>
        <hibernate.validator.version>4.1.0.Final</hibernate.validator.version>
        <spring.version>3.2.4.RELEASE</spring.version>
    </properties>
    <dependencies>
        <dependency><groupId>org.hibernate</groupId>                <artifactId>hibernate-core</artifactId>             <version>${hibernate.version}</version></dependency>
        <dependency><groupId>org.hibernate</groupId>                <artifactId>hibernate-entitymanager</artifactId>    <version>${hibernate.version}</version></dependency>
        <dependency><groupId>org.hibernate</groupId>                <artifactId>hibernate-validator</artifactId>        <version>${hibernate.validator.version}</version></dependency>
        <dependency><groupId>org.springframework</groupId>          <artifactId>spring-aop</artifactId>                 <version>${spring.version}</version></dependency>
        <dependency><groupId>org.springframework</groupId>          <artifactId>spring-aspects</artifactId>             <version>${spring.version}</version></dependency>
        <dependency><groupId>org.springframework</groupId>          <artifactId>spring-core</artifactId>                <version>${spring.version}</version></dependency>
        <dependency><groupId>org.springframework</groupId>          <artifactId>spring-context</artifactId>             <version>${spring.version}</version></dependency>
        <dependency><groupId>org.springframework</groupId>          <artifactId>spring-context-support</artifactId>     <version>${spring.version}</version></dependency>
        <dependency><groupId>org.springframework</groupId>          <artifactId>spring-orm</artifactId>                 <version>${spring.version}</version></dependency>
        <dependency><groupId>org.springframework</groupId>          <artifactId>spring-tx</artifactId>                  <version>${spring.version}</version></dependency>
        <dependency><groupId>org.springframework</groupId>          <artifactId>spring-web</artifactId>                 <version>${spring.version}</version></dependency>
        <dependency><groupId>org.springframework</groupId>          <artifactId>spring-webmvc</artifactId>              <version>${spring.version}</version></dependency>
        ...
    </dependencies>
    
    <?xml version="1.0" encoding="UTF-8"?>
    <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:context="http://www.springframework.org/schema/context"
        xmlns:jee="http://www.springframework.org/schema/jee" xmlns:p="http://www.springframework.org/schema/p"
        xmlns:task="http://www.springframework.org/schema/task" xmlns:util="http://www.springframework.org/schema/util"
        xmlns:cache="http://www.springframework.org/schema/cache"
        xmlns:tx="http://www.springframework.org/schema/tx"
        xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-3.0.xsd
            http://www.springframework.org/schema/aop http://www.springframework.org/schema/aop/spring-aop-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/jee http://www.springframework.org/schema/jee/spring-jee-3.0.xsd
            http://www.springframework.org/schema/task http://www.springframework.org/schema/task/spring-task-3.0.xsd
            http://www.springframework.org/schema/util http://www.springframework.org/schema/util/spring-util-3.0.xsd
            http://www.springframework.org/schema/cache http://www.springframework.org/schema/cache/spring-cache.xsd
            http://www.springframework.org/schema/tx http://www.springframework.org/schema/tx/spring-tx-3.0.xsd">
    
        ....
        <cache:annotation-driven cache-manager="cacheManager" mode="aspectj"/>
        <tx:annotation-driven transaction-manager="transactionManager" mode="aspectj"/>
        ....
        <bean id="transactionManager" class="org.springframework.orm.jpa.JpaTransactionManager">
            <property name="dataSource" ref="mainDataSource" />
            <property name="entityManagerFactory" ref="entityManagerFactory" />
            <property name="jpaDialect" ref="jpaDialect" />
        </bean>
        <!-- Service -->
        <bean class="...ClientService" />
        ....
    </beans>