No bean named 'injectionServiceImpl' is defined

来源:4-2 Spring Bean装配之Autowired注解说明-1

慕粉3674784

2016-08-12 10:21

public class TestInjection extends UnitTestBase{
  public TestInjection(){
      super("classpath*:spring-annotation.xml");
  }
  @Test
  public void testAutoWired(){
      InjectionService service =super.getBean("injectionServiceImpl");
      
      service.save("autowired");
  }
}

spring-annotation.xml:

<context:component-scan base-package="com.sbk.annotation"></context:component-scan>   
错误:org.springframework.beans.factory.NoSuchBeanDefinitionException: No bean named 'injectionServiceImpl' is defined






写回答 关注

1回答

  • 化_十
    2016-08-12 11:59:10
    已采纳

    InjectionServiceImpl类上没有注入@Component等注解吧?

    慕粉3674...

    非常感谢!

    2016-09-03 17:15:49

    共 1 条回复 >

Spring入门篇

为您带来IOC和AOP的基本概念及用法,为后续高级课程学习打下基础

268787 学习 · 963 问题

查看课程

相似问题