使用注解定义bean:通过注解的形式 将bean以及相应的属性值 放入ioc容器 <context:component-scan base-package="org.lanqiao.dao"> </context:component-scan>Spring在启动的时候,会根据base-package在 该包中扫描所有类,查找这些类是否有注解@Component("studentDao"),如果有,则将该类 加入spring Ioc容器。 @Component细化: 不知道的情况用这个 dao层注解:@Repository service层注解:@Service 控制器层注解:@Controller