插件里使用@Transactional注解实现事务
https://github.com/atlascommunity/jira-plugins-groovy这款插件的做法
jira的ao模块,默认是不支持@Transactional注解,如果需要使用事务,可以显式声明事务:
import
com.atlassian.jira.transaction.Transaction;
import
com.atlassian.jira.transaction.Txn;
Transaction txn = Txn.begin();
try
{
...
txn.commit();
...
}
finally
{
txn.finallyRollbackIfNotCommitted();
但是这样,稍显麻烦,最近查看了一款官方开源插件(https://github.com/atlascommunity/jira-plugins-groovy),这款插件里面是通过注解的方式实现事务的,实现方式如下
需要在pom文件里,增加aop支持,添加位置:
代码:
< Import-Package > <!-- imports --> org.springframework.osgi.*;resolution:="optional", org.eclipse.gemini.blueprint.*;resolution:="optional", <!-- spring imports --> org.springframework.aop, org.springframework.core, <!-- jira stuff --> com.atlassian.jira.plugin.webfragment.conditions, com.atlassian.jira.issue.customfields.searchers, com.atlassian.jira.jql.operand, <!-- required for spring lifecycle annotations --> <!--javax.annotation,--> <!-- exclude stuff for querydsl pocketknife --> !net.sf.cglib.proxy, !org.jvnet.hudson.annotation_indexer, <!-- everything else --> *;resolution:=optional </ Import-Package > < Require-Bundle >org.apache.felix.framework</ Require-Bundle > |
另外,需要增加几个类:
然后,就可以在service的方法上使用@Transactional注解了
react页面js不用加AJS.params.loggedInUser判断了,统一后台加,并且登录后会自动跳转
posted on 2021-02-09 18:50 Sunshine-jcy 阅读(172) 评论(0) 编辑 收藏 举报