为了账号安全,请及时绑定邮箱和手机立即绑定

springmvc 解析spring*.xml配置文件的异常

springmvc 解析spring*.xml配置文件的异常

慕妹3242003 2019-02-24 12:09:32
刚开始接触springmvc 目标:识别基于注解的控制器类(controller) 过程如下: 1.编写注解的controller 2.在spring*.xml文件中配置 <context:component-scan base-package="idv.song.controller"/> 3.重新编译,[重启tomcat] 4.报错如下 严重: Context initialization failed org.springframework.beans.factory.BeanDefinitionStoreException: Unexpected exception parsing XML document from ServletContext resource [/WEB-INF/config/springmvc-config.xml]; nested exception is java.lang.NoClassDefFoundError: org/springframework/aop/TargetSource 报错中加粗的部分都百度[木得google]过了,没有合适的答案 自我分析如下: -- bean没有实例化-- 配置文件中bean配置的错误(我的配置文件中只有关于识别注解控制器的配置)--| 尝试去掉<context:component-scan base-package="idv.song.controller"/> -- 编译正常(dispatcherServlet.init()成功)| --|base-package没有写错,是不是xml的语法错误或者引用content.xsd版本问题? 问题:识别注解控制器的spring配置文件的正确写法&分析我的问题 `<?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" xmlns:aop="http://www.springframework.org/schema/aop" xmlns:tx="http://www.springframework.org/schema/tx" xmlns:p="http://www.springframework.org/schema/p" xmlns:util="http://www.springframework.org/schema/util" xmlns:jdbc="http://www.springframework.org/schema/jdbc" xmlns:cache="http://www.springframework.org/schema/cache" xmlns:mvc="http://www.springframework.org/schema/mvc" xsi:schemaLocation=" http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context.xsd http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd http://www.springframework.org/schema/tx http://www.springframework.org/schema/tx/spring-tx.xsd http://www.springframework.org/schema/jdbc http://www.springframework.org/schema/jdbc/spring-jdbc.xsd http://www.springframework.org/schema/cache http://www.springframework.org/schema/cache/spring-cache.xsd http://www.springframework.org/schema/aop http://www.springframework.org/schema/aop/spring-aop.xsd http://www.springframework.org/schema/util http://www.springframework.org/schema/util/spring-util.xsd http://www.springframework.org/schema/mvc http://www.springframework.org/schema/mvc/spring-mvc.xsd "> <context:component-scan base-package="idv.song.controller"/> <!-- register beans that support the controllers that have annotated method --> <!-- <mvc:annotation-driven></mvc:annotation-driven> <mvc:resources location="/" mapping="/*.html"></mvc:resources> --> <!-- <bean id="/product_input" class="idv.song.controller.InputProductController"></bean> <bean id="/product_save" class = "idv.song.controller.SaveProductController"></bean> --> <bean id="veiwResolver" class="org.springframework.web.servlet.view.InternalResourceViewResolver"> <property name="prefix" value="/WEB-INF/jsp/"></property> <property name="suffix" value=".jsp"></property> </bean></beans>`
查看完整描述

1 回答

?
呼啦一阵风

TA贡献1802条经验 获得超6个赞

NoClassDefFoundError 说明类没有找到,看看依赖的包是否缺少spring-aop-*.jar aopalliance-1.0.jar

查看完整回答
反对 回复 2019-03-01
  • 1 回答
  • 0 关注
  • 1040 浏览

添加回答

举报

0/150
提交
取消
微信客服

购课补贴
联系客服咨询优惠详情

帮助反馈 APP下载

慕课网APP
您的移动学习伙伴

公众号

扫描二维码
关注慕课网微信公众号