I have a plugin. It can find the attachment manager using
ContainerManager.getComponent("attachmentManager")
but I cannot figure out how to autowire it. The relatively straightforward
@Autowired
public MyCustomServlet(AttachmentManager attachmentManager) {
}
Produces a stack trace that implies I need to use <component-import>, yet adding @ComponentImport did not resolve that error. I tried adding an import into my own spring xml,
<import resource="classpath:/applicationContext.xml"/>
but that did not work either. What am I missing?
This is what i used to do in some of my plugins:
@Scanned public class MyClass { protected static final Logger log = LoggerFactory.getLogger(MyClass.class); @ComponentImport private final AttachmentManager attachmentManager;
@Autowired public MyClass(AttachmentManager attachmentManager) { this.attachmentManager = attachmentManager; }
}
It seems you need all 3 annotations. @Scanned, @ComponentImport, AND @Autowired.
Thanks.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
First time I deal with this "new way" of DI i found quite useful the following documentation:
It helps me while i was creating Announcement Banner for Confluence
Hope this help to you as well.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Online forums and learning are now in one easy-to-use experience.
By continuing, you accept the updated Community Terms of Use and acknowledge the Privacy Policy. Your public name, photo, and achievements may be publicly visible and available in search engines.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.