Extend an existing component class in JIRA
I am writing a plugin for Jira 6.3.
I want to extend the Jira interface com.atlassian.jira.bc.issue.attachment.AttachmentService
:
public interface MyAttachmentService extend AttachmentService {
...
}
then I implemented my interface:
public class MyDefaultAttachmentService extends DefaultAttachmentService implements MyAttachmentService {
...
}
I have defined my class as a component in atlassian-plugin.xml:
<component key="myAttachmentService" name="MyAttachmentService" class="com.my.plugin.issue.attachment.MyDefaultAttachmentService">
<interface>com.my.plugin.issue.attachment.MyAttachmentService</interface>
</component>
How I use my plugin class (dependency injection):
public class DoSomethingWithAttachmentAction extends AbstractIssueSelectAction
{
private final MyAttachmentService myAttachmentService ;
public DoSomethingWithAttachmentAction(MyAttachmentService myAttachmentService) {
this.myAttachmentService = myAttachmentService;
}
public String doExecute() {
myAttachmentService.someMethod();
}
}
But then at runtime I get the following error:
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)
...
How do I fix it and use my new component?
+3
source to share