Announcement Announcement Module
Collapse
No announcement yet.
@Qualifier not working after 2.5 -> 3.0.3 upgrade Page Title Module
Move Remove Collapse
X
Conversation Detail Module
Collapse
  • Filter
  • Time
  • Show
Clear All
new posts

  • @Qualifier not working after 2.5 -> 3.0.3 upgrade

    Hi,

    Is there anything special I need to do in the config, to make springs @Qualifier work with 3.0.3? I had this perfectly working with 2.5, but after an upgrade, it does not. No code changes except upgrade of jars were done.

    I have a marker interface:

    Code:
    @Target({ElementType.FIELD, ElementType.PARAMETER, ElementType.TYPE})
    @Retention(RetentionPolicy.RUNTIME)
    @Qualifier
    @Inherited
    public @interface Autotaks {
    }
    which is @Qualifier annotated. I then have bean:


    Code:
    @Service
    @Autotaks
    @Transactional
    public class AutotaksTimeprisCollectorServiceImpl extends implements TimeprisCollectorService {
    ...
    }
    and then inject like this:

    Code:
      @Autowired
      @Autotaks
      TimeprisCollectorService timeprisCollectorService;
    which now fails in spring 3.0.3 :-(

    If I change it to:

    Code:
      @Resource(name = "autotaksTimeprisCollectorServiceImpl")
      TimeprisCollectorService timeprisCollectorService;
    it works, but it kinda defeats the purpose of the @Qualifier :-)

    Should I switch to JSR-330 @Inject with its qualifier instead?

  • #2
    Ooh yeah, one important thing I forgot to mention:

    This fails from spring-mock 2.0.8 tests only!!! When the applicationContext is bootstrapped through a testcase that inherits for instance org.springframework.test.jpa.AbstractJpaTests is fails.

    Strange hugh?!

    Comment


    • #3
      Hmmm,...never mind. Converted to Junit4 and the SpringJUnit4ClassRunner which made the problem dissappear (still have no clue why it didn't work with spring-mock-2.0.8+spring-3.0.3).

      Comment

      Working...
      X