2016-10-15 2 views
1

Этот вопрос может звучать старый, но я не в состоянии использовать несколько properties файлов, как после того, как ищет решение, которое я узнал, что для класса валидатора я добавил hibernate validator 4,5,Jboss Logging final jars и теперь его говорятпружина не работает с несколькими свойствами файлов

org.springframework.beans.factory.BeanCreationException: Error creating bean with name '(inner bean)#1197783': Cannot resolve reference to bean 'validator' while setting bean property 'validator'; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'validator' defined in ServletContext resource [/WEB-INF/springDispatcherServlet-servlet.xml]: Invocation of init method failed; nested exception is java.lang.AbstractMethodError: org.hibernate.validator.internal.engine.ConfigurationImpl.getDefaultParameterNameProvider()Ljavax/validation/ParameterNameProvider; 

и это мой configuration file

<mvc:annotation-driven enable-matrix-variables="true" 
     validator="validator" /> 
<context:component-scan base-package="com.*" /> 
    <bean 
     class="org.springframework.web.servlet.view.InternalResourceViewResolver"> 
     <property name="prefix" value="/views/" /> 
     <property name="suffix" value=".jsp" /> 
    </bean> 
<mvc:interceptors> 
     <mvc:interceptor> 
      <mvc:mapping path="/**" /> 
      <bean class="org.springframework.web.servlet.i18n.LocaleChangeInterceptor"> 
       <property name="paramName" value="language" /> 
      </bean> 
     </mvc:interceptor> 
    </mvc:interceptors> 
    <bean id="messageSource" 
     class="org.springframework.context.support.ResourceBundleMessageSource"> 
     value="/com/resources/messages,/com/resources/messages_validation.properties" 
     <property name="defaultEncoding" value="UTF-8" /> 
    </bean> 
    <bean id="localeResolver" 
     class="org.springframework.web.servlet.i18n.SessionLocaleResolver"> 
    </bean> 

    <bean id="validator" 
     class="org.springframework.validation.beanvalidation.LocalValidatorFactoryBean"> 
     <property name="validationMessageSource" ref="messageSource" /> 
    </bean> 

имя файла свойств (они находятся в той же папке)

messages_en.properties 
messages_nl.properties 
messages_validations.properties 

Я не могу понять, почему он дает мне ошибку, если все в нужном месте

Пожалуйста, помогите

ответ

0

Try,

<bean id="messageSource" class="org.springframework.context.support.ReloadableResourceBundleMessageSource"> 
     <property name="basenames"> 
      <list> 
       <value>classpath:com/resources/messages</value> 
       <value>classpath:com/resources</value>     
      </list> 
     </property> 
    </bean> 
+0

У меня есть одно сомнение, будет пружинный автомат выбрать другой класс 'properties'? –

+0

Я все еще получаю такую ​​же ошибку –

0

Я думаю, что это должно работать при условии, ваши messageproperties находится в/ru/ресурсы

<bean id="messageSource" 
    class="org.springframework.context.support.ReloadableResourceBundleMessageSource"> 
    <property name="basename" value="classpath:/com/resources/messages/" /> 
    <property name="defaultEncoding" value="UTF-8" /> 
    <property name="fallbackToSystemLocale" value="false"/> 
</bean> 
Смежные вопросы