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 Sign up to answer
How to earn badges on the Atlassian Community

How to earn badges on the Atlassian Community

Badges are a great way to show off community activity, whether you’re a newbie or a Champion.

Learn more
Community showcase
Published Monday in Jira Software

How large do you think Jira Software can grow?

Hi Atlassian Community! My name is Shana, and I’m on the Jira Software team. One of the many reasons this Community exists is to connect you to others on similar product journeys or with comparabl...

616 views 6 12
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