maven platform encoding

后端 未结 5 1067
滥情空心
滥情空心 2020-12-13 20:36

when you run mvn --version part of the output includes the locale and pratform encoding. For example: Default locale: en_GB, platform encoding: Cp1252

相关标签:
5条回答
  • 2020-12-13 20:51

    Best solution is:

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

    More: http://www.sonatype.com/people/2009/11/special-character-encoding-properties/

    0 讨论(0)
  • 2020-12-13 20:54

    maven picking these values from Java system properties. Here is how you could set encoding:

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

    Or:

      <plugin>
        <groupId>org.apache.maven.plugins</groupId>
        <artifactId>maven-resources-plugin</artifactId>
        <configuration>
          <encoding>UTF-8</encoding>
        </configuration>
      </plugin>
    

    Or pass parameter to maven command line:

    mvn -Dproject.build.sourceEncoding=UTF-8
    
    0 讨论(0)
  • 2020-12-13 20:56

    You could set environment information for maven (on a windows system) with

    set "MAVEN_OPTS=-Duser.language=fr -Dfile.encoding=UTF-8"
    
    0 讨论(0)
  • 2020-12-13 21:04

    I had the same problem. The only thing that works is to set the appropriate MAVEN_OPTS. So if you use windows you can adapt mvn.bat in %MAVEN_HOME%/bin as follows:

    set MAVEN_OPTS=%MAVEN_OPTS% -Dfile.encoding="UTF-8"
    

    Following this mvn -v shows this:

    ..
    Default locale: de_DE, platform encoding: UTF-8
    ..
    
    0 讨论(0)
  • 2020-12-13 21:08
    set MAVEN_OPTS= -Dfile.encoding="UTF-8"
    

    Actually it won't work, you need to remove the quotes ("") :

    set MAVEN_OPTS= -Dfile.encoding=UTF-8
    
    0 讨论(0)
提交回复
热议问题