Spring Scanner annotation not working in plugin

Hello, I got a problem with Spring Scanner(SS) annotation when tried to finish Jira custom mail handler plugin tutorial. I need to add <component> element to atlassian-plugin.xml but according to error: 

[ERROR] atlassian-plugin.xml contains a definition of component. This is not allowed when Atlassian-Plugin-Key is set.

I must use SS annotation for component injection. I upgraded my SS module from 1.2.13 to 2.0.x from here but problem with component still exists: 

[ERROR] Failed to execute goal org.apache.maven.plugins:maven-compiler-plugin:3.6.1:compile (default-compile) on project mail-handler-demo: Compilation failure
[ERROR] /C:/Users/Administrator/Jira/new_jira/mail-handler-demo1/src/main/java/com/example/plugins/tutorial/jira/mailhandlerdemo/IssueKeyValidator.java:[8,2] cannot find symbol
[ERROR] symbol: class Component
[ERROR] -> [Help 1]

Here are attached main plugin files (log, xml + descriptor and class file with annotation).

I'm using Atlassian SDK 6.14 to create plugin with atlas-create-jira-plugin command. 

Java_Home is ok - pointing on jdk 1.8.x

Jira v7.2.2

Any suggestions? This looks pretty strange...

Waiting for responses or questions.

With respect,

Alex.

 

1 answer

If you are using spring scanner you can not have <component> tag in atlassian-plugin.xml.

This could be of great help.

Thank you for answer. My problem was not in <component> tag (i removed it in the beging of project) but in @Component annotation. I needed to add Springframework dependency to use @Component.

 <dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-context</artifactId>
<version>4.3.9.RELEASE</version>
<scope>provided</scope>
</dependency>

With this dependency I can use class import in my java class:


import org.springframework.stereotype.Component;


import org.springframework.beans.factory.annotation.Autowired;

Suggest an answer

Log in or Join to answer
Community showcase
Sarah Schuster
Posted Jan 29, 2018 in Jira

What are common themes you've seen across successful & failed Jira Software implementations?

Hey everyone! My name is Sarah Schuster, and I'm a Customer Success Manager in Atlassian specializing in Jira Software Cloud. Over the next few weeks I will be posting discussion topics (8 total) to ...

2,826 views 12 18
Join discussion

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