Simple dependency injection in Atlassian?

Can I use simple dependency injection in Jira/Confluence? For example simply annotating a class with @Component and then injecting in another class with @Autowired... or I need to do it using Spring Dynamic Modules as described here -,+Spring+and+the+Plugin+Framework

3 answers

1 accepted

Thanks, for the reference Steve. As far as I can see I can only use xml declarations of beans? ... no component scanning is in place and therefore cannot use annotations?

It's a little bit more complicatet as beside spring each bean is a osgi component.

First, you do not use xml declarations, normally.

You will define a component module which represents a spring bean and an osgi component. This module is defined in the atlassian-plugin.xml. In generall you do not handle with spring directly. And you will not handle osgi directly. That's all wrapped in the atlassian plugin framework.

I'm not sure, but maybe @Reference from Felix-SCR might work. ->

But I have never tried that.

Yeah component module is what I need, thanks!


More Specifically First Add the component in your atlassian-plugin.xml like


<component key="myClass" class="com.componay.confluence.plugin.MyComponentClass">
<description>Provides Body markup service.</description>

Then use setter injection/constructor injection to inject the object like

private MyComponentClass componentClass;
public void setMyComponentClass(MyComponentClass componentClass) {
this.componentClass= componentClass;


It will inject the object reference in your target class.

Suggest an answer

Log in or Join to answer
Community showcase
Alexey Matveev
Published Saturday in Jira

How to run Jira in a docker container

Everything below is tested on Ubuntu 17.10. I prefer to use Jira in a docker container because: 1. I can install Jira with a couple of commands. 2. I can start and stop Jira just by starting and s...

352 views 6 8
Read article

Atlassian User Groups

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

Find a group

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

Find my local user group

Unfortunately there are no AUG chapters near you at the moment.

Start an AUG

You're one step closer to meeting fellow Atlassian users at your local meet up. Learn more about AUGs

Groups near you
Atlassian Team Tour

Join us on the Team Tour

We're bringing product updates and pro tips on teamwork to ten cities around the world.

Save your spot