looking for some solutions? You are welcome.

SOLVED: context:component-scan not working in junit

Ruchi Gupta:

I added all the base-package in my applicationContext.xml, but still i is showing noBeanDefinitionException.

applicationContext.xml

  <!-- Autowiring -->

            <context:component-scan base-package="com.paymentech.developercenter.services"/>

        <import resource="classpath:spring/applicationContext-fragment-mybatisMOCK.xml" />

DispathcherServlet-servlet.xml

   <import resource="classpath:spring/applicationContext.xml" /> 

      <bean id="localeResolver" class="org.springframework.web.servlet.i18n.FixedLocaleResolver">
        <property name="defaultLocale" value="en_US" />
    </bean>
    <bean class="org.springframework.web.servlet.DispatcherServlet"/>

FaqControllerTest.java

@RunWith(SpringJUnit4ClassRunner.class)
    @ContextConfiguration(locations = {"classpath:spring/DispatcherServlet-servlet.xml" })
    @WebAppConfiguration("WEB-INF/web.xml")

    public class FaqControllerTest {
        @Autowired
        private WebApplicationContext context;

        @Autowired
        private DispatcherServlet dispatcherServlet;

        @Before
        public void init() throws ServletException, IOException {
            SpringTestConfiguration.init(context, dispatcherServlet);

        }

Error:-

Caused by: org.springframework.beans.factory.UnsatisfiedDependencyException: Error creating bean with name 'integratorSolutionController': Unsatisfied dependency expressed through field 'solutionService'; nested exception is org.springframework.beans.factory.UnsatisfiedDependencyException: Error creating bean with name 'integratorSolutionService': Unsatisfied dependency expressed through field 'solutionStatusService'; nested exception is org.springframework.beans.factory.UnsatisfiedDependencyException: Error creating bean with name 'solutionStatusService': Unsatisfied dependency expressed through field 'solutionStatusMapper'; nested exception is org.springframework.beans.factory.NoSuchBeanDefinitionException: No qualifying bean of type 'com.paymentech.developercenter.persistence.isg.mappers.SolutionStatusMapper' available: expected at least 1 bean which qualifies as autowire candidate. Dependency annotations: {@org.springframework.beans.factory.annotation.Autowired(required=true)}



Posted in S.E.F
via StackOverflow & StackExchange Atomic Web Robots
Share:

No comments:

Recent