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.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.