我正在为 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/