XML配置文件
<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns="http://www.springframework.org/schema/beans"
xmlns:context="http://www.springframework.org/schema/context"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://www.springframework.org/schema/beans
http://www.springframework.org/schema/beans/spring-beans.xsd
//一下两句是配置注解的代码
http://www.springframework.org/schema/context
http://www.springframework.org/schema/context/spring-context.xsd">
<!-- 使用context命名空间,通过Spring扫描指定包annotation及其子包下的所有Bean的实现类,进行注解解析 -->
<context:component-scan base-package="annotation"/>
</bean>
导入jar包
在Spring 4.0 以上的版本 ,配置注解指定包中的注解进行扫描前需要事先导入Spring AOP的jar包spring-aop-5.0.2.RELEASE.jar