Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save marcelosantos/a73bf2380cf67eb310646920955495cb to your computer and use it in GitHub Desktop.
Save marcelosantos/a73bf2380cf67eb310646920955495cb to your computer and use it in GitHub Desktop.
Fix encoding utf8 during maven compilation

Configure the maven-compiler-plugin to use the same character encoding that your source files are encoded in (e.g):

<plugin>
    <groupId>org.apache.maven.plugins</groupId>
    <artifactId>maven-compiler-plugin</artifactId>
    <version>2.3.2</version>
    <configuration>
        <source>1.8</source> <!-- jdk version --> 
        <target>1.8</target> <!-- jdk version -->
        <encoding>UTF-8</encoding>
    </configuration>
</plugin>

Many maven plugins will by default use the "project.build.sourceEncoding" property so setting this in your pom will cover most plugins.

<project>
    <properties>
        <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
    </properties>
...
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment