基于注解完成IOC容器实例化
自动实例化注解
<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns="http://www.springframework.org/schema/beans"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:context="http://www.springframework.org/schema/context"
xsi:schemaLocation="http://www.springframework.org/schema/beans
https://www.springframework.org/schema/beans/spring-beans.xsd
http://www.springframework.org/schema/context
https://www.springframework.org/schema/context/spring-context.xsd">
<!--在IoC容器初始化时自动扫面四种组件类型注解并完成实例化
@Controller 当前mcv 控制类
@Repository 业务类 dao层 持久层
@Service 服务类
@Component 可以控制所有 不然确定的时候使用它就得了
-->
<context:component-scan base-package="top.xiongmingcai"/>
</beans>
xmlns:context="http://www.springframework.org/schema/context" 使用注解需要加入