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 Register to answer