In unit tests for java + spring, I pass a string with Russian letters to the method. Inside the method, the parameter does not contain what was recorded, for example, the order status is Paid, but the text in the bird's language comes.

String response = sendGet( new String(serverAddress + "/salesOrder?id=1&status=2. Оплачен"); 

Method itself

  private String sendGet(String url) { logger.log(WARN, "prepare sending GET.."); HttpHeaders headers = new HttpHeaders(); headers.add("Content-Type", "application/xml"); logger.log(WARN, url); ResponseEntity responseEntity = restTemplate.exchange( url, HttpMethod.GET, new HttpEntity<>(headers), String.class); return (String) responseEntity.getBody(); } 

Respectively

  1. Paid

, and inside the sendGet method and on the server comes a string of something like

  1. верждение
  • one
    What encoding was used when compiling? - Sergey Gornostaev
  • @SergeyGornostaev a good question, I do not how to look - Roberto
  • one
    It depends on how you compile. - Sergey Gornostaev
  • @SergeyGornostaev Compilation of maven from the terminal. Development environment - indelijIdea. I collect ear file and upload it to a server with a web-area 8.5.5.13 - Roberto
  • one
    Try adding the project.build.sourceEncoding property to pom.xml. - Sergey Gornostaev 2:51 pm

1 answer 1

In order for string literals to be normally displayed in the output, you need to specify the source code encoding for the compiler. In a maven project, this can be done by adding the project.build.sourceEncoding property to pom.xml:

 <project ...> ... <properties> <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding> ... </properties> .. </project>