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

This widget could not be displayed.

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
Atlassian Summit 2018

Meet the community IRL

Atlassian Summit is an excellent opportunity for in-person support, training, and networking.

Learn more
Community showcase
Posted Wednesday in New to Jira

Are you planning to trial, or are currently trialling Jira Software? - We want to talk to you!

Hello! I'm Rayen, a product manager at Atlassian. My team and I are working hard to improve the trial experience for Jira Software Cloud. We are interested in   talking to 20 people planning t...

148 views 2 0
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