Hi guys!
I'm trying to inject a PluginLicenseManager
on my Macro so i can disable it when the license is invalid, but the autowiring/import is not working.
I followed this tutorial and some other questions, but I always end up with the following exception:
[INFO] [talledLocalContainer] org.springframework.beans.factory.UnsatisfiedDependencyException: Error creating bean with name 'org.bitbucket.felipebrnd.confluence.jlatexmath.macro.JLatexMathInlineMacro': Unsatisfied dependency expressed through constructor argument with index 0 of type [com.atlassian.upm.api.license.PluginLicenseManager]: : No qualifying bean of type [com.atlassian.upm.api.license.PluginLicenseManager] found for dependency: expected at least 1 bean which qualifies as autowire candidate for this dependency. Dependency annotations: {@com.atlassian.plugin.spring.scanner.annotation.imports.ComponentImport(value=pluginLicenseManager)}; nested exception is org.springframework.beans.factory.NoSuchBeanDefinitionException: No qualifying bean of type [com.atlassian.upm.api.license.PluginLicenseManager] found for dependency: expected at least 1 bean which qualifies as autowire candidate for this dependency. Dependency annotations: {@com.atlassian.plugin.spring.scanner.annotation.imports.ComponentImport(value=pluginLicenseManager)
Can you guys help me get this working ?
Tks in advance!
My atlassian-plugin.xml
looks like this:
<!-- License manager --> <component-import key="pluginLicenseManager" interface="com.atlassian.upm.api.license.PluginLicenseManager"/>
I've added the dependecies on pom.xml
as follows:
<!-- Atlassian License API --> <dependency> <groupId>com.atlassian.upm</groupId> <artifactId>licensing-api</artifactId> <version>2.0.1</version> <scope>provided</scope> </dependency> <dependency> <groupId>com.atlassian.upm</groupId> <artifactId>upm-api</artifactId> <version>2.0.1</version> <scope>provided</scope> </dependency>
And my Macro class looks like this:
public class MyBlockMacro implements Macro { private PluginLicenseManager licenseManager; public MyBlockMacro(@ComponentImport("pluginLicenseManager") PluginLicenseManager pluginLicenseManager) { this.licenseManager = pluginLicenseManager; } //.... }
Community moderators have prevented the ability to post new answers.
I guess you need @Scanned above MyBlockMacro class.
Mr Volodymyr, you saved my day =).
Thank you very much!!
I just feel bad I didn't find it anywhere around docs our other sources.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Spring scanner doesn't use component-import or component entries in atlassian-plugin.xml - you should also remove those, to save future confusion.
Spring scanner 2.x (available in the next Server release of Confluence) will save you ever having to use the Scanned annotation in future, but that's not available today for you to use in your plugin. For the moment, you need to put Scanned on any class that is using any other spring scanner annotations (ComponentImport, ConfluenceImport, ConfluenceComponent, ExportAsService).
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi @Richard Atkins, It would be great if you put it to current spring-scanner docs. I myself hit this problem and I see that other developers face it again and again.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.