Announcement Announcement Module
Collapse
No announcement yet.
Autowire class which extends non-container class Page Title Module
Move Remove Collapse
X
Conversation Detail Module
Collapse
  • Filter
  • Time
  • Show
Clear All
new posts

  • Autowire class which extends non-container class

    Hi,

    I have next structure:

    Code:
    @Component
    public abstract class HuginJob extends QuartzJobBean {...}
    
    
    @Component("CisxJob")
    public class CisxJob extends HuginJob {...}
    Now I want to test CisxJob:

    Code:
    RunWith(SpringJUnit4ClassRunner.class)
    @ContextConfiguration({ "/applicationContext-test.xml" })
    public class CisxJobTest {
    
        @Autowired
        @Qualifier("CisxJob")
        private CisxJob          cisxJob;
    .....
    }
    Here is part of applicationContext-test.xml
    Code:
    <context:annotation-config />
    <context:component-scan base-package="no.hugin.jobscheduler" />

    Error is
    Code:
    org.springframework.beans.factory.BeanCreationException: 
    Error creating bean with name 'no.hugin.jobscheduler.job.cisx.CisxJobTest': Injection of autowired dependencies failed;
    nested exception is rg.springframework.beans.factory.BeanCreationException:
    Could not autowire field: private no.hugin.jobscheduler.job.cisx.CisxJob
    no.hugin.jobscheduler.job.cisx.CisxJobTest.cisxJob; nested exception is org.springframework.beans.factory.NoSuchBeanDefinitionException: 
    No matching bean of type [no.hugin.jobscheduler.job.cisx.CisxJob] found for dependency:
    expected at least 1 bean which qualifies as autowire candidate for this dependency. 
    Dependency annotations: {@org.springframework.beans.factory.annotation.Autowired(required=true), @org.springframework.beans.factory.annotation.Qualifier(value=CisxJob)}
    	at org.springframework.beans.factory.annotation.AutowiredAnnotationBeanPostProcessor.postProcessPropertyValues(AutowiredAnnotationBeanPostProcessor.java:286)
    .............
    The problem is in extending of QuartzJobBean - but I need it.

    Thank you
Working...
X