Announcement Announcement Module
Collapse
No announcement yet.
A question about inheritance Page Title Module
Move Remove Collapse
X
Conversation Detail Module
Collapse
  • Filter
  • Time
  • Show
Clear All
new posts

  • A question about inheritance

    Hello everyone,

    currently I'm experiencing some strange behaviour when using inheritance on one of my classes.

    The class ReminderReport is derived from InvoiceReport since they share a lot of common functionality.

    Most of my application uses annotations for configuration, so I annotated
    Code:
    @Component("reminderReport")
    public class ReminderReport extends InvoiceReport
    and
    Code:
    @Component("invoiceReport")
    public class InvoiceReport extends AddressedReport<Invoice>
    as usual.

    Now when I try to inject the InvoiceReport into another bean, like so:
    Code:
    @Resource
    private InvoiceReport invoiceReport
    Spring injects a ReminderReport, which would probably make sense in another context but of course is not what I want in this case.
    I tried adding
    Code:
    @Qualifier("invoice")
    to both InvoiceReport class and injected field, but unfortunately that didn't help.
    Probably I'll just try and configure the beans via a separate XML file for the moment (to force instantiation of InvoiceReport as a separate class) and see if that works for me.
    In the long run, annotation-based configuration would be much preferable, though.

    Best regards
    Marcus
Working...
X