0

私は自分のプロジェクトをアップグレードしようとしているので、トランザクションに来ました。これが私が今までやっていた方法です。

<bean id="userServiceTarget" class="com.forgin.service.UserServiceImpl">
    <property name="userDAO" ref="userDAO" />
</bean>

<bean id="userService" class="org.springframework.transaction.interceptor.TransactionProxyFactoryBean">
        <property name="target" ref="userServiceTarget" />
        <property name="transactionManager" ref="transactionManager" />
        <property name="transactionAttributes">
            <props>
                <prop key="get*">PROPAGATION_SUPPORTS</prop>
                <prop key="is*">PROPAGATION_SUPPORTS</prop>
                <prop key="save*">PROPAGATION_REQUIRED</prop>
                <prop key="remove*">PROPAGATION_REQUIRED</prop>
            </props>
        </property>
</bean>

以下のようにトランザクション属性を変更しましたが、サービスを正確にこれにリンクする方法がよくわかりませんtxAdvice。私は通常、サービスごとに異なるトランザクション属性を持っているため、複数あるはずですtxAdvice@Transactionalこの特定の txAdvice を使用する方法はありますか?

<tx:advice id="txAdvice">
    <tx:attributes>
        <tx:method name="get*" read-only="true" />
        <tx:method name="is*" read-only="true" />
        <tx:method name="save*" propagation="REQUIRED" />
        <tx:method name="remove*" propagation="REQUIRED" />
    </tx:attributes>
</tx:advice>
4

1 に答える 1

0

わかりました、私はそれを理解しました..それはちょうど私に来ました。ハハ..追加aop:advisorの とを提供する必要がありaop:pointcutます。それと同じくらい簡単です。

<aop:config>
    <aop:pointcut id="userOperation"
            expression="execution(* com.forgin.service.UserServiceImpl.*(..))" />
    <aop:advisor advice-ref="txAdvice" pointcut-ref="serviceOperation" />
        <aop:pointcut id="differentOperation"
            expression="execution(* com.forgin.service.DifferentServiceImpl.*(..))" />
    <aop:advisor advice-ref="txAdviceDifferent" pointcut-ref="differentOperation" />
</aop:config>
于 2011-05-13T15:50:46.043 に答える