在Spring4.0以上版本,配置注解指定包中的注解进行扫描前需要事先导入SpringAOP的JAR包spring-aop-5.0.2.RELEASE.jar(已导入,看下面)
ch1项目结构目录如下:
配置文件报错:
解决办法:
配置文件缺少属性说明,标签内添加以下文字:
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
http://www.springframework.org/schema/beans/spring-beans.xsd
http://www.springframework.org/schema/context
http://www.springframework.org/schema/context/spring-context-3.0.xsd">
如下图: