title: configuration to encode Hibernate Validator customized error messages through Spring Framework
body: <p>I am working with Spring (4.0.5) and Hibernate Validator (5.1.2.Final)</p>
  
  <p>I already have working the error messages through a .properties file, <strong>it works too about i18n</strong>.</p>
  
  <ul>
  <li>It in a <strong>standalone</strong> and <strong>testing</strong> (JUnit) environment, by the moment. I don't want include the Web environment yet to keep the things simple. </li>
  </ul>
  
  <p>I have the following:</p>
  
  <p>For the <strong>ValidationMessages_es_PE.properties</strong> file (in spanish)</p>
  
  <pre><code>person.salary.digits=Dato invalido '${validatedValue}', máximo tamaño no decimal permitido es {integer}, máximo tamaño decimal permitido es {fraction}
  </code></pre>
  
  <p>About the infrastructure </p>
  
  <pre><code>@Configuration
  public class ValidatorConfiguration {
  
      @Bean
      public ResourceBundleMessageSource resourceBundleMessageSource(){
          ResourceBundleMessageSource resourceBundleMessageSource = new ResourceBundleMessageSource();
          resourceBundleMessageSource.setDefaultEncoding("UTF-8");
          resourceBundleMessageSource.setBasenames("com.manuel.jordan.validation.messages.ValidationMessages");
          return resourceBundleMessageSource;
      }
  
      @Bean
      public LocalValidatorFactoryBean localValidatorFactoryBean(){
  
  LocalValidatorFactoryBean localValidatorFactoryBean = new LocalValidatorFactoryBean();
          localValidatorFactoryBean.setValidationMessageSource(resourceBundleMessageSource());
  
          MessageSourceResourceBundleLocator messageSourceResourceBundleLocator = new MessageSourceResourceBundleLocator(resourceBundleMessageSource()); 
          ResourceBundleMessageInterpolator resourceBundleMessageInterpolator = new ResourceBundleMessageInterpolator(messageSourceResourceBundleLocator);
          localValidatorFactoryBean.setMessageInterpolator(resourceBundleMessageInterpolator);
  
          return localValidatorFactoryBean;
      }
  
  
  }
  </code></pre>
  
  <p>Observe I have <code>setDefaultEncoding("UTF-8")</code></p>
  
  <p>The test class</p>
  
  <pre><code>@RunWith(SpringJUnit4ClassRunner.class)
  @ContextConfiguration(classes=ValidatorConfiguration.class)
  public class InvalidPersonValidation03Test {
  
      private static final Logger logger = LoggerFactory.getLogger(InvalidPersonValidation03Test.class);
  
      @Autowired
      private LocalValidatorFactoryBean validator;
  
      public InvalidPersonValidation03Test(){
          LocaleContextHolder.setLocale(new Locale("es","PE"));
      }
  
      @Test
      public void testInvalidNullId(){
      ...
  </code></pre>
  
  <p>Part of the output is the following</p>
  
  <pre><code>- &gt;&gt;&gt;testInvalidFractionSalary
  - ConstraintViolationImpl{interpolatedMessage='Dato invalido '1578.100', m�ximo tama�o no decimal permitido es 4, m�ximo tama�o decimal permitido es 2', propertyPath=salary, rootBeanClass=class com.manuel.jordan.domain.PersonValidation03, messageTemplate='{person.salary.digits}'}
  - ConstraintViolationImpl{interpolatedMessage='Dato invalido '1578.100', m�ximo tama�o no decimal permitido es 4, m�ximo tama�o decimal permitido es 2', propertyPath=salary, rootBeanClass=class com.manuel.jordan.domain.PersonValidation03, messageTemplate='{person.salary.digits}'}
  </code></pre>
  
  <p>The characters <code>ñ</code> and <code>á</code> are not showing how it is expected</p>
  
  <p>My IDE already has </p>
  
  <p><code>Preferences -&gt; Workspace -&gt; Text file encoding</code> with <strong>UTF-8</strong></p>
  
  <p>What extra missing configuration I need?</p>