2014年5月31日土曜日

SpringでprivateメソッドにもTransactionalアノテーションを適用させる

SpringでprivateメソッドにもTransactionalアノテーションを適用させるにはAspectJを使う必要がある。
以下設定例。

 ■XML
  <tx:annotation-driven mode="aspectj"/>
  <context:annotation-config/>
  <context:load-time-weaver/>

■VM arguments
-javaagent:/path/spring-instrument-4.0.5.RELEASE.jar 

■必要なJAR(以下はcradleの例)
compile 'org.springframework:spring-core:4.0.5.RELEASE'
compile 'org.springframework:spring-context:4.0.5.RELEASE'
compile 'org.springframework:spring-jdbc:4.0.5.RELEASE'
compile 'org.springframework:spring-aspects:4.0.5.RELEASE'
compile 'org.springframework:spring-instrument:4.0.5.RELEASE'
compile 'org.aspectj:aspectjrt:1.8.0'
compile 'org.aspectj:aspectjweaver:1.8.0'

0 件のコメント:

コメントを投稿