title: Spring Boot + Spring Data + Spring MVC Encoding
body: <p>As is clear from the topic of the question, this is my stack of technologies. I have a problem encoding Russian characters.</p>
  
  <p>Its my controller:</p>
  
  <pre><code>@RestController
  public class ProductController {
  
      @Autowired
      private ProductService productService;
  
      @RequestMapping("/Product/ByQuery")
      public List getProductsByQuery(@RequestHeader(name = "query" , required = false) String query) {
          System.out.println(new String(query.getBytes(),StandardCharsets.ISO_8859_1));
          return productService.findByQuery(new String(query.getBytes(),StandardCharsets.ISO_8859_1));
      }
  }
  </code></pre>
  
  <p>its my Service :</p>
  
  <pre><code>    public class ProductServiceImpl implements ProductService {
          @Autowired
          private ProductRepository productRepository;
    @Override
      public List&lt;Product&gt; findByQuery(String query) {
          List&lt;DataModel.Product&gt; productList = productRepository.findDistinctByNameContainingIgnoreCaseOrCategoryContainingIgnoreCaseOrManufacturerContainingIgnoreCaseOrInformationValueContainingIgnoreCase(query,query,query,query);
          List&lt;Product&gt; resultProducts = new ArrayList&lt;&gt;();
          ModelMapper modelMapper = new ModelMapper();
          for (int i = 0; i &lt; productList.size(); i++) {
              int like = 0;
              int dislike = 0;
  
              for (Rating rating : productList.get(i).getRating()) {
                  if (rating.getType().equals("Like")) {
                      like += 1;
                  } else {
                      dislike += 1;
                  }
              }
              resultProducts.add(modelMapper.map(productList.get(i), Product.class));
              resultProducts.get(i).setCommentCnt(productList.get(i).getComment().size());
              resultProducts.get(i).setLike(like);
              resultProducts.get(i).setDislike(dislike);
              resultProducts.get(i).setImage(productList.get(i).getImage().get(0).getUrl());
          }
          return resultProducts;
      }
          }
  </code></pre>
  
  <p>Repository:</p>
  
  <pre><code>@Repository
  public interface ProductRepository extends JpaRepository&lt;Product,Long&gt; {
      List&lt;Product&gt; findDistinctByNameContainingIgnoreCaseOrCategoryContainingIgnoreCaseOrManufacturerContainingIgnoreCaseOrInformationValueContainingIgnoreCase(String name,String category, String manufacturer, String value);
  }
  </code></pre>
  
  <p>Application :</p>
  
  <pre><code>@SpringBootApplication(scanBasePackages = {"Service", "repository", "controller"})
  @EntityScan("DataModel")
  @EnableJpaRepositories(basePackages = "repository")
  public class CloudliquidApplication extends SpringBootServletInitializer {
  
      public static void main(String[] args) {
          ApplicationContext ctx = SpringApplication.run(CloudliquidApplication.class, args);
          System.out.println("Let's inspect the beans provided by Spring Boot:");
  
          String[] beanNames = ctx.getBeanDefinitionNames();
          Arrays.sort(beanNames);
          for (String beanName : beanNames) {
              System.out.println(beanName);
          }
      }
      @Bean
      public ProductService productService() {
          return new ProductServiceImpl();
      }
  
      @Bean
      public TomcatServletWebServerFactory tomcatFactory() {
          return new TomcatServletWebServerFactory() {
              @Override
              protected void postProcessContext(Context context) {
                  ((StandardJarScanner) context.getJarScanner()).setScanManifest(false);
              }
          };
      }
  }
  </code></pre>
  
  <p>Property :</p>
  
  <pre><code>spring.http.encoding.charset=UTF-8
  spring.http.encoding.enabled=true
  spring.http.encoding.force=true
  </code></pre>
  
  <p>pom:</p>
  
  <pre><code>&lt;?xml version="1.0" encoding="UTF-8"?&gt;
  &lt;project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
           xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"&gt;
      &lt;modelVersion&gt;4.0.0&lt;/modelVersion&gt;
  
      &lt;groupId&gt;com.lopamoko&lt;/groupId&gt;
      &lt;artifactId&gt;cloudliquid&lt;/artifactId&gt;
      &lt;version&gt;0.0.1-SNAPSHOT&lt;/version&gt;
      &lt;packaging&gt;jar&lt;/packaging&gt;
  
      &lt;name&gt;cloudliquid&lt;/name&gt;
      &lt;description&gt;Demo project for Spring Boot&lt;/description&gt;
  
      &lt;pluginRepositories&gt;
          &lt;pluginRepository&gt;
              &lt;id&gt;maven-annotation-plugin-repo&lt;/id&gt;
              &lt;url&gt;http://maven-annotation-plugin.googlecode.com/svn/trunk/mavenrepo&lt;/url&gt;
          &lt;/pluginRepository&gt;
      &lt;/pluginRepositories&gt;
  
  
      &lt;parent&gt;
          &lt;groupId&gt;org.springframework.boot&lt;/groupId&gt;
          &lt;artifactId&gt;spring-boot-starter-parent&lt;/artifactId&gt;
          &lt;version&gt;2.1.0.RELEASE&lt;/version&gt;
  
          &lt;relativePath/&gt; &lt;!-- lookup parent from repository --&gt;
      &lt;/parent&gt;
  
      &lt;properties&gt;
          &lt;project.build.sourceEncoding&gt;UTF-8&lt;/project.build.sourceEncoding&gt;
          &lt;project.reporting.outputEncoding&gt;UTF-8&lt;/project.reporting.outputEncoding&gt;
          &lt;java.version&gt;1.8&lt;/java.version&gt;
      &lt;/properties&gt;
  
      &lt;dependencies&gt;
          &lt;dependency&gt;
              &lt;groupId&gt;org.springframework.boot&lt;/groupId&gt;
              &lt;artifactId&gt;spring-boot-starter&lt;/artifactId&gt;
          &lt;/dependency&gt;
  
  
          &lt;dependency&gt;
              &lt;groupId&gt;org.springframework.boot&lt;/groupId&gt;
              &lt;artifactId&gt;spring-boot-starter-web&lt;/artifactId&gt;
          &lt;/dependency&gt;
          &lt;dependency&gt;
              &lt;groupId&gt;org.springframework.boot&lt;/groupId&gt;
              &lt;artifactId&gt;spring-boot-starter-data-jpa&lt;/artifactId&gt;
              &lt;version&gt;2.1.1.RELEASE&lt;/version&gt;
          &lt;/dependency&gt;
  
  
          &lt;dependency&gt;
              &lt;groupId&gt;org.springframework.boot&lt;/groupId&gt;
              &lt;artifactId&gt;spring-boot-starter-test&lt;/artifactId&gt;
              &lt;scope&gt;test&lt;/scope&gt;
          &lt;/dependency&gt;
          &lt;dependency&gt;
              &lt;groupId&gt;org.projectlombok&lt;/groupId&gt;
              &lt;artifactId&gt;lombok&lt;/artifactId&gt;
              &lt;version&gt;1.18.0&lt;/version&gt;
              &lt;scope&gt;provided&lt;/scope&gt;
          &lt;/dependency&gt;
          &lt;dependency&gt;
              &lt;groupId&gt;org.springframework.boot&lt;/groupId&gt;
              &lt;artifactId&gt;spring-boot&lt;/artifactId&gt;
              &lt;version&gt;2.1.0.RELEASE&lt;/version&gt;
          &lt;/dependency&gt;
          &lt;dependency&gt;
              &lt;groupId&gt;org.modelmapper&lt;/groupId&gt;
              &lt;artifactId&gt;modelmapper&lt;/artifactId&gt;
              &lt;version&gt;0.7.4&lt;/version&gt;
          &lt;/dependency&gt;
          &lt;dependency&gt;
              &lt;groupId&gt;org.postgresql&lt;/groupId&gt;
              &lt;artifactId&gt;postgresql&lt;/artifactId&gt;
              &lt;version&gt;42.2.5&lt;/version&gt;
          &lt;/dependency&gt;
  
  
  
  
      &lt;/dependencies&gt;
  
      &lt;build&gt;
          &lt;plugins&gt;
              &lt;plugin&gt;
                  &lt;groupId&gt;org.springframework.boot&lt;/groupId&gt;
                  &lt;artifactId&gt;spring-boot-maven-plugin&lt;/artifactId&gt;
              &lt;/plugin&gt;
          &lt;/plugins&gt;
      &lt;/build&gt;
  
  
  &lt;/project&gt;
  </code></pre>
  
  <p>What do I need to do, so that Russian characters will finally begin to be perceived?
  Before moving to the spring, it helped me - new String (source.getBytes (), StandardCharsets.UTF-8)). But after the move it stopped working (in any format).</p>
  
  <p>What else should you try? If anything, I transfer the data from Android (Retrofit).</p>