Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/spring/12.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
由于conversionService,无法创建Spring InternalResourceViewResolver?_Spring_Spring Mvc_Spring Data - Fatal编程技术网

由于conversionService,无法创建Spring InternalResourceViewResolver?

由于conversionService,无法创建Spring InternalResourceViewResolver?,spring,spring-mvc,spring-data,Spring,Spring Mvc,Spring Data,我在创建视图解析器时遇到以下错误: org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'viewResolver' defined in ServletContext resource [/WEB-INF/webmvc-config.xml]: Initialization of bean failed; nested exception is org.springfra

我在创建视图解析器时遇到以下错误:

org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'viewResolver' defined in ServletContext resource [/WEB-INF/webmvc-config.xml]: 
Initialization of bean failed; nested exception is org.springframework.beans.TypeMismatchException: 
Failed to convert property value of type 'java.lang.String' to required type 'java.lang.String' for property 'prefix'; 
nested exception is java.lang.IllegalArgumentException: No class 'java.lang.String' was registered
我的spring webmvc配置如下所示:

<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<beans xmlns="http://www.springframework.org/schema/beans"
    xmlns:context="http://www.springframework.org/schema/context"
    xmlns:mvc="http://www.springframework.org/schema/mvc"
    xmlns:p="http://www.springframework.org/schema/p"
    xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
    xsi:schemaLocation="
        http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-3.2.xsd
        http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context-3.2.xsd
        http://www.springframework.org/schema/mvc http://www.springframework.org/schema/mvc/spring-mvc-3.2.xsd">

    <context:component-scan base-package="com.mycompany.web" use-default-filters="false">
        <context:include-filter expression="org.springframework.stereotype.Controller" type="annotation" />
    </context:component-scan>

    <mvc:annotation-driven conversion-service="conversionService" />

    <bean id="conversionService" class="org.springframework.format.support.FormattingConversionServiceFactoryBean"/>

    <bean class="org.springframework.data.repository.support.DomainClassConverter">
        <constructor-arg ref="conversionService"/>
    </bean>

    <bean id="viewResolver" class="org.springframework.web.servlet.view.InternalResourceViewResolver" p:prefix="/WEB-INF/views/" p:suffix=".jsp" />

</beans>


这与conversionService有关吗?

如果不需要注册自定义转换器或格式化程序,可以尝试从mvc:annotation-driven元素中删除conversionService bean声明以及conversion service属性

仅拥有
就足以启用默认格式规则:


如果使用普通的
元素会发生什么?@Sotirios同样的问题我需要conversionService来填充Spring Data DomainClassConverter