java - 扩展 JIRA 中现有的组件类

标签 java dependency-injection jira

我正在为 Jira 6.3 编写插件。
我想扩展 Jira 的接口(interface)com.atlassian.jira.bc.issue.attachment.AttachmentService:

public interface MyAttachmentService extend AttachmentService {
    ...
}

然后我实现了我的接口(interface):

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>

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

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

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

最佳答案

也尝试使用 component-import 并说明要使用哪个接口(interface) - MyAttachmentService ,这应该配置 spring ioc

关于java - 扩展 JIRA 中现有的组件类,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/31452913/

相关文章:

java - 如何解决尝试在空对象引用上调用虚拟方法 'void android.widget.TextView.setText(java.lang.CharSequence)'

java - Hibernate 4.3 通过具有嵌入式 ID 的多个列表进行级联合并

jira - 如何过滤掉只有特定用户才能看到和访问的JIRA项目?

java - 如何在 Jira 中以编程方式通过项目 ID 检索项目 key ?

c# - StructureMap 开放通用类型

java - 如何忽略创建 jira api 请求负载中的额外字段?

java - 按下按钮时未输入任何内容时 Android 应用程序崩溃

java - 在java中从头开始创建链表但删除方法不起作用

Java 构造函数注入(inject)

c# - WebApi Controller 中使用 SimpleInjector 的运行时空引用异常