Create
cancel
Showing results for 
Search instead for 
Did you mean: 
Sign up Log in
It's not the same without you

Join the community to find out what other Atlassian users are discussing, debating and creating.

Atlassian Community Hero Image Collage

How to find AttachmentManager using @Autowire

I have a plugin. It can find the attachment manager using

ContainerManager.getComponent("attachmentManager")

but I cannot figure out how to autowire it. The relatively straightforward

@Autowired
public MyCustomServlet(AttachmentManager attachmentManager) {

}

 Produces a stack trace that implies I need to use <component-import>, yet adding @ComponentImport did not resolve that error. I tried adding an import into my own spring xml,

<import resource="classpath:/applicationContext.xml"/>

but that did not work either. What am I missing?

1 answer

Hi robert_egan_305

 

This is what i used to do in some of my plugins:

 

@Scanned
public class MyClass
{
    protected static final Logger log = LoggerFactory.getLogger(MyClass.class);

    @ComponentImport
    private final AttachmentManager attachmentManager;

@Autowired public MyClass(AttachmentManager attachmentManager) { this.attachmentManager = attachmentManager; }
}

It seems you need all 3 annotations. @Scanned, @ComponentImport, AND  @Autowired.

Thanks.

 

 

First time I deal with this "new way" of DI i found quite useful the following documentation:

 

It helps me while i was creating Announcement Banner for Confluence

Hope this help to you as well.

Suggest an answer

Log in or Sign up to answer
TAGS
Community showcase
Published in Confluence

You’re invited: Confluence for MS Teams Live demo + Q&A

This past summer, we joined forces with Microsoft Teams as a part of our mission to help your team collaborate better, starting with more effective meetings. We released a new and improved Confluence...

95 views 0 1
Read article

Community Events

Connect with like-minded Atlassian users at free events near you!

Find an event

Connect with like-minded Atlassian users at free events near you!

Unfortunately there are no Community Events near you at the moment.

Host an event

You're one step closer to meeting fellow Atlassian users at your local event. Learn more about Community Events

Events near you