質問

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

<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になるはずです。この特定のTxAdviceを使用するように@Transactionalを言う方法はありますか?

<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>
.

役に立ちましたか?

解決

大丈夫、私はそれを考え出した。haha ..私は、追加のaop:advisoraop: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>
.

ライセンス: CC-BY-SA帰属
所属していません StackOverflow
scroll top