刚接触spring,遇到一个aop问题
配置文件代码如下:
<?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"
xmlns:aop="http://www.springframework.org/schema/aop"
xsi:schemaLocation="http://www.springframework.org/schema/beans
http://www.springframework.org/schema/beans/spring-beans-2.5.xsd
http://www.springframework.org/schema/context
http://www.springframework.org/schema/context/spring-context-2.5.xsd>
http://www.springframework.org/schema/aop>
http://www.springframework.org/schema/aop/spring-aop-2.5.xsd">
<bean id="userService" class="demo.service.UserServiceImpl"></bean>
<bean id="optlogger" class="demo.aop.OptLogger"></bean>
<aop:config>
<aop:pointcut id="servicepointcut"
expression="execution(* demo.service.*.*(..))" />
<aop:aspect id="loggeraspect" ref="optlogger">
<aop:before method="logger" pointcut-ref="servicepointcut"/>
</aop:aspect>
</aop:config>
</beans>
测试类代码如下:
package demo.service;
import org.springframework.context.ApplicationContext;
import org.springframework.context.support.ClassPathXmlApplicationContext;
public class Test {
private static final String CONFIGS = "aop.xml";
public static void main(String[] args) {
ApplicationContext ac = new ClassPathXmlApplicationContext(CONFIGS);
UserService userService = (UserService)ac.getBean("userService");
userService.update();
userService.save();
userService.delete();
}
}
运行之后报这样的异常:
Exception in thread "main" org.springframework.beans.factory.xml.XmlBeanDefinitionStoreException: Line 17 in XML document from class path resource [aop.xml] is invalid; nested exception is org.xml.sax.SAXParseException: cvc-complex-type.2.4.c: The matching wildcard is strict, but no declaration can be found for element 'aop:config'.
请问到底是哪里的问题?