no thanks
no thanks

Reputation: 73

UTF-8 encoding is not enabled when running Spring Boot from the command line

I have a spring boot application and I use IntelliJ IDEA and everything is fine.

But when I run the application using the command line I face one problem with the UTF-8 encoding which converts all the text of a different language than English to non-understandable symbols as you can see in the photo below.

I guess the problem is that the UTF-8 encoding is untenable while when I use IntelliJ IDEA I don't face this problem.

I run the application using:

mvn spring-boot:run

and I added this option but still not working

mvn spring-boot:run -Dfile.encoding=UTF-8

I updated the properties file also, but no difference

server.servlet.encoding.charset=UTF-8
server.tomcat.uri-encoding=UTF-8

Is there a specific way to enable the UTF-8 encoding, so the text will show in the right language?

enter image description here

Upvotes: 1

Views: 4683

Answers (1)

no thanks
no thanks

Reputation: 73

Well, this plugin solved the problem

  <plugin>
    <groupId>org.springframework.boot</groupId>
    <artifactId>spring-boot-maven-plugin</artifactId>
    <configuration>
      <executable>true</executable>
      <jvmArguments>-Dfile.encoding=UTF8</jvmArguments>
    </configuration>
  </plugin>

Upvotes: 3

Related Questions