扩展JIRA中的现有组件类

时间:2015-07-16 11:29:19

标签: java dependency-injection jira

我正在为Jira 6.3编写插件 我想扩展Jira的界面com.atlassian.jira.bc.issue.attachment.AttachmentService

public interface MyAttachmentService extend AttachmentService {
    ...
}

然后我实现了我的界面:

public class MyDefaultAttachmentService extends DefaultAttachmentService implements MyAttachmentService {
    ...
}

我将我的类定义为atlassian-plugin.xml中的一个组件:

<component key="myAttachmentService" name="MyAttachmentService" class="com.my.plugin.issue.attachment.MyDefaultAttachmentService">
    <interface>com.my.plugin.issue.attachment.MyAttachmentService</interface>
</component>

我有如何使用我的插件类(依赖注入):

public class DoSomethingWithAttachmentAction extends AbstractIssueSelectAction 
{
    private final MyAttachmentService myAttachmentService ;

    public DoSomethingWithAttachmentAction(MyAttachmentService myAttachmentService) {
        this.myAttachmentService = myAttachmentService;
    }

    public String doExecute() {
        myAttachmentService.someMethod();
    }
}

但是我在运行时遇到以下错误:

Caused by: org.springframework.beans.factory.NoSuchBeanDefinitionException: No unique bean of type [com.atlassian.jira.bc.issue.attachment.AttachmentService] is defined: expected single matching bean but found 2: [attachmentService, myAttachmentService]
    at org.springframework.beans.factory.support.DefaultListableBeanFactory.resolveDependency(DefaultListableBeanFactory.java:621)
    ...

如何修复它并使用我的新组件?

1 个答案:

答案 0 :(得分:0)

尝试同时使用component-import并说出要使用的接口 - MyAttachmentService,这应该配置spring ioc