刚接触spring,遇到一个aop问题

Ericans 2012-06-18 05:38:20
配置文件代码如下:
<?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'.
请问到底是哪里的问题?

...全文
66 1 打赏 收藏 转发到动态 举报
写回复
用AI写文章
1 条回复
切换为时间正序
请发表友善的回复…
发表回复
Ericans 2012-06-18
  • 打赏
  • 举报
回复
解决了。
刚开始知道肯定是配置文件解析的问题,后来没办法一行一行的看,果真多了两个">"。删除后问题就解决了
自己给自己做个反面教材吧

81,094

社区成员

发帖
与我相关
我的任务
社区描述
Java Web 开发
社区管理员
  • Web 开发社区
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧