2 visual0522 Visual0522 于 2016.04.13 09:34 提问

springmvc项目中springmvc.xml文件配置错误?

图片说明
org.springframework.beans.factory. BeanCreationException: Error creating bean with name 'houseChangeInfoController': Injection of autowired dependencies failed; nested exception is org.springframework.beans.factory. BeanCreationException: Could not autowire field: private cn.teen.service. HouseChangeInfoService cn.teen.controller.HouseChangeInfoController. service; nested exception is org.springframework.beans.factory. CannotLoadBeanClassException: Error loading class [org.springframework.validation.beanvalidation. LocalValidatorFactoryBean] for bean with name 'validator' defined in class path resource [spring-mvc. xml]: problem with class file or dependent class; nested exception is java.lang. NoClassDefFoundError: javax/validation/ValidatorFactory
org.springframework.beans.factory。BeanCreationException:创建bean与错误的名字“houseChangeInfoController”:注入autowired的依赖关系失败;嵌套org.springframework.beans.factory是个例外。私人cn.teen.service BeanCreationException:不能自动装配领域。HouseChangeInfoService cn.teen.controller.HouseChangeInfoController。服务;嵌套org.springframework.beans.factory是个例外。[org.springframework.validation.beanvalidation CannotLoadBeanClassException:错误加载类。LocalValidatorFactoryBean]为bean名称验证器的类路径中定义的资源(spring mvc。类文件或xml):问题依赖类;嵌套异常. lang。NoClassDefFoundError:javax /验证/ ValidatorFactory

Caused by: org.springframework.beans.factory. BeanCreationException: Could not autowire field: private cn.teen.service. HouseChangeInfoService cn.teen.controller.HouseChangeInfoController. service; nested exception is org.springframework.beans.factory. CannotLoadBeanClassException: Error loading class [org.springframework.validation.beanvalidation. LocalValidatorFactoryBean] for bean with name 'validator' defined in class path resource [spring-mvc. xml]: problem with class file or dependent class; nested exception is java.lang. NoClassDefFoundError: javax/validation/ValidatorFactory
引起的:org.springframework.beans.factory。私人cn.teen.service BeanCreationException:不能自动装配领域。HouseChangeInfoService cn.teen.controller.HouseChangeInfoController。服务;嵌套org.springframework.beans.factory是个例外。[org.springframework.validation.beanvalidation CannotLoadBeanClassException:错误加载类。LocalValidatorFactoryBean]为bean名称验证器的类路径中定义的资源(spring mvc。类文件或xml):问题依赖类;嵌套异常. lang。NoClassDefFoundError:javax /验证/ ValidatorFacto

4个回答

Visual0522
Visual0522   2016.04.13 09:54
已采纳

Error loading class [org.springframework.validation.beanvalidation.LocalValidatorFactoryBean] for bean with name 'validator' defined in class path resource [spring-mvc.xml]: problem with class file or dependent class; nested exception is java.lang.NoClassDefFoundError: javax/validation/ValidatorFactory

Visual0522
Visual0522   2016.04.13 09:38

这个是springmvc.xml文件

<?xml version="1.0" encoding="UTF-8"?>
xmlns:aop="http://www.springframework.org/schema/aop"
xmlns:context="http://www.springframework.org/schema/context"
xmlns:mvc="http://www.springframework.org/schema/mvc"
xmlns:tx="http://www.springframework.org/schema/tx"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:p="http://www.springframework.org/schema/p"
xsi:schemaLocation="http://www.springframework.org/schema/aop http://www.springframework.org/schema/aop/spring-aop.xsd
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
http://www.springframework.org/schema/mvc http://www.springframework.org/schema/mvc/spring-mvc.xsd
http://www.springframework.org/schema/tx http://www.springframework.org/schema/tx/spring-tx.xsd">

<!-- 扫描controller(controller层注入) -->
<context:component-scan base-package="cn.teen.controller"/>

<mvc:annotation-driven/>



<!-- 对模型视图添加前后缀 -->
<bean id="viewResolver" class="org.springframework.web.servlet.view.InternalResourceViewResolver"
      p:prefix="/WEB-INF/views/" p:suffix=".jsp"/>

<!-- 以下 validator ConversionService 在使用 mvc:annotation-driven 会 自动注册 -->


<!-- 如果不加默认到 使用classpath下的 ValidationMessages.properties -->

<!-- 国际化的消息资源文件(本系统中主要用于显示/错误消息定制) -->
<!-- <bean id="messageSource" class="org.springframework.context.support.ReloadableResourceBundleMessageSource">
    <property name="basenames">
        <list>
            在web环境中一定要定位到classpath 否则默认到当前web应用下找
            <value>classpath:messages</value>
            <value>classpath:org/hibernate/validator/ValidationMessages</value>
        </list>
    </property>
    <property name="useCodeAsDefaultMessage" value="false"/>
    <property name="defaultEncoding" value="UTF-8"/>
    <property name="cacheSeconds" value="60"/>
</bean>
 -->

<!-- 支持返回json(避免IE在ajax请求时,返回json出现下载 ) -->
<bean class="org.springframework.web.servlet.mvc.annotation.AnnotationMethodHandlerAdapter">
    <property name="messageConverters">
        <list>
            <ref bean="mappingJacksonHttpMessageConverter"/>
        </list>
    </property>
</bean>
<bean id="mappingJacksonHttpMessageConverter"
      class="org.springframework.http.converter.json.MappingJacksonHttpMessageConverter">
    <property name="supportedMediaTypes">
        <list>
            <value>text/plain;charset=UTF-8</value>
            <value>application/json;charset=UTF-8</value>
        </list>
    </property>
</bean>
<!-- 支持返回json -->




<bean class="org.springframework.web.servlet.mvc.support.ControllerClassNameHandlerMapping" />

<!-- <bean class="org.springframework.web.servlet.view.XmlViewResolver">
   <property name="location">
       <value>classpath:spring-excel-views.xml</value>
   </property>
   <property name="order" value="0" />
</bean>
 -->

<!-- 配置springMVC处理上传文件的信息 -->
<!-- <bean id="multipartResolver" class="org.springframework.web.multipart.commons.CommonsMultipartResolver">
    <property name="defaultEncoding" value="utf-8"/>
    <property name="maxUploadSize" value="10485760000"/>
    <property name="maxInMemorySize" value="40960"/>
</bean>

启用shrio授权注解拦截方式
<aop:config proxy-target-class="true"></aop:config>
<bean class="org.apache.shiro.spring.security.interceptor.AuthorizationAttributeSourceAdvisor">
    <property name="securityManager" ref="securityManager"/>
</bean> -->


<!-- 控制器异常处理 -->

<!--

-->

CSDNXIAOD
CSDNXIAOD   2016.04.13 09:42

SpringMvc的xml文件的配置
----------------------biu~biu~biu~~~在下问答机器人小D,这是我依靠自己的聪明才智给出的答案,如果不正确,你来咬我啊!

hou1263047562
hou1263047562   2016.04.15 16:05

私人cn.teen.service BeanCreationException:不能自动装配领域。

Csdn user default icon
上传中...
上传图片
插入图片
准确详细的回答,更有利于被提问者采纳,从而获得C币。复制、灌水、广告等回答会被删除,是时候展现真正的技术了!