I’m writing a plugin for JIRA server and I want to use Atlassian’s built-in caching functionality. However, I’m having trouble injecting the CacheManager. If I include @Scanned
at the top of my class, my plugin loads up fine BUT returns an exception at runtime:
No qualifying bean of type [com.atlassian.cache.CacheManager] found for dependency: expected at least 1 bean which qualifies as autowire candidate for this dependency.
When I include @Named
on top of the class, the plugin won’t even become enabled.
With either annotation, when I package the plugin in verbose mode, this little tidbit pops up:
[INFO] (/) Found annotation 'com.atlassian.plugin.spring.scanner.annotation.component.Scanned' inside class 'com.cdk.alm.releaseui.apiextension.RestReleaseService'
[INFO] (/) Found 'com.atlassian.plugin.spring.scanner.annotation.imports.ComponentImport' inside class 'com.cdk.alm.releaseui.apiextension.RestReleaseService' method '<init>' parameter 'com.atlassian.cache.CacheManager'
[INFO] (X) Class not suitable 'com.cdk.alm.releaseui.apiextension.RestReleaseService$1'. Skipping...
I’m not sure what I’m doing wrong here. How do you inject CacheManager into JIRA Rest Plugin Modules?
Here’s the class that I’m trying to inject CacheManager into:
import com.atlassian.plugin.spring.scanner.annotation.component.Scanned;
import javax.inject.Inject;
import com.atlassian.plugin.spring.scanner.annotation.imports.ComponentImport;
// Other imports
@Scanned
@Path("/")
@Consumes({MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML})
@Produces({MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML})
public class RestReleaseService
{
@Inject
public RestReleaseService(@ComponentImport CacheManager cacheManager)
{
// Do stuff with cacheManager here
}
}