Note that there are some explanatory texts on larger screens.

plurals
  1. POspring-data autowiring not working
    primarykey
    data
    text
    <p>I have following test class:</p> <pre><code>@RunWith(SpringJUnit4ClassRunner.class) @ContextConfiguration("classpath:ApplicationContext.xml") public class CompoundServiceImplTest { @Autowired @Qualifier("testCompoundService") private TestCompoundService testCompoundService; //... } </code></pre> <p>and ApplicationContext contains:</p> <pre><code>&lt;bean id="testCompoundService" autowire="byType" class="myPackage.TestCompoundService"&gt; &lt;/bean&gt; </code></pre> <p>If also tried autowire byName or leaving @Qualifier away (I added that because it did not work but that did not help either).</p> <p>I get following exception:</p> <pre><code>Caused by: org.springframework.beans.factory.NoSuchBeanDefinitionException: No matching bean of type [myPackage.TestCompoundService] 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=testCompoundService)} </code></pre> <p>The bean is clearly configure yet spring claims it isn't?</p> <p>How can i solve this?</p> <p>EDIT:</p> <p>When I change @Autowired to @Resource I get following error:</p> <pre><code>Injection of resource dependencies failed; nested exception is org.springframework.beans.factory.BeanNotOfRequiredTypeException: Bean named 'testCompoundService' must be of type [myPackage.TestCompoundService], but was actually of type [$Proxy68] </code></pre>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload