2016-12-01 380 views
0

我试图让一个JIRA Listener与tutorial但教程是过时的,我遇到了一个问题。插件生产,安装,但是当我要注册监听我越来越JIRA问题事件监听器

Class [com.example.tutorial.plugins.IssueCreatedResolvedListener] is not of type JiraListener. 

我试图做到这一点的JIRA 6.4.13,但教程JIRA 7.x版亦将apprieciated。

回答

0

最近的Jira版本使用Spring Scanner,如https://bitbucket.org/atlassian/atlassian-spring-scanner所述。一般来说,你应该:

  • 的pom.xml附加提供的依赖于Atlassian的弹簧扫描仪的注释
  • 创建的src /主/资源/ META-INF一个Spring XML文件/ spring/;
  • 删除任何component-import from atlassian-plugin.xml;
  • 而不是删除component-import,add @Component注释到您的监听器类;
  • 你类应该实现的InitializingBeanDisposableBean的LifecycleAware接口;
  • overover afterPropertiesSet()注册您的监听器。

所以,你的代码应该看起来像这样

@ExportAsService 
@Component 
@Named("IssueCreatedResolvedListener") 
public class IssueCreatedResolvedListener implements InitializingBean, DisposableBean, LifecycleAware { 
    @ComponentImport 
    private final ApplicationProperties applicationProperties; 
    @ComponentImport 
    private final EventPublisher eventPublisher; 
    @ComponentImport 
    protected final LifecycleManager lifecycleManager; 

    @Inject 
    public IssueCreatedResolvedListener(final ApplicationProperties applicationProperties, final EventPublisher eventPublisher, 
     final LifecycleManager lifecycleManager) { 
     this.applicationProperties = applicationProperties; 
     this.eventPublisher = eventPublisher; 
     this.lifecycleManager = lifecycleManager; 
    } 

    @Override 
    public void afterPropertiesSet() { 
     eventPublisher.register(this); 
    } 

    @EventListener 
    public void onIssueEvent(IssueEvent issueEvent) { 
     ... 
    } 

    ... 

} 

希望这有助于!